From 3f4c9638ac50f31de309b25be49cce4f06b65dc6 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 11 Nov 2017 16:13:22 +0000 Subject: Use Rect.translate to create rects for addFlashRect --- content_scripts/link_hints.coffee | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 96370bb4..07cec5f4 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -388,9 +388,8 @@ class LinkHintsMode installKeyboardBlocker = (startKeyboardBlocker) -> if linkMatched.isLocalMarker {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft() - for rect in (Rect.copy rect for rect in clickEl.getClientRects()) - extend rect, top: rect.top + viewportTop, left: rect.left + viewportLeft - flashEl = DomUtils.addFlashRect rect + for rect in clickEl.getClientRects() + flashEl = DomUtils.addFlashRect Rect.translate rect, viewportLeft, viewportTop do (flashEl) -> HintCoordinator.onExit.push -> DomUtils.removeElement flashEl if windowIsFocused() -- cgit v1.2.3 From 291f52bc319e6790d8fbb1e0384c8c5d023e61c7 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 11 Nov 2017 16:17:03 +0000 Subject: Tidy up multiple/redundant checks in LinkHints.activateLink --- content_scripts/link_hints.coffee | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 07cec5f4..0b44ea45 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -305,7 +305,7 @@ class LinkHintsMode if linksMatched.length == 0 @deactivateMode() else if linksMatched.length == 1 - @activateLink linksMatched[0], userMightOverType ? false + @activateLink linksMatched[0], userMightOverType else @hideMarker marker for marker in @hintMarkers @showMarker matched, @markerMatcher.hintKeystrokeQueue.length for matched in linksMatched @@ -359,7 +359,7 @@ class LinkHintsMode # When only one hint remains, activate it in the appropriate way. The current frame may or may not contain # the matched link, and may or may not have the focus. The resulting four cases are accounted for here by # selectively pushing the appropriate HintCoordinator.onExit handlers. - activateLink: (linkMatched, userMightOverType=false) -> + activateLink: (linkMatched, userMightOverType) -> @removeHintMarkers() if linkMatched.isLocalMarker @@ -397,10 +397,11 @@ class LinkHintsMode # If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the # frame containing the matched link does. - if userMightOverType and Settings.get "waitForEnterForFilteredHints" - installKeyboardBlocker (callback) -> new WaitForEnter callback - else if userMightOverType - installKeyboardBlocker (callback) -> new TypingProtector 200, callback + if userMightOverType + if Settings.get "waitForEnterForFilteredHints" + installKeyboardBlocker (callback) -> new WaitForEnter callback + else + installKeyboardBlocker (callback) -> new TypingProtector 200, callback else if linkMatched.isLocalMarker DomUtils.flashRect linkMatched.rect HintCoordinator.sendMessage "exit", isSuccess: true -- cgit v1.2.3 From 48e556d2ea209c22485ee07710dbac2f32fe481f Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 11 Nov 2017 16:19:57 +0000 Subject: Inline installKeyboardBlocker --- content_scripts/link_hints.coffee | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 0b44ea45..e3e96ffe 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -385,7 +385,9 @@ class LinkHintsMode clickEl.focus() linkActivator clickEl - installKeyboardBlocker = (startKeyboardBlocker) -> + # If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the + # frame containing the matched link does. + if userMightOverType if linkMatched.isLocalMarker {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft() for rect in clickEl.getClientRects() @@ -393,15 +395,11 @@ class LinkHintsMode do (flashEl) -> HintCoordinator.onExit.push -> DomUtils.removeElement flashEl 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 - # frame containing the matched link does. - if userMightOverType - if Settings.get "waitForEnterForFilteredHints" - installKeyboardBlocker (callback) -> new WaitForEnter callback - else - installKeyboardBlocker (callback) -> new TypingProtector 200, callback + callback = (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess} + if Settings.get "waitForEnterForFilteredHints" + new WaitForEnter callback + else + new TypingProtector 200, callback else if linkMatched.isLocalMarker DomUtils.flashRect linkMatched.rect HintCoordinator.sendMessage "exit", isSuccess: true -- cgit v1.2.3 From 4f5667c427a1d14fc8c6eb3477eb58c69b467bf9 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Sat, 11 Nov 2017 16:51:47 +0000 Subject: Unify link hint flash codepaths --- content_scripts/link_hints.coffee | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index e3e96ffe..d919dae1 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -385,15 +385,15 @@ class LinkHintsMode clickEl.focus() linkActivator clickEl + if linkMatched.isLocalMarker + {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft() + for rect in clickEl.getClientRects() + flashEl = DomUtils.addFlashRect Rect.translate rect, viewportLeft, viewportTop + do (flashEl) -> HintCoordinator.onExit.push -> DomUtils.removeElement flashEl + # If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the # frame containing the matched link does. if userMightOverType - if linkMatched.isLocalMarker - {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft() - for rect in clickEl.getClientRects() - flashEl = DomUtils.addFlashRect Rect.translate rect, viewportLeft, viewportTop - do (flashEl) -> HintCoordinator.onExit.push -> DomUtils.removeElement flashEl - if windowIsFocused() callback = (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess} if Settings.get "waitForEnterForFilteredHints" @@ -401,7 +401,6 @@ class LinkHintsMode else new TypingProtector 200, callback else if linkMatched.isLocalMarker - DomUtils.flashRect linkMatched.rect HintCoordinator.sendMessage "exit", isSuccess: true # -- cgit v1.2.3 From 4a95a750c0642212c7907f3e8673013d473b2618 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Nov 2017 15:01:37 +0000 Subject: Flash the clicked element for alphabet hints --- content_scripts/link_hints.coffee | 8 +++++--- lib/dom_utils.coffee | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index d919dae1..814ae3b7 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -387,13 +387,14 @@ class LinkHintsMode if linkMatched.isLocalMarker {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft() - for rect in clickEl.getClientRects() - flashEl = DomUtils.addFlashRect Rect.translate rect, viewportLeft, viewportTop - do (flashEl) -> HintCoordinator.onExit.push -> DomUtils.removeElement flashEl + flashElements = for rect in clickEl.getClientRects() + DomUtils.addFlashRect Rect.translate rect, viewportLeft, viewportTop # If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the # frame containing the matched link does. if userMightOverType + if flashElements? + HintCoordinator.onExit.push -> DomUtils.removeElement flashEl for flashEl in flashElements if windowIsFocused() callback = (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess} if Settings.get "waitForEnterForFilteredHints" @@ -401,6 +402,7 @@ class LinkHintsMode else new TypingProtector 200, callback else if linkMatched.isLocalMarker + Utils.setTimeout 400, -> DomUtils.removeElement flashEl for flashEl in flashElements HintCoordinator.sendMessage "exit", isSuccess: true # diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 67d5a44c..df2c2b56 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -311,7 +311,7 @@ DomUtils = flashEl # momentarily flash a rectangular border to give user some visual feedback - flashRect: (rect) -> + flashRect: (rect, callback) -> flashEl = @addFlashRect rect setTimeout((-> DomUtils.removeElement flashEl), 400) -- cgit v1.2.3 From 8be9c399386049d9a44579f9be59aee9d525f8d8 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Nov 2017 15:02:55 +0000 Subject: Reintroduce default value for argument in LinkHints::activateLink --- content_scripts/link_hints.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 814ae3b7..9ab917d1 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -359,7 +359,7 @@ class LinkHintsMode # When only one hint remains, activate it in the appropriate way. The current frame may or may not contain # the matched link, and may or may not have the focus. The resulting four cases are accounted for here by # selectively pushing the appropriate HintCoordinator.onExit handlers. - activateLink: (linkMatched, userMightOverType) -> + activateLink: (linkMatched, userMightOverType = false) -> @removeHintMarkers() if linkMatched.isLocalMarker -- cgit v1.2.3 From 07e49297b567f1b836de4733140909daf6b47438 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Nov 2017 15:05:07 +0000 Subject: Remove unused callback parameter --- lib/dom_utils.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index df2c2b56..67d5a44c 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -311,7 +311,7 @@ DomUtils = flashEl # momentarily flash a rectangular border to give user some visual feedback - flashRect: (rect, callback) -> + flashRect: (rect) -> flashEl = @addFlashRect rect setTimeout((-> DomUtils.removeElement flashEl), 400) -- cgit v1.2.3 From b53999b4ce7ec03b3994c52ae33cb904ce686603 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 24 Nov 2017 15:28:08 +0000 Subject: Localise the logic for handling flash elements. --- content_scripts/link_hints.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 9ab917d1..a7a46e99 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -385,16 +385,18 @@ class LinkHintsMode clickEl.focus() linkActivator clickEl + # If flash elements are created, then this function can be used later to remove them. + removeFlashElements = -> if linkMatched.isLocalMarker {top: viewportTop, left: viewportLeft} = DomUtils.getViewportTopLeft() flashElements = for rect in clickEl.getClientRects() DomUtils.addFlashRect Rect.translate rect, viewportLeft, viewportTop + removeFlashElements = -> DomUtils.removeElement flashEl for flashEl in flashElements # If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the # frame containing the matched link does. if userMightOverType - if flashElements? - HintCoordinator.onExit.push -> DomUtils.removeElement flashEl for flashEl in flashElements + HintCoordinator.onExit.push removeFlashElements if windowIsFocused() callback = (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess} if Settings.get "waitForEnterForFilteredHints" @@ -402,7 +404,7 @@ class LinkHintsMode else new TypingProtector 200, callback else if linkMatched.isLocalMarker - Utils.setTimeout 400, -> DomUtils.removeElement flashEl for flashEl in flashElements + Utils.setTimeout 400, removeFlashElements HintCoordinator.sendMessage "exit", isSuccess: true # -- cgit v1.2.3