mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 10:36:02 +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
Notes:
sideshowbarker
2024-07-17 08:02:20 +09:00
Author: https://github.com/MacDue
Commit: 40ad8b793d
Pull-request: https://github.com/SerenityOS/serenity/pull/14980
Reviewed-by: https://github.com/bgianfo
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