LibWeb: Remove ClippableAndScrollable mixin

Initially ClippableAndScrollable was introduced, because we had
PaintableBox and InlinePaintable and both wanted to share clipping and
scrolling logic. Now, when InlinePaintable is gone, we could inline
ClippableAndScrollable implementation into PaintableBox.
This commit is contained in:
Aliaksandr Kalenik 2025-07-07 19:17:19 +02:00 committed by Alexander Kalenik
commit 5a874cc62a
Notes: github-actions[bot] 2025-07-07 20:06:47 +00:00
6 changed files with 95 additions and 136 deletions

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2022-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2022-2025, Sam Atkins <sam@ladybird.org>
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
* Copyright (c) 2024-2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@ -619,6 +619,67 @@ BorderRadiiData PaintableBox::normalized_border_radii_data(ShrinkRadiiForBorders
return border_radii_data;
}
Optional<int> PaintableBox::own_scroll_frame_id() const
{
if (m_own_scroll_frame)
return m_own_scroll_frame->id();
return {};
}
Optional<int> PaintableBox::scroll_frame_id() const
{
if (m_enclosing_scroll_frame)
return m_enclosing_scroll_frame->id();
return {};
}
CSSPixelPoint PaintableBox::cumulative_offset_of_enclosing_scroll_frame() const
{
if (m_enclosing_scroll_frame)
return m_enclosing_scroll_frame->cumulative_offset();
return {};
}
Optional<CSSPixelRect> PaintableBox::clip_rect_for_hit_testing() const
{
if (m_enclosing_clip_frame)
return m_enclosing_clip_frame->clip_rect_for_hit_testing();
return {};
}
void PaintableBox::apply_clip(PaintContext& context, RefPtr<ClipFrame const> const& from_clip_frame)
{
auto const& clip_rects = from_clip_frame->clip_rects();
if (clip_rects.is_empty())
return;
auto& display_list_recorder = context.display_list_recorder();
display_list_recorder.save();
for (auto const& clip_rect : clip_rects) {
Optional<i32> clip_scroll_frame_id;
if (clip_rect.enclosing_scroll_frame)
clip_scroll_frame_id = clip_rect.enclosing_scroll_frame->id();
display_list_recorder.push_scroll_frame_id(clip_scroll_frame_id);
auto rect = context.rounded_device_rect(clip_rect.rect).to_type<int>();
auto corner_radii = clip_rect.corner_radii.as_corners(context);
if (corner_radii.has_any_radius()) {
display_list_recorder.add_rounded_rect_clip(corner_radii, rect, CornerClip::Outside);
} else {
display_list_recorder.add_clip_rect(rect);
}
display_list_recorder.pop_scroll_frame_id();
}
}
void PaintableBox::restore_clip(PaintContext& context, RefPtr<ClipFrame const> const& from_clip_frame)
{
auto const& clip_rects = from_clip_frame->clip_rects();
if (clip_rects.is_empty())
return;
context.display_list_recorder().restore();
}
void PaintableBox::apply_scroll_offset(PaintContext& context) const
{
if (scroll_frame_id().has_value()) {