mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
LibWeb: Support rendering background images with 'background-repeat'
Update the painting of background images for both <body> nodes and other non-initial nodes. Currently, only the following values are supported: repeat, repeat-x, repeat-y, no-repeat This also doesn't support the two-value syntax which allows for setting horizontal and vertical repetition separately.
This commit is contained in:
parent
bd5a91269f
commit
fa9ba8bce5
4 changed files with 55 additions and 6 deletions
|
@ -49,6 +49,23 @@ void Box::paint(PaintContext& context, PaintPhase phase)
|
|||
auto background_rect = enclosing_int_rect(padded_rect);
|
||||
context.painter().fill_rect(background_rect, computed_values().background_color());
|
||||
if (background_image() && background_image()->bitmap()) {
|
||||
switch (computed_values().background_repeat()) {
|
||||
case CSS::Repeat::Repeat:
|
||||
// The background rect is already sized to align with 'repeat'.
|
||||
break;
|
||||
case CSS::Repeat::RepeatX:
|
||||
background_rect.set_height(background_image()->bitmap()->height());
|
||||
break;
|
||||
case CSS::Repeat::RepeatY:
|
||||
background_rect.set_width(background_image()->bitmap()->width());
|
||||
break;
|
||||
case CSS::Repeat::NoRepeat:
|
||||
default: // FIXME: Support 'round' and 'square'
|
||||
background_rect.set_width(background_image()->bitmap()->width());
|
||||
background_rect.set_height(background_image()->bitmap()->height());
|
||||
break;
|
||||
}
|
||||
|
||||
context.painter().blit_tiled(background_rect, *background_image()->bitmap(), background_image()->bitmap()->rect());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue