Skip to content

fix(dom): resolve viewport units again after a device rebuild that left them alone - #19

Merged
adammharris merged 1 commit into
leaffrom
viewport-units-after-rebuild
Oct 23, 2026
Merged

adammharris merged 1 commit into
leaffrom
viewport-units-after-rebuild

Conversation

@adammharris

Copy link
Copy Markdown
Member

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.

BaseDocument now 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::invalidate visits only the elements that are flagged, so the cost is small.

Tests: viewport_units_tests in blitz-dom/src/document.rs. vh_follows_a_resize_after_a_scale_change fails without the fix (600 instead of 400).

…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.
@adammharris
adammharris merged commit 6b3f4e6 into leaf Oct 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant