2023-03-24 17:35:31 +00:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2023-03-24 17:35:31 +00: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
|
|
|
|
|
|
2023-03-30 17:13:37 +01:00
|
|
|
#include <LibWeb/CSS/PercentageOr.h>
|
2023-11-06 17:46:19 +00:00
|
|
|
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
2025-08-08 10:11:51 +01:00
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
2023-03-24 17:35:31 +00:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
|
|
class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> {
|
|
|
|
|
public:
|
2026-02-19 18:30:55 +13:00
|
|
|
static ValueComparingNonnullRefPtr<PositionStyleValue const> create(ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y);
|
|
|
|
|
static ValueComparingNonnullRefPtr<PositionStyleValue const> create_center();
|
|
|
|
|
static ValueComparingNonnullRefPtr<PositionStyleValue const> create_computed_center();
|
2023-03-24 17:35:31 +00:00
|
|
|
virtual ~PositionStyleValue() override = default;
|
|
|
|
|
|
2025-04-15 15:18:27 -06:00
|
|
|
ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x() const { return m_properties.edge_x; }
|
|
|
|
|
ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y() const { return m_properties.edge_y; }
|
2025-12-24 23:05:32 +13:00
|
|
|
bool is_center(SerializationMode) const;
|
2023-11-07 12:10:16 +00:00
|
|
|
CSSPixelPoint resolved(Layout::Node const&, CSSPixelRect const&) const;
|
2023-03-24 17:35:31 +00:00
|
|
|
|
2025-12-23 20:30:06 +13:00
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const& computation_context) const override;
|
2026-01-08 12:02:18 +00:00
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
2023-03-24 17:35:31 +00:00
|
|
|
|
|
|
|
|
bool properties_equal(PositionStyleValue 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.edge_x->is_computationally_independent() && m_properties.edge_y->is_computationally_independent(); }
|
|
|
|
|
|
2023-03-24 17:35:31 +00:00
|
|
|
private:
|
2025-04-15 15:18:27 -06:00
|
|
|
PositionStyleValue(ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y)
|
2023-03-24 17:35:31 +00:00
|
|
|
: StyleValueWithDefaultOperators(Type::Position)
|
2025-04-15 15:18:27 -06:00
|
|
|
, m_properties { .edge_x = move(edge_x), .edge_y = move(edge_y) }
|
2023-03-24 17:35:31 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Properties {
|
2025-04-15 15:18:27 -06:00
|
|
|
ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x;
|
|
|
|
|
ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y;
|
2023-03-24 17:35:31 +00:00
|
|
|
bool operator==(Properties const&) const = default;
|
|
|
|
|
} m_properties;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|