aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2017-11-10 07:20:24 +0000
committerGitHub2017-11-10 07:20:24 +0000
commit7cb53750bfb5f62849fcfb52f67b1e04ad0f9672 (patch)
tree11bc262e83097087d8363e82c4e0295e89628be3
parent56c2a89613199bc0369a66d19bf848e14b019671 (diff)
parentca6733c88e94c4e0d8d916eb4d494d4c8a179aa4 (diff)
downloadvimium-7cb53750bfb5f62849fcfb52f67b1e04ad0f9672.tar.bz2
Merge pull request #2782 from mrmr1993/suppress-link-hint-keys
Suppress link hint keys
-rw-r--r--content_scripts/link_hints.coffee7
-rw-r--r--lib/dom_utils.coffee7
-rw-r--r--lib/handler_stack.coffee5
-rw-r--r--tests/unit_tests/handler_stack_test.coffee1
4 files changed, 13 insertions, 7 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 9145454a..f2fb7c19 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -293,11 +293,10 @@ class LinkHintsMode
if keyChar.length == 1
@markerMatcher.pushKeyChar keyChar
@updateVisibleMarkers()
- handlerStack.suppressEvent
- return
+ else
+ return
- # We've handled the event, so suppress it and update the mode indicator.
- DomUtils.suppressEvent event
+ handlerStack.suppressEvent
updateVisibleMarkers: (tabCount = 0) ->
{hintKeystrokeQueue, linkTextKeystrokeQueue} = @markerMatcher
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index d8a5d203..95b9f4b3 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -344,7 +344,7 @@ DomUtils =
consumeKeyup: do ->
handlerId = null
- (event, callback = null) ->
+ (event, callback = null, suppressPropagation) ->
unless event.repeat
handlerStack.remove handlerId if handlerId?
code = event.code
@@ -353,7 +353,10 @@ DomUtils =
keyup: (event) ->
return handlerStack.continueBubbling unless event.code == code
@remove()
- DomUtils.suppressEvent event
+ if suppressPropagation
+ DomUtils.suppressPropagation event
+ else
+ DomUtils.suppressEvent event
handlerStack.continueBubbling
# We cannot track keyup events if we lose the focus.
blur: (event) ->
diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee
index 646ddfbd..a43fc356 100644
--- a/lib/handler_stack.coffee
+++ b/lib/handler_stack.coffee
@@ -57,7 +57,10 @@ class HandlerStack
if result == @passEventToPage
return true
else if result == @suppressPropagation
- DomUtils.suppressPropagation event
+ if type == "keydown"
+ DomUtils.consumeKeyup event, null, true
+ else
+ DomUtils.suppressPropagation event
return false
else if result == @restartBubbling
return @bubbleEvent type, event
diff --git a/tests/unit_tests/handler_stack_test.coffee b/tests/unit_tests/handler_stack_test.coffee
index 7b62af07..374c235b 100644
--- a/tests/unit_tests/handler_stack_test.coffee
+++ b/tests/unit_tests/handler_stack_test.coffee
@@ -4,6 +4,7 @@ extend(global, require "../../lib/handler_stack.js")
context "handlerStack",
setup ->
stub global, "DomUtils", {}
+ stub DomUtils, "consumeKeyup", ->
stub DomUtils, "suppressEvent", ->
stub DomUtils, "suppressPropagation", ->
@handlerStack = new HandlerStack