2023-03-24 17:04:04 +00:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2023-03-24 17:04:04 +00:00
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
2024-08-14 16:25:48 +01:00
|
|
|
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
2023-03-24 17:04:04 +00:00
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-08-14 16:25:48 +01:00
|
|
|
#include <LibWeb/CSS/Length.h>
|
2025-08-08 11:08:54 +01:00
|
|
|
#include <LibWeb/CSS/StyleValues/DimensionStyleValue.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2023-03-24 17:04:04 +00:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API LengthStyleValue final : public DimensionStyleValue {
|
2023-03-24 17:04:04 +00:00
|
|
|
public:
|
2025-04-15 15:18:27 -06:00
|
|
|
static ValueComparingNonnullRefPtr<LengthStyleValue const> create(Length const&);
|
2023-03-24 17:04:04 +00:00
|
|
|
virtual ~LengthStyleValue() override = default;
|
|
|
|
|
|
|
|
|
|
Length const& length() const { return m_length; }
|
2025-08-08 11:08:54 +01:00
|
|
|
virtual double raw_value() const override { return m_length.raw_value(); }
|
2025-09-11 11:50:59 +01:00
|
|
|
virtual FlyString unit_name() const override { return m_length.unit_name(); }
|
2023-03-24 17:04:04 +00:00
|
|
|
|
2026-01-08 14:55:48 +00:00
|
|
|
virtual void serialize(StringBuilder& builder, SerializationMode mode) const override { m_length.serialize(builder, mode); }
|
2025-10-22 00:48:32 +13:00
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
2023-03-24 17:04:04 +00:00
|
|
|
|
2026-03-08 16:19:00 +13:00
|
|
|
virtual bool is_computationally_independent() const override { return !m_length.is_font_relative(); }
|
|
|
|
|
|
2025-08-08 10:11:51 +01:00
|
|
|
bool equals(StyleValue const& other) const override;
|
2023-03-24 17:04:04 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
explicit LengthStyleValue(Length const& length)
|
2025-08-08 11:08:54 +01:00
|
|
|
: DimensionStyleValue(Type::Length)
|
2023-03-24 17:04:04 +00:00
|
|
|
, m_length(length)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Length m_length;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|