mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Parse gradient functions with TokenStream
They already used TokenStream for parsing the function parameters, but this makes the `parse_foo_gradient()` functions themselves take a TokenStream.
This commit is contained in:
parent
29d7aa9fc9
commit
9de73bf89b
Notes:
github-actions[bot]
2024-08-10 08:38:51 +00:00
Author: https://github.com/AtkinsSJ
Commit: 9de73bf89b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1018
Reviewed-by: https://github.com/awesomekling
3 changed files with 25 additions and 21 deletions
|
@ -135,10 +135,13 @@ Optional<Vector<AngularColorStopListElement>> Parser::parse_angular_color_stop_l
|
|||
[](Dimension& dimension) { return dimension.angle_percentage(); });
|
||||
}
|
||||
|
||||
RefPtr<StyleValue> Parser::parse_linear_gradient_function(ComponentValue const& component_value)
|
||||
RefPtr<StyleValue> Parser::parse_linear_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
using GradientType = LinearGradientStyleValue::GradientType;
|
||||
|
||||
auto transaction = outer_tokens.begin_transaction();
|
||||
auto& component_value = outer_tokens.next_token();
|
||||
|
||||
if (!component_value.is_function())
|
||||
return nullptr;
|
||||
|
||||
|
@ -260,11 +263,15 @@ RefPtr<StyleValue> Parser::parse_linear_gradient_function(ComponentValue const&
|
|||
if (!color_stops.has_value())
|
||||
return nullptr;
|
||||
|
||||
transaction.commit();
|
||||
return LinearGradientStyleValue::create(gradient_direction, move(*color_stops), gradient_type, repeating_gradient);
|
||||
}
|
||||
|
||||
RefPtr<StyleValue> Parser::parse_conic_gradient_function(ComponentValue const& component_value)
|
||||
RefPtr<StyleValue> Parser::parse_conic_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
auto transaction = outer_tokens.begin_transaction();
|
||||
auto& component_value = outer_tokens.next_token();
|
||||
|
||||
if (!component_value.is_function())
|
||||
return nullptr;
|
||||
|
||||
|
@ -360,10 +367,11 @@ RefPtr<StyleValue> Parser::parse_conic_gradient_function(ComponentValue const& c
|
|||
if (!at_position)
|
||||
at_position = PositionStyleValue::create_center();
|
||||
|
||||
transaction.commit();
|
||||
return ConicGradientStyleValue::create(from_angle, at_position.release_nonnull(), move(*color_stops), repeating_gradient);
|
||||
}
|
||||
|
||||
RefPtr<StyleValue> Parser::parse_radial_gradient_function(ComponentValue const& component_value)
|
||||
RefPtr<StyleValue> Parser::parse_radial_gradient_function(TokenStream<ComponentValue>& outer_tokens)
|
||||
{
|
||||
using EndingShape = RadialGradientStyleValue::EndingShape;
|
||||
using Extent = RadialGradientStyleValue::Extent;
|
||||
|
@ -371,6 +379,9 @@ RefPtr<StyleValue> Parser::parse_radial_gradient_function(ComponentValue const&
|
|||
using EllipseSize = RadialGradientStyleValue::EllipseSize;
|
||||
using Size = RadialGradientStyleValue::Size;
|
||||
|
||||
auto transaction = outer_tokens.begin_transaction();
|
||||
auto& component_value = outer_tokens.next_token();
|
||||
|
||||
if (!component_value.is_function())
|
||||
return nullptr;
|
||||
|
||||
|
@ -511,6 +522,7 @@ RefPtr<StyleValue> Parser::parse_radial_gradient_function(ComponentValue const&
|
|||
if (!at_position)
|
||||
at_position = PositionStyleValue::create_center();
|
||||
|
||||
transaction.commit();
|
||||
return RadialGradientStyleValue::create(ending_shape, size, at_position.release_nonnull(), move(*color_stops), repeating_gradient);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue