Implement document.scrollingElement (#35994)

<!-- Please describe your changes on the following line: -->
This implements `document.scrollingElement`
(https://drafts.csswg.org/cssom-view/#dom-document-scrollingelement).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #35700
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

---------

Signed-off-by: JimmyDdotEXE <50691404+JimmyDdotEXE@users.noreply.github.com>
This commit is contained in:
Jimmy D. Buckets 2025-05-05 08:50:42 -04:00 committed by GitHub
parent 7ea5951e34
commit 1f6050f931
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 195 additions and 272 deletions

View file

@ -617753,7 +617753,7 @@
]
],
"scrollingElement.html": [
"408fa47be9a3330aff88ef01e9b8be90fd4008ce",
"093c016da557ff867f86b13f5dff9c6d118230ff",
[
null,
{}

View file

@ -1,3 +0,0 @@
[no-overflow-with-table-cell-margins.html]
[no-overflow-with-table-cell-margins]
expected: FAIL

View file

@ -1,13 +1,4 @@
[HTMLBody-ScrollArea_quirksmode.html]
[document.scrollingElement should be body element in quirks.]
expected: FAIL
[scrollingElement in quirks should be null when body is potentially scrollable.]
expected: FAIL
[scrollingElement in quirks should be body if any of document and body has a visible overflow.]
expected: FAIL
[When body potentially scrollable, document.body.scrollHeight changes when changing the height of the body content in quirks.]
expected: FAIL

View file

@ -38,9 +38,6 @@
[Window interface: window must inherit property "screenTop" with the proper type]
expected: FAIL
[Document interface: attribute scrollingElement]
expected: FAIL
[CSSPseudoElement interface: operation convertRectFromNode(DOMRectReadOnly, GeometryNode, ConvertCoordinateOptions)]
expected: FAIL
@ -107,9 +104,6 @@
[Document interface: document must inherit property "convertRectFromNode(DOMRectReadOnly, GeometryNode, ConvertCoordinateOptions)" with the proper type]
expected: FAIL
[Document interface: document must inherit property "scrollingElement" with the proper type]
expected: FAIL
[CaretPosition interface object name]
expected: FAIL

View file

@ -1,13 +1,4 @@
[scroll-behavior-main-frame-root.html]
[Main frame with auto scroll-behavior ; scroll() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
@ -17,21 +8,9 @@
[Main frame with smooth scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
@ -41,21 +20,9 @@
[Main frame with smooth scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -65,9 +32,6 @@
[Main frame with smooth scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -95,23 +59,11 @@
[Main frame with smooth scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL
[Set scrollLeft to frame with auto scroll-behavior]
expected: FAIL
[Set scrollLeft to frame with smooth scroll-behavior]
expected: FAIL
[Set scrollTop to frame with auto scroll-behavior]
expected: FAIL
[Set scrollTop to frame with smooth scroll-behavior]
expected: FAIL
[Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling]
expected: FAIL
[Aborting an ongoing smooth scrolling on the main frame with an instant scrolling]
expected: FAIL
[Make sure the page is ready for animation.]
expected: FAIL

View file

@ -1,13 +1,4 @@
[scroll-behavior-main-frame-window.html]
[Main frame with auto scroll-behavior ; scroll() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
@ -17,21 +8,9 @@
[Main frame with smooth scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
@ -41,21 +20,9 @@
[Main frame with smooth scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -65,17 +32,8 @@
[Main frame with smooth scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
[Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling]
expected: FAIL
[Aborting an ongoing smooth scrolling on the main frame with an instant scrolling]
expected: FAIL
[Make sure the page is ready for animation.]
expected: FAIL

View file

@ -1,13 +1,4 @@
[scroll-behavior-subframe-root.html]
[Subframe with auto scroll-behavior ; scroll() with default behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
@ -17,21 +8,9 @@
[Subframe with smooth scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollTo() with default behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
@ -41,21 +20,9 @@
[Subframe with smooth scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollBy() with default behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Subframe with auto scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -65,9 +32,6 @@
[Subframe with smooth scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Subframe with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -95,23 +59,11 @@
[Subframe with smooth scroll-behavior ; scrollIntoView() with smooth behavior]
expected: FAIL
[Subframe setting scrollLeft with auto scroll-behavior]
expected: FAIL
[Subframe setting scrollLeft with smooth scroll-behavior]
expected: FAIL
[Subframe setting scrollTop with auto scroll-behavior]
expected: FAIL
[Subframe setting scrollTop with smooth scroll-behavior]
expected: FAIL
[Aborting an ongoing smooth scrolling on a subframe with another smooth scrolling]
expected: FAIL
[Aborting an ongoing smooth scrolling on a subframe with an instant scrolling]
expected: FAIL
[Make sure the page is ready for animation.]
expected: FAIL

View file

@ -1,13 +1,4 @@
[scroll-behavior-subframe-window.html]
[Main frame with auto scroll-behavior ; scroll() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
@ -17,21 +8,9 @@
[Main frame with smooth scroll-behavior ; scroll() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scroll() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scroll() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
@ -41,21 +20,9 @@
[Main frame with smooth scroll-behavior ; scrollTo() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollTo() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollTo() with smooth behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with default behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Main frame with auto scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
@ -65,17 +32,8 @@
[Main frame with smooth scroll-behavior ; scrollBy() with auto behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollBy() with instant behavior]
expected: FAIL
[Main frame with smooth scroll-behavior ; scrollBy() with smooth behavior]
expected: FAIL
[Aborting an ongoing smooth scrolling on the main frame with another smooth scrolling]
expected: FAIL
[Aborting an ongoing smooth scrolling on the main frame with an instant scrolling]
expected: FAIL
[Make sure the page is ready for animation.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[scroll-overflow-clip-quirks-001.html]
[CSSOM scrollingElement reflects the propagated scroll to viewport correctly]
expected: FAIL

View file

@ -1,4 +0,0 @@
[scroll-overflow-clip-quirks-002.html]
[CSSOM scrollingElement reflects the propagated scroll to viewport correctly]
expected: FAIL

View file

@ -1,22 +1,10 @@
[scrolling-quirks-vs-nonquirks.html]
[scrollingElement in non-quirks mode]
expected: FAIL
[scrollLeft/scrollRight of the content in quirks mode]
expected: FAIL
[scrollWidth/scrollHeight on the root element in non-quirks mode]
expected: FAIL
[scrollingElement in quirks mode]
expected: FAIL
[scrollWidth/scrollHeight on the root element in quirks mode]
expected: FAIL
[scrollLeft/scrollRight of the content in non-quirks mode]
expected: FAIL
[scrollWidth/scrollHeight on the HTML body element in quirks mode]
expected: FAIL

View file

@ -1,28 +0,0 @@
[scrollingElement.html]
[scrollingElement in quirks mode]
expected: FAIL
[scrollingElement in no-quirks mode]
expected: FAIL
[scrollingElement in quirks mode (body table)]
expected: FAIL
[scrollingElement in no-quirks mode ]
expected: FAIL
[scrollingElement in no-quirks mode (root table)]
expected: FAIL
[scrollingElement in no-quirks mode (body table)]
expected: FAIL
[scrollingElement in quirks mode (root table, body table)]
expected: FAIL
[scrollingElement in quirks mode (root table)]
expected: FAIL
[scrollingElement in no-quirks mode (root table, body table)]
expected: FAIL

View file

@ -1,3 +0,0 @@
[003.html]
[Fragment Navigation: Updating scroll position]
expected: FAIL

View file

@ -1,6 +1,12 @@
[cross-origin-iframe.sub.html]
[Intersection observer test with no explicit root and target in a cross-origin iframe.]
expected: FAIL
[First rAF]
expected: FAIL
[topDocument.scrollingElement.scrollTop = 200]
expected: FAIL
[iframeDocument.scrollingElement.scrollTop = 250]
expected: FAIL
[topDocument.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +0,0 @@
[disconnect.html]
[First rAF.]
expected: FAIL

View file

@ -1,3 +1,9 @@
[iframe-no-root-with-wrapping-scroller.html]
[First rAF.]
expected: FAIL
[iframe.contentDocument.scrollingElement.scrollTop = 250]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,9 @@
[iframe-no-root.html]
[First rAF.]
expected: FAIL
[iframe.contentDocument.scrollingElement.scrollTop = 250]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,9 @@
[multiple-targets.html]
[First rAF.]
[document.scrollingElement.scrollTop = 150]
expected: FAIL
[document.scrollingElement.scrollTop = 10000]
expected: FAIL
[document.scrollingElement.scrollTop = 0]
expected: FAIL

View file

@ -1,3 +1,21 @@
[multiple-thresholds.html]
[First rAF.]
[document.scrollingElement.scrollTop = 120]
expected: FAIL
[document.scrollingElement.scrollTop = 160]
expected: FAIL
[document.scrollingElement.scrollTop = 200]
expected: FAIL
[document.scrollingElement.scrollTop = 240]
expected: FAIL
[document.scrollingElement.scrollTop = window.innerHeight + 140]
expected: FAIL
[document.scrollingElement.scrollTop = window.innerHeight + 160]
expected: FAIL
[document.scrollingElement.scrollTop = window.innerHeight + 200]
expected: FAIL

View file

@ -1,3 +1,3 @@
[observer-without-js-reference.html]
[First rAF]
[document.scrollingElement.scrollTop = 300]
expected: FAIL

View file

@ -1,3 +1,15 @@
[root-margin-root-element.html]
[First rAF]
expected: FAIL
[root.scrollTop = 50, putting target into root margin]
expected: FAIL
[document.scrollingElement.scrollTop = 0.]
expected: FAIL
[root.scrollTop = 0]
expected: FAIL
[root.scrollTop = 50 with root scrolled out of view.]
expected: FAIL

View file

@ -1,3 +1,9 @@
[root-margin.html]
[First rAF.]
[document.scrollingElement.scrollLeft = 100]
expected: FAIL
[document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200]
expected: FAIL
[document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300]
expected: FAIL

View file

@ -1,3 +1,6 @@
[same-document-no-root.html]
[First rAF.]
[document.scrollingElement.scrollTop = 300]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,15 @@
[same-document-root.html]
[First rAF]
expected: FAIL
[root.scrollTop = 150 with root scrolled into view.]
expected: FAIL
[document.scrollingElement.scrollTop = 0.]
expected: FAIL
[root.scrollTop = 0]
expected: FAIL
[root.scrollTop = 150 with root scrolled out of view.]
expected: FAIL

View file

@ -1,3 +1,3 @@
[same-document-with-document-root.html]
[First rAF.]
[document.scrollingElement.scrollTop = 300]
expected: FAIL

View file

@ -1,3 +1,6 @@
[same-document-zero-size-target.html]
[First rAF]
[document.scrollingElement.scrollTop = 300]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,9 @@
[svg-clipped-rect-target.html]
[First rAF.]
expected: FAIL
[document.scrollingElement.scrollTop = 300]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,9 @@
[svg-intersection-with-fractional-bounds.html]
[Initial Observation]
expected: FAIL
[Intersection observation after scrolling 300]
expected: FAIL
[Intersection observation after scrolling 100]
expected: FAIL

View file

@ -1,3 +1,9 @@
[svg-rect-target.html]
[First rAF.]
expected: FAIL
[document.scrollingElement.scrollTop = 300]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,6 @@
[text-target.html]
[First rAF.]
[document.scrollingElement.scrollTop = 300]
expected: FAIL
[document.scrollingElement.scrollTop = 100]
expected: FAIL

View file

@ -1,3 +1,3 @@
[timestamp.html]
[First rAF after iframe is loaded.]
[Generate notifications.]
expected: FAIL

View file

@ -1,3 +1,3 @@
[visibility-hidden.html]
[First rAF.]
[document.scrollingElement.scrollTop = 300]
expected: FAIL

View file

@ -35,6 +35,18 @@ function quirksTest(rootDisplay, bodyDisplay) {
assert_equals(quirksDoc.scrollingElement, quirksDoc.body,
"scrollingElement in quirks mode should default to body element.");
quirksDoc.documentElement.style.overflow = "clip";
quirksDoc.body.style.overflow = "auto";
assert_equals(quirksDoc.scrollingElement, null);
quirksDoc.body.style.overflow = "hidden";
assert_equals(quirksDoc.scrollingElement, null);
quirksDoc.body.style.overflow = "scroll";
assert_equals(quirksDoc.scrollingElement, null);
quirksDoc.body.style.overflow = "visible";
assert_equals(quirksDoc.scrollingElement, quirksDoc.body);
quirksDoc.body.style.overflow = "clip";
assert_equals(quirksDoc.scrollingElement, quirksDoc.body);
quirksDoc.documentElement.style.overflow = "scroll";
quirksDoc.body.style.overflow = "scroll";
assert_equals(quirksDoc.scrollingElement, null,