/* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Tobias Christiansen * Copyright (c) 2021-2023, Sam Atkins * Copyright (c) 2022-2023, MacDue * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Web::CSS { class RectStyleValue : public StyleValueWithDefaultOperators { public: static ValueComparingNonnullRefPtr create(NonnullRefPtr top, NonnullRefPtr right, NonnullRefPtr bottom, NonnullRefPtr left); virtual ~RectStyleValue() override = default; NonnullRefPtr top() const { return m_top; } NonnullRefPtr right() const { return m_right; } NonnullRefPtr bottom() const { return m_bottom; } NonnullRefPtr left() const { return m_left; } EdgeRect rect() const { return { LengthOrAuto::from_style_value(m_top, {}), LengthOrAuto::from_style_value(m_right, {}), LengthOrAuto::from_style_value(m_bottom, {}), LengthOrAuto::from_style_value(m_left, {}) }; } virtual void serialize(StringBuilder&, SerializationMode) const override; virtual ValueComparingNonnullRefPtr absolutized(ComputationContext const&) const override; bool properties_equal(RectStyleValue const& other) const { return m_top == other.m_top && m_right == other.m_right && m_bottom == other.m_bottom && m_left == other.m_left; } virtual bool is_computationally_independent() const override { return m_top->is_computationally_independent() && m_right->is_computationally_independent() && m_bottom->is_computationally_independent() && m_left->is_computationally_independent(); } private: explicit RectStyleValue(NonnullRefPtr top, NonnullRefPtr right, NonnullRefPtr bottom, NonnullRefPtr left) : StyleValueWithDefaultOperators(Type::Rect) , m_top(move(top)) , m_right(move(right)) , m_bottom(move(bottom)) , m_left(move(left)) { } ValueComparingNonnullRefPtr m_top; ValueComparingNonnullRefPtr m_right; ValueComparingNonnullRefPtr m_bottom; ValueComparingNonnullRefPtr m_left; }; }