2023-03-24 17:40:28 +00:00
|
|
|
/*
|
2024-08-14 16:25:48 +01:00
|
|
|
* Copyright (c) 2022-2024, Sam Atkins <sam@ladybird.org>
|
2023-03-24 17:40:28 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/CSS/Resolution.h>
|
2025-08-08 11:08:54 +01:00
|
|
|
#include <LibWeb/CSS/StyleValues/DimensionStyleValue.h>
|
2023-03-24 17:40:28 +00:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2025-08-08 11:08:54 +01:00
|
|
|
class ResolutionStyleValue : public DimensionStyleValue {
|
2023-03-24 17:40:28 +00:00
|
|
|
public:
|
2025-04-15 15:18:27 -06:00
|
|
|
static ValueComparingNonnullRefPtr<ResolutionStyleValue const> create(Resolution resolution)
|
2023-03-24 17:40:28 +00:00
|
|
|
{
|
2023-08-19 14:00:10 +01:00
|
|
|
return adopt_ref(*new (nothrow) ResolutionStyleValue(move(resolution)));
|
2023-03-24 17:40:28 +00:00
|
|
|
}
|
|
|
|
virtual ~ResolutionStyleValue() override = default;
|
|
|
|
|
|
|
|
Resolution const& resolution() const { return m_resolution; }
|
2025-08-08 11:08:54 +01:00
|
|
|
virtual double raw_value() const override { return m_resolution.raw_value(); }
|
2025-09-11 11:50:59 +01:00
|
|
|
virtual FlyString unit_name() const override { return m_resolution.unit_name(); }
|
2023-03-24 17:40:28 +00:00
|
|
|
|
2025-05-16 20:02:16 +01:00
|
|
|
virtual String to_string(SerializationMode serialization_mode) const override { return m_resolution.to_string(serialization_mode); }
|
2023-03-24 17:40:28 +00:00
|
|
|
|
2025-08-08 10:11:51 +01:00
|
|
|
bool equals(StyleValue const& other) const override
|
2024-08-14 16:25:48 +01:00
|
|
|
{
|
|
|
|
if (type() != other.type())
|
|
|
|
return false;
|
|
|
|
auto const& other_resolution = other.as_resolution();
|
|
|
|
return m_resolution == other_resolution.m_resolution;
|
|
|
|
}
|
2023-03-24 17:40:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit ResolutionStyleValue(Resolution resolution)
|
2025-08-08 11:08:54 +01:00
|
|
|
: DimensionStyleValue(Type::Resolution)
|
2023-03-24 17:40:28 +00:00
|
|
|
, m_resolution(move(resolution))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Resolution m_resolution;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|