mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
This was a pretty straightforward change of storing registered counter styles on the relevant `StyleScope`s and resolving by following the process to dereference a global tree-scoped name, the only things of note are: - We only define predefined counter styles (e.g. decimal) on the document's scope (since otherwise overrides in outer scopes would themselves be overriden). - When registering counter styles we don't have the full list of extendable styles so we defer fallback to "decimal" for undefined styles until `CounterStyle::from_counter_style_definition`.
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2026, Callum Law <callumlaw1709@outlook.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class CounterStyleStyleValue : public StyleValueWithDefaultOperators<CounterStyleStyleValue> {
|
|
|
|
public:
|
|
struct SymbolsFunction {
|
|
SymbolsType type;
|
|
Vector<FlyString> symbols;
|
|
|
|
bool operator==(SymbolsFunction const& other) const = default;
|
|
};
|
|
|
|
static ValueComparingNonnullRefPtr<CounterStyleStyleValue const> create(Variant<FlyString, SymbolsFunction> value)
|
|
{
|
|
return adopt_ref(*new (nothrow) CounterStyleStyleValue(move(value)));
|
|
}
|
|
|
|
virtual ~CounterStyleStyleValue() override = default;
|
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
|
|
|
RefPtr<CounterStyle const> resolve_counter_style(StyleScope const&) const;
|
|
|
|
bool properties_equal(CounterStyleStyleValue const& other) const { return m_value == other.m_value; }
|
|
|
|
virtual bool is_computationally_independent() const override { return true; }
|
|
|
|
private:
|
|
explicit CounterStyleStyleValue(Variant<FlyString, SymbolsFunction> value)
|
|
: StyleValueWithDefaultOperators(Type::CounterStyle)
|
|
, m_value(move(value))
|
|
{
|
|
}
|
|
|
|
Variant<FlyString, SymbolsFunction> m_value;
|
|
};
|
|
|
|
}
|