aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrmr19932014-12-18 13:39:22 +0000
committermrmr19932014-12-18 13:39:22 +0000
commitaa047d5b4b6124f7e2d1230ab590b9244db6ebb3 (patch)
treef089a07419f6e644c3344dfcca254fe9c9348423
parent93a5a571cc06087b2abfe383424c2fcc6ef02358 (diff)
downloadvimium-aa047d5b4b6124f7e2d1230ab590b9244db6ebb3.tar.bz2
Improve comments for LinkHints.getVisibleClickableElements
-rw-r--r--content_scripts/link_hints.coffee9
1 files changed, 6 insertions, 3 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 95026cba..b1c44e42 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -125,9 +125,11 @@ LinkHints =
marker
#
- # Returns all clickable elements that are not hidden and are in the current viewport.
- # We prune invisible elements partly for performance reasons, but moreso it's to decrease the number
- # of digits needed to enumerate all of the links on screen.
+ # Returns all clickable elements that are not hidden and are in the current viewport, along with rectangles
+ # at which (parts of) the elements are displayed.
+ # In the process, we try to find rects where elements do not overlap so that link hints are unambiguous.
+ # Because of this, the rects returned will frequently *NOT* be equivalent to the rects for the whole
+ # element.
#
getVisibleClickableElements: ->
elements = document.documentElement.getElementsByTagName "*"
@@ -197,6 +199,7 @@ LinkHints =
#
# Remove rects from elements where another clickable element lies above it.
nonOverlappingElements = []
+ # Traverse the DOM from first to last, since later elements show above earlier elements.
visibleElements = visibleElements.reverse()
while visibleElement = visibleElements.pop()
rects = [visibleElement.rect]