mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:47:35 +00:00
LibWeb: Implement background-repeat: space
This commit is contained in:
parent
3d1ee5b2de
commit
493435c655
1 changed files with 26 additions and 4 deletions
|
@ -127,8 +127,19 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
|
|
||||||
switch (layer.repeat_x) {
|
switch (layer.repeat_x) {
|
||||||
case CSS::Repeat::Round:
|
case CSS::Repeat::Round:
|
||||||
case CSS::Repeat::Space:
|
break;
|
||||||
// FIXME: Support 'round' and 'space'. Fall through to 'repeat' since that most closely resembles these.
|
case CSS::Repeat::Space: {
|
||||||
|
int whole_images = background_positioning_area.width() / image_rect.width();
|
||||||
|
if (whole_images <= 1) {
|
||||||
|
x_step = image_rect.width();
|
||||||
|
repeat_x = false;
|
||||||
|
} else {
|
||||||
|
int space = background_positioning_area.width() % image_rect.width();
|
||||||
|
x_step = image_rect.width() + ((float)space / (float)(whole_images - 1));
|
||||||
|
repeat_x = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CSS::Repeat::Repeat:
|
case CSS::Repeat::Repeat:
|
||||||
x_step = image_rect.width();
|
x_step = image_rect.width();
|
||||||
repeat_x = true;
|
repeat_x = true;
|
||||||
|
@ -145,8 +156,19 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
|
|
||||||
switch (layer.repeat_y) {
|
switch (layer.repeat_y) {
|
||||||
case CSS::Repeat::Round:
|
case CSS::Repeat::Round:
|
||||||
case CSS::Repeat::Space:
|
break;
|
||||||
// FIXME: Support 'round' and 'space'. Fall through to 'repeat' since that most closely resembles these.
|
case CSS::Repeat::Space: {
|
||||||
|
int whole_images = background_positioning_area.height() / image_rect.height();
|
||||||
|
if (whole_images <= 1) {
|
||||||
|
y_step = image_rect.height();
|
||||||
|
repeat_y = false;
|
||||||
|
} else {
|
||||||
|
int space = background_positioning_area.height() % image_rect.height();
|
||||||
|
y_step = image_rect.height() + ((float)space / (float)(whole_images - 1));
|
||||||
|
repeat_y = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CSS::Repeat::Repeat:
|
case CSS::Repeat::Repeat:
|
||||||
y_step = image_rect.height();
|
y_step = image_rect.height();
|
||||||
repeat_y = true;
|
repeat_y = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue