Skip to content

Fix DOMRect calc in ResizeObserverEntry #32549

@gterzian

Description

@gterzian

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:

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

window_size: Cell<WindowSizeData>,

and accessible via

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions