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
|
@ -4458,6 +4458,21 @@ RefPtr<CalculationNode const> Parser::parse_a_calculation(Vector<ComponentValue>
|
|||
return simplify_a_calculation_tree(*calculation_tree, context, CalculationResolutionContext {});
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-color-4/#typedef-opacity-opacity-value
|
||||
RefPtr<StyleValue const> Parser::parse_opacity_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
auto value = parse_number_percentage_value(tokens);
|
||||
|
||||
if (!value)
|
||||
return nullptr;
|
||||
|
||||
// Percentages map to the range [0,1] for opacity values
|
||||
if (value->is_percentage())
|
||||
return NumberStyleValue::create(value->as_percentage().percentage().as_fraction());
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-fonts/#typedef-opentype-tag
|
||||
RefPtr<StringStyleValue const> Parser::parse_opentype_tag_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
|
@ -4869,6 +4884,8 @@ RefPtr<StyleValue const> Parser::parse_value(ValueType value_type, TokenStream<C
|
|||
return parse_length_value(tokens);
|
||||
case ValueType::Number:
|
||||
return parse_number_value(tokens);
|
||||
case ValueType::Opacity:
|
||||
return parse_opacity_value(tokens);
|
||||
case ValueType::OpentypeTag:
|
||||
return parse_opentype_tag_value(tokens);
|
||||
case ValueType::Paint:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue