mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +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. 😅
		
	
			
		
			
				
	
	
		
			43 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/CSS/StyleValues/StyleValue.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> {
 | |
| public:
 | |
|     static ValueComparingNonnullRefPtr<ShorthandStyleValue const> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
 | |
|     {
 | |
|         return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values)));
 | |
|     }
 | |
|     virtual ~ShorthandStyleValue() override;
 | |
| 
 | |
|     Vector<PropertyID> const& sub_properties() const { return m_properties.sub_properties; }
 | |
|     Vector<ValueComparingNonnullRefPtr<StyleValue const>> const& values() const { return m_properties.values; }
 | |
| 
 | |
|     ValueComparingRefPtr<StyleValue const> longhand(PropertyID) const;
 | |
| 
 | |
|     virtual String to_string(SerializationMode) const override;
 | |
| 
 | |
|     bool properties_equal(ShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
 | |
| 
 | |
| private:
 | |
|     ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values);
 | |
| 
 | |
|     virtual void set_style_sheet(GC::Ptr<CSSStyleSheet>) override;
 | |
| 
 | |
|     struct Properties {
 | |
|         PropertyID shorthand_property;
 | |
|         Vector<PropertyID> sub_properties;
 | |
|         Vector<ValueComparingNonnullRefPtr<StyleValue const>> values;
 | |
|         bool operator==(Properties const&) const = default;
 | |
|     } m_properties;
 | |
| };
 | |
| 
 | |
| }
 |