mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
LibWeb: Add RatioStyleValue and parsing
This commit is contained in:
parent
b9f9d87bd0
commit
5e3da93f1a
8 changed files with 88 additions and 2 deletions
39
Userland/Libraries/LibWeb/CSS/StyleValues/RatioStyleValue.h
Normal file
39
Userland/Libraries/LibWeb/CSS/StyleValues/RatioStyleValue.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/Ratio.h>
|
||||
#include <LibWeb/CSS/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class RatioStyleValue final : public StyleValueWithDefaultOperators<RatioStyleValue> {
|
||||
public:
|
||||
static ErrorOr<ValueComparingNonnullRefPtr<RatioStyleValue>> create(Ratio ratio)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) RatioStyleValue(move(ratio)));
|
||||
}
|
||||
virtual ~RatioStyleValue() override = default;
|
||||
|
||||
Ratio const& ratio() const { return m_ratio; }
|
||||
Ratio& ratio() { return m_ratio; }
|
||||
|
||||
virtual ErrorOr<String> to_string() const override { return m_ratio.to_string(); }
|
||||
|
||||
bool properties_equal(RatioStyleValue const& other) const { return m_ratio == other.m_ratio; }
|
||||
|
||||
private:
|
||||
RatioStyleValue(Ratio&& ratio)
|
||||
: StyleValueWithDefaultOperators(Type::Ratio)
|
||||
, m_ratio(ratio)
|
||||
{
|
||||
}
|
||||
|
||||
Ratio m_ratio;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue