LibWeb: Give Element a CustomStateSet, exposed by ElementInternals

This commit is contained in:
Sam Atkins 2025-07-04 14:03:44 +01:00 committed by Tim Ledbetter
commit b6ffea8990
Notes: github-actions[bot] 2025-07-04 17:11:47 +00:00
10 changed files with 209 additions and 1 deletions

View file

@ -46,6 +46,7 @@
#include <LibWeb/HTML/CustomElements/CustomElementName.h>
#include <LibWeb/HTML/CustomElements/CustomElementReactionNames.h>
#include <LibWeb/HTML/CustomElements/CustomElementRegistry.h>
#include <LibWeb/HTML/CustomElements/CustomStateSet.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
@ -118,6 +119,7 @@ void Element::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_class_list);
visitor.visit(m_shadow_root);
visitor.visit(m_custom_element_definition);
visitor.visit(m_custom_state_set);
visitor.visit(m_cascaded_properties);
visitor.visit(m_computed_properties);
if (m_pseudo_element_data) {
@ -3824,6 +3826,13 @@ auto Element::ensure_custom_element_reaction_queue() -> CustomElementReactionQue
return *m_custom_element_reaction_queue;
}
HTML::CustomStateSet& Element::ensure_custom_state_set()
{
if (!m_custom_state_set)
m_custom_state_set = HTML::CustomStateSet::create(realm(), *this);
return *m_custom_state_set;
}
CSS::StyleSheetList& Element::document_or_shadow_root_style_sheets()
{
auto& root_node = root();