From e825758435fd5d77d6e1254210afec3ffe4651f0 Mon Sep 17 00:00:00 2001 From: Clemens Buchacher Date: Sun, 12 Dec 2010 12:11:38 +0100 Subject: fix named key regex This regular expression was broken since commit 9d0061dc (Allow mapping to arrow keys and f-keys). As a result, keys such as for example "" could not be parsed correctly. This fixes https://github.com/philc/vimium/issues#issue/110 . --- background_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background_page.html b/background_page.html index f4a40ffa..9ed81509 100644 --- a/background_page.html +++ b/background_page.html @@ -20,7 +20,7 @@ // Keys are either literal characters, or "named" - for example (alt+b), (the left arrow) or // This regular expression captures two groups, the first is a named key, the second is the remainder of the string. - var namedKeyRegex = /^(<[amc-].|(?:[amc]-)?[a-z0-9]{2,5}>)(.*)$/; + var namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/; var defaultSettings = { scrollStepSize: 60, -- cgit v1.2.3 From 3173156ee2e674069db6769936e9f767869899d9 Mon Sep 17 00:00:00 2001 From: Ilya Sukhar Date: Tue, 14 Dec 2010 01:40:14 -0800 Subject: Added default exclude URLs. This is a huge pain point for users and it just makes sense at this point to provide some defaults. --- background_page.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/background_page.html b/background_page.html index 9ed81509..ad15c2be 100644 --- a/background_page.html +++ b/background_page.html @@ -28,7 +28,9 @@ linkHintCharacters: "sadfjklewcmpgh", userDefinedLinkHintCss: ".vimiumHintMarker {\n\n}\n" + - ".vimiumHintMarker > .matchingCharacter {\n\n}" + ".vimiumHintMarker > .matchingCharacter {\n\n}", + excludedUrls: "http*://mail.google.com/*\n" + + "http*://www.google.com/reader/*\n" }; // This is the base internal link hints CSS. It's combined with the userDefinedLinkHintCss before @@ -136,7 +138,7 @@ */ function isEnabledForUrl(request) { // excludedUrls are stored as a series of URL expressions separated by newlines. - var excludedUrls = (localStorage["excludedUrls"] || "").split("\n"); + var excludedUrls = (localStorage["excludedUrls"] || defaultSettings.excludedUrls).split("\n"); var isEnabled = true; for (var i = 0; i < excludedUrls.length; i++) { // The user can add "*" to the URL which means ".*" -- cgit v1.2.3 From b658a81acdf8b789cae1c464c2a4fbad5dbf7928 Mon Sep 17 00:00:00 2001 From: Ilya Sukhar Date: Tue, 14 Dec 2010 01:41:36 -0800 Subject: Start README section for 1.22 --- README.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.markdown b/README.markdown index ba16e643..04e7375d 100644 --- a/README.markdown +++ b/README.markdown @@ -84,6 +84,11 @@ When you're done, send us a pull request on Github. Feel free to include a chang Release Notes ------------- +1.22 + +- Some sites are now excluded by default. +- Bugfixes. + 1.21 (10/24/2010) - Critical bugfix for an excluded URLs regression due to frame support. -- cgit v1.2.3 From 031b3453f1f34df0a6b3bc83d5e920d869b329e9 Mon Sep 17 00:00:00 2001 From: Ilya Sukhar Date: Tue, 14 Dec 2010 01:59:51 -0800 Subject: Fixed a regression with completion key logic after the introduction of frame support. Closes #249. --- background_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/background_page.html b/background_page.html index ad15c2be..264cf299 100644 --- a/background_page.html +++ b/background_page.html @@ -552,7 +552,7 @@ // The second key might be a valid command by its self. if (keyToCommandRegistry[splitKey.second]) - newKeyQueue = checkKeyQueue(splitKey.second); + newKeyQueue = checkKeyQueue(splitKey.second, tabId, frameId); else newKeyQueue = (validFirstKeys[splitKey.second] ? splitKey.second : ""); } else { -- cgit v1.2.3 From def44f37109c2cd120893060e95551fd9a64c4ac Mon Sep 17 00:00:00 2001 From: Ilya Sukhar Date: Tue, 14 Dec 2010 02:24:32 -0800 Subject: Expand the XPath used to find DOM elements for focusInput(). Closes #250. --- test_harnesses/form.html | 2 ++ vimiumFrontend.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test_harnesses/form.html b/test_harnesses/form.html index 740edb46..d7104ac2 100644 --- a/test_harnesses/form.html +++ b/test_harnesses/form.html @@ -10,6 +10,8 @@

Text: Text 2: + Email: + No Type:

