1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibWeb: Move scroll_offset() from Layout::Box to PaintableBox

Nodes in layout tree should not be aware of scroll state.
This commit is contained in:
Aliaksandr Kalenik 2023-08-06 20:51:46 +02:00 committed by Andreas Kling
parent 23a07a8ab6
commit 5b7926fa53
6 changed files with 23 additions and 26 deletions

View file

@ -61,23 +61,10 @@ bool Box::is_scrollable() const
return computed_values().overflow_y() == CSS::Overflow::Scroll;
}
CSSPixelPoint Box::scroll_offset() const
{
if (is_generated_for_before_pseudo_element())
return pseudo_element_generator()->scroll_offset(DOM::Element::ScrollOffsetFor::PseudoBefore);
if (is_generated_for_after_pseudo_element())
return pseudo_element_generator()->scroll_offset(DOM::Element::ScrollOffsetFor::PseudoAfter);
if (!is<DOM::Element>(*dom_node()))
return {};
return static_cast<DOM::Element const*>(dom_node())->scroll_offset(DOM::Element::ScrollOffsetFor::Self);
}
void Box::set_scroll_offset(CSSPixelPoint offset)
{
// FIXME: If there is horizontal and vertical scroll ignore only part of the new offset
if (offset.y() < 0 || scroll_offset() == offset)
if (offset.y() < 0 || paintable_box()->scroll_offset() == offset)
return;
if (is_generated_for_before_pseudo_element()) {

View file

@ -54,7 +54,6 @@ public:
bool is_scroll_container() const;
bool is_scrollable() const;
CSSPixelPoint scroll_offset() const;
void set_scroll_offset(CSSPixelPoint);
protected: