From 0289df9357fc0727f3d65d92906e5672d062ae54 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 24 Apr 2025 11:22:52 -0400 Subject: [PATCH] LibWeb: Move ariaActiveDescendantElement to ARIAMixin Not an issue right now, but all IDL types that include the ARIA mixin will need this. --- Libraries/LibWeb/ARIA/ARIAMixin.cpp | 8 ++++++++ Libraries/LibWeb/ARIA/ARIAMixin.h | 12 ++++++++++-- Libraries/LibWeb/DOM/Element.cpp | 4 ++-- Libraries/LibWeb/DOM/Element.h | 5 ----- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.cpp b/Libraries/LibWeb/ARIA/ARIAMixin.cpp index 6fb48c9f3f3..b34f0a3775d 100644 --- a/Libraries/LibWeb/ARIA/ARIAMixin.cpp +++ b/Libraries/LibWeb/ARIA/ARIAMixin.cpp @@ -11,6 +11,14 @@ namespace Web::ARIA { +ARIAMixin::ARIAMixin() = default; +ARIAMixin::~ARIAMixin() = default; + +void ARIAMixin::visit_edges(GC::Cell::Visitor& visitor) +{ + visitor.visit(m_aria_active_descendant_element); +} + // https://www.w3.org/TR/wai-aria-1.2/#introroles Optional ARIAMixin::role_from_role_attribute_value() const { diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.h b/Libraries/LibWeb/ARIA/ARIAMixin.h index 09cf8f7566c..552d323d4bc 100644 --- a/Libraries/LibWeb/ARIA/ARIAMixin.h +++ b/Libraries/LibWeb/ARIA/ARIAMixin.h @@ -17,7 +17,7 @@ namespace Web::ARIA { class ARIAMixin { public: - virtual ~ARIAMixin() = default; + virtual ~ARIAMixin(); #define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \ virtual Optional name() const = 0; \ @@ -48,10 +48,18 @@ public: // https://www.w3.org/TR/wai-aria-1.2/#valuetype_idref_list Vector parse_id_reference_list(Optional const&) const; + GC::Ptr aria_active_descendant_element() { return m_aria_active_descendant_element; } + void set_aria_active_descendant_element(GC::Ptr value) { m_aria_active_descendant_element = value; } + protected: - ARIAMixin() = default; + ARIAMixin(); + + void visit_edges(GC::Cell::Visitor&); virtual bool id_reference_exists(String const&) const = 0; + +private: + GC::Ptr m_aria_active_descendant_element; }; } diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 9af9b500461..5622ec8af08 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -105,8 +105,8 @@ void Element::visit_edges(Cell::Visitor& visitor) Base::visit_edges(visitor); SlottableMixin::visit_edges(visitor); Animatable::visit_edges(visitor); + ARIAMixin::visit_edges(visitor); - visitor.visit(m_aria_active_descendant_element); visitor.visit(m_attributes); visitor.visit(m_inline_style); visitor.visit(m_class_list); @@ -3607,7 +3607,7 @@ void Element::attribute_changed(FlyString const& local_name, Optional co } else if (local_name == ARIA::AttributeNames::aria_active_descendant) { // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:concept-element-attributes-change-ext // Set element's explicitly set attr-element to null. - m_aria_active_descendant_element = nullptr; + set_aria_active_descendant_element({}); } } diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 80c1469f806..5fb0dfcffa4 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -323,9 +323,6 @@ public: ENUMERATE_ARIA_ATTRIBUTES #undef __ENUMERATE_ARIA_ATTRIBUTE - GC::Ptr aria_active_descendant_element() { return m_aria_active_descendant_element; } - void set_aria_active_descendant_element(GC::Ptr value) { m_aria_active_descendant_element = value; } - virtual bool exclude_from_accessibility_tree() const override; virtual bool include_in_accessibility_tree() const override; @@ -579,8 +576,6 @@ private: OwnPtr m_counters_set; - GC::Ptr m_aria_active_descendant_element; - // https://drafts.csswg.org/css-contain/#proximity-to-the-viewport ProximityToTheViewport m_proximity_to_the_viewport { ProximityToTheViewport::NotDetermined }; };