diff options
| author | Stephen Blott | 2015-01-08 12:02:03 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-08 12:40:34 +0000 |
| commit | 2fe40dd69bb93b620da60464b9cb57c36adaeca1 (patch) | |
| tree | fb88cbc9081da1f66ec435dd96b0872ce45762e4 /lib | |
| parent | 637d90be6847051d20a4cf3b704d599c877a97d3 (diff) | |
| download | vimium-2fe40dd69bb93b620da60464b9cb57c36adaeca1.tar.bz2 | |
Modes; incorporate small changes from #1413.
Slightly more significant:
Move several utilities to dome_utils.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dom_utils.coffee | 18 | ||||
| -rw-r--r-- | lib/handler_stack.coffee | 6 |
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 1a992b43..9d7ca867 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -141,6 +141,24 @@ DomUtils = (element.nodeName.toLowerCase() == "input" && unselectableTypes.indexOf(element.type) == -1) || element.nodeName.toLowerCase() == "textarea" + # Input or text elements are considered focusable and able to receieve their own keyboard events, and will + # enter insert mode if focused. Also note that the "contentEditable" attribute can be set on any element + # which makes it a rich text editor, like the notes on jjot.com. + isEditable: (element) -> + return true if element.isContentEditable + nodeName = element.nodeName?.toLowerCase() + # Use a blacklist instead of a whitelist because new form controls are still being implemented for html5. + if nodeName == "input" and element.type not in ["radio", "checkbox"] + return true + nodeName in ["textarea", "select"] + + # Embedded elements like Flash and quicktime players can obtain focus. + isEmbed: (element) -> + element.nodeName?.toLowerCase() in ["embed", "object"] + + isFocusable: (element) -> + @isEditable(element) or @isEmbed element + isDOMDescendant: (parent, child) -> node = child while (node != null) diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index 718bee9d..97e189c5 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -58,10 +58,10 @@ class HandlerStack @stack.splice(i, 1) break - # The handler stack handles chrome events (which may need to be suppressed) and internal (fake) events. - # This checks whether that the event at hand is a chrome event. + # The handler stack handles chrome events (which may need to be suppressed) and internal (pseudo) events. + # This checks whether the event at hand is a chrome event. isChromeEvent: (event) -> - event?.preventDefault? and event?.stopImmediatePropagation? + event?.preventDefault? or event?.stopImmediatePropagation? # Convenience wrappers. alwaysContinueBubbling: (handler) -> |
