Skip to content

Commit d6bb247

Browse files
Calme1709gmta
authored andcommitted
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.
1 parent 5c0fdd3 commit d6bb247

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

Libraries/LibWeb/CSS/ComputedProperties.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,9 @@ Vector<TextDecorationLine> ComputedProperties::text_decoration_line() const
12251225
{
12261226
auto const& value = property(PropertyID::TextDecorationLine);
12271227

1228+
if (value.to_keyword() == Keyword::None)
1229+
return {};
1230+
12281231
if (value.is_value_list()) {
12291232
Vector<TextDecorationLine> lines;
12301233
auto& values = value.as_value_list().values();
@@ -1234,14 +1237,7 @@ Vector<TextDecorationLine> ComputedProperties::text_decoration_line() const
12341237
return lines;
12351238
}
12361239

1237-
if (value.is_keyword()) {
1238-
if (value.to_keyword() == Keyword::None)
1239-
return {};
1240-
return { keyword_to_text_decoration_line(value.to_keyword()).release_value() };
1241-
}
1242-
1243-
dbgln("FIXME: Unsupported value for text-decoration-line: {}", value.to_string(SerializationMode::Normal));
1244-
return {};
1240+
VERIFY_NOT_REACHED();
12451241
}
12461242

12471243
TextDecorationStyle ComputedProperties::text_decoration_style() const

Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4691,7 +4691,7 @@ RefPtr<StyleValue const> Parser::parse_text_decoration_line_value(TokenStream<Co
46914691
if (auto maybe_line = keyword_to_text_decoration_line(value->to_keyword()); maybe_line.has_value()) {
46924692
if (maybe_line == TextDecorationLine::None) {
46934693
if (!style_values.is_empty())
4694-
break;
4694+
return nullptr;
46954695
return value;
46964696
}
46974697
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
47034703
continue;
47044704
}
47054705

4706-
break;
4706+
VERIFY_NOT_REACHED();
47074707
}
47084708

47094709
if (style_values.is_empty())
@@ -4713,9 +4713,6 @@ RefPtr<StyleValue const> Parser::parse_text_decoration_line_value(TokenStream<Co
47134713
if (style_values.size() > 1 && includes_spelling_or_grammar_error_value)
47144714
return nullptr;
47154715

4716-
if (style_values.size() == 1)
4717-
return *style_values.first();
4718-
47194716
quick_sort(style_values, [](auto& left, auto& right) {
47204717
return *keyword_to_text_decoration_line(left->to_keyword()) < *keyword_to_text_decoration_line(right->to_keyword());
47214718
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#foo { }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
3+
<style>
4+
#foo {
5+
text-decoration-line: underline none;
6+
}
7+
</style>
8+
<script src="../include.js"></script>
9+
<script>
10+
test(() => {
11+
println(document.styleSheets[0].cssRules[0].cssText);
12+
});
13+
</script>

0 commit comments

Comments
 (0)