Skip to content

Commit 86b57a5

Browse files
committed
LibWeb/CSS: Use font_format_is_supported() when parsing font sources
1 parent bd7a08d commit 86b57a5

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Libraries/LibWeb/CSS/Parser/RuleParsing.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <LibWeb/CSS/CSSStyleProperties.h>
2626
#include <LibWeb/CSS/CSSStyleRule.h>
2727
#include <LibWeb/CSS/CSSSupportsRule.h>
28+
#include <LibWeb/CSS/FontFace.h>
2829
#include <LibWeb/CSS/Parser/Parser.h>
2930
#include <LibWeb/CSS/PropertyName.h>
3031
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
@@ -592,15 +593,6 @@ GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
592593
template<typename T>
593594
Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<T>& component_values)
594595
{
595-
// FIXME: Get this information from the system somehow?
596-
// Format-name table: https://www.w3.org/TR/css-fonts-4/#font-format-definitions
597-
auto font_format_is_supported = [](StringView name) {
598-
// The spec requires us to treat opentype and truetype as synonymous.
599-
if (name.is_one_of_ignoring_ascii_case("opentype"sv, "truetype"sv, "woff"sv, "woff2"sv))
600-
return true;
601-
return false;
602-
};
603-
604596
Vector<ParsedFontFace::Source> supported_sources;
605597

606598
auto list_of_source_token_lists = parse_a_comma_separated_list_of_component_values(component_values);
@@ -637,7 +629,7 @@ Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<T>& compo
637629
TokenStream format_tokens { function.value };
638630
format_tokens.discard_whitespace();
639631
auto const& format_name_token = format_tokens.consume_a_token();
640-
StringView format_name;
632+
FlyString format_name;
641633
if (format_name_token.is(Token::Type::Ident)) {
642634
format_name = format_name_token.token().ident();
643635
} else if (format_name_token.is(Token::Type::String)) {
@@ -652,7 +644,7 @@ Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<T>& compo
652644
continue;
653645
}
654646

655-
format = FlyString::from_utf8(format_name).release_value_but_fixme_should_propagate_errors();
647+
format = move(format_name);
656648
} else {
657649
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (unrecognized function token `{}`); discarding.", function.name);
658650
return {};

0 commit comments

Comments
 (0)