2023-03-24 21:33:20 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2023-03-24 21:33:20 -03:00
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
|
|
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
|
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/CSS/Length.h>
|
2023-03-30 13:13:37 -03:00
|
|
|
#include <LibWeb/CSS/PercentageOr.h>
|
2025-08-08 06:11:51 -03:00
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
2023-03-24 21:33:20 -03:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
|
|
class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> {
|
|
|
|
|
public:
|
2026-01-05 04:55:26 -03:00
|
|
|
static ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> create_zero()
|
|
|
|
|
{
|
|
|
|
|
return create(LengthStyleValue::create(Length::make_px(0)), LengthStyleValue::create(Length::make_px(0)));
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-02 00:55:22 -03:00
|
|
|
static ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> create(ValueComparingNonnullRefPtr<StyleValue const> const& horizontal_radius, ValueComparingNonnullRefPtr<StyleValue const> const& vertical_radius)
|
2023-03-24 21:33:20 -03:00
|
|
|
{
|
2023-08-19 10:00:10 -03:00
|
|
|
return adopt_ref(*new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius));
|
2023-03-24 21:33:20 -03:00
|
|
|
}
|
|
|
|
|
virtual ~BorderRadiusStyleValue() override = default;
|
|
|
|
|
|
2025-10-02 00:55:22 -03:00
|
|
|
ValueComparingNonnullRefPtr<StyleValue const> const& horizontal_radius() const { return m_properties.horizontal_radius; }
|
|
|
|
|
ValueComparingNonnullRefPtr<StyleValue const> const& vertical_radius() const { return m_properties.vertical_radius; }
|
2023-03-24 21:33:20 -03:00
|
|
|
bool is_elliptical() const { return m_properties.is_elliptical; }
|
|
|
|
|
|
2026-01-08 09:02:18 -03:00
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
2023-03-24 21:33:20 -03:00
|
|
|
|
|
|
|
|
bool properties_equal(BorderRadiusStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
|
|
|
|
2026-03-08 00:19:00 -03:00
|
|
|
virtual bool is_computationally_independent() const override { return m_properties.horizontal_radius->is_computationally_independent() && m_properties.vertical_radius->is_computationally_independent(); }
|
|
|
|
|
|
2023-03-24 21:33:20 -03:00
|
|
|
private:
|
2025-10-02 00:55:22 -03:00
|
|
|
BorderRadiusStyleValue(ValueComparingNonnullRefPtr<StyleValue const> const& horizontal_radius, ValueComparingNonnullRefPtr<StyleValue const> const& vertical_radius)
|
2023-03-24 21:33:20 -03:00
|
|
|
: StyleValueWithDefaultOperators(Type::BorderRadius)
|
|
|
|
|
, m_properties { .is_elliptical = horizontal_radius != vertical_radius, .horizontal_radius = horizontal_radius, .vertical_radius = vertical_radius }
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-21 08:48:32 -03:00
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
2023-03-24 21:33:20 -03:00
|
|
|
struct Properties {
|
|
|
|
|
bool is_elliptical;
|
2025-10-02 00:55:22 -03:00
|
|
|
ValueComparingNonnullRefPtr<StyleValue const> horizontal_radius;
|
|
|
|
|
ValueComparingNonnullRefPtr<StyleValue const> vertical_radius;
|
2023-03-24 21:33:20 -03:00
|
|
|
bool operator==(Properties const&) const = default;
|
|
|
|
|
} m_properties;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|