From ee1fc56f024c58877c114a1459c29a016d1217f4 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 27 May 2023 15:50:17 +0100 Subject: [PATCH] LibWeb: Resolve background-size property --- .../LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index e2e6e70809..fae2e031fb 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -323,6 +324,21 @@ ErrorOr> ResolvedCSSStyleDeclaration::style_value_for_p return StyleValueList::create(move(repeat), StyleValueList::Separator::Space); }, [] { return BackgroundRepeatStyleValue::create(Repeat::Repeat, Repeat::Repeat); }); + case PropertyID::BackgroundSize: + return style_value_for_background_property( + layout_node, + [](auto& layer) -> ErrorOr> { + switch (layer.size_type) { + case BackgroundSize::Contain: + return IdentifierStyleValue::create(ValueID::Contain); + case BackgroundSize::Cover: + return IdentifierStyleValue::create(ValueID::Cover); + case BackgroundSize::LengthPercentage: + return BackgroundSizeStyleValue::create(layer.size_x, layer.size_y); + } + VERIFY_NOT_REACHED(); + }, + [] { return IdentifierStyleValue::create(ValueID::Auto); }); case PropertyID::BorderBottom: { auto border = layout_node.computed_values().border_bottom(); auto width = TRY(LengthStyleValue::create(Length::make_px(border.width)));