mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-30 21:01:00 +00:00 
			
		
		
		
	 c57975c9fd
			
		
	
	
		c57975c9fd
		
	
	
	
	
		
			
			This reverts 0e3487b9ab.
Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.
While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
		
	
			
		
			
				
	
	
		
			55 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/FlyString.h>
 | |
| #include <LibWeb/CSS/StyleValues/StyleValue.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| // https://drafts.csswg.org/css-lists-3/#counter-functions
 | |
| class CounterStyleValue : public StyleValueWithDefaultOperators<CounterStyleValue> {
 | |
| public:
 | |
|     enum class CounterFunction {
 | |
|         Counter,
 | |
|         Counters,
 | |
|     };
 | |
| 
 | |
|     static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counter(FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style)
 | |
|     {
 | |
|         return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counter, move(counter_name), move(counter_style), {}));
 | |
|     }
 | |
|     static ValueComparingNonnullRefPtr<CounterStyleValue const> create_counters(FlyString counter_name, FlyString join_string, ValueComparingNonnullRefPtr<StyleValue const> counter_style)
 | |
|     {
 | |
|         return adopt_ref(*new (nothrow) CounterStyleValue(CounterFunction::Counters, move(counter_name), move(counter_style), move(join_string)));
 | |
|     }
 | |
|     virtual ~CounterStyleValue() override;
 | |
| 
 | |
|     CounterFunction function_type() const { return m_properties.function; }
 | |
|     auto counter_name() const { return m_properties.counter_name; }
 | |
|     auto counter_style() const { return m_properties.counter_style; }
 | |
|     auto join_string() const { return m_properties.join_string; }
 | |
| 
 | |
|     String resolve(DOM::AbstractElement&) const;
 | |
| 
 | |
|     virtual String to_string(SerializationMode) const override;
 | |
| 
 | |
|     bool properties_equal(CounterStyleValue const& other) const;
 | |
| 
 | |
| private:
 | |
|     explicit CounterStyleValue(CounterFunction, FlyString counter_name, ValueComparingNonnullRefPtr<StyleValue const> counter_style, FlyString join_string);
 | |
| 
 | |
|     struct Properties {
 | |
|         CounterFunction function;
 | |
|         FlyString counter_name;
 | |
|         ValueComparingNonnullRefPtr<StyleValue const> counter_style;
 | |
|         FlyString join_string;
 | |
|         bool operator==(Properties const&) const = default;
 | |
|     } m_properties;
 | |
| };
 | |
| 
 | |
| }
 |