diff options
| author | Stephen Blott | 2018-02-18 07:25:57 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2018-02-18 07:33:06 +0000 | 
| commit | d9f798998b2239b59806b34df9f8b57f11365e41 (patch) | |
| tree | 0ae4ca08aabea60ac07fdc691069a28182354e59 /lib | |
| parent | 9a5c2802a941a66b6dea4089352314a6e7a3c95a (diff) | |
| download | vimium-d9f798998b2239b59806b34df9f8b57f11365e41.tar.bz2 | |
Fix Firefox link hints.
Fixes #2958 (probably).
This appears to be correct for target "_blank" (or not) and modifiers
(or not).  That's four cases.
It will be *incorrect* if there is a click listener on a target "_blank"
link.  Some conditions are tested to try to prevent that from happening.
This only affects Firefox.  Chrome is unaffected.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dom_utils.coffee | 19 | 
1 files changed, 15 insertions, 4 deletions
| diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index ebd9cf3d..5c2a2bad 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -246,13 +246,24 @@ DomUtils =            if element.selectionStart == 0 and element.selectionEnd == 0              element.setSelectionRange element.value.length, element.value.length -  simulateClick: (element, modifiers) -> +  simulateClick: (element, modifiers = {}) -> +    console.log modifiers +    console.log Object.keys(modifiers).length      eventSequence = ["mouseover", "mousedown", "mouseup", "click"]      for event in eventSequence -      defaultActionShouldTrigger = @simulateMouseEvent event, element, modifiers -      if event == "click" and defaultActionShouldTrigger and Utils.isFirefox() and element.target != "_blank" +      defaultActionShouldTrigger = +        if Utils.isFirefox() and Object.keys(modifiers).length == 0 and event == "click" and +            element.target == "_blank" and element.href and +            not element.hasAttribute("onclick") and not element.hasAttribute("_vimium-has-onclick-listener") +          # Simulating a click on a target "_blank" element triggers the Firefox popup blocker. +          # Note(smblott) This will be incorrect if there is a click listener on the element. +          true +        else +          @simulateMouseEvent event, element, modifiers +      if event == "click" and defaultActionShouldTrigger and Utils.isFirefox()          # Firefox doesn't (currently) trigger the default action for modified keys. -        DomUtils.simulateClickDefaultAction element, modifiers +        if 0 < Object.keys(modifiers).length or element.target == "_blank" +          DomUtils.simulateClickDefaultAction element, modifiers        defaultActionShouldTrigger # return the values returned by each @simulateMouseEvent call.    simulateMouseEvent: do -> | 