Search: diff --git a/vimiumFrontend.js b/vimiumFrontend.js index b108d141..16f0fdde 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -26,6 +26,17 @@ var linkHintCss; // TODO(philc): This should be pulled from the extension's storage when the page loads. var currentZoomLevel = 100; +// The types in that we consider for focusInput command. Right now this is recalculated in +// each content script. Alternatively we could calculate it once in the background page and use a request to +// fetch it each time. +// +// Should we include the HTML5 date pickers here? +var textInputTypes = ["text", "search", "email", "url", "number"]; +// The corresponding XPath for such elements. +var textInputXPath = '//input[' + + textInputTypes.map(function (type) { return '@type="' + type + '"'; }).join(" or ") + + ' or not(@type)]'; + /* * Give this frame a unique id. */ @@ -232,8 +243,8 @@ function scrollLeft() { window.scrollBy(-1 * settings["scrollStepSize"], 0); } function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); } function focusInput(count) { - var xpath = '//input[@type="text" or @type="search"]'; - var results = document.evaluate(xpath, document.documentElement, null, + var results = document.evaluate(textInputXPath, + document.documentElement, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); var lastInputBox; -- cgit v1.2.3 From 416925e540067f56834bf9f6b7a4b21a77448926 Mon Sep 17 00:00:00 2001 From: jez Date: Sun, 26 Dec 2010 23:56:57 +0800 Subject: Fix hint marker positioning when body's position is not static. Closes #140. --- linkHints.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/linkHints.js b/linkHints.js index 16d6fcbf..d751b609 100644 --- a/linkHints.js +++ b/linkHints.js @@ -326,11 +326,20 @@ function createMarkerFor(link, linkHintNumber, linkHintDigits) { // Note: this call will be expensive if we modify the DOM in between calls. var clientRect = link.rect; - // The coordinates given by the window do not have the zoom factor included since the zoom is set only on - // the document node. - var zoomFactor = currentZoomLevel / 100.0; - marker.style.left = clientRect.left + window.scrollX / zoomFactor + "px"; - marker.style.top = clientRect.top + window.scrollY / zoomFactor + "px"; + var offsets = {}; + if (/^(absolute|fixed|relative)$/.test(window.getComputedStyle(document.body).position)) { + var bodyRect = document.body.getClientRects()[0]; + offsets.x = -bodyRect.left; + offsets.y = -bodyRect.top; + } else { + // The coordinates given by the window do not have the zoom factor included since the zoom is set only on + // the document node. + var zoomFactor = currentZoomLevel / 100.0; + offsets.x = window.scrollX / zoomFactor; + offsets.y = window.scrollY / zoomFactor; + } + marker.style.left = clientRect.left + offsets.x + "px"; + marker.style.top = clientRect.top + offsets.y + "px"; marker.clickableItem = link.element; return marker; -- cgit v1.2.3 From 04100b83aabe100d25f71ea25b3cdf2b50c30939 Mon Sep 17 00:00:00 2001 From: jez Date: Mon, 27 Dec 2010 00:41:00 +0800 Subject: Extend link hinting XPath to include tabindex and role properties. Captures some elements that were previously missed, e.g. on translate.google.com. --- linkHints.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linkHints.js b/linkHints.js index d751b609..d1f2ddaa 100644 --- a/linkHints.js +++ b/linkHints.js @@ -24,11 +24,11 @@ var linkHintsCssAdded = false; * The final expression will be something like "//button | //xhtml:button | ..." */ var clickableElementsXPath = (function() { - var clickableElements = ["a", "textarea", "button", "select", "input[not(@type='hidden')]"]; + var clickableElements = ["a", "textarea", "button", "select", "input[not(@type='hidden')]", + "*[@onclick or @tabindex or @role='link' or @role='button']"]; var xpath = []; for (var i in clickableElements) xpath.push("//" + clickableElements[i], "//xhtml:" + clickableElements[i]); - xpath.push("//*[@onclick]"); return xpath.join(" | ") })(); -- cgit v1.2.3 From bc752823e5f531068cb765de4e01740c7296ec42 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 17:14:41 +0800 Subject: Revert "Fix hint marker positioning when body's position is not static. Closes #140." This reverts commit 416925e540067f56834bf9f6b7a4b21a77448926. --- linkHints.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/linkHints.js b/linkHints.js index d1f2ddaa..3e19df97 100644 --- a/linkHints.js +++ b/linkHints.js @@ -326,20 +326,11 @@ function createMarkerFor(link, linkHintNumber, linkHintDigits) { // Note: this call will be expensive if we modify the DOM in between calls. var clientRect = link.rect; - var offsets = {}; - if (/^(absolute|fixed|relative)$/.test(window.getComputedStyle(document.body).position)) { - var bodyRect = document.body.getClientRects()[0]; - offsets.x = -bodyRect.left; - offsets.y = -bodyRect.top; - } else { - // The coordinates given by the window do not have the zoom factor included since the zoom is set only on - // the document node. - var zoomFactor = currentZoomLevel / 100.0; - offsets.x = window.scrollX / zoomFactor; - offsets.y = window.scrollY / zoomFactor; - } - marker.style.left = clientRect.left + offsets.x + "px"; - marker.style.top = clientRect.top + offsets.y + "px"; + // The coordinates given by the window do not have the zoom factor included since the zoom is set only on + // the document node. + var zoomFactor = currentZoomLevel / 100.0; + marker.style.left = clientRect.left + window.scrollX / zoomFactor + "px"; + marker.style.top = clientRect.top + window.scrollY / zoomFactor + "px"; marker.clickableItem = link.element; return marker; -- cgit v1.2.3 From e64b5ac3790b9af1c2bcdbf0548be95444f35839 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 17:32:31 +0800 Subject: Append hint div to documentElement instead of body. Closes issue #140. --- linkHints.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linkHints.js b/linkHints.js index 3e19df97..58d6e979 100644 --- a/linkHints.js +++ b/linkHints.js @@ -83,7 +83,7 @@ function buildLinkHints() { hintMarkerContainingDiv.className = "internalVimiumHintMarker"; for (var i = 0; i < hintMarkers.length; i++) hintMarkerContainingDiv.appendChild(hintMarkers[i]); - document.body.appendChild(hintMarkerContainingDiv); + document.documentElement.appendChild(hintMarkerContainingDiv); } function logXOfBase(x, base) { return Math.log(x) / Math.log(base); } -- cgit v1.2.3 From d1885a7078589e875ae0c6801ec935309566dd10 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 18:04:23 +0800 Subject: Set width:auto on the HUD. Some sites set this value for all divs, so this overrides it back to the default. --- vimiumFrontend.js | 1 + 1 file changed, 1 insertion(+) diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 16f0fdde..e72764fe 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -636,6 +636,7 @@ HUD = { "bottom: 0px;" + "color: black;" + "height: 13px;" + + "width: auto;" + "max-width: 400px;" + "min-width: 150px;" + "text-align: left;" + -- cgit v1.2.3 From bb9387946cb573123a33541eb01b90fd8f9a744d Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 18:17:26 +0800 Subject: Create HEAD element if it is not present. Allows us to inject CSS when viewing some non-HTML documents, e.g. images. Does not work on SVG documents though. --- vimiumFrontend.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimiumFrontend.js b/vimiumFrontend.js index e72764fe..e3c28371 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -799,8 +799,8 @@ Tween = { function addCssToPage(css) { var head = document.getElementsByTagName("head")[0]; if (!head) { - console.log("Warning: unable to add CSS to the page."); - return; + head = document.createElement("head"); + document.documentElement.appendChild(head); } var style = document.createElement("style"); style.type = "text/css"; -- cgit v1.2.3 From 064a8b523ea53d4999bbd5987be5dc3db5caa4c8 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 22:30:35 +0800 Subject: Add command repetition for goUp command. Closes #179. --- commands.js | 2 +- vimiumFrontend.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands.js b/commands.js index c86b129f..3b9203dc 100644 --- a/commands.js +++ b/commands.js @@ -170,7 +170,7 @@ addCommand('goBack', 'Go back in history'); addCommand('goForward', 'Go forward in history'); // Navigating the URL hierarchy -addCommand('goUp', 'Go up the URL hierarchy'); +addCommand('goUp', 'Go up the URL hierarchy', false, true); // Manipulating tabs: addCommand('nextTab', 'Go one tab right', true); diff --git a/vimiumFrontend.js b/vimiumFrontend.js index e3c28371..a18c7966 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -266,7 +266,7 @@ function reload() { window.location.reload(); } function goBack() { history.back(); } function goForward() { history.forward(); } -function goUp() { +function goUp(count) { var url = window.location.href; if (url[url.length-1] == '/') url = url.substring(0, url.length - 1); @@ -274,7 +274,7 @@ function goUp() { var urlsplit = url.split('/'); // make sure we haven't hit the base domain yet if (urlsplit.length > 3) { - delete urlsplit[urlsplit.length-1]; + urlsplit = urlsplit.slice(0, Math.max(3, urlsplit.length - count)); window.location.href = urlsplit.join('/'); } } -- cgit v1.2.3 From 1fd0a389ffe7460ac1c658227f0627c050153632 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 16:27:22 +0800 Subject: Revamp visibility test; include tests for nested floats and SVGs --- test_harnesses/visibility_test.html | 175 ++++++++++++++++++++++++++++-------- 1 file changed, 138 insertions(+), 37 deletions(-) diff --git a/test_harnesses/visibility_test.html b/test_harnesses/visibility_test.html index 5fa4d728..7cfab412 100644 --- a/test_harnesses/visibility_test.html +++ b/test_harnesses/visibility_test.html @@ -7,65 +7,166 @@ Visibility test - - - +

+ + + + +
Node/Test
+ +
+ test + + - +
+ test +
- + -
- -
-
- -
-
- +
+ test +
+ + test + +
+ test +
+
+ test +
+ + + test + +
-- cgit v1.2.3