mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Pass AbstractElement in ComputationContext
Passing the `AbstractElement` rather than the `TreeCountingFunctionResolutionContext` allows us to only compute the resolution context when necessary (i.e. when we actually need to resolve a tree counting function)
This commit is contained in:
committed by
Jelle Raaijmakers
parent
a4184fda1f
commit
5b9a36b172
Notes:
github-actions[bot]
2025-10-21 23:02:05 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5b9a36b1725 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6526 Reviewed-by: https://github.com/gmta ✅
@@ -23,10 +23,12 @@ String TreeCountingFunctionStyleValue::to_string(SerializationMode) const
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
size_t TreeCountingFunctionStyleValue::resolve(TreeCountingFunctionResolutionContext const& tree_counting_function_resolution_context, PropertyComputationDependencies& property_computation_dependencies) const
|
||||
size_t TreeCountingFunctionStyleValue::resolve(DOM::AbstractElement const& abstract_element, PropertyComputationDependencies& property_computation_dependencies) const
|
||||
{
|
||||
property_computation_dependencies.tree_counting_function = true;
|
||||
|
||||
auto tree_counting_function_resolution_context = abstract_element.tree_counting_function_resolution_context();
|
||||
|
||||
switch (m_function) {
|
||||
case TreeCountingFunction::SiblingCount:
|
||||
return tree_counting_function_resolution_context.sibling_count;
|
||||
@@ -39,20 +41,20 @@ size_t TreeCountingFunctionStyleValue::resolve(TreeCountingFunctionResolutionCon
|
||||
|
||||
RefPtr<CalculationNode const> TreeCountingFunctionStyleValue::resolve_to_calculation_node(CalculationContext const& calculation_context, CalculationResolutionContext const& calculation_resolution_context, PropertyComputationDependencies* property_computation_dependencies) const
|
||||
{
|
||||
if (!calculation_resolution_context.tree_counting_function_resolution_context.has_value())
|
||||
if (!calculation_resolution_context.abstract_element.has_value())
|
||||
return nullptr;
|
||||
|
||||
VERIFY(property_computation_dependencies);
|
||||
|
||||
return NumericCalculationNode::create(Number { Number::Type::Number, static_cast<double>(resolve(calculation_resolution_context.tree_counting_function_resolution_context.value(), *property_computation_dependencies)) }, calculation_context);
|
||||
return NumericCalculationNode::create(Number { Number::Type::Number, static_cast<double>(resolve(calculation_resolution_context.abstract_element.value(), *property_computation_dependencies)) }, calculation_context);
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue const> TreeCountingFunctionStyleValue::absolutized(ComputationContext const& computation_context, PropertyComputationDependencies& property_computation_dependencies) const
|
||||
{
|
||||
// FIXME: We should clamp this value in case it falls outside the valid range for the context it is in
|
||||
VERIFY(computation_context.tree_counting_function_resolution_context.has_value());
|
||||
VERIFY(computation_context.abstract_element.has_value());
|
||||
|
||||
size_t value = resolve(computation_context.tree_counting_function_resolution_context.value(), property_computation_dependencies);
|
||||
size_t value = resolve(computation_context.abstract_element.value(), property_computation_dependencies);
|
||||
|
||||
switch (m_computed_type) {
|
||||
case ComputedType::Integer:
|
||||
|
||||
Reference in New Issue
Block a user