vimium icon indicating copy to clipboard operation
vimium copied to clipboard

Add zoom commands

Open chjj opened this issue 7 months ago • 1 comments

Implements zoom commands in a manner similar to cVim (which I recently migrated away from as it seems unmaintained).

The three new commands are zoomIn, zoomOut, and zoomReset. These are combined with a configurable zoomStep option which defaults to 0.10 (10%).

The default key mappings for the above commands are zi, zo, and z0 (cVim defaults) -- may be worth bikeshedding over.

Fixes #1866 and #4161 (also see #2978).

chjj avatar Nov 19 '23 01:11 chjj

This is awesome and I think this should get added to Vimium. Thank you @chjj for implementing.

I think the simplest and least surprising implementation is to make this work the same as Chrome and Firefox's built-in zoom behavior.

Chrome's zoom has these properties:

  • All tabs from the same origin are zoomed, and any time you change the zoom, it becomes the origin's default zoom level.

  • In Chrome, the zoom factor can only be one of this fixed range:

    25%
    33%
    50%
    75%
    80% (interesting that they have both an 80% and 75%)
    90%
    100%
    110%
    125%
    150%
    175%
    200%
    250%
    300%
    400%
    500%
    
    • (You can see them all listed in Settings > Appearance > Page zoom)
    • In Firefox, it's a slightly different list. I propose we ignore this difference for now and use one list of factors.
  • "Zoom in" and "zoom out" begin from the site's current zoom level.

  • "Zoom reset" should ideally reset to the zoom level that the user has defined in their settings (Appearance > Page Zoom).

I think the non-linear range of zoom factors is helpful in practice, and presumably someone on the Chrome team thought hard about which specific ones to use.

This PR is pretty close to Chrome's implementation already, but for these changes:

  • Remove the Vimium setting for a fixed zoom step
  • Remove the per-tab scope when calling setZoomSettings
  • Select the next zoom factor from the fixed list of factors above, based on the tab's current zoom level (chrome.tabs.getZoom). This is how it works in Chrome; in this PR, z0 sets the zoom to 100%, no matter what the user's default is.

What do you think?

About key mappings:

zi, zo, and z0 are the mappings I would expect for these commands. You mentioned others; are you aware of any popular alternatives?

[1] Firefox's zoom levels are 30%, 50%, 67%, 80%, 90%, 100%, 120%, 133%, 150%, 170%, 200%, 240%, 300%, 400%, 500%.

philc avatar Dec 09 '23 00:12 philc