diff options
| author | Phil Crosby | 2009-11-28 03:05:54 -0800 |
|---|---|---|
| committer | Phil Crosby | 2009-11-28 03:05:54 -0800 |
| commit | ee2e9c686d7715286a426feb199b6ccb33b4dae9 (patch) | |
| tree | d86d3928828897d1cea926bc8f4546aa89454f0e /linkHints.js | |
| parent | d3bc056ca40f35f7e6a44ad168c7dc986f3ae972 (diff) | |
| download | vimium-ee2e9c686d7715286a426feb199b6ccb33b4dae9.tar.bz2 | |
Factor in the page zoom when showing link hints when the document is scrolled.
Diffstat (limited to 'linkHints.js')
| -rw-r--r-- | linkHints.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/linkHints.js b/linkHints.js index 2af1c720..82ffb1fd 100644 --- a/linkHints.js +++ b/linkHints.js @@ -3,12 +3,12 @@ * the page have a hint marker displayed containing a sequence of letters. Typing those letters will select * a link. */ -var linkHintsCss = +var linkHintsCss = '.vimiumHintMarker {' + 'background-color:yellow;' + 'color:black;' + 'font-weight:bold;' + - 'font-size:13px;' + + 'font-size:12px;' + 'padding:0 1px;' + 'line-height:100%;' + 'border:1px solid #E3BE23;' + @@ -73,7 +73,7 @@ function getVisibleClickableElements() { var boundingRect = element.getBoundingClientRect(); if (boundingRect.bottom < 0 || boundingRect.top > window.innerHeight) continue; - + // Using getElementFromPoint will omit elements which have visibility=hidden or display=none, and // elements inside of containers that are also hidden. if (element != getElementFromPoint(boundingRect.left, boundingRect.top)) @@ -89,8 +89,8 @@ function getVisibleClickableElements() { * to do. This should become unnecessary when webkit fixes their bug. */ function getElementFromPoint(x, y) { - var zoomLevel = parseInt(document.documentElement.style.zoom || 100) / 100.0; - return document.elementFromPoint(Math.ceil(x * zoomLevel), Math.ceil(y * zoomLevel)); + var zoomFactor = currentZoomLevel / 100.0; + return document.elementFromPoint(Math.ceil(x * zoomFactor), Math.ceil(y * zoomFactor)); } /* @@ -114,7 +114,7 @@ function onKeyDownInLinkHintsMode(event) { if (!keyChar) return; - // TODO(philc): Ignore keys that have modifiers. + // TODO(philc): Ignore keys that have modifiers. if (event.keyCode == keyCodes.ESC) { deactivateLinkHintsMode(); } else if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey) { @@ -227,8 +227,11 @@ function addMarkerFor(link, linkHintNumber) { marker.style.position = "absolute"; var boundingRect = link.getBoundingClientRect(); - marker.style.left = boundingRect.left + window.scrollX + "px"; - marker.style.top = boundingRect.top + window.scrollY + "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 = boundingRect.left + window.scrollX / zoomFactor + "px"; + marker.style.top = boundingRect.top + window.scrollY / zoomFactor + "px"; marker.clickableItem = link; // Note(philc): Append these markers to document.body instead of as child nodes to the link itself, @@ -251,4 +254,4 @@ function addCssToPage(css) { style.type = "text/css"; style.appendChild(document.createTextNode(css)); head.appendChild(style); -}
\ No newline at end of file +} |
