diff options
| author | Stephen Blott | 2014-12-30 15:09:53 +0000 |
|---|---|---|
| committer | Stephen Blott | 2014-12-30 15:09:53 +0000 |
| commit | c3df7699527f88c660e0d61fafdd1ad334236d77 (patch) | |
| tree | 8d41d8e1743c65473a6a1489305df2a6c7a1d456 /content_scripts | |
| parent | 0a0892792f56cc4724def1dd60089492e2df4dc6 (diff) | |
| download | vimium-c3df7699527f88c660e0d61fafdd1ad334236d77.tar.bz2 | |
Minor changes to link-hint code.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/link_hints.coffee | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 70e6a626..8d476529 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -125,8 +125,10 @@ LinkHints = marker # - # Determine whether the element is visible and clickable. If it is, return the element and the rect - # bounding the element in the viewport. + # Determine whether the element is visible and clickable. If it is, return the element and the rect bounding + # the element in the viewport. There may be more than one part of element which is clickable (for example, + # if it's an image), therefore we return a list of element/rect pairs. + # getVisibleClickable: (element) -> tagName = element.tagName.toLowerCase() isClickable = false @@ -148,7 +150,7 @@ LinkHints = # Check aria properties to see if the element should be ignored. if (element.getAttribute("aria-hidden")?.toLowerCase() in ["", "true"] or element.getAttribute("aria-disabled")?.toLowerCase() in ["", "true"]) - return null # This element should never have a link hint. + return [] # This element should never have a link hint. # Check for attributes that make an element clickable regardless of its tagName. if (element.hasAttribute("onclick") or @@ -187,7 +189,7 @@ LinkHints = if isClickable clientRect = DomUtils.getVisibleClientRect element if clientRect != null - visibleElements.push {element: element, rect: clientRect, onlyHasTabIndex: onlyHasTabIndex} + visibleElements.push {element: element, rect: clientRect, secondClassCitizen: onlyHasTabIndex} visibleElements @@ -236,10 +238,11 @@ LinkHints = nonOverlappingElements.push {element: visibleElement.element, rect: rects[0]} else # Every part of the element is covered by some other element, so just insert the whole element's - # rect. Except for elements with tabIndex set; these are often more trouble than they're worth. + # rect. Except for elements with tabIndex set (second class citizens); these are often more trouble + # than they're worth. # TODO(mrmr1993): This is probably the wrong thing to do, but we don't want to stop being able to # click some elements that we could click before. - nonOverlappingElements.push visibleElement unless visibleElement.onlyHasTabIndex + nonOverlappingElements.push visibleElement unless visibleElement.secondClassCitizen nonOverlappingElements |
