mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-03 23:00:58 +00:00 
			
		
		
		
	This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that caches the interface name in a local static FlyString. This means that we only pay for FlyString-from-literal lookup once per browser lifetime instead of every time the interface is instantiated.
		
			
				
	
	
		
			65 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 | 
						|
 * Copyright (c) 2021, the SerenityOS developers.
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#include <LibWeb/HTML/HTMLStyleElement.h>
 | 
						|
 | 
						|
namespace Web::HTML {
 | 
						|
 | 
						|
JS_DEFINE_ALLOCATOR(HTMLStyleElement);
 | 
						|
 | 
						|
HTMLStyleElement::HTMLStyleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
 | 
						|
    : HTMLElement(document, move(qualified_name))
 | 
						|
{
 | 
						|
}
 | 
						|
 | 
						|
HTMLStyleElement::~HTMLStyleElement() = default;
 | 
						|
 | 
						|
void HTMLStyleElement::initialize(JS::Realm& realm)
 | 
						|
{
 | 
						|
    Base::initialize(realm);
 | 
						|
    WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLStyleElement);
 | 
						|
}
 | 
						|
 | 
						|
void HTMLStyleElement::visit_edges(Cell::Visitor& visitor)
 | 
						|
{
 | 
						|
    Base::visit_edges(visitor);
 | 
						|
    visitor.visit(m_style_element_utils.sheet());
 | 
						|
}
 | 
						|
 | 
						|
void HTMLStyleElement::children_changed()
 | 
						|
{
 | 
						|
    m_style_element_utils.update_a_style_block(*this);
 | 
						|
    Base::children_changed();
 | 
						|
}
 | 
						|
 | 
						|
void HTMLStyleElement::inserted()
 | 
						|
{
 | 
						|
    m_style_element_utils.update_a_style_block(*this);
 | 
						|
    Base::inserted();
 | 
						|
}
 | 
						|
 | 
						|
void HTMLStyleElement::removed_from(Node* old_parent)
 | 
						|
{
 | 
						|
    m_style_element_utils.update_a_style_block(*this);
 | 
						|
    Base::removed_from(old_parent);
 | 
						|
}
 | 
						|
 | 
						|
// https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
 | 
						|
CSS::CSSStyleSheet* HTMLStyleElement::sheet()
 | 
						|
{
 | 
						|
    // The sheet attribute must return the associated CSS style sheet for the node or null if there is no associated CSS style sheet.
 | 
						|
    return m_style_element_utils.sheet();
 | 
						|
}
 | 
						|
 | 
						|
// https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
 | 
						|
CSS::CSSStyleSheet const* HTMLStyleElement::sheet() const
 | 
						|
{
 | 
						|
    // The sheet attribute must return the associated CSS style sheet for the node or null if there is no associated CSS style sheet.
 | 
						|
    return m_style_element_utils.sheet();
 | 
						|
}
 | 
						|
 | 
						|
}
 |