mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +00:00
LibWeb: Implement text-decoration: spelling-error and grammar-error
This commit is contained in:
parent
7668f91b60
commit
532c01c388
Notes:
github-actions[bot]
2025-02-28 16:35:04 +00:00
Author: https://github.com/AtkinsSJ
Commit: 532c01c388
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3724
9 changed files with 74 additions and 13 deletions
|
@ -1008,8 +1008,11 @@ Vector<TextDecorationLine> ComputedProperties::text_decoration_line() const
|
|||
return lines;
|
||||
}
|
||||
|
||||
if (value.is_keyword() && value.to_keyword() == Keyword::None)
|
||||
return {};
|
||||
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(CSSStyleValue::SerializationMode::Normal));
|
||||
return {};
|
||||
|
|
|
@ -545,7 +545,9 @@
|
|||
"underline",
|
||||
"overline",
|
||||
"line-through",
|
||||
"blink"
|
||||
"blink",
|
||||
"spelling-error",
|
||||
"grammar-error"
|
||||
],
|
||||
"text-decoration-style": [
|
||||
"dashed",
|
||||
|
|
|
@ -190,6 +190,7 @@
|
|||
"fullscreen",
|
||||
"grab",
|
||||
"grabbing",
|
||||
"grammar-error",
|
||||
"graytext",
|
||||
"grid",
|
||||
"groove",
|
||||
|
@ -404,6 +405,7 @@
|
|||
"space-around",
|
||||
"space-between",
|
||||
"space-evenly",
|
||||
"spelling-error",
|
||||
"square",
|
||||
"square-button",
|
||||
"srgb",
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue