aboutsummaryrefslogtreecommitdiffstats
path: root/linkHints.js
diff options
context:
space:
mode:
authorPhil Crosby2009-12-06 15:52:52 -0800
committerPhil Crosby2009-12-06 16:38:57 -0800
commit5cec207d5a3a991601a313d7d3f2e81061d23bb4 (patch)
tree1dbf98f5a2bf5868d2e590f7c567ca9655d9650c /linkHints.js
parent0133464c4f520750bf6d5d678737cac1c57e2147 (diff)
downloadvimium-5cec207d5a3a991601a313d7d3f2e81061d23bb4.tar.bz2
Use both the upper-left corner and the center of a link's bounding box to determine if it's visible.
I previously switched the logic to use the center of the bounding box, but that does not work well for multi-line links.
Diffstat (limited to 'linkHints.js')
-rw-r--r--linkHints.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/linkHints.js b/linkHints.js
index 92e4a7e4..178efedb 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -84,13 +84,17 @@ function getVisibleClickableElements() {
continue;
// Using getElementFromPoint will omit elements which have visibility=hidden or display=none, and
- // elements inside of containers that are also hidden. Check for whether the element occupies the center
- // of its bounding box instead of simply the upper-left corner of that box because this is more accurate
- // when inline links have vertical padding, like in the links ("Source", "Commits") at the top of github.com.
+ // elements inside of containers that are also hidden. We're checking for whether the element occupies
+ // the upper left corner and if that fails, we also check whether the element occupies the center of the
+ // box. We use the center of the box because it's more accurate when inline links have vertical padding,
+ // like in the links ("Source", "Commits") at the top of github.com.
// This will not exclude links with "opacity=0", like the links on Google's homepage (see bug #16).
- if (!elementOccupiesPoint(element, boundingRect.left + boundingRect.width / 2,
- boundingRect.top + boundingRect.height / 2))
- continue;
+ if (!elementOccupiesPoint(element, boundingRect.left, boundingRect.top)) {
+ var elementOccupiesCenter = elementOccupiesPoint(element, boundingRect.left + boundingRect.width / 2,
+ boundingRect.top + boundingRect.height / 2);
+ if (!elementOccupiesCenter)
+ continue;
+ }
visibleElements.push(element);
}