mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Give Element a CustomStateSet, exposed by ElementInternals
This commit is contained in:
parent
e63d81b36e
commit
b6ffea8990
Notes:
github-actions[bot]
2025-07-04 17:11:47 +00:00
Author: https://github.com/AtkinsSJ
Commit: b6ffea8990
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5302
Reviewed-by: https://github.com/tcl3 ✅
10 changed files with 209 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -351,6 +351,9 @@ public:
|
|||
CustomElementReactionQueue const* custom_element_reaction_queue() const { return m_custom_element_reaction_queue; }
|
||||
CustomElementReactionQueue& ensure_custom_element_reaction_queue();
|
||||
|
||||
HTML::CustomStateSet const* custom_state_set() const { return m_custom_state_set; }
|
||||
HTML::CustomStateSet& ensure_custom_state_set();
|
||||
|
||||
JS::ThrowCompletionOr<void> upgrade_element(GC::Ref<HTML::CustomElementDefinition> custom_element_definition);
|
||||
void try_to_upgrade();
|
||||
|
||||
|
@ -587,6 +590,9 @@ private:
|
|||
// https://dom.spec.whatwg.org/#concept-element-is-value
|
||||
Optional<String> m_is_value;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/custom-elements.html#states-set
|
||||
GC::Ptr<HTML::CustomStateSet> m_custom_state_set;
|
||||
|
||||
// https://www.w3.org/TR/intersection-observer/#dom-element-registeredintersectionobservers-slot
|
||||
// Element objects have an internal [[RegisteredIntersectionObservers]] slot, which is initialized to an empty list.
|
||||
OwnPtr<Vector<IntersectionObserver::IntersectionObserverRegistration>> m_registered_intersection_observers;
|
||||
|
|
|
@ -208,6 +208,13 @@ WebIDL::ExceptionOr<GC::Ptr<DOM::NodeList>> ElementInternals::labels()
|
|||
return WebIDL::NotSupportedError::create(realm(), "FIXME: ElementInternals::labels()"_string);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-states
|
||||
GC::Ptr<CustomStateSet> ElementInternals::states()
|
||||
{
|
||||
// The states getter steps are to return this's target element's states set.
|
||||
return m_target_element->ensure_custom_state_set();
|
||||
}
|
||||
|
||||
void ElementInternals::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(ElementInternals);
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
WebIDL::ExceptionOr<bool> report_validity() const;
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ptr<DOM::NodeList>> labels();
|
||||
GC::Ptr<CustomStateSet> states();
|
||||
|
||||
private:
|
||||
explicit ElementInternals(JS::Realm&, HTMLElement& target_element);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#import <DOM/ShadowRoot.idl>
|
||||
#import <HTML/CustomElements/CustomStateSet.idl>
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/custom-elements.html#elementinternals
|
||||
[Exposed=Window]
|
||||
|
@ -24,7 +25,7 @@ interface ElementInternals {
|
|||
readonly attribute NodeList labels;
|
||||
|
||||
// Custom state pseudo-class
|
||||
[FIXME, SameObject] readonly attribute CustomStateSet states;
|
||||
[SameObject] readonly attribute CustomStateSet states;
|
||||
};
|
||||
|
||||
// Accessibility semantics
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue