script/layout: Implement HTMLElement.scrollParent (#39110)

This new API allows getting the element which establishes an element's
scroll container. This will be used to properly implement
`scrollIntoView`. There is still work to do for this API and
`offsetParent` to properly handle ancestors which are
closed-shadow-hidden from the original query element.

In addition, fix an issue where inline boxes were establishing scrolling
containers (they shouldn't do that).

Testing: There are tests for this change.
Fixes: #39096.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-09-03 11:52:15 -07:00 committed by GitHub
parent 5c7ea4bdee
commit 2c7866eb24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 173 additions and 49 deletions

View file

@ -598,6 +598,14 @@ impl ComputedValuesExt for ComputedValues {
let mut overflow_x = style_box.overflow_x;
let mut overflow_y = style_box.overflow_y;
// Inline boxes should never establish scroll containers.
if self.is_inline_box(fragment_flags) {
return AxesOverflow {
x: Overflow::Visible,
y: Overflow::Visible,
};
}
// https://www.w3.org/TR/css-overflow-3/#overflow-propagation
// The element from which the value is propagated must then have a used overflow value of visible.
if fragment_flags.contains(FragmentFlags::PROPAGATED_OVERFLOW_TO_VIEWPORT) {