mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Rewrite CSS Parser core methods according to new spec
CSS Syntax 3 (https://drafts.csswg.org/css-syntax) has changed significantly since we implemented it a couple of years ago. Just about every parsing algorithm has been rewritten in terms of the new token stream concept, and to support nested styles. As all of those algorithms call into each other, this is an unfortunately chonky diff. As part of this, the transitory types (Declaration, Function, AtRule...) have been rewritten. That's both because we have new requirements of what they should be and contain, and also because the spec asks us to create and then gradually modify them in place, which is easier if they are plain structs.
This commit is contained in:
parent
f11c0e6cc0
commit
e0be17e4fb
Notes:
github-actions[bot]
2024-10-14 06:09:33 +00:00
Author: https://github.com/AtkinsSJ
Commit: e0be17e4fb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1729
24 changed files with 1126 additions and 1278 deletions
|
@ -148,7 +148,7 @@ RefPtr<CSSStyleValue> Parser::parse_linear_gradient_function(TokenStream<Compone
|
|||
GradientRepeating repeating_gradient = GradientRepeating::No;
|
||||
GradientType gradient_type { GradientType::Standard };
|
||||
|
||||
auto function_name = component_value.function().name().bytes_as_string_view();
|
||||
auto function_name = component_value.function().name.bytes_as_string_view();
|
||||
|
||||
function_name = consume_if_starts_with(function_name, "-webkit-"sv, [&] {
|
||||
gradient_type = GradientType::WebKit;
|
||||
|
@ -163,7 +163,7 @@ RefPtr<CSSStyleValue> Parser::parse_linear_gradient_function(TokenStream<Compone
|
|||
|
||||
// linear-gradient() = linear-gradient([ <angle> | to <side-or-corner> ]?, <color-stop-list>)
|
||||
|
||||
TokenStream tokens { component_value.function().values() };
|
||||
TokenStream tokens { component_value.function().value };
|
||||
tokens.discard_whitespace();
|
||||
|
||||
if (!tokens.has_next_token())
|
||||
|
@ -277,7 +277,7 @@ RefPtr<CSSStyleValue> Parser::parse_conic_gradient_function(TokenStream<Componen
|
|||
|
||||
GradientRepeating repeating_gradient = GradientRepeating::No;
|
||||
|
||||
auto function_name = component_value.function().name().bytes_as_string_view();
|
||||
auto function_name = component_value.function().name.bytes_as_string_view();
|
||||
|
||||
function_name = consume_if_starts_with(function_name, "repeating-"sv, [&] {
|
||||
repeating_gradient = GradientRepeating::Yes;
|
||||
|
@ -286,7 +286,7 @@ RefPtr<CSSStyleValue> Parser::parse_conic_gradient_function(TokenStream<Componen
|
|||
if (!function_name.equals_ignoring_ascii_case("conic-gradient"sv))
|
||||
return nullptr;
|
||||
|
||||
TokenStream tokens { component_value.function().values() };
|
||||
TokenStream tokens { component_value.function().value };
|
||||
tokens.discard_whitespace();
|
||||
|
||||
if (!tokens.has_next_token())
|
||||
|
@ -387,7 +387,7 @@ RefPtr<CSSStyleValue> Parser::parse_radial_gradient_function(TokenStream<Compone
|
|||
|
||||
auto repeating_gradient = GradientRepeating::No;
|
||||
|
||||
auto function_name = component_value.function().name().bytes_as_string_view();
|
||||
auto function_name = component_value.function().name.bytes_as_string_view();
|
||||
|
||||
function_name = consume_if_starts_with(function_name, "repeating-"sv, [&] {
|
||||
repeating_gradient = GradientRepeating::Yes;
|
||||
|
@ -396,7 +396,7 @@ RefPtr<CSSStyleValue> Parser::parse_radial_gradient_function(TokenStream<Compone
|
|||
if (!function_name.equals_ignoring_ascii_case("radial-gradient"sv))
|
||||
return nullptr;
|
||||
|
||||
TokenStream tokens { component_value.function().values() };
|
||||
TokenStream tokens { component_value.function().value };
|
||||
tokens.discard_whitespace();
|
||||
if (!tokens.has_next_token())
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue