Files
raea/runtime/dom
Luke, I am your fatherandshinyobjectz ea741f6bef Page: give Blitz its viewport in device pixels (a Retina window's interface sits in a quarter of it) (#120)
* Page: Blitz's viewport is in device pixels, so a page at scale 2 fills its image (#119)

a78fb95 gives the app window's page the display's scale. With a scale other than 1, raea-sys-page still gave
Blitz a viewport whose window_size was the page's size in points. Blitz's window_size is in device pixels (it
divides by hidpi_scale for the CSS viewport), as the page's image and paint_scene already are, so on a Retina
display the interface was sharp but laid out in the top-left quarter of the window.

Page::px is the page's size in device pixels, used for the image, the paint and the viewport.

Nothing changes at scale 1.

* Page: the page's JS and its element list read the viewport in CSS px, and devicePixelRatio is the page's scale

With Blitz's viewport in device pixels, two readers of window_size in runtime/dom still took it for CSS px.
snapshot sent it as vw and vh with dpr 1, so at scale 2 innerWidth and matchMedia answered twice the width the
page is laid out at; elements tested boxes against a window twice the size, so elements up to a window's width
off screen were listed as visible. Both read the viewport's logical size now, and dpr is its scale.

tests/viewport.rs: a page at scale 2 lays a 100vw x 100vh element out at its size in CSS px; scale 1 is as it
was; a fractional scale rounds the image up.

Rebased onto main at 6da2995: main's LR1 (7fb2194) moved the layout snapshot into raea-sys-page (systems/page/src/snapshot.rs, snapshot_by, which a composition's page.layout answers too), so the vw, vh and dpr change is made there, and elements.rs re-exports it.

* Page tests: q and attr live in tests/common, which vars.rs and viewport.rs both use, not one copy each (dupes back to 293)

---------

Co-authored-by: shinyobjectz <[email protected]>
2026-11-12 19:48:36 -05:00
..
2026-10-31 13:15:29 -07:00