mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb/CSS: Remove redundant font-face src parsing code
We now always parse this as a descriptor.
This commit is contained in:
parent
ff491843b6
commit
f17e151b8d
3 changed files with 0 additions and 116 deletions
|
@ -1617,11 +1617,6 @@ bool Parser::context_allows_quirky_length() const
|
|||
return unitless_length_allowed;
|
||||
}
|
||||
|
||||
Vector<ParsedFontFace::Source> Parser::parse_as_font_face_src()
|
||||
{
|
||||
return parse_font_face_src(m_token_stream);
|
||||
}
|
||||
|
||||
Vector<ComponentValue> Parser::parse_as_list_of_component_values()
|
||||
{
|
||||
return parse_a_list_of_component_values(m_token_stream);
|
||||
|
|
|
@ -123,8 +123,6 @@ public:
|
|||
|
||||
Optional<ComponentValue> parse_as_component_value();
|
||||
|
||||
Vector<ParsedFontFace::Source> parse_as_font_face_src();
|
||||
|
||||
Vector<ComponentValue> parse_as_list_of_component_values();
|
||||
|
||||
static NonnullRefPtr<CSSStyleValue> resolve_unresolved_style_value(ParsingParams const&, DOM::Element&, Optional<PseudoElement>, PropertyID, UnresolvedStyleValue const&);
|
||||
|
@ -226,9 +224,6 @@ private:
|
|||
|
||||
OwnPtr<GeneralEnclosed> parse_general_enclosed(TokenStream<ComponentValue>&, MatchResult);
|
||||
|
||||
template<typename T>
|
||||
Vector<ParsedFontFace::Source> parse_font_face_src(TokenStream<T>&);
|
||||
|
||||
enum class AllowBlankLayerName {
|
||||
No,
|
||||
Yes,
|
||||
|
|
|
@ -590,112 +590,6 @@ GC::Ptr<CSSPropertyRule> Parser::convert_to_property_rule(AtRule const& rule)
|
|||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<T>& component_values)
|
||||
{
|
||||
Vector<ParsedFontFace::Source> supported_sources;
|
||||
|
||||
auto list_of_source_token_lists = parse_a_comma_separated_list_of_component_values(component_values);
|
||||
for (auto const& source_token_list : list_of_source_token_lists) {
|
||||
TokenStream source_tokens { source_token_list };
|
||||
source_tokens.discard_whitespace();
|
||||
|
||||
// <url> [ format(<font-format>)]?
|
||||
// FIXME: Implement optional tech() function from CSS-Fonts-4.
|
||||
if (auto maybe_url = parse_url_function(source_tokens); maybe_url.has_value()) {
|
||||
auto url = maybe_url.release_value();
|
||||
if (!url.is_valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Optional<FlyString> format;
|
||||
|
||||
source_tokens.discard_whitespace();
|
||||
if (!source_tokens.has_next_token()) {
|
||||
supported_sources.empend(move(url), format);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const& maybe_function = source_tokens.consume_a_token();
|
||||
if (!maybe_function.is_function()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (token after `url()` that isn't a function: {}); discarding.", maybe_function.to_debug_string());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto const& function = maybe_function.function();
|
||||
if (function.name.equals_ignoring_ascii_case("format"sv)) {
|
||||
auto context_guard = push_temporary_value_parsing_context(FunctionContext { function.name });
|
||||
|
||||
TokenStream format_tokens { function.value };
|
||||
format_tokens.discard_whitespace();
|
||||
auto const& format_name_token = format_tokens.consume_a_token();
|
||||
FlyString format_name;
|
||||
if (format_name_token.is(Token::Type::Ident)) {
|
||||
format_name = format_name_token.token().ident();
|
||||
} else if (format_name_token.is(Token::Type::String)) {
|
||||
format_name = format_name_token.token().string();
|
||||
} else {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (`format()` parameter not an ident or string; is: {}); discarding.", format_name_token.to_debug_string());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!font_format_is_supported(format_name)) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src format({}) not supported; skipping.", format_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
format = move(format_name);
|
||||
} else {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (unrecognized function token `{}`); discarding.", function.name);
|
||||
return {};
|
||||
}
|
||||
|
||||
source_tokens.discard_whitespace();
|
||||
if (source_tokens.has_next_token()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (extra token `{}`); discarding.", source_tokens.next_token().to_debug_string());
|
||||
return {};
|
||||
}
|
||||
|
||||
supported_sources.empend(move(url), format);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const& first = source_tokens.consume_a_token();
|
||||
if (first.is_function("local"sv)) {
|
||||
// local(<family-name>)
|
||||
if (first.function().value.is_empty()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (`local()` syntax is invalid: no arguments); discarding.");
|
||||
return {};
|
||||
}
|
||||
|
||||
TokenStream function_tokens { first.function().value };
|
||||
function_tokens.discard_whitespace();
|
||||
auto font_family = parse_family_name_value(function_tokens);
|
||||
function_tokens.discard_whitespace();
|
||||
if (!font_family || function_tokens.has_next_token()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (`local()` syntax is invalid: `{}`); discarding.", first.function().original_source_text());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (font_family->is_string())
|
||||
supported_sources.empend(font_family->as_string().string_value(), Optional<FlyString> {});
|
||||
else if (font_family->is_custom_ident())
|
||||
supported_sources.empend(font_family->as_custom_ident().custom_ident(), Optional<FlyString> {});
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (failed to parse url from: {}); discarding.", first.to_debug_string());
|
||||
return {};
|
||||
}
|
||||
|
||||
return supported_sources;
|
||||
}
|
||||
template Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<Token>& component_values);
|
||||
template Vector<ParsedFontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>& component_values);
|
||||
|
||||
GC::Ptr<CSSFontFaceRule> Parser::convert_to_font_face_rule(AtRule const& rule)
|
||||
{
|
||||
// https://drafts.csswg.org/css-fonts/#font-face-rule
|
||||
|
|
Loading…
Add table
Reference in a new issue