File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Userland/Libraries/LibWeb/CSS Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -4210,10 +4210,16 @@ Optional<CalculatedStyleValue::CalcValue> Parser::parse_calc_value(TokenStream<S
4210
4210
return CalculatedStyleValue::CalcValue { static_cast <float >(current_token.token ().number_value ()) };
4211
4211
4212
4212
if (current_token.is (Token::Type::Dimension) || current_token.is (Token::Type::Percentage)) {
4213
- auto maybe_length = parse_length (current_token);
4214
- if (maybe_length.has_value () && !maybe_length.value ().is_undefined ())
4215
- return CalculatedStyleValue::CalcValue { maybe_length.value () };
4216
- return {};
4213
+ auto maybe_dimension = parse_dimension (current_token);
4214
+ if (!maybe_dimension.has_value ())
4215
+ return {};
4216
+ auto & dimension = maybe_dimension.value ();
4217
+
4218
+ if (dimension.is_length ())
4219
+ return CalculatedStyleValue::CalcValue { dimension.length () };
4220
+ if (dimension.is_percentage ())
4221
+ return CalculatedStyleValue::CalcValue { dimension.percentage () };
4222
+ VERIFY_NOT_REACHED ();
4217
4223
}
4218
4224
4219
4225
return {};
Original file line number Diff line number Diff line change @@ -574,6 +574,7 @@ Optional<CalculatedStyleValue::ResolvedType> CalculatedStyleValue::CalcValue::re
574
574
return value.visit (
575
575
[](float ) -> Optional<CalculatedStyleValue::ResolvedType> { return { ResolvedType::Number }; },
576
576
[](Length const &) -> Optional<CalculatedStyleValue::ResolvedType> { return { ResolvedType::Length }; },
577
+ [](Percentage const &) -> Optional<CalculatedStyleValue::ResolvedType> { return { ResolvedType::Percentage }; },
577
578
[](NonnullOwnPtr<CalcSum> const & sum) { return sum->resolved_type (); });
578
579
}
579
580
@@ -604,6 +605,9 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcValue::resolve
604
605
[&](Length const & length) -> CalculatedStyleValue::CalculationResult {
605
606
return CalculatedStyleValue::CalculationResult { length };
606
607
},
608
+ [&](Percentage const & percentage) -> CalculatedStyleValue::CalculationResult {
609
+ return CalculatedStyleValue::CalculationResult { percentage };
610
+ },
607
611
[&](NonnullOwnPtr<CalcSum> const & sum) -> CalculatedStyleValue::CalculationResult {
608
612
return sum->resolve (layout_node, percentage_basis);
609
613
});
Original file line number Diff line number Diff line change @@ -707,7 +707,7 @@ class CalculatedStyleValue : public StyleValue {
707
707
};
708
708
709
709
struct CalcValue {
710
- Variant<float , CSS:: Length, NonnullOwnPtr<CalcSum>> value;
710
+ Variant<float , Length, Percentage , NonnullOwnPtr<CalcSum>> value;
711
711
Optional<ResolvedType> resolved_type () const ;
712
712
CalculationResult resolve (Layout::Node const *, Length const & percentage_basis) const ;
713
713
};
You can’t perform that action at this time.
0 commit comments