LibWeb: Implement ariaActiveDescendantElement spiritually closer to spec
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Lint Code / lint (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

We are meant to store a weak reference to the element indicated by this
attribute, rather than a GC-protected strong reference. This also hoists
the "get the attr-associated element" AO into its own function, rather
than being hidden in IDL, to match "get the attr-associated elements".
This commit is contained in:
Timothy Flynn 2025-04-24 16:00:14 -04:00 committed by Tim Ledbetter
commit 13ac6c4fde
Notes: github-actions[bot] 2025-04-25 00:21:14 +00:00
5 changed files with 87 additions and 67 deletions

View file

@ -15,6 +15,9 @@
namespace Web::ARIA {
#define ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES \
__ENUMERATE_ARIA_ATTRIBUTE(aria_active_descendant_element, aria_active_descendant)
#define ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES \
__ENUMERATE_ARIA_ATTRIBUTE(aria_controls_elements, aria_controls) \
__ENUMERATE_ARIA_ATTRIBUTE(aria_described_by_elements, aria_described_by) \
@ -57,8 +60,11 @@ public:
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_idref_list
Vector<String> parse_id_reference_list(Optional<String> const&) const;
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; }
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
GC::Ptr<DOM::Element> attribute() const; \
void set_##attribute(GC::Ptr<DOM::Element> value);
ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES
#undef __ENUMERATE_ARIA_ATTRIBUTE
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
Optional<Vector<WeakPtr<DOM::Element>>> const& attribute() const; \
@ -69,12 +75,13 @@ public:
protected:
ARIAMixin();
void visit_edges(GC::Cell::Visitor&);
virtual bool id_reference_exists(String const&) const = 0;
private:
GC::Ptr<DOM::Element> m_aria_active_descendant_element;
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
WeakPtr<DOM::Element> m_##attribute;
ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES
#undef __ENUMERATE_ARIA_ATTRIBUTE
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
Optional<Vector<WeakPtr<DOM::Element>>> m_##attribute;