diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index 6a1db917838..7cdffb387b5 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -2865,9 +2865,7 @@ RefPtr Parser::parse_font_value(TokenStream& t RefPtr Parser::parse_font_family_value(TokenStream& tokens) { // [ | ]# - // FIXME: We currently require font-family to always be a list, even with one item. - // Maybe change that? - auto result = parse_comma_separated_value_list(tokens, [this](auto& inner_tokens) -> RefPtr { + return parse_comma_separated_value_list(tokens, [this](auto& inner_tokens) -> RefPtr { inner_tokens.discard_whitespace(); // @@ -2883,15 +2881,6 @@ RefPtr Parser::parse_font_family_value(TokenStream return parse_family_name_value(inner_tokens); }); - - if (!result) - return nullptr; - - if (result->is_value_list()) - return result.release_nonnull(); - - // It's a single value, so wrap it in a list - see FIXME above. - return StyleValueList::create(StyleValueVector { result.release_nonnull() }, StyleValueList::Separator::Comma); } RefPtr Parser::parse_font_language_override_value(TokenStream& tokens) diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index c701636e106..3aab6dcde62 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1901,28 +1901,18 @@ RefPtr StyleComputer::compute_font_for_style_values( }; auto font_list = Gfx::FontCascadeList::create(); - if (font_family.is_value_list()) { - auto const& family_list = static_cast(font_family).values(); - for (auto const& family : family_list) { - RefPtr other_font_list; - if (family->is_keyword()) { - other_font_list = find_generic_font(family->to_keyword()); - } else if (family->is_string()) { - other_font_list = find_font(family->as_string().string_value()); - } else if (family->is_custom_ident()) { - other_font_list = find_font(family->as_custom_ident().custom_ident()); - } - if (other_font_list) - font_list->extend(*other_font_list); + + for (auto const& family : font_family.as_value_list().values()) { + RefPtr other_font_list; + if (family->is_keyword()) { + other_font_list = find_generic_font(family->to_keyword()); + } else if (family->is_string()) { + other_font_list = find_font(family->as_string().string_value()); + } else if (family->is_custom_ident()) { + other_font_list = find_font(family->as_custom_ident().custom_ident()); } - } else if (font_family.is_keyword()) { - if (auto other_font_list = find_generic_font(font_family.to_keyword())) - font_list->extend(*other_font_list); - } else if (font_family.is_string()) { - if (auto other_font_list = find_font(font_family.as_string().string_value())) - font_list->extend(*other_font_list); - } else if (font_family.is_custom_ident()) { - if (auto other_font_list = find_font(font_family.as_custom_ident().custom_ident())) + + if (other_font_list) font_list->extend(*other_font_list); } @@ -2430,14 +2420,12 @@ GC::Ptr StyleComputer::compute_style_impl(DOM::AbstractEleme static bool is_monospace(StyleValue const& value) { - if (value.to_keyword() == Keyword::Monospace) - return true; - if (value.is_value_list()) { - auto const& values = value.as_value_list().values(); - if (values.size() == 1 && values[0]->to_keyword() == Keyword::Monospace) - return true; - } - return false; + if (!value.is_value_list()) + return false; + + auto const& values = value.as_value_list().values(); + + return values.size() == 1 && values[0]->to_keyword() == Keyword::Monospace; } // HACK: This function implements time-travelling inheritance for the font-size property