diff options
| author | Stephen Blott | 2015-01-08 07:44:53 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-08 09:33:40 +0000 |
| commit | 5d199e6c786bb2874f7ecb700d505e7b2d70d982 (patch) | |
| tree | d8160473402140c7045e16bc45499af03f4f3ee8 /content_scripts/mode_find.coffee | |
| parent | 7c886d32cca6c0540a9ec6247eb1617b8f1db86a (diff) | |
| download | vimium-5d199e6c786bb2874f7ecb700d505e7b2d70d982.tar.bz2 | |
Modes; refactor and simplify.
- Insert mode trigger and blocker.
- Better comments for PostFindMode.
- Better comments for FocusSelector.
- Make insert mode consistent with master.
Diffstat (limited to 'content_scripts/mode_find.coffee')
| -rw-r--r-- | content_scripts/mode_find.coffee | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 837606f3..2ef74a89 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -1,7 +1,7 @@ # 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, -# PostFindMode handles three special cases: +# special considerations apply. We implement three special cases: # 1. Be an InsertModeBlocker. This prevents 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 @@ -16,12 +16,15 @@ class PostFindMode extends InsertModeBlocker super name: "post-find" + # Be a singleton. That way, we don't have to keep track of any currently-active instance. Such an + # instance is automatically deactivated when a new instance is created. singleton: PostFindMode trapAllKeyboardEvents: element return @exit() unless element and findModeAnchorNode - # Special cases only arise if the active element can take input. So, exit immediately if it cannot. + # Special considerations only arise if the active element can take input. So, exit immediately if it + # cannot. canTakeInput = DomUtils.isSelectable(element) and DomUtils.isDOMDescendant findModeAnchorNode, element canTakeInput ||= element.isContentEditable canTakeInput ||= findModeAnchorNode.parentElement?.isContentEditable |
