From 9f01eebff361aba0014be9ccb7dc55f99f6e7a54 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Thu, 19 Dec 2024 16:56:58 +0900 Subject: [PATCH] LibWeb: Add a to_element function to ARIAMixin This change adds a virtual to_element function to ARIAMixin, and overrides it in DOM::Element so it can then be used back inside ARIAMixin to get an element when needed (for example, when computing a role requires checking the roles of ancestors of an element). --- Libraries/LibWeb/ARIA/ARIAMixin.cpp | 1 + Libraries/LibWeb/ARIA/ARIAMixin.h | 2 ++ Libraries/LibWeb/DOM/Element.h | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.cpp b/Libraries/LibWeb/ARIA/ARIAMixin.cpp index 73c64b2897e..2dd47c2dcb5 100644 --- a/Libraries/LibWeb/ARIA/ARIAMixin.cpp +++ b/Libraries/LibWeb/ARIA/ARIAMixin.cpp @@ -6,6 +6,7 @@ #include #include +#include #include namespace Web::ARIA { diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.h b/Libraries/LibWeb/ARIA/ARIAMixin.h index d570c784099..b8b2b7452e0 100644 --- a/Libraries/LibWeb/ARIA/ARIAMixin.h +++ b/Libraries/LibWeb/ARIA/ARIAMixin.h @@ -28,6 +28,8 @@ public: // https://www.w3.org/TR/html-aria/#docconformance virtual Optional default_role() const { return {}; } + virtual DOM::Element const* to_element() const { return {}; } + Optional role_from_role_attribute_value() const; Optional role_or_default() const; diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index 7a469063a1a..278971ad4ed 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -315,6 +315,8 @@ public: virtual bool include_in_accessibility_tree() const override; + virtual Element const* to_element() const override { return this; } + bool is_hidden() const; bool has_hidden_ancestor() const;