mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Precision when using background-size: contain
This ensures that precision is maintained when calculating the image size when using `background-size: contain`.
This commit is contained in:
parent
e48cb80a66
commit
8c4dc9476b
Notes:
sideshowbarker
2024-07-17 01:46:00 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/SerenityOS/serenity/commit/8c4dc9476b Pull-request: https://github.com/SerenityOS/serenity/pull/24241 Issue: https://github.com/SerenityOS/serenity/issues/24225
3 changed files with 2 additions and 2 deletions
Binary file not shown.
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 401 KiB |
Binary file not shown.
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
|
@ -277,8 +277,8 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
CSSPixelRect image_rect;
|
||||
switch (layer.size_type) {
|
||||
case CSS::BackgroundSize::Contain: {
|
||||
double max_width_ratio = (background_positioning_area.width() / concrete_image_size.width()).to_double();
|
||||
double max_height_ratio = (background_positioning_area.height() / concrete_image_size.height()).to_double();
|
||||
double max_width_ratio = background_positioning_area.width().to_double() / concrete_image_size.width().to_double();
|
||||
double max_height_ratio = background_positioning_area.height().to_double() / concrete_image_size.height().to_double();
|
||||
double ratio = min(max_width_ratio, max_height_ratio);
|
||||
image_rect.set_size(concrete_image_size.width().scaled(ratio), concrete_image_size.height().scaled(ratio));
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue