From 5c3e4bda2968486e23f8cc3410e776de67fec849 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 17 Apr 2016 11:54:28 +0100 Subject: Better window focus handling. This fixes two issues: - We cannot set windowHasFocus until the DOM is ready (because document.hasFocus isn't set until then. - We should use windowhasFocus in prefernce to document.hasFocus because, for framesets, document.hasFocus is true for both the frameset and a focused contained frame. --- content_scripts/link_hints.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'content_scripts/link_hints.coffee') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index f2b9cd0f..702ff69d 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -334,7 +334,7 @@ class LinkHintsMode flashEl = DomUtils.addFlashRect linkMatched.rect HintCoordinator.onExit.push -> DomUtils.removeElement flashEl - if document.hasFocus() + if windowIsFocused() startKeyboardBlocker (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess} # If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the @@ -613,12 +613,12 @@ LocalHints = isClickable ||= element.control? and (@getVisibleClickable element.control).length == 0 when "body" isClickable ||= - if element == document.body and not document.hasFocus() and + if element == document.body and not windowIsFocused() and 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 + if element == document.body and windowIsFocused() and Scroller.isScrollableElement element reason = "Scroll." when "div", "ol", "ul" isClickable ||= -- cgit v1.2.3