2023-04-02 22:56:45 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-10-23 19:33:58 +13:00
|
|
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
2025-08-08 10:11:51 +01:00
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
2023-04-02 22:56:45 +01:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
|
|
class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
|
|
|
|
|
public:
|
2025-10-23 19:33:58 +13:00
|
|
|
static ValueComparingNonnullRefPtr<EdgeStyleValue const> create(Optional<PositionEdge> edge, RefPtr<StyleValue const> const& offset)
|
2023-04-02 22:56:45 +01:00
|
|
|
{
|
2023-08-19 14:00:10 +01:00
|
|
|
return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset));
|
2023-04-02 22:56:45 +01:00
|
|
|
}
|
|
|
|
|
virtual ~EdgeStyleValue() override = default;
|
|
|
|
|
|
2026-01-04 01:07:21 +13:00
|
|
|
// This is nonnull as it is only called after resolving keywords
|
2025-12-24 15:54:27 +13:00
|
|
|
NonnullRefPtr<StyleValue const> offset() const { return *m_properties.offset; }
|
2024-11-29 22:44:14 +11:00
|
|
|
|
2025-12-24 23:05:32 +13:00
|
|
|
bool is_center(SerializationMode) const;
|
2023-04-02 22:56:45 +01:00
|
|
|
|
2026-01-08 12:02:18 +00:00
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
2026-01-04 01:07:21 +13:00
|
|
|
|
|
|
|
|
ValueComparingNonnullRefPtr<EdgeStyleValue const> with_resolved_keywords() const;
|
2025-12-24 15:54:27 +13:00
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const& computation_context) const override;
|
2023-04-02 22:56:45 +01:00
|
|
|
bool properties_equal(EdgeStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
|
|
|
|
2026-03-08 16:19:00 +13:00
|
|
|
virtual bool is_computationally_independent() const override { return m_properties.offset->is_computationally_independent(); }
|
|
|
|
|
|
2023-04-02 22:56:45 +01:00
|
|
|
private:
|
2025-10-23 19:33:58 +13:00
|
|
|
EdgeStyleValue(Optional<PositionEdge> edge, RefPtr<StyleValue const> const& offset)
|
2023-04-02 22:56:45 +01:00
|
|
|
: StyleValueWithDefaultOperators(Type::Edge)
|
|
|
|
|
, m_properties { .edge = edge, .offset = offset }
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Properties {
|
2024-11-29 22:44:14 +11:00
|
|
|
Optional<PositionEdge> edge;
|
2025-10-23 19:33:58 +13:00
|
|
|
ValueComparingRefPtr<StyleValue const> offset;
|
2023-04-02 22:56:45 +01:00
|
|
|
bool operator==(Properties const&) const = default;
|
|
|
|
|
} m_properties;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|