diff options
| author | Phil Crosby | 2010-01-30 21:28:12 -0800 |
|---|---|---|
| committer | Phil Crosby | 2010-01-30 21:28:12 -0800 |
| commit | 99848a6dedfda243f02f4544ed309f8d4f869f1c (patch) | |
| tree | 7f0fc3600e51b0357c927109b0c47a9536d37474 /linkHints.js | |
| parent | f10846526b80efd54e67dfa43cc07bea001360a9 (diff) | |
| download | vimium-99848a6dedfda243f02f4544ed309f8d4f869f1c.tar.bz2 | |
Avoid calling document.elementFromPoint for very small links. This helps link hinting performance.
Helps address #71.
Diffstat (limited to 'linkHints.js')
| -rw-r--r-- | linkHints.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/linkHints.js b/linkHints.js index dd80d6bf..1e240183 100644 --- a/linkHints.js +++ b/linkHints.js @@ -69,12 +69,17 @@ function getVisibleClickableElements() { if (boundingRect.bottom < 0 || boundingRect.top > window.innerHeight) continue; + if (boundingRect.width < 3 || boundingRect.height < 3) + continue; + // Using getElementFromPoint will omit elements which have visibility=hidden or display=none, and // 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). + // Note(philc): this is the most expensive part our link hinting process, so we should try hard to filter + // out elements by whatever means possible prior to getting to this check. if (!elementOccupiesPoint(element, boundingRect.left, boundingRect.top)) { var elementOccupiesCenter = elementOccupiesPoint(element, boundingRect.left + boundingRect.width / 2, boundingRect.top + boundingRect.height / 2); |
