mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb: Store ShadowStyleValue's color as a StyleValue
Colors can be specified in a way that `Gfx::Color` can't represent, such as named system colors, `currentColor`, or functions involving `calc()`.
This commit is contained in:
parent
581d00293c
commit
4e48afd9a7
Notes:
github-actions[bot]
2024-08-21 09:53:11 +00:00
Author: https://github.com/AtkinsSJ
Commit: 4e48afd9a7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1091
6 changed files with 20 additions and 21 deletions
|
@ -4280,7 +4280,7 @@ RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentVal
|
|||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
Optional<Color> color;
|
||||
RefPtr<CSSStyleValue> color;
|
||||
RefPtr<CSSStyleValue> offset_x;
|
||||
RefPtr<CSSStyleValue> offset_y;
|
||||
RefPtr<CSSStyleValue> blur_radius;
|
||||
|
@ -4296,10 +4296,10 @@ RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentVal
|
|||
};
|
||||
|
||||
while (tokens.has_next_token()) {
|
||||
if (auto maybe_color = parse_color(tokens); maybe_color.has_value()) {
|
||||
if (color.has_value())
|
||||
if (auto maybe_color = parse_color_value(tokens); maybe_color) {
|
||||
if (color)
|
||||
return nullptr;
|
||||
color = maybe_color.release_value();
|
||||
color = maybe_color.release_nonnull();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -4355,9 +4355,9 @@ RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentVal
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// FIXME: If color is absent, default to `currentColor`
|
||||
if (!color.has_value())
|
||||
color = Color::NamedColor::Black;
|
||||
// If color is absent, default to `currentColor`
|
||||
if (!color)
|
||||
color = CSSKeywordValue::create(Keyword::Currentcolor);
|
||||
|
||||
// x/y offsets are required
|
||||
if (!offset_x || !offset_y)
|
||||
|
@ -4374,7 +4374,7 @@ RefPtr<CSSStyleValue> Parser::parse_single_shadow_value(TokenStream<ComponentVal
|
|||
placement = ShadowPlacement::Outer;
|
||||
|
||||
transaction.commit();
|
||||
return ShadowStyleValue::create(color.release_value(), offset_x.release_nonnull(), offset_y.release_nonnull(), blur_radius.release_nonnull(), spread_distance.release_nonnull(), placement.release_value());
|
||||
return ShadowStyleValue::create(color.release_nonnull(), offset_x.release_nonnull(), offset_y.release_nonnull(), blur_radius.release_nonnull(), spread_distance.release_nonnull(), placement.release_value());
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue> Parser::parse_content_value(TokenStream<ComponentValue>& tokens)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue