aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-01-10 11:31:57 +0000
committerStephen Blott2015-01-10 11:31:57 +0000
commit2199ad1bf9a7b063cc68a8e75f7a4a76ba125588 (patch)
tree856d8c50ad45f97c4933045b45a425418e426729 /content_scripts
parentfdcdd0113049042c94b2b56a6b716e2da58b860e (diff)
downloadvimium-2199ad1bf9a7b063cc68a8e75f7a4a76ba125588.tar.bz2
Modes; revert to master's handling of #1415.
The behaviour in the situations described in #1415 require more thought and discussion.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/mode_find.coffee9
-rw-r--r--content_scripts/mode_insert.coffee29
2 files changed, 2 insertions, 36 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee
index 0ce03af6..740358d5 100644
--- a/content_scripts/mode_find.coffee
+++ b/content_scripts/mode_find.coffee
@@ -1,14 +1,10 @@
# NOTE(smblott). Ultimately, all of the FindMode-related code should be moved to this file.
# When we use find mode, the selection/focus can end up in a focusable/editable element. In this situation,
-# special considerations apply. We implement three special cases:
+# special considerations apply. We implement two special cases:
# 1. Prevent keyboard events from dropping us unintentionally into insert mode. This is achieved by
# inheriting from InsertModeBlocker.
-# 2. Prevent all keyboard events on the active element from propagating. This is achieved by setting the
-# trapAllKeyboardEvents option. There's some controversy as to whether this is the right thing to do.
-# See discussion in #1415. This implements Option 2 from there, although Option 3 would be a reasonable
-# alternative.
-# 3. If the very-next keystroke is Escape, then drop immediately into insert mode.
+# 2. If the very-next keystroke is Escape, then drop immediately into insert mode.
#
class PostFindMode extends InsertModeBlocker
constructor: (findModeAnchorNode) ->
@@ -20,7 +16,6 @@ class PostFindMode extends InsertModeBlocker
# instance is automatically deactivated when a new instance is activated.
singleton: PostFindMode
exitOnBlur: element
- trapAllKeyboardEvents: element
return @exit() unless element and findModeAnchorNode
diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee
index 7668d794..1887adbc 100644
--- a/content_scripts/mode_insert.coffee
+++ b/content_scripts/mode_insert.coffee
@@ -94,35 +94,6 @@ class InsertModeBlocker extends Mode
new @options.onClickMode
targetElement: document.activeElement
-# There's some unfortunate feature interaction with chrome's contentEditable handling. If the selection is
-# contentEditable and a descendant of the active element, then chrome focuses it on any unsuppressed keyboard
-# event. This has the unfortunate effect of dropping us unintentally into insert mode. See #1415. A single
-# instance of this mode sits near the bottom of the handler stack and suppresses keyboard events if:
-# - they haven't been handled by any other mode (so not by normal mode, passkeys, insert, ...),
-# - the selection is content editable, and
-# - the selection is a descendant of the active element.
-# This should rarely fire, typically only on fudged keypresses in normal mode. And, even then, only in the
-# circumstances outlined above. So, we shouldn't usually be blocking keyboard events for other extensions or
-# the page itself.
-# There's some controversy as to whether this is the right thing to do. See discussion in #1415. This
-# implements Option 2 from there, although Option 3 would be a reasonable alternative.
-new class ContentEditableTrap extends Mode
- constructor: ->
- super
- name: "content-editable-trap"
- keydown: (event) => @handle => DomUtils.suppressPropagation event
- keypress: (event) => @handle => @suppressEvent
- keyup: (event) => @handle => @suppressEvent
-
- handle: (func) -> if @wouldTriggerInsert() then func() else @continueBubbling
-
- # True if the selection is content editable and a descendant of the active element.
- wouldTriggerInsert: ->
- element = document.getSelection()?.anchorNode?.parentElement
- return element?.isContentEditable and
- document.activeElement and
- DomUtils.isDOMDescendant document.activeElement, element
-
root = exports ? window
root.InsertMode = InsertMode
root.InsertModeTrigger = InsertModeTrigger