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

@ -232173,6 +232173,19 @@
{}
]
],
"overflow-does-not-apply-to-inline-box.html": [
"f4c8a1816399ed368fb219bd1a4e49f61f18d083",
[
null,
[
[
"/css/reference/ref-filled-green-100px-square.xht",
"=="
]
],
{}
]
],
"overflow-ellipsis-dynamic-001.html": [
"2a9edba9308bf06009d7b9a27f21f1e0f1a231c7",
[
@ -630023,7 +630036,7 @@
]
],
"scrollParent.html": [
"9faa0c9a3e92e38662ac77d25b08731fe00a7db3",
"344ee522ef2664e0b963e79812074f08f343f5bf",
[
null,
{}

View file

@ -574,12 +574,3 @@
[Document interface: calling caretPositionFromPoint(double, double, optional CaretPositionFromPointOptions) on document with too few arguments must throw TypeError]
expected: FAIL
[HTMLElement interface: attribute scrollParent]
expected: FAIL
[HTMLElement interface: document.createElement("div") must inherit property "scrollParent" with the proper type]
expected: FAIL
[HTMLElement interface: document.createElement("img") must inherit property "scrollParent" with the proper type]
expected: FAIL

View file

@ -4,9 +4,3 @@
[scrollParent skips intermediate open shadow tree nodes]
expected: FAIL
[scrollParent from inside closed shadow tree]
expected: FAIL
[scrollParent from inside open shadow tree]
expected: FAIL

View file

@ -1,27 +0,0 @@
[scrollParent.html]
[scrollParent returns the nearest scroll container.]
expected: FAIL
[hidden element is a scroll container.]
expected: FAIL
[Element with no box has null scrollParent.]
expected: FAIL
[scrollParent follows absolute positioned containing block chain.]
expected: FAIL
[scrollParent follows fixed positioned containing block chain.]
expected: FAIL
[scrollParent of element fixed to root is null.]
expected: FAIL
[scrollParent of child in root viewport returns document scrolling element.]
expected: FAIL
[scrollParent of fixed element contained within root is document scrolling element.]
expected: FAIL
[scrollParent of body is null.]
expected: FAIL

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-overflow-3/#overflow-control">
<meta name="assert" content="Overflow does not apply to inline boxes so they do not establish scroll containers.">
<link rel="match" href="../reference/ref-filled-green-100px-square.xht">
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css">
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="font: 100px/1 Ahem; background: red; width: 100px">
<span style="overflow: hidden; border-radius: 50%; color: green">X</span>
</div>

View file

@ -29,6 +29,7 @@
display: none;
}
.contains-fixed {
transform: scale(1);
contain: paint;
}
</style>
@ -83,4 +84,4 @@ test(() => { assert_equals(document.body.scrollParent, null); },
"scrollParent of body is null.");
</script>
</html>
</html>