-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Part of #31182 (see observe.html).
Relevant tests: all those testing contentRect.top or contentRect.left, such as
| assert_equals(entries[0].contentRect.top, 0, "target top padding"); |
Code is at:
servo/components/script/dom/resizeobserver.rs
Line 127 in 70982df
| box_size.origin.x.to_f64_px(), |
Currently it is wrong, by using box_size.origin, instead it should calculate the distance between it and the viewport.
For example, for x, the spec says to calculate the "The horizontal distance between the viewport’s left edge and the rectangle’s origin."
To make these calculations, I think we need to use the viewport found on the WindowSizeData stored at
servo/components/script/dom/window.rs
Line 243 in 70982df
| window_size: Cell<WindowSizeData>, |
and accessible via
servo/components/script/dom/window.rs
Line 2298 in 70982df
| pub fn window_size(&self) -> WindowSizeData { |
and using the available box_size and/or the available box_size.origin.
These are all using measurements from https://docs.rs/euclid/latest/euclid/index.html, but it is not clear how to exactly get to "the distance between" the box size origin and the viewport(one is a https://docs.rs/euclid/latest/euclid/struct.Point2D.html and the other a https://docs.rs/euclid/latest/euclid/struct.Size2D.html)