ladybird/Libraries/LibWeb/CSS/StyleValues/AddFunctionStyleValue.cpp
Callum Law 2c3ddc294f LibWeb: Compute math-depth in line with other font properties
The main change here is that we now properly absolutize values which
means we now support `random()` and `sibling-{count,index}()`

We are also more consistent with how we handle computation for the other
font properties
2026-01-15 12:03:16 +00:00

29 lines
747 B
C++

/*
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2026, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "AddFunctionStyleValue.h"
namespace Web::CSS {
ValueComparingNonnullRefPtr<StyleValue const> AddFunctionStyleValue::absolutized(ComputationContext const& context) const
{
auto absolutized_value = m_value->absolutized(context);
if (absolutized_value == m_value)
return *this;
return AddFunctionStyleValue::create(m_value->absolutized(context));
}
void AddFunctionStyleValue::serialize(StringBuilder& builder, SerializationMode mode) const
{
builder.append("add("sv);
m_value->serialize(builder, mode);
builder.append(')');
}
}