mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 23:29:52 +00:00
This reverts 0e3487b9ab
.
Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.
While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> {
|
|
public:
|
|
static ValueComparingNonnullRefPtr<MathDepthStyleValue const> create_auto_add();
|
|
static ValueComparingNonnullRefPtr<MathDepthStyleValue const> create_add(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
|
|
static ValueComparingNonnullRefPtr<MathDepthStyleValue const> create_integer(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
|
|
virtual ~MathDepthStyleValue() override = default;
|
|
|
|
bool is_auto_add() const { return m_type == MathDepthType::AutoAdd; }
|
|
bool is_add() const { return m_type == MathDepthType::Add; }
|
|
bool is_integer() const { return m_type == MathDepthType::Integer; }
|
|
auto integer_value() const
|
|
{
|
|
VERIFY(!m_integer_value.is_null());
|
|
return m_integer_value;
|
|
}
|
|
virtual String to_string(SerializationMode) const override;
|
|
|
|
bool properties_equal(MathDepthStyleValue const& other) const;
|
|
|
|
private:
|
|
enum class MathDepthType {
|
|
AutoAdd,
|
|
Add,
|
|
Integer,
|
|
};
|
|
|
|
MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<StyleValue const> integer_value = nullptr);
|
|
|
|
MathDepthType m_type;
|
|
ValueComparingRefPtr<StyleValue const> m_integer_value;
|
|
};
|
|
|
|
}
|