LibWeb: Naive support for CSS "background" shorthand

Many sites simply use "background" as an alias for "background-color"
so let's at least support that.
This commit is contained in:
Andreas Kling 2020-05-30 11:58:05 +02:00
parent 62885b5646
commit 3c6801c3a5
Notes: sideshowbarker 2024-07-19 05:57:36 +09:00
2 changed files with 13 additions and 0 deletions

View file

@ -1,4 +1,6 @@
{
"background": {
},
"background-attachment": {
"inherited": false,
"initial": "scroll"

View file

@ -256,6 +256,17 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
return;
}
if (property_id == CSS::PropertyID::Background) {
auto parts = split_on_whitespace(value.to_string());
NonnullRefPtrVector<StyleValue> values;
for (auto& part : parts) {
values.append(parse_css_value(part));
}
if (values[0].is_color())
style.set_property(CSS::PropertyID::BackgroundColor, values[0]);
return;
}
if (property_id == CSS::PropertyID::Margin) {
if (value.is_length()) {
style.set_property(CSS::PropertyID::MarginTop, value);