Files
ladybird/Libraries/LibWeb/CSS/StyleValues/CounterStyleStyleValue.h
Callum Law 858989e006 LibWeb: Make CounterStyle ref counted
Previously we just passed around a reference to the `CounterStyle`
stored on `Document::registered_counter_styles` but this won't be
possible for anonymous counter styles (i.e. those created by the
`<symbols()>` function)
2026-02-27 16:25:53 +00:00

40 lines
1.0 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;
RefPtr<CounterStyle const> resolve_counter_style(HashMap<FlyString, NonnullRefPtr<CounterStyle const>> 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;
};
}