| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-20 21:59:45 +13:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2023-02-25 15:50:34 -06:00
										 |  |  | #include <AK/Vector.h>
 | 
					
						
							|  |  |  | #include <LibWeb/ARIA/AriaData.h>
 | 
					
						
							| 
									
										
										
										
											2024-12-05 08:33:26 -05:00
										 |  |  | #include <LibWeb/ARIA/AttributeNames.h>
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  | #include <LibWeb/ARIA/Roles.h>
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | #include <LibWeb/WebIDL/ExceptionOr.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  | namespace Web::ARIA { | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 16:00:14 -04:00
										 |  |  | #define ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES \
 | 
					
						
							|  |  |  |     __ENUMERATE_ARIA_ATTRIBUTE(aria_active_descendant_element, aria_active_descendant) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 13:41:12 -04:00
										 |  |  | #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)   \ | 
					
						
							|  |  |  |     __ENUMERATE_ARIA_ATTRIBUTE(aria_details_elements, aria_details)             \ | 
					
						
							|  |  |  |     __ENUMERATE_ARIA_ATTRIBUTE(aria_error_message_elements, aria_error_message) \ | 
					
						
							|  |  |  |     __ENUMERATE_ARIA_ATTRIBUTE(aria_flow_to_elements, aria_flow_to)             \ | 
					
						
							|  |  |  |     __ENUMERATE_ARIA_ATTRIBUTE(aria_labelled_by_elements, aria_labelled_by)     \ | 
					
						
							|  |  |  |     __ENUMERATE_ARIA_ATTRIBUTE(aria_owns_elements, aria_owns) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | class ARIAMixin { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-04-24 11:22:52 -04:00
										 |  |  |     virtual ~ARIAMixin(); | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-05 08:33:26 -05:00
										 |  |  | #define __ENUMERATE_ARIA_ATTRIBUTE(name, attribute) \
 | 
					
						
							|  |  |  |     virtual Optional<String> name() const = 0;      \ | 
					
						
							|  |  |  |     virtual WebIDL::ExceptionOr<void> set_##name(Optional<String> const&) = 0; | 
					
						
							|  |  |  |     ENUMERATE_ARIA_ATTRIBUTES | 
					
						
							|  |  |  | #undef __ENUMERATE_ARIA_ATTRIBUTE
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/html-aria/#docconformance
 | 
					
						
							| 
									
										
										
										
											2023-07-07 22:48:11 -04:00
										 |  |  |     virtual Optional<Role> default_role() const { return {}; } | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 11:18:07 -04:00
										 |  |  |     virtual DOM::Element& to_element() = 0; | 
					
						
							|  |  |  |     virtual DOM::Element const& to_element() const = 0; | 
					
						
							| 
									
										
										
										
											2024-12-19 16:56:58 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-06 18:41:38 +09:00
										 |  |  |     Optional<Role> role_from_role_attribute_value() const; | 
					
						
							| 
									
										
										
										
											2023-01-28 22:23:16 +00:00
										 |  |  |     Optional<Role> role_or_default() const; | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 10:53:37 -06:00
										 |  |  |     // https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion
 | 
					
						
							|  |  |  |     virtual bool exclude_from_accessibility_tree() const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/wai-aria-1.2/#tree_inclusion
 | 
					
						
							|  |  |  |     virtual bool include_in_accessibility_tree() const = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 10:52:58 -06:00
										 |  |  |     bool has_global_aria_attribute() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-25 15:50:34 -06:00
										 |  |  |     // https://www.w3.org/TR/wai-aria-1.2/#valuetype_idref
 | 
					
						
							| 
									
										
										
										
											2023-11-20 21:59:45 +13:00
										 |  |  |     Optional<String> parse_id_reference(Optional<String> const&) const; | 
					
						
							| 
									
										
										
										
											2023-02-25 15:50:34 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/wai-aria-1.2/#valuetype_idref_list
 | 
					
						
							| 
									
										
										
										
											2023-11-20 21:59:45 +13:00
										 |  |  |     Vector<String> parse_id_reference_list(Optional<String> const&) const; | 
					
						
							| 
									
										
										
										
											2023-02-25 15:50:34 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 16:00:14 -04:00
										 |  |  | #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
 | 
					
						
							| 
									
										
										
										
											2025-04-24 11:22:52 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 13:41:12 -04:00
										 |  |  | #define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute)  \
 | 
					
						
							|  |  |  |     Optional<Vector<WeakPtr<DOM::Element>>> const& attribute() const; \ | 
					
						
							| 
									
										
										
										
											2025-04-25 13:47:08 -04:00
										 |  |  |     void set_##attribute(Optional<Vector<WeakPtr<DOM::Element>>>);    \ | 
					
						
							|  |  |  |                                                                       \ | 
					
						
							|  |  |  |     GC::Ptr<JS::Array> cached_##attribute() const;                    \ | 
					
						
							|  |  |  |     void set_cached_##attribute(GC::Ptr<JS::Array>); | 
					
						
							| 
									
										
										
										
											2025-04-24 13:41:12 -04:00
										 |  |  |     ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES | 
					
						
							|  |  |  | #undef __ENUMERATE_ARIA_ATTRIBUTE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2025-04-24 11:22:52 -04:00
										 |  |  |     ARIAMixin(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-25 13:47:08 -04:00
										 |  |  |     void visit_edges(GC::Cell::Visitor&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-20 21:59:45 +13:00
										 |  |  |     virtual bool id_reference_exists(String const&) const = 0; | 
					
						
							| 
									
										
										
										
											2025-04-24 11:22:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2025-04-24 16:00:14 -04:00
										 |  |  | #define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
 | 
					
						
							|  |  |  |     WeakPtr<DOM::Element> m_##attribute; | 
					
						
							|  |  |  |     ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES | 
					
						
							|  |  |  | #undef __ENUMERATE_ARIA_ATTRIBUTE
 | 
					
						
							| 
									
										
										
										
											2025-04-24 13:41:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
 | 
					
						
							| 
									
										
										
										
											2025-04-25 13:47:08 -04:00
										 |  |  |     Optional<Vector<WeakPtr<DOM::Element>>> m_##attribute;           \ | 
					
						
							|  |  |  |     GC::Ptr<JS::Array> m_cached_##attribute; | 
					
						
							| 
									
										
										
										
											2025-04-24 13:41:12 -04:00
										 |  |  |     ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES | 
					
						
							|  |  |  | #undef __ENUMERATE_ARIA_ATTRIBUTE
 | 
					
						
							| 
									
										
										
										
											2022-11-28 17:58:13 -06:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |