LibWeb: Reject non-exclusive none in text-decoration-line

This updates the `parse_text_decoration_line_value` to reject values
which non-exclusively include `none` e.g. `underline none`.

It also simplifies handling by always producing a Vector (except for
`none`) and adding VERIFY_NOT_REACHED in more places which shouldn't be
reachable.
This commit is contained in:
Callum Law 2025-11-13 17:25:00 +13:00 committed by Jelle Raaijmakers
parent 5c0fdd371a
commit d6bb247bf7
Notes: github-actions[bot] 2025-11-13 09:16:20 +00:00
4 changed files with 20 additions and 13 deletions

View file

@ -1225,6 +1225,9 @@ Vector<TextDecorationLine> ComputedProperties::text_decoration_line() const
{
auto const& value = property(PropertyID::TextDecorationLine);
if (value.to_keyword() == Keyword::None)
return {};
if (value.is_value_list()) {
Vector<TextDecorationLine> lines;
auto& values = value.as_value_list().values();
@ -1234,14 +1237,7 @@ Vector<TextDecorationLine> ComputedProperties::text_decoration_line() const
return lines;
}
if (value.is_keyword()) {
if (value.to_keyword() == Keyword::None)
return {};
return { keyword_to_text_decoration_line(value.to_keyword()).release_value() };
}
dbgln("FIXME: Unsupported value for text-decoration-line: {}", value.to_string(SerializationMode::Normal));
return {};
VERIFY_NOT_REACHED();
}
TextDecorationStyle ComputedProperties::text_decoration_style() const

View file

@ -4691,7 +4691,7 @@ RefPtr<StyleValue const> Parser::parse_text_decoration_line_value(TokenStream<Co
if (auto maybe_line = keyword_to_text_decoration_line(value->to_keyword()); maybe_line.has_value()) {
if (maybe_line == TextDecorationLine::None) {
if (!style_values.is_empty())
break;
return nullptr;
return value;
}
if (first_is_one_of(*maybe_line, TextDecorationLine::SpellingError, TextDecorationLine::GrammarError)) {
@ -4703,7 +4703,7 @@ RefPtr<StyleValue const> Parser::parse_text_decoration_line_value(TokenStream<Co
continue;
}
break;
VERIFY_NOT_REACHED();
}
if (style_values.is_empty())
@ -4713,9 +4713,6 @@ RefPtr<StyleValue const> Parser::parse_text_decoration_line_value(TokenStream<Co
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());
});

View file

@ -0,0 +1 @@
#foo { }

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<style>
#foo {
text-decoration-line: underline none;
}
</style>
<script src="../include.js"></script>
<script>
test(() => {
println(document.styleSheets[0].cssRules[0].cssText);
});
</script>