aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-10 15:05:58 +0000
committerStephen Blott2015-01-10 15:05:58 +0000
commitc554d1fd5b6d81506864516b6f86a14f8672bec5 (patch)
tree5e2d15e17a0344a0882cd57dda1d4d2665a1b9f1 /content_scripts/mode.coffee
parent35cb54fec7242fac5c68503a32ef9dd4fea5d9b6 (diff)
downloadvimium-c554d1fd5b6d81506864516b6f86a14f8672bec5.tar.bz2
Modes; reinstate key blockers:
- when the selection is contentEditable - in PostFindMode Restricted to printable characters.
Diffstat (limited to 'content_scripts/mode.coffee')
-rw-r--r--content_scripts/mode.coffee20
1 files changed, 9 insertions, 11 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index a33197b0..5c6201e0 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -111,23 +111,21 @@ class Mode
@passKeys = passKeys
@registerStateChange?()
- # If @options.trapAllKeyboardEvents is truthy, then it should be an element. All keyboard events on that
- # element are suppressed *after* bubbling the event down the handler stack. This prevents such events
- # from propagating to other extensions or the host page.
- if @options.trapAllKeyboardEvents
+ # If @options.suppressPrintableEvents is truthy, then it should be an element. All printable keyboard
+ # events on that element are suppressed, if necessary (that is, *after* bubbling down the handler stack).
+ # We only suppress keypress events. This is used by PostFindMode to protect active, editable elements.
+ # Note: We use unshift here, not push, so the handler is installed at the bottom of the stack.
+ if @options.suppressPrintableEvents
@unshift
- _name: "mode-#{@id}/trapAllKeyboardEvents"
- keydown: (event) =>
- if event.srcElement == @options.trapAllKeyboardEvents then @suppressEvent else @continueBubbling
+ _name: "mode-#{@id}/suppressPrintableEvents"
keypress: (event) =>
- if event.srcElement == @options.trapAllKeyboardEvents then @suppressEvent else @continueBubbling
- keyup: (event) =>
- if event.srcElement == @options.trapAllKeyboardEvents then @suppressEvent else @continueBubbling
+ if DomUtils.isPrintable(event) and
+ event.srcElement == @options.suppressPrintableEvents then @suppressEvent else @continueBubbling
Mode.updateBadge() if @badge
Mode.modes.push @
@log() if @debug
- handlerStack.debugOn()
+ # handlerStack.debugOn()
# End of Mode constructor.
push: (handlers) ->