Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds a Vim tab to the options page and rebuilds the two features behind it —
link hints and scrolling — to match the behaviour of Vimium-C.
Three parts:
1. Vim tab (new screen)
Global settings for the Vim-style actions, stored as
vimSettingsin sync storage(
useVimSettings). Changes save automatically and reach open tabs right away.detection level, look inside web components, hint scrollable areas, skip covered elements
Per-shortcut
hintCharsandsmoothScrollingstill win over the global values.2. Link hint detection — finds far more targets
src/utils/hint-targets.tsreplaces the old fixed CSS selector:getClientRects()instead of the bounding box, so a link wrapped over twolines gets its hint on the first line box instead of over empty space. A wrapper whose own
boxes are empty descends into floated or positioned children instead of being dropped.
onclick, ARIA role,ng-click,jsaction,tabindex), then fuzzy signals (class-name patterns, computedcursor: pointer,scrollable containers).
<area>, and coveredelements are dropped with a hit test that fails open.
cursor: pointercardgets one hint and not one per child.
MAX_ELEMENTS,MAX_COMPUTED_STYLES) to stay quick on large pages.link-hints.tskeeps the overlay and adds filter mode (type the link text, pick a number,optional wait for Enter), blue hints for scrollable panes, and a pointer/mouse event sequence
before the native click for sites that ignore a bare
click().3. Scrolling — runs in the page
src/utils/smooth-scroll.tsmoves scrolling out of the background script. Every scrollkeypress used to cost a message round trip plus a
chrome.scripting.executeScriptinjection,and CSS
behavior: 'smooth'restarted its animation on each repeat — that is the stutter youfeel when you hold a key.
The new scroller runs one
requestAnimationFrameloop per element and axis, and a repeatkeypress adds to the running animation instead of restarting it. Reversing direction
cancels the old motion. It also walks up to the real scrollable ancestor and remembers the
last container scrolled, instead of only looking at
document.activeElement.Scroll actions moved into
contentScriptActionsin the background script and fall back to theold injected handlers only when no content script answers.
Licensing
Vimium-C is Apache-2.0 (MIT for code before 2023-07-15), which is compatible with this MIT
project. No Vimium-C source is copied — its content scripts are written against a private
runtime and build-time constant folding, so these are reimplementations of the techniques.
NOTICE.mdrecords the attribution, a file-by-file table of what came from where, and thechanges made relative to Vimium-C.
Behaviour changes for existing users
Vimium-C. Both are adjustable in the Vim tab.
anyone who turned it off keeps that.
Not included
addEventListenerhook for true click-listener detection. It is thesingle biggest remaining win, but it patches a DOM builtin on every page, so it deserves its
own PR and an opt-in setting.
Testing
hint-targets,smooth-scrollandvim-settings).cursor: pointer-only div, a shadow-DOM button,role="button", anonclickspan and a scrollable panejmoves exactly 100px; ten fast presses sample 61 → 140 → 243 → … → 943 and settleat exactly 1000, so motion is continuous with no dropped or doubled steps
smoothScrolling: falsescrolls instantly
plainnarrows to one match, Enter opens itnpm run visual-review.