mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
Previously we only supported a subset of the predefined counter styles, we now respect counter styles defined by `@counter-style` rules when resolving the value of `counter()` and `counters()` functions
41 lines
1.1 KiB
C++
41 lines
1.1 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:
|
|
static ValueComparingNonnullRefPtr<CounterStyleStyleValue const> create(FlyString name)
|
|
{
|
|
return adopt_ref(*new (nothrow) CounterStyleStyleValue(move(name)));
|
|
}
|
|
|
|
virtual ~CounterStyleStyleValue() override = default;
|
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
|
|
|
Optional<CounterStyleNameKeyword> to_counter_style_name_keyword() const;
|
|
|
|
Optional<CounterStyle const&> resolve_counter_style(HashMap<FlyString, CounterStyle> const& registered_counter_styles) const;
|
|
|
|
bool properties_equal(CounterStyleStyleValue const& other) const { return m_name == other.m_name; }
|
|
|
|
private:
|
|
explicit CounterStyleStyleValue(FlyString name)
|
|
: StyleValueWithDefaultOperators(Type::CounterStyle)
|
|
, m_name(move(name))
|
|
{
|
|
}
|
|
|
|
FlyString m_name;
|
|
};
|
|
|
|
}
|