script: Get scroll offsets from layout (#37509)

No longer store scroll offsets for elements in the DOM. Instead
consistently get and set these in layout's `ScrollTree`. This more
consistently requires layout to run when querying scroll offsets, which
ensures that they are up-to-date and properly bounded by scrollable
overflow area.

Testing: This causes several WPT tests to start passing, and one to
start
failing. In the case of
`/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html`, I believe the
issue
is that we don't properly handle scrolling and shadow DOM elements.
Before, the
faulty scrolling was hiding this issue.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-06-20 11:39:12 +02:00 committed by GitHub
parent 518729a4f5
commit 3774ef00d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 116 additions and 117 deletions

View file

@ -424,6 +424,15 @@ impl ScrollTree {
_ => None,
}))
}
/// Get the scroll offset for the given [`ExternalScrollId`] or `None` if that node cannot
/// be found in the tree.
pub fn scroll_offset(&self, id: ExternalScrollId) -> Option<LayoutVector2D> {
self.nodes.iter().find_map(|node| match node.info {
SpatialTreeNodeInfo::Scroll(ref info) if info.external_id == id => Some(info.offset),
_ => None,
})
}
}
/// In order to pretty print the [ScrollTree] structure, we are converting