mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb/CSS: Make CalculationNodes ref-counted
Calc simplification (which I'm working towards) involves repeatedly deriving a new calculation tree from an existing one, and in many cases, either the whole result or a portion of it will be identical to that of the original. Using RefPtr lets us avoid making unnecessary copies. As a bonus it will also make it easier to return either `this` or a new node. In future we could also cache commonly-used nodes, similar to how we do so for 1px and 0px LengthStyleValues and various keywords.
This commit is contained in:
parent
385c3d273a
commit
c3d61020e7
Notes:
github-actions[bot]
2025-01-30 18:33:46 +00:00
Author: https://github.com/AtkinsSJ
Commit: c3d61020e7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3383
7 changed files with 185 additions and 185 deletions
|
@ -536,7 +536,7 @@ NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, Calc
|
|||
}
|
||||
};
|
||||
|
||||
static auto to_calculation_node = [calculation_context](CSSStyleValue const& value) -> NonnullOwnPtr<CalculationNode> {
|
||||
static auto to_calculation_node = [calculation_context](CSSStyleValue const& value) -> NonnullRefPtr<CalculationNode> {
|
||||
switch (value.type()) {
|
||||
case CSSStyleValue::Type::Angle:
|
||||
return NumericCalculationNode::create(value.as_angle().angle(), calculation_context);
|
||||
|
@ -565,7 +565,7 @@ NonnullRefPtr<CSSStyleValue const> interpolate_value(DOM::Element& element, Calc
|
|||
auto interpolated_from = interpolate_value(element, calculation_context, from, from_base_type_and_default->default_value, delta);
|
||||
auto interpolated_to = interpolate_value(element, calculation_context, to_base_type_and_default->default_value, to, delta);
|
||||
|
||||
Vector<NonnullOwnPtr<CalculationNode>> values;
|
||||
Vector<NonnullRefPtr<CalculationNode>> values;
|
||||
values.ensure_capacity(2);
|
||||
values.unchecked_append(to_calculation_node(interpolated_from));
|
||||
values.unchecked_append(to_calculation_node(interpolated_to));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue