diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-01-23 11:27:17 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-23 10:21:23 +0100 |
commit | 802d9336f01e89c78efaaf827a01e899c6643f39 (patch) | |
tree | df736b94f73ad141aee6bf64663550fa10fdf287 /Userland | |
parent | 3bd96f29d2d42a6cc99da530cbc900ac8176d4ce (diff) | |
download | serenity-802d9336f01e89c78efaaf827a01e899c6643f39.zip |
LibWeb: Use CSS Pixels for overflow clip rect
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/PaintableBox.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 213e36a2cd..4d15d45847 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -318,7 +318,7 @@ BorderRadiiData PaintableBox::normalized_border_radii_data(ShrinkRadiiForBorders return border_radius_data; } -Optional<Gfx::IntRect> PaintableBox::clip_rect() const +Optional<CSSPixelRect> PaintableBox::clip_rect() const { if (!m_clip_rect.has_value()) { if (containing_block() && containing_block()->paint_box()) @@ -329,9 +329,9 @@ Optional<Gfx::IntRect> PaintableBox::clip_rect() const if (overflow_x == CSS::Overflow::Hidden && overflow_y == CSS::Overflow::Hidden) { if (m_clip_rect.has_value()) { - m_clip_rect->intersect(absolute_padding_box_rect().to_type<float>().to_rounded<int>()); + m_clip_rect->intersect(absolute_padding_box_rect()); } else { - m_clip_rect = absolute_padding_box_rect().to_type<float>().to_rounded<int>(); + m_clip_rect = absolute_padding_box_rect(); } } } @@ -352,7 +352,7 @@ void PaintableBox::before_children_paint(PaintContext& context, PaintPhase phase auto clip_overflow = [&] { if (!m_clipping_overflow) { context.painter().save(); - context.painter().add_clip_rect(*clip_rect); + context.painter().add_clip_rect(context.rounded_device_rect(*clip_rect).to_type<int>()); m_clipping_overflow = true; } }; @@ -364,7 +364,7 @@ void PaintableBox::before_children_paint(PaintContext& context, PaintPhase phase if (overflow_y == CSS::Overflow::Hidden || overflow_x == CSS::Overflow::Hidden) { auto border_radii_data = normalized_border_radii_data(ShrinkRadiiForBorders::Yes); if (border_radii_data.has_any_radius()) { - auto corner_clipper = BorderRadiusCornerClipper::create(context, clip_rect->to_type<DevicePixels>(), border_radii_data, CornerClip::Outside, BorderRadiusCornerClipper::UseCachedBitmap::No); + auto corner_clipper = BorderRadiusCornerClipper::create(context, context.rounded_device_rect(*clip_rect), border_radii_data, CornerClip::Outside, BorderRadiusCornerClipper::UseCachedBitmap::No); if (corner_clipper.is_error()) { dbgln("Failed to create overflow border-radius corner clipper: {}", corner_clipper.error()); return; diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.h b/Userland/Libraries/LibWeb/Painting/PaintableBox.h index d6a2b9a491..170041772e 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.h +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.h @@ -98,7 +98,7 @@ public: return m_overflow_data->scrollable_overflow_rect; } - Optional<Gfx::IntRect> clip_rect() const; + Optional<CSSPixelRect> clip_rect() const; void set_overflow_data(Optional<OverflowData> data) { m_overflow_data = move(data); } void set_containing_line_box_fragment(Optional<Layout::LineBoxFragmentCoordinate>); @@ -157,7 +157,7 @@ private: Optional<CSSPixelRect> mutable m_absolute_rect; Optional<CSSPixelRect> mutable m_absolute_paint_rect; - Optional<Gfx::IntRect> mutable m_clip_rect; + Optional<CSSPixelRect> mutable m_clip_rect; mutable bool m_clipping_overflow { false }; Optional<BorderRadiusCornerClipper> mutable m_overflow_corner_radius_clipper; |