aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorJimmy D. Buckets <50691404+JimmyDdotEXE@users.noreply.github.com>2025-05-05 08:50:42 -0400
committerGitHub <noreply@github.com>2025-05-05 12:50:42 +0000
commit1f6050f9314c84745ab6451ddb78b8cebe8237e5 (patch)
tree6ef73f0eda46150a02203324196a33aace6be244 /components/script/dom/document.rs
parent7ea5951e3436a60980661cc63a25cec976e727e9 (diff)
downloadservo-1f6050f9314c84745ab6451ddb78b8cebe8237e5.tar.gz
servo-1f6050f9314c84745ab6451ddb78b8cebe8237e5.zip
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>
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index bb30a84172c..ae48fa1fb2f 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -6369,6 +6369,30 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
)
}
+ /// <https://drafts.csswg.org/cssom-view/#dom-document-scrollingelement>
+ fn GetScrollingElement(&self, can_gc: CanGc) -> Option<DomRoot<Element>> {
+ // Step 1. If the Document is in quirks mode, follow these steps:
+ if self.quirks_mode() == QuirksMode::Quirks {
+ // Step 1.1. If the body element exists,
+ if let Some(ref body) = self.GetBody() {
+ let e = body.upcast::<Element>();
+ // and it is not potentially scrollable, return the body element and abort these steps.
+ // For this purpose, a value of overflow:clip on the the body element’s parent element
+ // must be treated as overflow:hidden.
+ if !e.is_potentially_scrollable_body_for_scrolling_element(can_gc) {
+ return Some(DomRoot::from_ref(e));
+ }
+ }
+
+ // Step 1.2. Return null and abort these steps.
+ return None;
+ }
+
+ // Step 2. If there is a root element, return the root element and abort these steps.
+ // Step 3. Return null.
+ self.GetDocumentElement()
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-document-open
fn Open(
&self,