ladybird/Libraries/LibWeb/CSS/StyleValues/SuperellipseStyleValue.h
Callum Law ed2909674f LibWeb: Add computationally independent check for custom properties
Registered custom properties only accept "computationally independent"
values for their initial value
2026-03-26 01:11:39 +00:00

47 lines
1.6 KiB
C++

/*
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
class SuperellipseStyleValue final : public StyleValueWithDefaultOperators<SuperellipseStyleValue> {
public:
static ValueComparingNonnullRefPtr<SuperellipseStyleValue const> create(ValueComparingNonnullRefPtr<StyleValue const> const& parameter)
{
return adopt_ref(*new (nothrow) SuperellipseStyleValue(parameter));
}
virtual ~SuperellipseStyleValue() override = default;
// NOTE: This function can only be called after absolutization
double parameter() const
{
return number_from_style_value(*m_parameter, {});
}
virtual void serialize(StringBuilder&, SerializationMode) const override;
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
bool properties_equal(SuperellipseStyleValue const& other) const { return m_parameter == other.m_parameter; }
virtual bool is_computationally_independent() const override { return m_parameter->is_computationally_independent(); }
private:
explicit SuperellipseStyleValue(ValueComparingNonnullRefPtr<StyleValue const> const& parameter)
: StyleValueWithDefaultOperators(Type::Superellipse)
, m_parameter(parameter)
{
}
ValueComparingNonnullRefPtr<StyleValue const> m_parameter;
};
}