mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:27:35 +00:00
LibWeb: Implement document.scrollingElement
This returns a reference to the element that scrolls the document. In standards mode it is equivalent to `document.documentElement`.
This commit is contained in:
parent
fc8f6c07b4
commit
c24652bd2e
7 changed files with 44 additions and 0 deletions
|
@ -3857,4 +3857,26 @@ Vector<JS::NonnullGCPtr<Element>> Document::elements_from_point(double x, double
|
|||
return sequence;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-document-scrollingelement
|
||||
JS::GCPtr<Element const> Document::scrolling_element() const
|
||||
{
|
||||
// 1. If the Document is in quirks mode, follow these substeps:
|
||||
if (in_quirks_mode()) {
|
||||
// 1. If the body element exists, 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 (auto const* body_element = body(); body_element && !body_element->is_potentially_scrollable())
|
||||
return body_element;
|
||||
|
||||
// 2. Return null and abort these steps.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 2. If there is a root element, return the root element and abort these steps.
|
||||
if (auto const* root_element = document_element(); root_element)
|
||||
return root_element;
|
||||
|
||||
// 3. Return null.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -568,6 +568,7 @@ public:
|
|||
|
||||
Element const* element_from_point(double x, double y);
|
||||
Vector<JS::NonnullGCPtr<Element>> elements_from_point(double x, double y);
|
||||
JS::GCPtr<Element const> scrolling_element() const;
|
||||
|
||||
void set_needs_to_resolve_paint_only_properties() { m_needs_to_resolve_paint_only_properties = true; }
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ interface Document : Node {
|
|||
// https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
|
||||
Element? elementFromPoint(double x, double y);
|
||||
sequence<Element> elementsFromPoint(double x, double y);
|
||||
readonly attribute Element? scrollingElement;
|
||||
};
|
||||
|
||||
dictionary ElementCreationOptions {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue