diff options
| author | Stephen Blott | 2015-01-18 06:27:38 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-18 10:25:31 +0000 |
| commit | 0e59b99e95e6a4fd3f64fd284e7417ba5f7e22e1 (patch) | |
| tree | 19fddb33de1e00b8024c4cb5c86dc483169da885 /lib | |
| parent | 9cb0f2853a155e39270282e6ed224966afffc61e (diff) | |
| download | vimium-0e59b99e95e6a4fd3f64fd284e7417ba5f7e22e1.tar.bz2 | |
Modes; pre-merge clean up.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dom_utils.coffee | 8 | ||||
| -rw-r--r-- | lib/handler_stack.coffee | 18 |
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 322188b3..e1f1f442 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -166,6 +166,14 @@ DomUtils = node = node.parentNode false + # True if element contains the active selection range. + isSelected: (element) -> + if element.isContentEditable + node = document.getSelection()?.anchorNode + node and @isDOMDescendant element, node + else + element.selectionStart? and element.selectionEnd? and element.selectionStart != element.selectionEnd + simulateSelect: (element) -> element.focus() # When focusing a textbox, put the selection caret at the end of the textbox's contents. diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index fddc45db..76d835b7 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -13,25 +13,24 @@ class HandlerStack @stopBubblingAndTrue = new Object() # A handler should return this value to indicate that the event has been consumed, and no further - # processing should take place. + # processing should take place. The event does not propagate to the underlying page. @stopBubblingAndFalse = new Object() # A handler should return this value to indicate that bubbling should be restarted. Typically, this is - # used when, while bubbling an event, a new mode is pushed onto the stack. See `focusInput` for an - # example. + # used when, while bubbling an event, a new mode is pushed onto the stack. @restartBubbling = new Object() # Adds a handler to the top of the stack. Returns a unique ID for that handler that can be used to remove it # later. push: (handler) -> - handler.id = ++@counter handler._name ||= "anon-#{@counter}" @stack.push handler - handler.id + handler.id = ++@counter - # Adds a handler to the bottom of the stack. Returns a unique ID for that handler that can be used to remove - # it later. + # As above, except the new handler is added to the bottom of the stack. unshift: (handler) -> + handler._name ||= "anon-#{@counter}" + handler._name += "/unshift" @stack.unshift handler handler.id = ++@counter @@ -84,8 +83,9 @@ class HandlerStack # Debugging. logResult: (type, event, handler, result) -> # FIXME(smblott). Badge updating is too noisy, so we filter it out. However, we do need to look at how - # many badge update events are happening. It seems to be more than necessary. - return if type == "updateBadge" + # many badge update events are happening. It seems to be more than necessary. We also filter out + # registerKeyQueue as unnecessarily noisy and not particularly helpful. + return if type in [ "updateBadge", "registerKeyQueue" ] label = switch result when @stopBubblingAndTrue then "stop/true" |
