mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Support tree counting functions within calc()
This commit is contained in:
parent
55bcdcf824
commit
e9036c7c75
Notes:
github-actions[bot]
2025-10-20 15:13:31 +00:00
Author: https://github.com/Calme1709
Commit: e9036c7c75
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6426
Reviewed-by: https://github.com/AtkinsSJ ✅
15 changed files with 62 additions and 44 deletions
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "TreeCountingFunctionStyleValue.h"
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
|
||||
|
|
@ -34,6 +35,14 @@ size_t TreeCountingFunctionStyleValue::resolve(TreeCountingFunctionResolutionCon
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<CalculationNode const> TreeCountingFunctionStyleValue::resolve_to_calculation_node(CalculationContext const& calculation_context, CalculationResolutionContext const& calculation_resolution_context) const
|
||||
{
|
||||
if (!calculation_resolution_context.tree_counting_function_resolution_context.has_value())
|
||||
return nullptr;
|
||||
|
||||
return NumericCalculationNode::create(Number { Number::Type::Number, static_cast<double>(resolve(calculation_resolution_context.tree_counting_function_resolution_context.value())) }, calculation_context);
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue const> TreeCountingFunctionStyleValue::absolutized(ComputationContext const& computation_context) const
|
||||
{
|
||||
// FIXME: We should clamp this value in case it falls outside the valid range for the context it is in
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/AbstractNonMathCalcFunctionStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class TreeCountingFunctionStyleValue final : public StyleValue {
|
||||
class TreeCountingFunctionStyleValue final : public AbstractNonMathCalcFunctionStyleValue {
|
||||
public:
|
||||
enum class TreeCountingFunction : u8 {
|
||||
SiblingCount,
|
||||
|
|
@ -32,13 +32,14 @@ public:
|
|||
|
||||
size_t resolve(TreeCountingFunctionResolutionContext const&) const;
|
||||
|
||||
virtual RefPtr<CalculationNode const> resolve_to_calculation_node(CalculationContext const&, CalculationResolutionContext const&) const override;
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
||||
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
TreeCountingFunctionStyleValue(TreeCountingFunction function, ComputedType computed_type)
|
||||
: StyleValue(Type::TreeCountingFunction)
|
||||
: AbstractNonMathCalcFunctionStyleValue(Type::TreeCountingFunction)
|
||||
, m_function(function)
|
||||
, m_computed_type(computed_type)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue