diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp index dd98da083e..cd1549147d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -542,7 +542,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto& parts = static_cast(value).values(); if (!parts.is_empty() && parts.size() <= 3) { RefPtr color_value; @@ -614,7 +614,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto& parts = static_cast(value).values(); if (parts.size() == 2) { auto diagonal1 = Parser::parse_css_value(context, property_id, parts[0]); @@ -691,7 +691,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto& parts = static_cast(value).values(); if (parts.size() == 1) { @@ -746,7 +746,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::BorderStyle) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto& parts = static_cast(value).values(); if (parts.size() == 4) { auto top = Parser::parse_css_value(context, property_id, parts[0]); @@ -799,7 +799,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::BorderWidth) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto& parts = static_cast(value).values(); if (parts.size() == 4) { auto top_border_width = Parser::parse_css_value(context, property_id, parts[0]); @@ -851,7 +851,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::BorderColor) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto& parts = static_cast(value).values(); if (parts.size() == 4) { auto top = Parser::parse_css_value(context, property_id, parts[0]); @@ -918,7 +918,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); RefPtr background_color_value; @@ -1026,7 +1026,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); // FIXME: Handle multiple backgrounds. if (!parts.is_empty()) { @@ -1059,7 +1059,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope assign_background_repeat_from_single_value(value); } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); NonnullRefPtrVector repeat_values; for (auto& part : parts) { @@ -1100,7 +1100,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); if (parts.size() == 2) { auto vertical = Parser::parse_css_value(context, property_id, parts[0]); @@ -1151,7 +1151,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); if (parts.size() == 2) { auto vertical = Parser::parse_css_value(context, property_id, parts[0]); @@ -1194,7 +1194,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::ListStyle) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); if (!parts.is_empty() && parts.size() <= 3) { @@ -1251,7 +1251,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::Font) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); RefPtr font_style_value; @@ -1352,7 +1352,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::FontFamily) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); // FIXME: Handle multiple font-families separated by commas, for fallback purposes. for (auto& part : parts) { @@ -1380,7 +1380,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); if (parts.size() == 1) { auto value = Parser::parse_css_value(context, property_id, parts[0]); @@ -1434,7 +1434,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::FlexFlow) { - if (value.is_value_list()) { + if (value.is_component_value_list()) { auto parts = static_cast(value).values(); if (parts.is_empty() || parts.size() > 2) return; @@ -1471,7 +1471,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } - if (value.is_value_list()) { + if (value.is_component_value_list()) { dbgln("Values list for CSS property '{}' went unhandled. List: '{}'", string_from_property_id(property_id), value.to_string()); return; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 551ed1f53b..f7300c5dee 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -173,7 +173,7 @@ void ImageStyleValue::resource_did_load() } ValueListStyleValue::ValueListStyleValue(Vector&& values) - : StyleValue(Type::ValueList) + : StyleValue(Type::ComponentValueList) , m_values(move(values)) { } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 3ca4d66d77..1e6e7c250b 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -227,6 +227,7 @@ public: CustomProperty, Numeric, ValueList, + ComponentValueList, Calculated, BoxShadow, }; @@ -243,8 +244,9 @@ public: bool is_custom_property() const { return type() == Type::CustomProperty; } bool is_numeric() const { return type() == Type::Numeric; } bool is_value_list() const { return type() == Type::ValueList; } - bool is_box_shadow() const { return type() == Type::BoxShadow; } + bool is_component_value_list() const { return type() == Type::ComponentValueList; } bool is_calculated() const { return type() == Type::Calculated; } + bool is_box_shadow() const { return type() == Type::BoxShadow; } bool is_builtin() const { return is_inherit() || is_initial(); } @@ -621,6 +623,35 @@ private: RefPtr m_bitmap; }; +class StyleValueList final : public StyleValue { +public: + static NonnullRefPtr create(NonnullRefPtrVector&& values) { return adopt_ref(*new StyleValueList(move(values))); } + + NonnullRefPtrVector const& values() const { return m_values; } + + virtual String to_string() const + { + StringBuilder builder; + builder.appendff("List[{}](", m_values.size()); + for (size_t i = 0; i < m_values.size(); ++i) { + if (i) + builder.append(','); + builder.append(m_values[i].to_string()); + } + builder.append(')'); + return builder.to_string(); + } + +private: + StyleValueList(NonnullRefPtrVector&& values) + : StyleValue(Type::ValueList) + , m_values(move(values)) + { + } + + NonnullRefPtrVector m_values; +}; + class ValueListStyleValue final : public StyleValue { public: static NonnullRefPtr create(Vector&& values) { return adopt_ref(*new ValueListStyleValue(move(values))); }