feat(html): let a host ask the view to measure the fit itself - #745
Merged
Conversation
Base automatically changed from
fix/viewport-rect-space-and-held-position
to
main
August 26, 2026 05:56
andiwand
force-pushed
the
feat/viewport-fit-measured-by-the-view
branch
from
August 26, 2026 05:59
53c2726 to
61b8de7
Compare
`HtmlViewportMode::fit_width_by_view`. The fit was measured in a frame only, on the reasoning that the viewport meta tag covers a top-level document - which holds for a webview honouring it and fitting on its own, and not for one that does not. A host that fits nothing was left with `viewport_width`, a factor frozen at translation time that a rotation cannot follow. The new mode writes `--odr-fit:view`, which drops the frame condition, and pins `initial-scale=1.0` so a browser that would fit it does not do so as well. Nothing else moves: `automatic` and `fit_width` still leave a top-level document to the meta tag. `fits_width` becomes `width_fit`, returning who fits it rather than whether anyone does, since the answer is now three-valued. Closes #726 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ7jMy9qsh5CofYxiAncUG
andiwand
force-pushed
the
feat/viewport-fit-measured-by-the-view
branch
from
August 26, 2026 06:17
61b8de7 to
d7eb7f4
Compare
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.
🤖 Generated with Claude Code
Stacked on #744 — review that first; base moves to
mainonce it lands.Mode (4) from #726: the view measures the fit and keeps it current, at the top level, opt-in.
What it does
HtmlViewportMode::fit_width_by_viewwrites--odr-fit:view, which drops theframedcondition in the script, and pinsinitial-scale=1.0.The meta tag is the part #726 does not mention, and it is what makes this one switch rather than a negotiation:
loadWithOverviewModeonly fires where the page has not stated a scale. So droid does not have to turn it off, ios has nothing left for its user script to correct, and no host can end up fitting the document twice.The three existing modes are untouched —
automaticandfit_widthstill leave a top-level document to the meta tag, so nothing in the 377 public reference renders moves (full suite run below).viewport_widthset alongside it loses:viewmeans the view keeps the fit current, which is the opposite of freezing a factor into the css. A host under a CSP that cannot run the script wantsviewport_widthand not this mode.The internal shape
fits_width→width_fit, returningWidthFit::{none, host, view}. The question stopped being yes/no —#726puts it as three modes where four are wanted — and a tri-state makes the contradictory combinations unrepresentable rather than something callers have to not write.The enumerator is appended after
none: apple casts the enum toNSIntegerand jni maps it by ordinal, so the existing values stay put.Verification
odr_testin full: 1199 tests, 1193 passed, 6 pre-existing skips — including the 280 reference-output comparisons, so no existing render moved.html_common.fit_width_by_view_pins_the_scale_the_browser_would_fit,html_common.the_view_measures_the_fit_where_it_was_asked_to,width_fit_follows_the_resolved_modeextended, and a case inhtml.paged_output_fits_the_viewport.viewportModeReachesTheHtmlextended and run green.test/browser/viewport/, a 2400px page: top level--odr-fit:viewopens at 0.63 with no overflow in a 1512px window and refits to 0.3333 when the window goes to 800 — and--odr-fit:autoat the top level still opens at 1 and overflows, which is the behaviour this must not change. Framed, both fit.tests.htmllinks the two top-level pages since a frame cannot tell the modes apart.Not run here
viewport_width) #726 says this mode buys the apps — the ios user script deleted,loadWithOverviewModeturned off — is unmeasured from this side.ODR_SAME_ENUMordinal asserts hold.