mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Resolve circle()/ellipse() position keywords at parse time
This commit is contained in:
Notes:
github-actions[bot]
2026-01-05 11:43:14 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/96a4e33eaf0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7308 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -38,7 +38,7 @@ String EdgeStyleValue::to_string(SerializationMode mode) const
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue const> EdgeStyleValue::absolutized(ComputationContext const& computation_context) const
|
||||
ValueComparingNonnullRefPtr<EdgeStyleValue const> EdgeStyleValue::with_resolved_keywords() const
|
||||
{
|
||||
if (m_properties.edge == PositionEdge::Center)
|
||||
return EdgeStyleValue::create({}, PercentageStyleValue::create(Percentage(50)));
|
||||
@@ -51,18 +51,27 @@ ValueComparingNonnullRefPtr<StyleValue const> EdgeStyleValue::absolutized(Comput
|
||||
if (!m_properties.offset)
|
||||
return EdgeStyleValue::create({}, PercentageStyleValue::create(Percentage(100)));
|
||||
|
||||
auto flipped_percentage = SumCalculationNode::create({ NumericCalculationNode::create(Percentage { 100 }, calculation_context),
|
||||
NegateCalculationNode::create(CalculationNode::from_style_value(*m_properties.offset, calculation_context)) });
|
||||
auto negated_offset = NegateCalculationNode::create(CalculationNode::from_style_value(*m_properties.offset, calculation_context));
|
||||
|
||||
auto flipped_percentage_style_value = CalculatedStyleValue::create(flipped_percentage, NumericType(NumericType::BaseType::Length, 1), calculation_context);
|
||||
auto flipped_offset = simplify_a_calculation_tree(
|
||||
SumCalculationNode::create({ NumericCalculationNode::create(Percentage { 100 }, calculation_context), negated_offset }),
|
||||
calculation_context,
|
||||
{});
|
||||
|
||||
return EdgeStyleValue::create({}, flipped_percentage_style_value->absolutized(computation_context));
|
||||
auto flipped_percentage_style_value = CalculatedStyleValue::create(flipped_offset, NumericType(NumericType::BaseType::Length, 1), calculation_context);
|
||||
|
||||
return EdgeStyleValue::create({}, flipped_percentage_style_value);
|
||||
}
|
||||
|
||||
if (!m_properties.offset)
|
||||
return EdgeStyleValue::create({}, PercentageStyleValue::create(Percentage(0)));
|
||||
|
||||
return EdgeStyleValue::create({}, m_properties.offset->absolutized(computation_context));
|
||||
return EdgeStyleValue::create({}, m_properties.offset);
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue const> EdgeStyleValue::absolutized(ComputationContext const& computation_context) const
|
||||
{
|
||||
return EdgeStyleValue::create({}, with_resolved_keywords()->offset()->absolutized(computation_context));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user