diff options
| author | Stephen Blott | 2017-11-03 07:06:32 +0000 | 
|---|---|---|
| committer | GitHub | 2017-11-03 07:06:32 +0000 | 
| commit | 1eceb1413b43b0b43f225a5270dc9f2e6c212836 (patch) | |
| tree | 7b3bb922916e246fbeeb71c53d6263f996ead4bc | |
| parent | e3ca00a9f6402730b21a059a751a1b6f1d9d19ea (diff) | |
| parent | 66cd3b27c2183bc1cc2dcc1aac82d7c12ffeff54 (diff) | |
| download | vimium-1eceb1413b43b0b43f225a5270dc9f2e6c212836.tar.bz2 | |
Merge pull request #2766 from mrmr1993/bugs-fixup
Fix comments from #2763 and #2762
| -rw-r--r-- | content_scripts/mode_find.coffee | 13 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 6 | 
2 files changed, 8 insertions, 11 deletions
| diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 950b08e9..f19b5db4 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -6,7 +6,7 @@ class SuppressPrintable extends Mode    constructor: (options) ->      super options      handler = (event) => if KeyboardUtils.isPrintable event then @suppressEvent else @continueBubbling -    type = document.getSelection().type +    type = DomUtils.getSelectionType()      # We use unshift here, so we see events after normal mode, so we only see unmapped keys.      @unshift @@ -16,7 +16,7 @@ class SuppressPrintable extends Mode        keyup: (event) =>          # If the selection type has changed (usually, no longer "Range"), then the user is interacting with          # the input element, so we get out of the way.  See discussion of option 5c from #1415. -        @exit() if document.getSelection().type != type +        @exit() if DomUtils.getSelectionType() != type  # When we use find, the selection/focus can land in a focusable/editable element.  In this situation, special  # considerations apply.  We implement three special cases: @@ -235,17 +235,14 @@ class FindMode extends Mode  getCurrentRange = ->    selection = getSelection() -  if selection.type == "None" +  if DomUtils.getSelectionType(selection) == "None"      range = document.createRange()      range.setStart document.body, 0      range.setEnd document.body, 0      range    else -    selection.collapseToStart() if selection.type == "Range" -    if selection.rangeCount > 0 -      selection.getRangeAt 0 -    else # Firefox returns a selection with no ranges and null anchor/focusNode in some situations. -      null +    selection.collapseToStart() if DomUtils.getSelectionType(selection) == "Range" +    selection.getRangeAt 0  getLinkFromSelection = ->    node = window.getSelection().anchorNode diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index b44f5f51..d8a5d203 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -219,7 +219,7 @@ DomUtils =        node = selection.anchorNode        node and @isDOMDescendant element, node      else -      if selection.type == "Range" and selection.isCollapsed +      if DomUtils.getSelectionType(selection) == "Range" and selection.isCollapsed  	      # The selection is inside the Shadow DOM of a node. We can check the node it registers as being  	      # before, since this represents the node whose Shadow DOM it's inside.          containerNode = selection.anchorNode.childNodes[selection.anchorOffset] @@ -364,7 +364,7 @@ DomUtils =        handlerStack.suppressEvent    # Polyfill for selection.type (which is not available in Firefox). -  getSelectionType: (selection) -> +  getSelectionType: (selection = document.getSelection()) ->      selection.type or do ->        if selection.rangeCount == 0          "None" @@ -377,7 +377,7 @@ DomUtils =    # This finds the element containing the selection focus.    getElementWithFocus: (selection, backwards) ->      r = t = selection.getRangeAt 0 -    if selection.type == "Range" +    if DomUtils.getSelectionType(selection) == "Range"        r = t.cloneRange()        r.collapse backwards      t = r.startContainer | 
