Skip to content

Commit

Permalink
LibWeb: Support the ariaActiveDescendantElement IDL attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshowbarker authored and tcl3 committed Jan 1, 2025
1 parent e1b4aa9 commit 1be55fe
Show file tree
Hide file tree
Showing 5 changed files with 890 additions and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/LibWeb/ARIA/ARIAMixin.idl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// https://w3c.github.io/aria/#ARIAMixin
interface mixin ARIAMixin {
[CEReactions] attribute DOMString? role;
[Reflect=aria-activedescendant, CEReactions] attribute Element? ariaActiveDescendantElement;
[CEReactions] attribute DOMString? ariaAtomic;
[CEReactions] attribute DOMString? ariaAutoComplete;
[CEReactions] attribute DOMString? ariaBrailleLabel;
Expand Down
5 changes: 5 additions & 0 deletions Libraries/LibWeb/DOM/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void Element::visit_edges(Cell::Visitor& visitor)
SlottableMixin::visit_edges(visitor);
Animatable::visit_edges(visitor);

visitor.visit(m_aria_active_descendant_element);
visitor.visit(m_attributes);
visitor.visit(m_inline_style);
visitor.visit(m_class_list);
Expand Down Expand Up @@ -2926,6 +2927,10 @@ void Element::attribute_changed(FlyString const& local_name, Optional<String> co
m_dir = Dir::Auto;
else
m_dir = {};
} 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;
}
}

Expand Down
5 changes: 5 additions & 0 deletions Libraries/LibWeb/DOM/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ class Element
ENUMERATE_ARIA_ATTRIBUTES
#undef __ENUMERATE_ARIA_ATTRIBUTE

GC::Ptr<DOM::Element> aria_active_descendant_element() { return m_aria_active_descendant_element; }
void set_aria_active_descendant_element(GC::Ptr<DOM::Element> value) { m_aria_active_descendant_element = value; }

virtual bool exclude_from_accessibility_tree() const override;

virtual bool include_in_accessibility_tree() const override;
Expand Down Expand Up @@ -464,6 +467,8 @@ class Element
bool m_in_top_layer { false };

OwnPtr<CSS::CountersSet> m_counters_set;

GC::Ptr<DOM::Element> m_aria_active_descendant_element;
};

template<>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Harness status: OK

Found 27 tests

16 Pass
11 Fail
Pass aria-activedescendant element reflection
Pass aria-activedescendant If the content attribute is set directly, the IDL attribute getter always returns the first element whose ID matches the content attribute.
Pass aria-activedescendant Setting the IDL attribute to an element which is not the first element in DOM order with its ID causes the content attribute to be an empty string
Pass aria-activedescendant Setting an element reference that crosses into a shadow tree is disallowed, but setting one that is in a shadow inclusive ancestor is allowed.
Fail aria-errormessage
Pass ariaErrorMessageElement is not defined
Fail aria-details
Pass aria-activedescendant Deleting a reflected element should return null for the IDL attribute and the content attribute will be empty.
Pass aria-activedescendant Changing the ID of an element doesn't lose the reference.
Pass aria-activedescendant Reparenting an element into a descendant shadow scope hides the element reference.
Pass aria-activedescendant Reparenting referenced element cannot cause retargeting of reference.
Pass aria-activedescendant Element reference set in invalid scope remains intact throughout move to valid scope.
Fail aria-labelledby.
Fail aria-controls.
Fail aria-describedby.
Fail aria-flowto.
Fail aria-owns.
Fail shadow DOM behaviour for FrozenArray element reflection.
Fail Moving explicitly set elements across shadow DOM boundaries.
Fail Moving explicitly set elements around within the same scope, and removing from the DOM.
Pass aria-activedescendant Reparenting.
Pass aria-activedescendant Attaching element reference before it's inserted into the DOM.
Pass aria-activedescendant Cross-document references and moves.
Pass aria-activedescendant Adopting element keeps references.
Pass Caching invariant different attributes.
Pass Caching invariant different elements.
Fail Passing values of the wrong type should throw a TypeError
Loading

0 comments on commit 1be55fe

Please sign in to comment.