aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrmr19932017-10-29 14:35:36 +0000
committermrmr19932017-10-29 14:55:37 +0000
commitaf74bf84adbe0abcf7fa491f352d31b417c78cd4 (patch)
treedb063eea867e723f878674ff54ad87dc9bc04d62
parent52bd2cdbf662e3d40c0f5273485379be77ef8c19 (diff)
downloadvimium-af74bf84adbe0abcf7fa491f352d31b417c78cd4.tar.bz2
Suppress all keyup events automatically if we consume the keydown
-rw-r--r--content_scripts/link_hints.coffee1
-rw-r--r--content_scripts/mode.coffee13
-rw-r--r--content_scripts/mode_find.coffee2
-rw-r--r--content_scripts/mode_insert.coffee1
-rw-r--r--lib/dom_utils.coffee3
-rw-r--r--lib/handler_stack.coffee6
6 files changed, 9 insertions, 17 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 38ac3b28..7d3cd91c 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -166,7 +166,6 @@ class LinkHintsMode
name: "hint/#{@mode.name}"
indicator: false
singleton: "link-hints-mode"
- passInitialKeyupEvents: true
suppressAllKeyboardEvents: true
suppressTrailingKeyEvents: true
exitOnEscape: true
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 2057d093..6f4bed29 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -55,7 +55,7 @@ class Mode
# the need for modes which suppress all keyboard events 1) to provide handlers for all of those events,
# or 2) to worry about event suppression and event-handler return values.
if @options.suppressAllKeyboardEvents
- for type in [ "keydown", "keypress", "keyup" ]
+ for type in [ "keydown", "keypress" ]
do (handler = @options[type]) =>
@options[type] = (event) => @alwaysSuppressPropagation => handler? event
@@ -120,16 +120,6 @@ class Mode
singletons[key]?.exit()
singletons[key] = this
- # If @options.passInitialKeyupEvents is set, then we pass initial non-printable keyup events to the page
- # or to other extensions (because the corresponding keydown events were passed). This is used when
- # activating link hints, see #1522.
- if @options.passInitialKeyupEvents
- @push
- _name: "mode-#{@id}/passInitialKeyupEvents"
- keydown: => @alwaysContinueBubbling -> handlerStack.remove()
- keyup: (event) =>
- if KeyboardUtils.isPrintable event then @suppressPropagation else @passEventToPage
-
# if @options.suppressTrailingKeyEvents is set, then -- on exit -- we suppress all key events until a
# subsquent (non-repeat) keydown or keypress. In particular, the intention is to catch keyup events for
# keys which we have handled, but which otherwise might trigger page actions (if the page is listening for
@@ -147,7 +137,6 @@ class Mode
name: "suppress-trailing-key-events"
keydown: handler
keypress: handler
- keyup: -> handlerStack.suppressPropagation
Mode.modes.push this
@setIndicator()
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee
index b6c80cec..12c3bb1a 100644
--- a/content_scripts/mode_find.coffee
+++ b/content_scripts/mode_find.coffee
@@ -16,7 +16,7 @@ class SuppressPrintable extends Mode
keyup: (event) =>
# If the selection type has changed (usually, no longer "Range"), then the user is interacting with
# the input element, so we get out of the way. See discussion of option 5c from #1415.
- if document.getSelection().type != type then @exit() else handler event
+ @exit() if document.getSelection().type != type
# When we use find, the selection/focus can land in a focusable/editable element. In this situation, special
# considerations apply. We implement three special cases:
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee
index a43a129f..f512574c 100644
--- a/content_scripts/mode_insert.coffee
+++ b/content_scripts/mode_insert.coffee
@@ -32,7 +32,6 @@ class InsertMode extends Mode
name: "insert"
indicator: if not @permanent and not Settings.get "hideHud" then "Insert mode"
keypress: handleKeyEvent
- keyup: handleKeyEvent
keydown: handleKeyEvent
super extend defaults, options
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index e771d436..b44f5f51 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -353,7 +353,8 @@ DomUtils =
keyup: (event) ->
return handlerStack.continueBubbling unless event.code == code
@remove()
- handlerStack.suppressEvent
+ DomUtils.suppressEvent event
+ handlerStack.continueBubbling
# We cannot track keyup events if we lose the focus.
blur: (event) ->
@remove() if event.target == window
diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee
index 2439f55c..646ddfbd 100644
--- a/lib/handler_stack.coffee
+++ b/lib/handler_stack.coffee
@@ -65,7 +65,11 @@ class HandlerStack
true # Do nothing, but continue bubbling.
else
# result is @suppressEvent or falsy.
- DomUtils.suppressEvent event if @isChromeEvent event
+ if @isChromeEvent event
+ if type == "keydown"
+ DomUtils.consumeKeyup event
+ else
+ DomUtils.suppressEvent event
return false
# None of our handlers care about this event, so pass it to the page.