mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb/CSS: Give calc() a CalculationContext for resolving percentages
This is passed in at construction, meaning we will be able to refer to it later, when we're no longer inside the Parser.
This commit is contained in:
parent
bc00ef8314
commit
4efdb76857
Notes:
github-actions[bot]
2025-01-13 11:00:31 +00:00
Author: https://github.com/AtkinsSJ
Commit: 4efdb76857
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3198
8 changed files with 111 additions and 84 deletions
|
@ -16,15 +16,19 @@ String EdgeStyleValue::to_string(SerializationMode mode) const
|
|||
auto flipped_percentage = 100 - offset().percentage().value();
|
||||
return Percentage(flipped_percentage).to_string();
|
||||
}
|
||||
|
||||
// FIXME: Figure out how to get the proper calculation context here
|
||||
CalculationContext context = {};
|
||||
|
||||
Vector<NonnullOwnPtr<CalculationNode>> sum_parts;
|
||||
sum_parts.append(NumericCalculationNode::create(Percentage(100)));
|
||||
sum_parts.append(NumericCalculationNode::create(Percentage(100), context));
|
||||
if (offset().is_length()) {
|
||||
sum_parts.append(NegateCalculationNode::create(NumericCalculationNode::create(offset().length())));
|
||||
sum_parts.append(NegateCalculationNode::create(NumericCalculationNode::create(offset().length(), context)));
|
||||
} else {
|
||||
// FIXME: Flip calculated offsets (convert CalculatedStyleValue to CalculationNode, then negate and append)
|
||||
return to_string(CSSStyleValue::SerializationMode::Normal);
|
||||
}
|
||||
auto flipped_absolute = CalculatedStyleValue::create(SumCalculationNode::create(move(sum_parts)), CSSNumericType(CSSNumericType::BaseType::Length, 1));
|
||||
auto flipped_absolute = CalculatedStyleValue::create(SumCalculationNode::create(move(sum_parts)), CSSNumericType(CSSNumericType::BaseType::Length, 1), context);
|
||||
return flipped_absolute->to_string(mode);
|
||||
}
|
||||
return offset().to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue