diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-05-27 15:50:17 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-27 20:55:00 +0200 |
commit | ee1fc56f024c58877c114a1459c29a016d1217f4 (patch) | |
tree | 820370c4b3a005ab56042cebd89c81a366b0f9dc | |
parent | d5fbec8a494668881dc5539c0e69faf2b49499ea (diff) | |
download | serenity-ee1fc56f024c58877c114a1459c29a016d1217f4.zip |
LibWeb: Resolve background-size property
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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 <LibWeb/CSS/ResolvedCSSStyleDeclaration.h> #include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h> +#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> #include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.h> #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> @@ -323,6 +324,21 @@ ErrorOr<RefPtr<StyleValue const>> 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<NonnullRefPtr<StyleValue>> { + 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))); |