mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	We already had setProperty() but it was full of ad-hoc idiosyncracies. This patch aligns setProperty() with the CSSOM spec and also implements removeProperty() since that's actually needed by setProperty() now. Some things fixed by this: - We now support the "priority" parameter to setProperty() - Element "style" attributes now update to reflect CSSOM mutations
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <LibWeb/CSS/CSSStyleDeclaration.h>
 | 
						|
 | 
						|
namespace Web::CSS {
 | 
						|
 | 
						|
class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
 | 
						|
public:
 | 
						|
    static NonnullRefPtr<ResolvedCSSStyleDeclaration> create(DOM::Element& element)
 | 
						|
    {
 | 
						|
        return adopt_ref(*new ResolvedCSSStyleDeclaration(element));
 | 
						|
    }
 | 
						|
 | 
						|
    virtual ~ResolvedCSSStyleDeclaration() override = default;
 | 
						|
 | 
						|
    virtual size_t length() const override;
 | 
						|
    virtual String item(size_t index) const override;
 | 
						|
    virtual Optional<StyleProperty> property(PropertyID) const override;
 | 
						|
    virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
 | 
						|
    virtual DOM::ExceptionOr<String> remove_property(PropertyID) override;
 | 
						|
 | 
						|
    virtual String serialized() const override;
 | 
						|
 | 
						|
private:
 | 
						|
    explicit ResolvedCSSStyleDeclaration(DOM::Element&);
 | 
						|
 | 
						|
    RefPtr<StyleValue> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;
 | 
						|
 | 
						|
    NonnullRefPtr<DOM::Element> m_element;
 | 
						|
};
 | 
						|
 | 
						|
}
 |