aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom_utils.coffee
AgeCommit message (Collapse)Author
2018-02-18Remove console.log()s.Stephen Blott
2018-02-18Fix Firefox link hints.Stephen Blott
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.
2017-12-16Do not open tab for target "_blank".Stephen Blott
Fixes #2860. That issue reports that, when the target is "_blank", Firefox/Vimium ends up opening two tabs.
2017-11-14Don't suppress default action for non-printing keys in link hintsmrmr1993
This restores the old behaviour prior to c4cc76e9f6a0a99ebc297e420be739a0fc77f827 (PR #2772).
2017-11-09Suppress propagation for keyup events when we have for keydown eventsmrmr1993
2017-11-02Replace all references to selection.type with our FF polyfillmrmr1993
Credit to @gdh1995 for catching these oversights.
2017-10-29Suppress all keyup events automatically if we consume the keydownmrmr1993
2017-10-25FF: Share |root| global proxy, re-add the globals to window on DOMLoadmrmr1993
This is a workaround for Firefox bug 1408996.
2017-09-30Merge pull request #2683 from mrmr1993/inject-css-for-framesStephen Blott
Inject user css into all frames
2017-09-29Manually inject custom user CSS into our own frames/pagesmrmr1993
2017-09-29Simulate default click action for <a target="_blank">smrmr1993
2017-09-21Move simulating click default action to DomUtils, add shift handlingmrmr1993
2017-09-14FF: Tweak getViewportTopLeft to use borderTop/Left for clientTop/Leftmrmr1993
2017-09-14Always use getBoundingClientRect for getViewportTopLeftmrmr1993
2017-09-14Revert #2636.Stephen Blott
Mention @mrmr1993. Mention @gdh1995. We have zoom issues resulting from: - style - zoom - --force-device-scale-factor=1.5 - HiDPI This intended to fix HiDPI, but seems to have created problems in the some of the other cases. I don't have time to figure out the problem right now, so I'm going to revert this and push it as 1.60.2. That leaves us pretty much where we were before, I think, in terms of zoom. We can come back to it later.
2017-09-12FF: Don't use devicePixelRatio fix for HiDPI link hintsmrmr1993
2017-09-12Consider devicePixelRatio when calculating viewportmrmr1993
This should fix #2635, fix #2633 and fix #2620.
2017-08-18Check whether events are trusted before executing listenersmrmr1993
2017-04-22Firefox: Polyfill for selection.type for visual mode.Stephen Blott
@mrmr1993... This puts the logic of how we choose the selection type in one place; so, if you have a better idea of how to determine the selection type, then we just change it here. Once.
2017-04-22Refactor getSelectionType() to DOM utils.Stephen Blott
This is a no-op. It is preparatory to implementing a suitable polyfill for `selection.type` for Firefox.
2017-04-18Better check for handlerId.Stephen Blott
2017-04-18Set handlerId directly to a non-id.Stephen Blott
2017-04-18Make the consumeKeyup handler a singleton.Stephen Blott
That is, allow at most one handler to be installed at any one time. I have not observed this to be necessary. However, if there were any systematic way in which we weren't seeing the necessary keyup events, then these handlers would just be added and added. So this seems safer.
2017-04-18Use event.code to detect/suppress keyup events.Stephen Blott
This avoids the possibility of leaking keyup events if the keys a released in a different order from that in which they were pressed. Also, replace suppressKeyupAfterEscape with this same mechanism. This fixes a bug (in master/1.59) whereby we leak the keyup event for `i` when entering insert mode. TODO: - `/`, `<Escape>` leaks a keyup event - `i` leaks a keyup event
2017-04-18Ignore keybiard repeats.Stephen Blott
Keyboard repeats were interfering with smooth scrolling. But we should be ignoreing them anyway.
2017-04-18Move keyboard utils to keydown and migrate normal/visual modes.Stephen Blott
2017-03-04Merge pull request #2369 from gdh1995/zoomed-docEl-offsetStephen Blott
getViewportTopLeft: support zoomed static documentElement
2017-02-09Guard against undefined (out of spec) getDestinationInsertionPointsmrmr1993
2017-01-03take documentElement's border into considerationgdh1995
2017-01-03getViewportTopLeft: consider the new style "contain"gdh1995
If an element's `contain` is/contains `paint`, then it will be forced showing just as its `position` is `relative`.
2017-01-03getViewportTopLeft: support zoomed static documentElementgdh1995
if `document.documentElement` is zoomed, Vimium's hints `<div>` are also zoomed, and then `scrollY` may be not equal with viewport client rect's `top`. Example: * make the tab zoom level is 1, `documentElement`'s `zoom` style is 2 * open a page, scroll to the top left corner * press `f`, and all things are right * exit LinkHints mode, scroll down for 100px, and then press `f` * this time all hints has moved down 200px from the correct place
2016-10-15enterNormalMode; new command - implementationStephen Blott
Here's the problem... Many sites define their own keyboard shortcuts, for example Google Play Music defines `gh` for "go home". On such sites, it's natural to set up pass keys for `g` and `h`. But that makes any Vimium key bindings which begin with `g` inaccessible. Here, we add a new command `enterNormalMode` which installs a new normal-mode instance (without any pass keys). This executes a single normal-mode command then exits. Example: map \ enterNormalMode map | enterNormalMode count=999999 Assuming `g` and `o` are pass keys: - `gh` or `o` - use the page's binding - `\gg` - scroll to top - `2\ggo` - scroll to the top and open the Vomnibar - `\g<Escape>o` - open the Vomnibar - `\<Escape>o` - use the page's bindings - `\\\\\\<Escape>o` - use the page's bindings (new normal-mode instances displace previous ones) This required some changes to the scroller. Previously, we only ever had one normal-mode instance, and could arrange statically that the scroller's key listeners were above normal-mode's key listeners in the handler stack. Here, we fix this by adding and removing the scroller's listeners dynamically, so they're always at the top of the handler stack.
2016-10-08Better positioning of link-hints flash rect.Stephen Blott
When an <a> spans the end of a line and the start of the next line, we now highlight both parts of the link (instead of just the first). Also, refactor code for calculating the position of the viewport into a separate utility in DomUtils.
2016-05-07Merge pull request #2118 from smblott-github/fix-ui-component-init-issuesStephen Blott
Fix UI-component initialization issues (maybe).
2016-04-28Fix UI-component initialization issues.Stephen Blott
This fixes some UI component initialization issues. It's a long story... The problem. - Go to this page: http://www.thejournal.ie/seanad-election-results-2016-2737768-Apr2016/ - Click one of the links from the "Most Popular" box on the right. - Navigate back (`H`) and, as the original page is loading, activate the Vomnibar. In 1.54 this renders Vimium unusable. In `master` this renders the Vomnibar unsable, but the rest of Vimium usable. It seems the source of the issue is that we're initializing UI components too soon. We need to wait until the `readyState` is "complete". With this PR: - The Vomnibar is initialised when the `readyState` is "complete" (in the top frame only, and only if Vimium is enabled). Requests arriving prior to then are silently discarded. - The HUD is also initialized only when the `readyState` is "complete"; however, requests arriving before then are queued. So, if the user immediately enters insert mode, then the "Insert mode" indicator will eventually be displayed. - The help dialog silently discards requests until the `readyState` is "complete. I'm posting this as a PR because: 1. It needs some visibility. 2. With this, if the `readyState` *never* reaches "complete", then the Vomnibar would be unusable. And that's pretty serious.
2016-04-28Make vimiumFlash a class.Stephen Blott
There are circumstances when we hav two (identical) vimiumFlash elements displayed: specifically, when using the waitForEnter keyboard blocker. So, we should use a class (rather than an id) to style the flash element.
2016-04-18Revert "UI-compnent commands must wait for the document to be ready."Stephen Blott
This reverts commit c01d7eea8675f9a7d84999777e8de72244d687b6. Preparatory to implementing an alternative approach.
2016-04-17UI-compnent commands must wait for the document to be ready.Stephen Blott
2016-04-12Make rects absolute in window earlier.Stephen Blott
This is part of an effort (as yet incomplete) to track down some CSP violations we're getting, in this case related to global link hints. Prior to this, we were seeing CSP violations when accessing the window subsequently to collecting the hints, specifically when accessing window.scrollX/Y. Here, we collect the window position immediately, when initially harvesting the hints.
2016-04-05Check for document.activeElement.Stephen Blott
When DomUtils.isFocusable() is called from GrabBackFocus-pushState-monitor it is possible that document.activeElement is not ready. So we should check. Here, we check in DomUtils.isFocusable(), because we always need element to be defined for this test, not just in GrabBackFocus-pushState-monitor.
2016-04-02Refactor DomUtils.documentReady.Stephen Blott
We do not need to install separate event listeners for every callback. Just install one listener and keep track of the callbacks ourself. This is clearer, and also determines the order in which callbacks are called. (Although, we don't rely on that currently.) This also adds a tests.
2016-04-02Rework DomUtils.documentReady().Stephen Blott
There seems to be an issue on this page: - http://i.imgur.com/PdmUjij.jpg whereby "DOMContentLoaded" isn't firing. The page structure is unusual (involving a shadow-DOM element), which might be the source of the problem. What happens is that the "DOMContentLoaded" event fires as required, but the document state is still "loading". Here, we just say that if the "DOMContentLoaded" handler has fired once, then we're good to go.
2016-04-02Move the test for small windows to DomUtils.Stephen Blott
The reason for doing this is that we will be using the same test to decide whether or not to register a frame.
2016-03-28Global link hints; revert b7535a604954b5873d825eb66bfecd08f1f2c99b.Stephen Blott
Here's why: - b7535a604954b5873d825eb66bfecd08f1f2c99b is complicated and complex (O(n^2)). - With experience, it is not obviously better than what was there before, and in some cases it's worse. - b7535a604954b5873d825eb66bfecd08f1f2c99b selects way too much text in some cases; e.g. on Google Inbox, it selects text lengths in the tens of thousands of characters. That cannot be useful. - With global hints, this extra cost (resulting from passing large objects between frames) is significant and noticable. - The simpler approach of accounting for text length when scoring filtered hints (tweaked here: 5cbc5ad702a01a81b98f8c82edb3b6d227c2c7b5) works better in practice.
2016-03-27Remove simulateUnhover(); not being used.Stephen Blott
2016-03-21Rework visual mode.Stephen Blott
- Refactor the three visual-mode modes. - Use the key-handling framework from #2022. - Strip some legacy edit-mode code. - Rename the file (the old file name was misleading). - Add "aw" and "as", previously we had the code for this from edit mode.
2016-03-06Tweak documentReady().Stephen Blott
We can remove these listeners once we're done.
2016-03-03Remove methods which aren't used.Stephen Blott
2016-02-26Don't try to evaluate DomUtils.isSelectable on non-elementsmrmr1993
This stops us from throwing errors when document, window, etc. end up being passed into DomUtils.isSelectable.
2016-02-26Remove outdated blacklist in DomUtils.isEditable, use .isSelectablemrmr1993
This fixes #1964.