mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-21 15:40:28 +00:00
LibWeb: Define <opacity-value>
as a ValueType
Since `<opacity-value>` is used across multiple properties it makes sense to have it defined as a value.
This commit is contained in:
parent
01c5b6f74f
commit
0e82ab2966
Notes:
github-actions[bot]
2025-10-17 10:11:38 +00:00
Author: https://github.com/Calme1709
Commit: 0e82ab2966
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6493
Reviewed-by: https://github.com/tcl3 ✅
7 changed files with 68 additions and 74 deletions
|
@ -172,6 +172,8 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
|
|||
return parsed.release_value();
|
||||
if (auto parsed = parse_for_type(ValueType::Ratio); parsed.has_value())
|
||||
return parsed.release_value();
|
||||
if (auto parsed = parse_for_type(ValueType::Opacity); parsed.has_value())
|
||||
return parsed.release_value();
|
||||
if (auto parsed = parse_for_type(ValueType::OpentypeTag); parsed.has_value())
|
||||
return parsed.release_value();
|
||||
if (auto parsed = parse_for_type(ValueType::Rect); parsed.has_value())
|
||||
|
@ -721,14 +723,6 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue const>> Parser::parse_css_value(Pr
|
|||
if (auto parsed_value = parse_comma_separated_value_list(tokens, [this, property_id](auto& tokens) { return parse_single_background_size_value(property_id, tokens); }))
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::Opacity:
|
||||
case PropertyID::FillOpacity:
|
||||
case PropertyID::FloodOpacity:
|
||||
case PropertyID::StopOpacity:
|
||||
case PropertyID::StrokeOpacity:
|
||||
if (auto parsed_value = parse_opacity_value(property_id, tokens); parsed_value && !tokens.has_next_token())
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
// FIXME: This can be removed once we have generic logic for parsing "positional-value-list-shorthand"s
|
||||
case PropertyID::Overflow:
|
||||
if (auto parsed_value = parse_overflow_value(tokens); parsed_value && !tokens.has_next_token())
|
||||
|
@ -4061,19 +4055,6 @@ RefPtr<StyleValue const> Parser::parse_math_depth_value(TokenStream<ComponentVal
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<StyleValue const> Parser::parse_opacity_value(PropertyID property_id, TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto value = parse_css_value_for_property(property_id, tokens);
|
||||
if (!value)
|
||||
return nullptr;
|
||||
|
||||
// Percentages map to the range [0,1] for opacity values
|
||||
if (value->is_percentage())
|
||||
value = NumberStyleValue::create(value->as_percentage().percentage().as_fraction());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
RefPtr<StyleValue const> Parser::parse_overflow_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue