@@ -313,24 +313,8 @@ BorderRadiiData PaintableBox::normalized_border_radii_data(ShrinkRadiiForBorders
313
313
return border_radius_data;
314
314
}
315
315
316
- Optional<CSSPixelRect > PaintableBox::clip_rect () const
316
+ Optional<Gfx::IntRect > PaintableBox::clip_rect () const
317
317
{
318
- if (!m_clip_rect.has_value ()) {
319
- if (containing_block () && containing_block ()->paint_box ())
320
- m_clip_rect = containing_block ()->paint_box ()->clip_rect ();
321
-
322
- auto overflow_x = computed_values ().overflow_x ();
323
- auto overflow_y = computed_values ().overflow_y ();
324
-
325
- if (overflow_x == CSS::Overflow::Hidden && overflow_y == CSS::Overflow::Hidden) {
326
- if (m_clip_rect.has_value ()) {
327
- m_clip_rect->intersect (absolute_padding_box_rect ());
328
- } else {
329
- m_clip_rect = absolute_padding_box_rect ();
330
- }
331
- }
332
- }
333
-
334
318
return m_clip_rect;
335
319
}
336
320
@@ -339,27 +323,36 @@ void PaintableBox::before_children_paint(PaintContext& context, PaintPhase phase
339
323
if (!AK::first_is_one_of (phase, PaintPhase::Background, PaintPhase::Border, PaintPhase::Foreground))
340
324
return ;
341
325
342
- // FIXME: Support more overflow variations.
343
- auto clip_rect = this ->clip_rect ();
326
+ auto clip_rect = context.painter ().clip_rect ();
327
+ if (containing_block () && containing_block ()->paint_box ()) {
328
+ if (containing_block ()->paint_box ()->clip_rect ().has_value ()) {
329
+ clip_rect = *containing_block ()->paint_box ()->clip_rect ();
330
+ }
331
+ }
332
+ context.painter ().set_clip_rect (clip_rect);
333
+
344
334
auto overflow_x = computed_values ().overflow_x ();
345
335
auto overflow_y = computed_values ().overflow_y ();
346
336
347
337
auto clip_overflow = [&] {
348
338
if (!m_clipping_overflow) {
349
339
context.painter ().save ();
350
- context.painter ().add_clip_rect (context.rounded_device_rect (*clip_rect ).to_type <int >());
340
+ context.painter ().add_clip_rect (context.rounded_device_rect (absolute_padding_box_rect () ).to_type <int >());
351
341
m_clipping_overflow = true ;
352
342
}
353
343
};
354
344
355
- if (clip_rect.has_value ()) {
345
+ // FIXME: Support more overflow variations.
346
+ if (overflow_x == CSS::Overflow::Hidden && overflow_y == CSS::Overflow::Hidden) {
356
347
clip_overflow ();
357
348
}
358
349
350
+ m_clip_rect = context.painter ().clip_rect ();
351
+
359
352
if (overflow_y == CSS::Overflow::Hidden || overflow_x == CSS::Overflow::Hidden) {
360
353
auto border_radii_data = normalized_border_radii_data (ShrinkRadiiForBorders::Yes);
361
354
if (border_radii_data.has_any_radius ()) {
362
- auto corner_clipper = BorderRadiusCornerClipper::create (context, context.rounded_device_rect (*clip_rect ), border_radii_data, CornerClip::Outside, BorderRadiusCornerClipper::UseCachedBitmap::No);
355
+ auto corner_clipper = BorderRadiusCornerClipper::create (context, context.rounded_device_rect (absolute_padding_box_rect () ), border_radii_data, CornerClip::Outside, BorderRadiusCornerClipper::UseCachedBitmap::No);
363
356
if (corner_clipper.is_error ()) {
364
357
dbgln (" Failed to create overflow border-radius corner clipper: {}" , corner_clipper.error ());
365
358
return ;
0 commit comments