2025-10-01 20:02:33 +13:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-10-01 21:32:14 +13:00
|
|
|
#include <LibWeb/CSS/StyleValues/AbstractNonMathCalcFunctionStyleValue.h>
|
2025-10-01 20:02:33 +13:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2025-10-01 21:32:14 +13:00
|
|
|
class TreeCountingFunctionStyleValue final : public AbstractNonMathCalcFunctionStyleValue {
|
2025-10-01 20:02:33 +13:00
|
|
|
public:
|
|
|
|
|
enum class TreeCountingFunction : u8 {
|
|
|
|
|
SiblingCount,
|
|
|
|
|
SiblingIndex
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class ComputedType : u8 {
|
|
|
|
|
Number,
|
|
|
|
|
Integer
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static ValueComparingNonnullRefPtr<TreeCountingFunctionStyleValue const> create(TreeCountingFunction function, ComputedType computed_type)
|
|
|
|
|
{
|
|
|
|
|
return adopt_ref(*new (nothrow) TreeCountingFunctionStyleValue(function, computed_type));
|
|
|
|
|
}
|
|
|
|
|
virtual ~TreeCountingFunctionStyleValue() override = default;
|
|
|
|
|
|
|
|
|
|
virtual String to_string(SerializationMode) const override;
|
|
|
|
|
|
2025-10-06 17:09:22 +13:00
|
|
|
size_t resolve(TreeCountingFunctionResolutionContext const&, PropertyComputationDependencies&) const;
|
2025-10-01 20:02:33 +13:00
|
|
|
|
2025-10-06 17:09:22 +13:00
|
|
|
virtual RefPtr<CalculationNode const> resolve_to_calculation_node(CalculationContext const&, CalculationResolutionContext const&, PropertyComputationDependencies*) const override;
|
|
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&, PropertyComputationDependencies&) const override;
|
2025-10-01 20:02:33 +13:00
|
|
|
|
|
|
|
|
virtual bool equals(StyleValue const& other) const override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TreeCountingFunctionStyleValue(TreeCountingFunction function, ComputedType computed_type)
|
2025-10-01 21:32:14 +13:00
|
|
|
: AbstractNonMathCalcFunctionStyleValue(Type::TreeCountingFunction)
|
2025-10-01 20:02:33 +13:00
|
|
|
, m_function(function)
|
|
|
|
|
, m_computed_type(computed_type)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TreeCountingFunction m_function;
|
|
|
|
|
ComputedType m_computed_type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|