codebytere

#54374: fix: clamp zoom levels to the displayable range and keep the page scale when visual zoom limits change

Merged
Created: Sep 25, 2026, 7:50:51 AM
Merged: Sep 25, 2026, 11:11:20 AM
4 comments
Target: main

Description of Change

Fixes #47044.
Fixes #52086.

After this change zoom in/out responds immediately at the ends of the zoom range, getZoomLevel()/getZoomFactor() report what is on screen, and setVisualZoomLevelLimits() with a minimum below 1 no longer shrinks the page.

Two causes. setZoomLevel(), setZoomFactor() and the zoomIn/zoomOut roles stored any level in the HostZoomMap while the renderer only displays 25% to 500%, so after zooming past an end the stored value kept moving and the opposite command had to be repeated before anything changed. Separately, Blink resolves an unset initial page scale to the minimum limit, so a visual zoom minimum below 1 rescaled the whole page on the next layout.

WebContentsZoomController::SetZoomLevel now clamps to Blink's displayable range, and the renderer pins the initial page scale to 1 when visual zoom limits are set. Three specs fail on main (factor 100 stored as 100, zoomIn does not recover, visualViewport.scale reads 0.25 after a resize) and pass here; the other zoom specs are unchanged. Docs state the clamping range.

Checklist

Release Notes

Notes:

  • Fixed zoom in/out getting stuck after zooming past the 25%-500% range.
  • Fixed setVisualZoomLevelLimits() shrinking pages when the minimum is under 1.

Backports

43-x-y
Pending
Waiting for a manual backport
44-x-y
Pending
Waiting for a manual backport
45-x-y
Merged
PR Number
#54395
Merged At
Sep 25, 2026, 1:49:05 PM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron