diff options
| author | Stephen Blott | 2015-04-29 12:33:41 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-04-29 12:33:41 +0100 |
| commit | dafe48a3e5f17d2b3380813a8dc9e5122def60b8 (patch) | |
| tree | 38656860b42d3c1af6a54cbdac8dc65f961852cb /content_scripts | |
| parent | 92b3c36a57111cf5fb72bca7dcd811f81f606a20 (diff) | |
| parent | 561a63f31e387c6383a2e62558a44df7ab2918f4 (diff) | |
| download | vimium-dafe48a3e5f17d2b3380813a8dc9e5122def60b8.tar.bz2 | |
Merge pull request #1619 from smblott-github/fix-text-link-hints
Fix matching text for text link hints
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/link_hints.coffee | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 440e6598..3cebac4c 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -60,6 +60,12 @@ LinkHints = # For these modes, we filter out those elements which don't have an HREF (since there's nothing we can do # with them). elements = (el for el in elements when el.element.href?) if mode in [ COPY_LINK_URL, OPEN_INCOGNITO ] + if settings.get "filterLinkHints" + # When using text filtering, we sort the elements such that we visit descendants before their ancestors. + # This allows us to exclude the text used for matching descendants from that used for matching their + # ancestors. + length = (el) -> el.element.innerHTML?.length ? 0 + elements.sort (a,b) -> length(a) - length b hintMarkers = (@createMarkerFor(el) for el in elements) @getMarkerMatcher().fillInMarkers(hintMarkers) @@ -238,8 +244,6 @@ 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. - # NOTE(smblott). filterHints.generateLinkText also assumes this order when generating the content text for - # each hint. Specifically, we consider descendents before we consider their ancestors. visibleElements = visibleElements.reverse() while visibleElement = visibleElements.pop() rects = [visibleElement.rect] |
