2023-03-23 17:26:13 +00:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2024-08-14 16:25:48 +01:00
|
|
|
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
2023-03-23 17:26:13 +00:00
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "AngleStyleValue.h"
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
AngleStyleValue::AngleStyleValue(Angle angle)
|
2024-08-14 16:25:48 +01:00
|
|
|
: CSSUnitValue(Type::Angle)
|
2023-03-23 17:26:13 +00:00
|
|
|
, m_angle(move(angle))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AngleStyleValue::~AngleStyleValue() = default;
|
|
|
|
|
2025-03-19 17:04:15 +00:00
|
|
|
String AngleStyleValue::to_string(SerializationMode serialization_mode) const
|
2023-03-23 17:26:13 +00:00
|
|
|
{
|
2025-03-19 17:04:15 +00:00
|
|
|
if (serialization_mode == SerializationMode::ResolvedValue)
|
|
|
|
return MUST(String::formatted("{}deg", m_angle.to_degrees()));
|
2023-03-23 17:26:13 +00:00
|
|
|
return m_angle.to_string();
|
|
|
|
}
|
|
|
|
|
2024-08-14 16:25:48 +01:00
|
|
|
bool AngleStyleValue::equals(CSSStyleValue const& other) const
|
2023-03-23 17:26:13 +00:00
|
|
|
{
|
2024-08-14 16:25:48 +01:00
|
|
|
if (type() != other.type())
|
|
|
|
return false;
|
|
|
|
auto const& other_angle = other.as_angle();
|
|
|
|
return m_angle == other_angle.m_angle;
|
2023-03-23 17:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|