1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

LibWeb: Implement the math-depth CSS property

This one is a bit fun because it can be `add(<integer>)` or `auto-add`,
but children have to inherit the computed value not the specified one.
We also have to compute it before computing the font-size, because of
`font-size: math` which will be implemented later.
This commit is contained in:
Sam Atkins 2023-09-07 15:29:54 +01:00 committed by Sam Atkins
parent 53f3ed026a
commit 6476dea898
19 changed files with 285 additions and 11 deletions

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
class MathDepthStyleValue : public StyleValueWithDefaultOperators<MathDepthStyleValue> {
public:
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_auto_add();
static ValueComparingNonnullRefPtr<MathDepthStyleValue> create_add(ValueComparingNonnullRefPtr<StyleValue const> integer_value);
static ValueComparingNonnullRefPtr<MathDepthStyleValue> 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() 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;
};
}