Repository navigation
fix(dom): resolve viewport units again after a device rebuild that left them alone - #19
Merged
Merged
Conversation
…ft them alone Stylo records the use of viewport units on the Device, and a rebuilt device starts without that record. A rebuild that changed only the scale (a window moved to a screen of another scale, its backing size and scale reported in one frame) or the color scheme restyles none of the elements that use vw/vh, so the next device forgot them, and the next resize left them sized for the old viewport: a body of height 100vh stayed at the old window's height. The document now keeps the record across rebuilds.
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.
Stylo records the use of viewport units on the
Device, and a rebuilt device starts without that record. A rebuild that changes only the scale or the color scheme restyles none of the elements that use vw/vh, so the next device does not know of them, and the next resize leaves them sized for the old viewport.On macOS this happens whenever a window moves to a screen of another scale: winit-appkit reports the halved backing size and the new scale in one frame (only the scale changes), and then the window manager resizes the window. In Diaryx,
html, body { height: 100vh }kept the old window's height, and the sidebar stopped short of the bottom of the window.BaseDocumentnow keeps the record across rebuilds (styles_used_viewport_units). Once a style has used a viewport unit, every later change to the viewport size invalidates those elements.viewport_units::invalidatevisits only the elements that are flagged, so the cost is small.Tests:
viewport_units_testsinblitz-dom/src/document.rs.vh_follows_a_resize_after_a_scale_changefails without the fix (600 instead of 400).