LibWeb/DOM: Move pseudo-element scroll offsets into PseudoElement

This commit is contained in:
Sam Atkins 2025-06-18 10:11:12 +01:00
commit f98312d022
Notes: github-actions[bot] 2025-06-19 11:36:37 +00:00
4 changed files with 33 additions and 19 deletions

View file

@ -3031,7 +3031,7 @@ void Element::scroll(double x, double y)
// as the element is not eligible to be the Document.scrollingElement.
if (x == 0
&& y == 0
&& scroll_offset(ScrollOffsetFor::Self).is_zero()
&& scroll_offset({}).is_zero()
&& this != document.body()
&& this != document.document_element()) {
return;
@ -3397,6 +3397,25 @@ IntersectionObserver::IntersectionObserverRegistration& Element::get_intersectio
return *registration_iterator;
}
CSSPixelPoint Element::scroll_offset(Optional<CSS::PseudoElement> pseudo_element_type) const
{
if (pseudo_element_type.has_value()) {
if (auto pseudo_element = get_pseudo_element(*pseudo_element_type); pseudo_element.has_value())
return pseudo_element->scroll_offset();
return {};
}
return m_scroll_offset;
}
void Element::set_scroll_offset(Optional<CSS::PseudoElement> pseudo_element_type, CSSPixelPoint offset)
{
if (pseudo_element_type.has_value()) {
if (auto pseudo_element = get_pseudo_element(*pseudo_element_type); pseudo_element.has_value())
pseudo_element->set_scroll_offset(offset);
}
m_scroll_offset = offset;
}
// https://html.spec.whatwg.org/multipage/dom.html#translation-mode
Element::TranslationMode Element::translation_mode() const
{