|
@@ -310,34 +310,53 @@ BorderRadiiData PaintableBox::normalized_border_radii_data(ShrinkRadiiForBorders
|
|
|
return border_radius_data;
|
|
|
}
|
|
|
|
|
|
-void PaintableBox::before_children_paint(PaintContext& context, PaintPhase phase, ShouldClipOverflow should_clip_overflow) const
|
|
|
+Optional<Gfx::IntRect> PaintableBox::clip_rect() const
|
|
|
{
|
|
|
- if (!AK::first_is_one_of(phase, PaintPhase::Background, PaintPhase::Border, PaintPhase::Foreground))
|
|
|
- return;
|
|
|
+ if (!m_clip_rect.has_value()) {
|
|
|
+ if (containing_block() && containing_block()->paint_box())
|
|
|
+ m_clip_rect = containing_block()->paint_box()->clip_rect();
|
|
|
+
|
|
|
+ auto overflow_x = computed_values().overflow_x();
|
|
|
+ auto overflow_y = computed_values().overflow_y();
|
|
|
+
|
|
|
+ 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_rounded<int>());
|
|
|
+ } else {
|
|
|
+ m_clip_rect = absolute_padding_box_rect().to_rounded<int>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (should_clip_overflow == ShouldClipOverflow::No)
|
|
|
+ return m_clip_rect;
|
|
|
+}
|
|
|
+
|
|
|
+void PaintableBox::before_children_paint(PaintContext& context, PaintPhase phase) const
|
|
|
+{
|
|
|
+ if (!AK::first_is_one_of(phase, PaintPhase::Background, PaintPhase::Border, PaintPhase::Foreground))
|
|
|
return;
|
|
|
|
|
|
// FIXME: Support more overflow variations.
|
|
|
- auto clip_rect = absolute_padding_box_rect().to_rounded<int>();
|
|
|
+ auto clip_rect = this->clip_rect();
|
|
|
auto overflow_x = computed_values().overflow_x();
|
|
|
auto overflow_y = computed_values().overflow_y();
|
|
|
|
|
|
auto clip_overflow = [&] {
|
|
|
if (!m_clipping_overflow) {
|
|
|
context.painter().save();
|
|
|
- context.painter().add_clip_rect(clip_rect);
|
|
|
+ context.painter().add_clip_rect(*clip_rect);
|
|
|
m_clipping_overflow = true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- if (overflow_x == CSS::Overflow::Hidden && overflow_y == CSS::Overflow::Hidden) {
|
|
|
+ if (clip_rect.has_value()) {
|
|
|
clip_overflow();
|
|
|
}
|
|
|
+
|
|
|
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(clip_rect, border_radii_data, CornerClip::Outside, BorderRadiusCornerClipper::UseCachedBitmap::No);
|
|
|
+ auto corner_clipper = BorderRadiusCornerClipper::create(absolute_padding_box_rect().to_rounded<int>(), 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;
|
|
@@ -349,14 +368,11 @@ void PaintableBox::before_children_paint(PaintContext& context, PaintPhase phase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void PaintableBox::after_children_paint(PaintContext& context, PaintPhase phase, ShouldClipOverflow should_clip_overflow) const
|
|
|
+void PaintableBox::after_children_paint(PaintContext& context, PaintPhase phase) const
|
|
|
{
|
|
|
if (!AK::first_is_one_of(phase, PaintPhase::Background, PaintPhase::Border, PaintPhase::Foreground))
|
|
|
return;
|
|
|
|
|
|
- if (should_clip_overflow == ShouldClipOverflow::No)
|
|
|
- return;
|
|
|
-
|
|
|
// FIXME: Support more overflow variations.
|
|
|
if (m_clipping_overflow) {
|
|
|
context.painter().restore();
|