mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:22:43 +00:00 
			
		
		
		
	 0fdfdbed9f
			
		
	
	
		0fdfdbed9f
		
	
	
	
	
		
			
			This commit changes inline CSS loaded from style attributes of HTML elements to be loaded as CSS::ElementInlineCSSStyleDeclaration instead of CSS::CSSStyleDeclaration, fixing a crash when the style of that element is changed from JavaScript.
		
			
				
	
	
		
			45 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/CSS/CSSStyleDeclaration.h>
 | |
| #include <LibWeb/DOM/Element.h>
 | |
| 
 | |
| namespace Web::CSS {
 | |
| 
 | |
| CSSStyleDeclaration::CSSStyleDeclaration(Vector<StyleProperty>&& properties, HashMap<String, StyleProperty>&& custom_properties)
 | |
|     : m_properties(move(properties))
 | |
|     , m_custom_properties(move(custom_properties))
 | |
| {
 | |
| }
 | |
| 
 | |
| CSSStyleDeclaration::~CSSStyleDeclaration()
 | |
| {
 | |
| }
 | |
| 
 | |
| String CSSStyleDeclaration::item(size_t index) const
 | |
| {
 | |
|     if (index >= m_properties.size())
 | |
|         return {};
 | |
|     return CSS::string_from_property_id(m_properties[index].property_id);
 | |
| }
 | |
| 
 | |
| ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element)
 | |
|     : CSSStyleDeclaration({}, {})
 | |
|     , m_element(element.make_weak_ptr<DOM::Element>())
 | |
| {
 | |
| }
 | |
| 
 | |
| ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, CSSStyleDeclaration& declaration)
 | |
|     : CSSStyleDeclaration(move(declaration.m_properties), move(declaration.m_custom_properties))
 | |
|     , m_element(element.make_weak_ptr<DOM::Element>())
 | |
| {
 | |
| }
 | |
| 
 | |
| ElementInlineCSSStyleDeclaration::~ElementInlineCSSStyleDeclaration()
 | |
| {
 | |
| }
 | |
| 
 | |
| }
 |