diff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.h index 88b2cbf30e..a64c44a196 100644 --- a/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Libraries/LibWeb/CSS/ComputedValues.h @@ -335,8 +335,10 @@ public: if (style_value->is_value_list()) { auto const& values = style_value->as_value_list().values(); - if (values.size() == 1) - return { values[0]->as_url().url(), {} }; + VERIFY(values.size() == 2); + + if (values[1]->is_empty_optional()) + return values[0]->as_url().url(); return { values[0]->as_url().url(), values[1]->to_color(color_resolution_context) }; } diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index fbc3116b72..8a6f52f744 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -435,7 +435,6 @@ private: RefPtr parse_image_value(TokenStream&); RefPtr parse_image_value(TokenStream&, AllowImageSet); RefPtr parse_image_set_function(TokenStream&); - RefPtr parse_paint_value(TokenStream&); enum class PositionParsingMode { Normal, BackgroundPosition, diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 7e9276a436..5d732ef9d7 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -2783,56 +2783,6 @@ RefPtr Parser::parse_image_value(TokenStream Parser::parse_paint_value(TokenStream& tokens) -{ - // ` = none | | [none | ]? | context-fill | context-stroke` - - auto parse_color_or_none = [&]() -> Optional> { - if (auto color = parse_color_value(tokens)) - return color; - - // NOTE: also accepts identifiers, so we do this identifier check last. - if (tokens.next_token().is(Token::Type::Ident)) { - auto maybe_keyword = keyword_from_string(tokens.next_token().token().ident()); - if (maybe_keyword.has_value()) { - // FIXME: Accept `context-fill` and `context-stroke` - switch (*maybe_keyword) { - case Keyword::None: - tokens.discard_a_token(); - return KeywordStyleValue::create(*maybe_keyword); - default: - return nullptr; - } - } - } - - return OptionalNone {}; - }; - - // FIXME: Allow context-fill/context-stroke here - if (auto color_or_none = parse_color_or_none(); color_or_none.has_value()) - return *color_or_none; - - if (auto url = parse_url_value(tokens)) { - tokens.discard_whitespace(); - - StyleValueVector values; - values.ensure_capacity(2); - values.unchecked_append(url.release_nonnull()); - - if (auto color_or_none = parse_color_or_none(); color_or_none == nullptr) { - // Fail to parse if the fallback is invalid, but otherwise ignore it. - return nullptr; - } else if (color_or_none.has_value() && *color_or_none && (*color_or_none)->has_color()) { - values.unchecked_append(color_or_none->release_nonnull()); - } - return StyleValueList::create(move(values), StyleValueList::Separator::Space, StyleValueList::Collapsible::No); - } - - return nullptr; -} - // https://www.w3.org/TR/css-values-4/#position RefPtr Parser::parse_position_value(TokenStream& tokens, PositionParsingMode position_parsing_mode) { diff --git a/Libraries/LibWeb/CSS/ValueTypes.json b/Libraries/LibWeb/CSS/ValueTypes.json index d28684faaa..0b59ef3fbe 100644 --- a/Libraries/LibWeb/CSS/ValueTypes.json +++ b/Libraries/LibWeb/CSS/ValueTypes.json @@ -3,6 +3,11 @@ "spec": "https://drafts.csswg.org/css-fonts-4/#font-weight-absolute-values", "grammar": "[ normal | bold | ]" }, + "": { + "spec": "https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint", + "grammar": "none | | [none | ]?", + "__comment": "FIXME: Support context-fill and context-stroke values here" + }, "": { "spec": "https://drafts.csswg.org/css-counter-styles-3/#typedef-symbol", "grammar": " | ", diff --git a/Meta/Generators/generate_libweb_css_value_types_parsing.py b/Meta/Generators/generate_libweb_css_value_types_parsing.py index 098bdfc1ae..540f177287 100644 --- a/Meta/Generators/generate_libweb_css_value_types_parsing.py +++ b/Meta/Generators/generate_libweb_css_value_types_parsing.py @@ -97,6 +97,8 @@ def generate_implementation_file(out: TextIO, value_type_data: dict[str, Any]) - #include #include #include +#include +#include namespace Web::CSS::Parser {