mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
Registered custom properties only accept "computationally independent" values for their initial value
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class RadialSizeStyleValue : public StyleValueWithDefaultOperators<RadialSizeStyleValue> {
|
|
public:
|
|
using Component = Variant<RadialExtent, NonnullRefPtr<StyleValue const>>;
|
|
static ValueComparingNonnullRefPtr<RadialSizeStyleValue const> create(Vector<Component> components)
|
|
{
|
|
VERIFY(components.size() == 1 || components.size() == 2);
|
|
return adopt_ref(*new (nothrow) RadialSizeStyleValue(move(components)));
|
|
}
|
|
|
|
virtual ~RadialSizeStyleValue() override = default;
|
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
|
|
|
Vector<Component> components() const { return m_components; }
|
|
|
|
CSSPixels resolve_circle_size(CSSPixelPoint const& center, CSSPixelRect const& reference_box, Layout::Node const&) const;
|
|
CSSPixelSize resolve_ellipse_size(CSSPixelPoint const& center, CSSPixelRect const& reference_box, Layout::Node const&) const;
|
|
|
|
bool properties_equal(RadialSizeStyleValue const& other) const { return m_components == other.m_components; }
|
|
|
|
virtual bool is_computationally_independent() const override
|
|
{
|
|
return all_of(m_components, [](auto const& component) {
|
|
return component.visit(
|
|
[](RadialExtent) { return true; },
|
|
[](NonnullRefPtr<StyleValue const> const& value) { return value->is_computationally_independent(); });
|
|
});
|
|
}
|
|
|
|
private:
|
|
explicit RadialSizeStyleValue(Vector<Component> components)
|
|
: StyleValueWithDefaultOperators(Type::RadialSize)
|
|
, m_components(move(components))
|
|
{
|
|
}
|
|
|
|
Vector<Component> m_components;
|
|
};
|
|
|
|
}
|