LibWeb: Implement text-decoration: spelling-error and grammar-error

This commit is contained in:
Sam Atkins 2025-02-27 19:51:36 +00:00
parent 7668f91b60
commit 532c01c388
Notes: github-actions[bot] 2025-02-28 16:35:04 +00:00
9 changed files with 74 additions and 13 deletions

View file

@ -3510,6 +3510,8 @@ RefPtr<CSSStyleValue> Parser::parse_text_decoration_line_value(TokenStream<Compo
{
StyleValueVector style_values;
bool includes_spelling_or_grammar_error_value = false;
while (tokens.has_next_token()) {
auto maybe_value = parse_css_value_for_property(PropertyID::TextDecorationLine, tokens);
if (!maybe_value)
@ -3522,6 +3524,9 @@ RefPtr<CSSStyleValue> Parser::parse_text_decoration_line_value(TokenStream<Compo
break;
return value;
}
if (first_is_one_of(*maybe_line, TextDecorationLine::SpellingError, TextDecorationLine::GrammarError)) {
includes_spelling_or_grammar_error_value = true;
}
if (style_values.contains_slow(value))
break;
style_values.append(move(value));
@ -3534,6 +3539,13 @@ RefPtr<CSSStyleValue> Parser::parse_text_decoration_line_value(TokenStream<Compo
if (style_values.is_empty())
return nullptr;
// These can only appear on their own.
if (style_values.size() > 1 && includes_spelling_or_grammar_error_value)
return nullptr;
if (style_values.size() == 1)
return *style_values.first();
quick_sort(style_values, [](auto& left, auto& right) {
return *keyword_to_text_decoration_line(left->to_keyword()) < *keyword_to_text_decoration_line(right->to_keyword());
});