mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Add pair of methods to apply/reset scroll offset of paintable
Separate scroll application from before_children_paint and after_children_paint.
This commit is contained in:
parent
8eacb81eba
commit
2952f01e84
4 changed files with 9 additions and 4 deletions
|
@ -117,6 +117,9 @@ public:
|
|||
virtual void before_children_paint(PaintContext&, PaintPhase) const { }
|
||||
virtual void after_children_paint(PaintContext&, PaintPhase) const { }
|
||||
|
||||
virtual void apply_scroll_offset(PaintContext&, PaintPhase) const { }
|
||||
virtual void reset_scroll_offset(PaintContext&, PaintPhase) const { }
|
||||
|
||||
virtual void apply_clip_overflow_rect(PaintContext&, PaintPhase) const { }
|
||||
virtual void clear_clip_overflow_rect(PaintContext&, PaintPhase) const { }
|
||||
|
||||
|
|
|
@ -430,14 +430,14 @@ Optional<CSSPixelRect> PaintableBox::calculate_overflow_clipped_rect() const
|
|||
return m_clip_rect;
|
||||
}
|
||||
|
||||
void PaintableBox::before_children_paint(PaintContext& context, PaintPhase) const
|
||||
void PaintableBox::apply_scroll_offset(PaintContext& context, PaintPhase) const
|
||||
{
|
||||
auto scroll_offset = -this->scroll_offset();
|
||||
context.translate_scroll_offset_by(scroll_offset);
|
||||
context.recording_painter().translate({ context.enclosing_device_pixels(scroll_offset.x()), context.enclosing_device_pixels(scroll_offset.y()) });
|
||||
}
|
||||
|
||||
void PaintableBox::after_children_paint(PaintContext& context, PaintPhase) const
|
||||
void PaintableBox::reset_scroll_offset(PaintContext& context, PaintPhase) const
|
||||
{
|
||||
auto scroll_offset = this->scroll_offset();
|
||||
context.translate_scroll_offset_by(scroll_offset);
|
||||
|
|
|
@ -133,8 +133,8 @@ public:
|
|||
DOM::Document const& document() const { return layout_box().document(); }
|
||||
DOM::Document& document() { return layout_box().document(); }
|
||||
|
||||
virtual void before_children_paint(PaintContext&, PaintPhase) const override;
|
||||
virtual void after_children_paint(PaintContext&, PaintPhase) const override;
|
||||
virtual void apply_scroll_offset(PaintContext&, PaintPhase) const override;
|
||||
virtual void reset_scroll_offset(PaintContext&, PaintPhase) const override;
|
||||
|
||||
virtual void apply_clip_overflow_rect(PaintContext&, PaintPhase) const override;
|
||||
virtual void clear_clip_overflow_rect(PaintContext&, PaintPhase) const override;
|
||||
|
|
|
@ -90,6 +90,7 @@ void StackingContext::paint_node_as_stacking_context(Paintable const& paintable,
|
|||
|
||||
void StackingContext::paint_descendants(PaintContext& context, Paintable const& paintable, StackingContextPaintPhase phase)
|
||||
{
|
||||
paintable.apply_scroll_offset(context, to_paint_phase(phase));
|
||||
paintable.before_children_paint(context, to_paint_phase(phase));
|
||||
paintable.apply_clip_overflow_rect(context, to_paint_phase(phase));
|
||||
|
||||
|
@ -174,6 +175,7 @@ void StackingContext::paint_descendants(PaintContext& context, Paintable const&
|
|||
|
||||
paintable.clear_clip_overflow_rect(context, to_paint_phase(phase));
|
||||
paintable.after_children_paint(context, to_paint_phase(phase));
|
||||
paintable.reset_scroll_offset(context, to_paint_phase(phase));
|
||||
}
|
||||
|
||||
void StackingContext::paint_child(PaintContext& context, StackingContext const& child)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue