mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:18:13 +00:00
LibWeb: Avoid infinite loops in background painting
Previously if `background-size` was 0px in any dimension we would go into in infinite loop whilst painting.
This commit is contained in:
parent
ae264c9143
commit
40ad8b793d
1 changed files with 8 additions and 0 deletions
|
@ -140,6 +140,10 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
auto natural_image_width = image.natural_width().value_or(background_positioning_area.width());
|
||||
auto natural_image_height = image.natural_height().value_or(background_positioning_area.height());
|
||||
|
||||
// If any of these are zero, the NaNs will pop up in the painting code.
|
||||
if (background_positioning_area.is_empty() || natural_image_height <= 0 || natural_image_width <= 0)
|
||||
continue;
|
||||
|
||||
// Size
|
||||
Gfx::FloatRect image_rect;
|
||||
switch (layer.size_type) {
|
||||
|
@ -181,6 +185,10 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
}
|
||||
}
|
||||
|
||||
// If after sizing we have a 0px image, we're done. Attempting to paint this would be an infinite loop.
|
||||
if (image_rect.is_empty())
|
||||
continue;
|
||||
|
||||
// If background-repeat is round for one (or both) dimensions, there is a second step.
|
||||
// The UA must scale the image in that dimension (or both dimensions) so that it fits a
|
||||
// whole number of times in the background positioning area.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue