mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02:00
LibWeb: Parse @counter-style system descriptor
This commit is contained in:
Notes:
github-actions[bot]
2026-02-06 10:38:11 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/f60bfd9e9e2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7708 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Callum Law <callumlaw1709@outlook.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class CounterStyleSystemStyleValue : public StyleValueWithDefaultOperators<CounterStyleSystemStyleValue> {
|
||||
public:
|
||||
NonnullRefPtr<StyleValue const> static create(CounterStyleSystem system)
|
||||
{
|
||||
return adopt_ref(*new CounterStyleSystemStyleValue(system));
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> static create_fixed(RefPtr<StyleValue const> first_symbol)
|
||||
{
|
||||
return adopt_ref(*new CounterStyleSystemStyleValue(Fixed { move(first_symbol) }));
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> static create_extends(FlyString name)
|
||||
{
|
||||
return adopt_ref(*new CounterStyleSystemStyleValue(Extends { move(name) }));
|
||||
}
|
||||
|
||||
virtual ~CounterStyleSystemStyleValue() override = default;
|
||||
|
||||
virtual void serialize(StringBuilder& builder, SerializationMode mode) const override;
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const& context) const override;
|
||||
bool algorithm_differs_from(CounterStyleSystemStyleValue const& other) const;
|
||||
|
||||
bool properties_equal(CounterStyleSystemStyleValue const& other) const { return m_value == other.m_value; }
|
||||
|
||||
private:
|
||||
struct Fixed {
|
||||
ValueComparingRefPtr<StyleValue const> first_symbol;
|
||||
bool operator==(Fixed const&) const = default;
|
||||
};
|
||||
|
||||
struct Extends {
|
||||
FlyString name;
|
||||
bool operator==(Extends const&) const = default;
|
||||
};
|
||||
|
||||
explicit CounterStyleSystemStyleValue(Variant<CounterStyleSystem, Fixed, Extends> value)
|
||||
: StyleValueWithDefaultOperators(Type::CounterStyleSystem)
|
||||
, m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
||||
Variant<CounterStyleSystem, Fixed, Extends> m_value;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user