Repository navigation
fix: don't let a widget measure its box while the page is laid out for print - #5636
Merged
Merged
Conversation
…r print Print media opens a shut tab's panel. A widget waiting in `measure` for the user to open that panel took the box paper laid out instead. The screen holds an undrawn widget at its stated height (layouts.css); paper holds no box, so an lf-chart there fixed its height from its source's printed box and kept it once the tab opened on screen. The corpus render gate emulates print for a moment in `pressable_paper_findings`. On CI the alert review's two hourly charts measured in that window and drew at height 1, so Plot wrote `<rect height="-59">` (1 − marginTop 20 − marginBottom 40) about seventy times, and the console errors failed the journey's teardown. `measure` now counts a box on paper as no box. It sets aside a paper delivery and observes the element afresh once the page is back on screen. Observing afresh matters because ResizeObserver reports only a change from the size it last delivered, so a screen box the same size as the paper one would never arrive. The new chart test fails before the change: a chart with data-height="200" in a shut tab, laid out once on paper, drew at 180, its source's height. It draws at 200 after. An earlier attempt that drew at the stated height on paper resized the box inside its own ResizeObserver delivery and raised "ResizeObserver loop completed with undelivered notifications" on the corpus. Closes #5463
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.
Print media opens a shut tab's panel, and a widget waiting in
measurefor the user to open that panel took the box paper laid out instead. The screen holds an undrawn widget at its stated height (layouts.css); paper holds no box. So anlf-chartin a shut tab fixed its height from its source's printed box, and kept that height once the tab opened on screen.measurenow counts a box on paper as no box. It sets aside a paper delivery and observes the element afresh once the page is back on screen. That's needed because ResizeObserver reports only a change from the size it last delivered, so a screen box the same size as the paper one would otherwise never arrive.This is the cause of the nightly corpus failure in #5463.
pressable_paper_findingsemulates print for a moment. On CI the alert review's two hourly charts (ar-canary-hours,ar-export-hours) measured in that window and drew at height 1, so Plot wrote<rect height="-59">(1 − marginTop 20 − marginBottom 40) about seventy times. Those console errors failed the journey's teardown. Drawing those two chart specs with Plot at height 1 gives exactly those-59bars. Locally, a probe showed both charts first receive a size whilematchMedia("print")matches: 1040×540 and 1040×560, against stated heights of 200 and 220.Verification
test_a_chart_first_laid_out_on_paper_draws_at_its_stated_height: a chart withdata-height="200"in a shut tab, laid out once on paper, draws at 180 (its source's height) on main and at 200 with this change.tests/browser/widgets/test_charts.pyandtests/smoke/test_plain_page.pypass, as do the print/paper-named tests across the browser files that emulate print.tests/journeys/test_render_gate.py::test_the_layer_holds_its_whole_page_rules_on_the_corpus --run-nightlypasses locally. It passed on main locally too: the CI-only window doesn't open on this host, even at 6× CPU throttle, so the nightly run after merge is the evidence for the journey itself.pnpm run checkandpnpm run test:runtimepass.Rejected alternatives: drawing at the stated
data-lf-heighteverywhere overrode an author's own CSS height (test_a_host_draws_each_widget_as_a_leaf_page_does). Drawing at the stated height only on paper resized the box inside its own ResizeObserver delivery and raised "ResizeObserver loop completed with undelivered notifications" on the corpus. Making the stated-height hold apply on paper as well would change what every x-height widget prints, so it's left alone.skills/leaf/references/module-authoring.mdsaysmeasurerunstake"once the element has a box". That's still accurate, but it could now say "a box on screen". That edit is left out because it touches shipped agent instructions.Closes #5463 — automated triage