From 88d8247dc79f082ca6215670fbe512500cc8fb36 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 6 Dec 2009 00:19:01 -0800 Subject: Use the center of a link's bounding box instead of its upper-left corner to detect if its visible. This is a slightly more accurate heuristic and fixes #17.--- linkHints.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linkHints.js b/linkHints.js index da33f202..fdafa1ed 100644 --- a/linkHints.js +++ b/linkHints.js @@ -82,8 +82,11 @@ function getVisibleClickableElements() { continue; // Using getElementFromPoint will omit elements which have visibility=hidden or display=none, and - // elements inside of containers that are also hidden. - if (!elementOccupiesPoint(element, boundingRect.left, boundingRect.top)) + // 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. + if (!elementOccupiesPoint(element, boundingRect.left + boundingRect.width / 2, + boundingRect.top + boundingRect.height / 2)) continue; visibleElements.push(element); -- cgit v1.2.3