From eb1b9ee9b4db56068cdc6b7864a6ff1a0fbf1ee4 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 2 Apr 2016 13:09:21 +0100 Subject: Make document.body selectable as scrollable. Previously, we could select divs, uls, and ols for scrolling, but we couldn't get back to scrolling the document body. This makes it possible to select document.body for scrolling. Unfortunately, sometimes the hint appears in a rather odd place (because it's "on top of" something else which is clickable. --- content_scripts/link_hints.coffee | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 0739d621..01ed6de5 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -68,8 +68,8 @@ HintCoordinator = Settings.onLoaded => @localHints = LocalHints.getLocalHints() @sendMessage "postHintDescriptors", hintDescriptors: - @localHints.map ({rect, linkText, showLinkText, hasHref}, localIndex) -> - {rect, linkText, showLinkText, hasHref, frameId, localIndex} + @localHints.map ({rect, linkText, showLinkText, hasHref, reason}, localIndex) -> + {rect, linkText, showLinkText, hasHref, reason, frameId, localIndex} # We activate LinkHintsMode() in every frame and provide every frame with exactly the same hint descriptors. # We also propagate the key state between frames. Therefore, the hint-selection process proceeds in lock @@ -283,8 +283,11 @@ class LinkHintsMode if clickEl? HintCoordinator.onExit.push (isSuccess) => if isSuccess - if clickEl == document.body + if linkMatched.hintDescriptor.reason == "Frame." Utils.nextTick -> focusThisFrame highlight: true + else if linkMatched.hintDescriptor.reason == "Scroll." + # Tell the scroller that this is the activated element. + handlerStack.bubbleEvent "DOMActivate", target: clickEl else if DomUtils.isSelectable clickEl window.focus() DomUtils.simulateSelect clickEl @@ -576,6 +579,9 @@ LocalHints = window.innerWidth > 3 and window.innerHeight > 3 and document.body?.tagName.toLowerCase() != "frameset" reason = "Frame." + isClickable ||= + if element == document.body and document.hasFocus() and Scroller.isScrollableElement element + reason = "Scroll." when "div", "ol", "ul" isClickable ||= if element.clientHeight < element.scrollHeight and Scroller.isScrollableElement element -- cgit v1.2.3