mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
LibWeb: Add Support for the ARIA Element Properties
Element now supports getting and setting ARIA properties from JS and HTML.
This commit is contained in:
parent
0a244b9c1f
commit
e63d9d4925
57 changed files with 976 additions and 1 deletions
35
Userland/Libraries/LibWeb/DOM/ARIAMixin.cpp
Normal file
35
Userland/Libraries/LibWeb/DOM/ARIAMixin.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/ARIAMixin.h>
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#introroles
|
||||
FlyString ARIAMixin::role_or_default() const
|
||||
{
|
||||
// 1. Use the rules of the host language to detect that an element has a role attribute and to identify the attribute value string for it.
|
||||
auto role_string = role();
|
||||
|
||||
// 2. Separate the attribute value string for that attribute into a sequence of whitespace-free substrings by separating on whitespace.
|
||||
auto role_list = role_string.split_view(Infra::is_ascii_whitespace);
|
||||
|
||||
// 3. Compare the substrings to all the names of the non-abstract WAI-ARIA roles. Case-sensitivity of the comparison inherits from the case-sensitivity of the host language.
|
||||
for (auto const& role : role_list) {
|
||||
// 4. Use the first such substring in textual order that matches the name of a non-abstract WAI-ARIA role.
|
||||
if (ARIARoleNames::is_non_abstract_aria_role(role))
|
||||
return role;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#document-handling_author-errors_roles
|
||||
// If the role attribute contains no tokens matching the name of a non-abstract WAI-ARIA role, the user agent MUST treat the element as if no role had been provided.
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#implicit_semantics
|
||||
return default_role();
|
||||
}
|
||||
|
||||
}
|
143
Userland/Libraries/LibWeb/DOM/ARIAMixin.h
Normal file
143
Userland/Libraries/LibWeb/DOM/ARIAMixin.h
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
class ARIAMixin {
|
||||
|
||||
public:
|
||||
virtual ~ARIAMixin() = default;
|
||||
|
||||
virtual DeprecatedString role() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_role(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_active_descendant() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_active_descendant(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_atomic() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_atomic(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_auto_complete() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_auto_complete(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_busy() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_busy(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_checked() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_checked(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_col_count() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_count(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_col_index() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_index(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_col_span() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_span(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_controls() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_controls(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_current() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_current(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_described_by() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_described_by(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_details() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_details(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_drop_effect() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_drop_effect(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_error_message() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_error_message(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_disabled() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_disabled(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_expanded() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_expanded(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_flow_to() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_flow_to(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_grabbed() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_grabbed(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_has_popup() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_has_popup(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_hidden() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_hidden(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_invalid() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_invalid(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_key_shortcuts() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_key_shortcuts(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_label() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_label(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_labelled_by() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_labelled_by(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_level() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_level(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_live() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_live(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_modal() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_modal(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_multi_line() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_multi_line(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_multi_selectable() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_multi_selectable(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_orientation() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_orientation(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_owns() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_owns(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_placeholder() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_placeholder(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_pos_in_set() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_pos_in_set(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_pressed() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_pressed(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_read_only() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_read_only(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_relevant() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_relevant(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_required() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_required(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_role_description() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_role_description(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_row_count() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_count(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_row_index() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_index(DeprecatedString const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_row_span() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_span(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_selected() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_selected(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_set_size() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_set_size(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_sort() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_sort(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_value_max() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_max(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_value_min() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_min(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_value_now() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_now(DeprecatedString const&) = 0;
|
||||
virtual DeprecatedString aria_value_text() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_text(DeprecatedString const&) = 0;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#docconformance
|
||||
virtual FlyString default_role() const { return {}; };
|
||||
|
||||
FlyString role_or_default() const;
|
||||
|
||||
protected:
|
||||
ARIAMixin() = default;
|
||||
};
|
||||
|
||||
}
|
53
Userland/Libraries/LibWeb/DOM/ARIAMixin.idl
Normal file
53
Userland/Libraries/LibWeb/DOM/ARIAMixin.idl
Normal file
|
@ -0,0 +1,53 @@
|
|||
// https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin
|
||||
interface mixin ARIAMixin {
|
||||
attribute DOMString? role;
|
||||
|
||||
attribute DOMString? ariaAtomic;
|
||||
attribute DOMString? ariaAutoComplete;
|
||||
attribute DOMString? ariaBusy;
|
||||
attribute DOMString? ariaChecked;
|
||||
attribute DOMString? ariaColCount;
|
||||
attribute DOMString? ariaColIndex;
|
||||
|
||||
attribute DOMString? ariaColSpan;
|
||||
|
||||
attribute DOMString? ariaCurrent;
|
||||
|
||||
|
||||
|
||||
attribute DOMString? ariaDisabled;
|
||||
|
||||
attribute DOMString? ariaExpanded;
|
||||
|
||||
attribute DOMString? ariaHasPopup;
|
||||
attribute DOMString? ariaHidden;
|
||||
attribute DOMString? ariaInvalid;
|
||||
attribute DOMString? ariaKeyShortcuts;
|
||||
attribute DOMString? ariaLabel;
|
||||
|
||||
attribute DOMString? ariaLevel;
|
||||
attribute DOMString? ariaLive;
|
||||
attribute DOMString? ariaModal;
|
||||
attribute DOMString? ariaMultiLine;
|
||||
attribute DOMString? ariaMultiSelectable;
|
||||
attribute DOMString? ariaOrientation;
|
||||
|
||||
attribute DOMString? ariaPlaceholder;
|
||||
attribute DOMString? ariaPosInSet;
|
||||
attribute DOMString? ariaPressed;
|
||||
attribute DOMString? ariaReadOnly;
|
||||
|
||||
attribute DOMString? ariaRequired;
|
||||
attribute DOMString? ariaRoleDescription;
|
||||
attribute DOMString? ariaRowCount;
|
||||
attribute DOMString? ariaRowIndex;
|
||||
|
||||
attribute DOMString? ariaRowSpan;
|
||||
attribute DOMString? ariaSelected;
|
||||
attribute DOMString? ariaSetSize;
|
||||
attribute DOMString? ariaSort;
|
||||
attribute DOMString? ariaValueMax;
|
||||
attribute DOMString? ariaValueMin;
|
||||
attribute DOMString? ariaValueNow;
|
||||
attribute DOMString? ariaValueText;
|
||||
};
|
167
Userland/Libraries/LibWeb/DOM/ARIARoleNames.cpp
Normal file
167
Userland/Libraries/LibWeb/DOM/ARIARoleNames.cpp
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
|
||||
namespace Web::DOM::ARIARoleNames {
|
||||
|
||||
#define __ENUMERATE_ARIA_ROLE(name) FlyString name;
|
||||
ENUMERATE_ARIA_ROLES
|
||||
#undef __ENUMERATE_ARIA_ROLE
|
||||
|
||||
[[gnu::constructor]] static void initialize()
|
||||
{
|
||||
static bool s_initialized = false;
|
||||
if (s_initialized)
|
||||
return;
|
||||
|
||||
#define __ENUMERATE_ARIA_ROLE(name) name = #name;
|
||||
ENUMERATE_ARIA_ROLES
|
||||
#undef __ENUMERATE_ARIA_ROLE
|
||||
|
||||
// Special case for C++ keyword
|
||||
switch_ = "switch";
|
||||
s_initialized = true;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#abstract_roles
|
||||
bool is_abstract_aria_role(FlyString const& role)
|
||||
{
|
||||
return role.is_one_of(
|
||||
ARIARoleNames::command,
|
||||
ARIARoleNames::composite,
|
||||
ARIARoleNames::input,
|
||||
ARIARoleNames::landmark,
|
||||
ARIARoleNames::range,
|
||||
ARIARoleNames::roletype,
|
||||
ARIARoleNames::section,
|
||||
ARIARoleNames::sectionhead,
|
||||
ARIARoleNames::select,
|
||||
ARIARoleNames::structure,
|
||||
ARIARoleNames::widget,
|
||||
ARIARoleNames::window);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#widget_roles
|
||||
bool is_widget_aria_role(FlyString const& role)
|
||||
{
|
||||
return role.to_lowercase().is_one_of(
|
||||
ARIARoleNames::button,
|
||||
ARIARoleNames::checkbox,
|
||||
ARIARoleNames::gridcell,
|
||||
ARIARoleNames::link,
|
||||
ARIARoleNames::menuitem,
|
||||
ARIARoleNames::menuitemcheckbox,
|
||||
ARIARoleNames::option,
|
||||
ARIARoleNames::progressbar,
|
||||
ARIARoleNames::radio,
|
||||
ARIARoleNames::scrollbar,
|
||||
ARIARoleNames::searchbox,
|
||||
ARIARoleNames::separator, // TODO: Only when focusable
|
||||
ARIARoleNames::slider,
|
||||
ARIARoleNames::spinbutton,
|
||||
ARIARoleNames::switch_,
|
||||
ARIARoleNames::tab,
|
||||
ARIARoleNames::tabpanel,
|
||||
ARIARoleNames::textbox,
|
||||
ARIARoleNames::treeitem,
|
||||
ARIARoleNames::combobox,
|
||||
ARIARoleNames::grid,
|
||||
ARIARoleNames::listbox,
|
||||
ARIARoleNames::menu,
|
||||
ARIARoleNames::menubar,
|
||||
ARIARoleNames::radiogroup,
|
||||
ARIARoleNames::tablist,
|
||||
ARIARoleNames::tree,
|
||||
ARIARoleNames::treegrid);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#document_structure_roles
|
||||
bool is_document_structure_aria_role(FlyString const& role)
|
||||
{
|
||||
return role.to_lowercase().is_one_of(
|
||||
ARIARoleNames::application,
|
||||
ARIARoleNames::article,
|
||||
ARIARoleNames::blockquote,
|
||||
ARIARoleNames::caption,
|
||||
ARIARoleNames::cell,
|
||||
ARIARoleNames::columnheader,
|
||||
ARIARoleNames::definition,
|
||||
ARIARoleNames::deletion,
|
||||
ARIARoleNames::directory,
|
||||
ARIARoleNames::document,
|
||||
ARIARoleNames::emphasis,
|
||||
ARIARoleNames::feed,
|
||||
ARIARoleNames::figure,
|
||||
ARIARoleNames::generic,
|
||||
ARIARoleNames::group,
|
||||
ARIARoleNames::heading,
|
||||
ARIARoleNames::img,
|
||||
ARIARoleNames::insertion,
|
||||
ARIARoleNames::list,
|
||||
ARIARoleNames::listitem,
|
||||
ARIARoleNames::math,
|
||||
ARIARoleNames::meter,
|
||||
ARIARoleNames::none,
|
||||
ARIARoleNames::note,
|
||||
ARIARoleNames::paragraph,
|
||||
ARIARoleNames::presentation,
|
||||
ARIARoleNames::row,
|
||||
ARIARoleNames::rowgroup,
|
||||
ARIARoleNames::rowheader,
|
||||
ARIARoleNames::separator, // TODO: Only when not focusable
|
||||
ARIARoleNames::strong,
|
||||
ARIARoleNames::subscript,
|
||||
ARIARoleNames::table,
|
||||
ARIARoleNames::term,
|
||||
ARIARoleNames::time,
|
||||
ARIARoleNames::toolbar,
|
||||
ARIARoleNames::tooltip);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#landmark_roles
|
||||
bool is_landmark_aria_role(FlyString const& role)
|
||||
{
|
||||
return role.to_lowercase().is_one_of(
|
||||
ARIARoleNames::banner,
|
||||
ARIARoleNames::complementary,
|
||||
ARIARoleNames::contentinfo,
|
||||
ARIARoleNames::form,
|
||||
ARIARoleNames::main,
|
||||
ARIARoleNames::navigation,
|
||||
ARIARoleNames::region,
|
||||
ARIARoleNames::search);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#live_region_roles
|
||||
bool is_live_region_aria_role(FlyString const& role)
|
||||
{
|
||||
return role.to_lowercase().is_one_of(
|
||||
ARIARoleNames::alert,
|
||||
ARIARoleNames::log,
|
||||
ARIARoleNames::marquee,
|
||||
ARIARoleNames::status,
|
||||
ARIARoleNames::timer);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#window_roles
|
||||
bool is_windows_aria_role(FlyString const& role)
|
||||
{
|
||||
return role.to_lowercase().is_one_of(
|
||||
ARIARoleNames::alertdialog,
|
||||
ARIARoleNames::dialog);
|
||||
}
|
||||
|
||||
bool is_non_abstract_aria_role(FlyString const& role)
|
||||
{
|
||||
return is_widget_aria_role(role)
|
||||
|| is_document_structure_aria_role(role)
|
||||
|| is_landmark_aria_role(role)
|
||||
|| is_live_region_aria_role(role)
|
||||
|| is_windows_aria_role(role);
|
||||
}
|
||||
|
||||
}
|
122
Userland/Libraries/LibWeb/DOM/ARIARoleNames.h
Normal file
122
Userland/Libraries/LibWeb/DOM/ARIARoleNames.h
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
|
||||
namespace Web::DOM::ARIARoleNames {
|
||||
|
||||
#define ENUMERATE_ARIA_ROLES \
|
||||
__ENUMERATE_ARIA_ROLE(alert) \
|
||||
__ENUMERATE_ARIA_ROLE(alertdialog) \
|
||||
__ENUMERATE_ARIA_ROLE(application) \
|
||||
__ENUMERATE_ARIA_ROLE(article) \
|
||||
__ENUMERATE_ARIA_ROLE(banner) \
|
||||
__ENUMERATE_ARIA_ROLE(blockquote) \
|
||||
__ENUMERATE_ARIA_ROLE(button) \
|
||||
__ENUMERATE_ARIA_ROLE(caption) \
|
||||
__ENUMERATE_ARIA_ROLE(cell) \
|
||||
__ENUMERATE_ARIA_ROLE(checkbox) \
|
||||
__ENUMERATE_ARIA_ROLE(code) \
|
||||
__ENUMERATE_ARIA_ROLE(columnheader) \
|
||||
__ENUMERATE_ARIA_ROLE(combobox) \
|
||||
__ENUMERATE_ARIA_ROLE(command) \
|
||||
__ENUMERATE_ARIA_ROLE(complementary) \
|
||||
__ENUMERATE_ARIA_ROLE(composite) \
|
||||
__ENUMERATE_ARIA_ROLE(contentinfo) \
|
||||
__ENUMERATE_ARIA_ROLE(definition) \
|
||||
__ENUMERATE_ARIA_ROLE(deletion) \
|
||||
__ENUMERATE_ARIA_ROLE(dialog) \
|
||||
__ENUMERATE_ARIA_ROLE(directory) \
|
||||
__ENUMERATE_ARIA_ROLE(document) \
|
||||
__ENUMERATE_ARIA_ROLE(emphasis) \
|
||||
__ENUMERATE_ARIA_ROLE(feed) \
|
||||
__ENUMERATE_ARIA_ROLE(figure) \
|
||||
__ENUMERATE_ARIA_ROLE(form) \
|
||||
__ENUMERATE_ARIA_ROLE(generic) \
|
||||
__ENUMERATE_ARIA_ROLE(grid) \
|
||||
__ENUMERATE_ARIA_ROLE(gridcell) \
|
||||
__ENUMERATE_ARIA_ROLE(group) \
|
||||
__ENUMERATE_ARIA_ROLE(heading) \
|
||||
__ENUMERATE_ARIA_ROLE(img) \
|
||||
__ENUMERATE_ARIA_ROLE(input) \
|
||||
__ENUMERATE_ARIA_ROLE(insertion) \
|
||||
__ENUMERATE_ARIA_ROLE(landmark) \
|
||||
__ENUMERATE_ARIA_ROLE(link) \
|
||||
__ENUMERATE_ARIA_ROLE(list) \
|
||||
__ENUMERATE_ARIA_ROLE(listbox) \
|
||||
__ENUMERATE_ARIA_ROLE(listitem) \
|
||||
__ENUMERATE_ARIA_ROLE(log) \
|
||||
__ENUMERATE_ARIA_ROLE(main) \
|
||||
__ENUMERATE_ARIA_ROLE(marquee) \
|
||||
__ENUMERATE_ARIA_ROLE(math) \
|
||||
__ENUMERATE_ARIA_ROLE(meter) \
|
||||
__ENUMERATE_ARIA_ROLE(menu) \
|
||||
__ENUMERATE_ARIA_ROLE(menubar) \
|
||||
__ENUMERATE_ARIA_ROLE(menuitem) \
|
||||
__ENUMERATE_ARIA_ROLE(menuitemcheckbox) \
|
||||
__ENUMERATE_ARIA_ROLE(menuitemradio) \
|
||||
__ENUMERATE_ARIA_ROLE(navigation) \
|
||||
__ENUMERATE_ARIA_ROLE(none) \
|
||||
__ENUMERATE_ARIA_ROLE(note) \
|
||||
__ENUMERATE_ARIA_ROLE(option) \
|
||||
__ENUMERATE_ARIA_ROLE(paragraph) \
|
||||
__ENUMERATE_ARIA_ROLE(presentation) \
|
||||
__ENUMERATE_ARIA_ROLE(progressbar) \
|
||||
__ENUMERATE_ARIA_ROLE(radio) \
|
||||
__ENUMERATE_ARIA_ROLE(radiogroup) \
|
||||
__ENUMERATE_ARIA_ROLE(range) \
|
||||
__ENUMERATE_ARIA_ROLE(region) \
|
||||
__ENUMERATE_ARIA_ROLE(roletype) \
|
||||
__ENUMERATE_ARIA_ROLE(row) \
|
||||
__ENUMERATE_ARIA_ROLE(rowgroup) \
|
||||
__ENUMERATE_ARIA_ROLE(rowheader) \
|
||||
__ENUMERATE_ARIA_ROLE(scrollbar) \
|
||||
__ENUMERATE_ARIA_ROLE(search) \
|
||||
__ENUMERATE_ARIA_ROLE(searchbox) \
|
||||
__ENUMERATE_ARIA_ROLE(section) \
|
||||
__ENUMERATE_ARIA_ROLE(sectionhead) \
|
||||
__ENUMERATE_ARIA_ROLE(select) \
|
||||
__ENUMERATE_ARIA_ROLE(separator) \
|
||||
__ENUMERATE_ARIA_ROLE(slider) \
|
||||
__ENUMERATE_ARIA_ROLE(spinbutton) \
|
||||
__ENUMERATE_ARIA_ROLE(status) \
|
||||
__ENUMERATE_ARIA_ROLE(strong) \
|
||||
__ENUMERATE_ARIA_ROLE(structure) \
|
||||
__ENUMERATE_ARIA_ROLE(subscript) \
|
||||
__ENUMERATE_ARIA_ROLE(superscript) \
|
||||
__ENUMERATE_ARIA_ROLE(switch_) \
|
||||
__ENUMERATE_ARIA_ROLE(tab) \
|
||||
__ENUMERATE_ARIA_ROLE(table) \
|
||||
__ENUMERATE_ARIA_ROLE(tablist) \
|
||||
__ENUMERATE_ARIA_ROLE(tabpanel) \
|
||||
__ENUMERATE_ARIA_ROLE(term) \
|
||||
__ENUMERATE_ARIA_ROLE(textbox) \
|
||||
__ENUMERATE_ARIA_ROLE(time) \
|
||||
__ENUMERATE_ARIA_ROLE(timer) \
|
||||
__ENUMERATE_ARIA_ROLE(toolbar) \
|
||||
__ENUMERATE_ARIA_ROLE(tooltip) \
|
||||
__ENUMERATE_ARIA_ROLE(tree) \
|
||||
__ENUMERATE_ARIA_ROLE(treegrid) \
|
||||
__ENUMERATE_ARIA_ROLE(treeitem) \
|
||||
__ENUMERATE_ARIA_ROLE(widget) \
|
||||
__ENUMERATE_ARIA_ROLE(window)
|
||||
|
||||
#define __ENUMERATE_ARIA_ROLE(name) extern FlyString name;
|
||||
ENUMERATE_ARIA_ROLES
|
||||
#undef __ENUMERATE_ARIA_ROLE
|
||||
|
||||
bool is_abstract_aria_role(FlyString const&);
|
||||
bool is_widget_aria_role(FlyString const&);
|
||||
bool is_document_structure_aria_role(FlyString const&);
|
||||
bool is_landmark_aria_role(FlyString const&);
|
||||
bool is_live_region_aria_role(FlyString const&);
|
||||
bool is_windows_aria_role(FlyString const&);
|
||||
|
||||
bool is_non_abstract_aria_role(FlyString const&);
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibWeb/Bindings/ElementPrototype.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/DOM/ARIAMixin.h>
|
||||
#include <LibWeb/DOM/Attr.h>
|
||||
#include <LibWeb/DOM/ChildNode.h>
|
||||
#include <LibWeb/DOM/NamedNodeMap.h>
|
||||
|
@ -40,7 +41,8 @@ struct ScrollIntoViewOptions : public ScrollOptions {
|
|||
class Element
|
||||
: public ParentNode
|
||||
, public ChildNode<Element>
|
||||
, public NonDocumentTypeChildNode<Element> {
|
||||
, public NonDocumentTypeChildNode<Element>
|
||||
, public ARIAMixin {
|
||||
WEB_PLATFORM_OBJECT(Element, ParentNode);
|
||||
|
||||
public:
|
||||
|
@ -177,6 +179,72 @@ public:
|
|||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
|
||||
ErrorOr<void> scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {});
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin
|
||||
#define ARIA_IMPL(name, attribute) \
|
||||
DeprecatedString name() const override \
|
||||
{ \
|
||||
return get_attribute(attribute); \
|
||||
} \
|
||||
\
|
||||
WebIDL::ExceptionOr<void> set_##name(DeprecatedString const& value) override \
|
||||
{ \
|
||||
TRY(set_attribute(attribute, value)); \
|
||||
return {}; \
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#accessibilityroleandproperties-correspondence
|
||||
ARIA_IMPL(role, "role");
|
||||
ARIA_IMPL(aria_active_descendant, "aria-activedescendant");
|
||||
ARIA_IMPL(aria_atomic, "aria-atomic");
|
||||
ARIA_IMPL(aria_auto_complete, "aria-autocomplete");
|
||||
ARIA_IMPL(aria_busy, "aria-busy");
|
||||
ARIA_IMPL(aria_checked, "aria-checked");
|
||||
ARIA_IMPL(aria_col_count, "aria-colcount");
|
||||
ARIA_IMPL(aria_col_index, "aria-colindex");
|
||||
ARIA_IMPL(aria_col_span, "aria-colspan");
|
||||
ARIA_IMPL(aria_controls, "aria-controls");
|
||||
ARIA_IMPL(aria_current, "aria-current");
|
||||
ARIA_IMPL(aria_described_by, "aria-describedby");
|
||||
ARIA_IMPL(aria_details, "aria-details");
|
||||
ARIA_IMPL(aria_drop_effect, "aria-dropeffect");
|
||||
ARIA_IMPL(aria_error_message, "aria-errormessage");
|
||||
ARIA_IMPL(aria_disabled, "aria-disabled");
|
||||
ARIA_IMPL(aria_expanded, "aria-expanded");
|
||||
ARIA_IMPL(aria_flow_to, "aria-flowto");
|
||||
ARIA_IMPL(aria_grabbed, "aria-grabbed");
|
||||
ARIA_IMPL(aria_has_popup, "aria-haspopup");
|
||||
ARIA_IMPL(aria_hidden, "aria-hidden");
|
||||
ARIA_IMPL(aria_invalid, "aria-invalid");
|
||||
ARIA_IMPL(aria_key_shortcuts, "aria-keyshortcuts");
|
||||
ARIA_IMPL(aria_label, "aria-label");
|
||||
ARIA_IMPL(aria_labelled_by, "aria-labelledby");
|
||||
ARIA_IMPL(aria_level, "aria-level");
|
||||
ARIA_IMPL(aria_live, "aria-live");
|
||||
ARIA_IMPL(aria_modal, "aria-modal");
|
||||
ARIA_IMPL(aria_multi_line, "aria-multiline");
|
||||
ARIA_IMPL(aria_multi_selectable, "aria-multiselectable");
|
||||
ARIA_IMPL(aria_orientation, "aria-orientation");
|
||||
ARIA_IMPL(aria_owns, "aria-owns");
|
||||
ARIA_IMPL(aria_placeholder, "aria-placeholder");
|
||||
ARIA_IMPL(aria_pos_in_set, "aria-posinset");
|
||||
ARIA_IMPL(aria_pressed, "aria-pressed");
|
||||
ARIA_IMPL(aria_read_only, "aria-readonly");
|
||||
ARIA_IMPL(aria_relevant, "aria-relevant");
|
||||
ARIA_IMPL(aria_required, "aria-required");
|
||||
ARIA_IMPL(aria_role_description, "aria-roledescription");
|
||||
ARIA_IMPL(aria_row_count, "aria-rowcount");
|
||||
ARIA_IMPL(aria_row_index, "aria-rowindex");
|
||||
ARIA_IMPL(aria_row_span, "aria-rowspan");
|
||||
ARIA_IMPL(aria_selected, "aria-selected");
|
||||
ARIA_IMPL(aria_set_size, "aria-setsize");
|
||||
ARIA_IMPL(aria_sort, "aria-sort");
|
||||
ARIA_IMPL(aria_value_max, "aria-valuemax");
|
||||
ARIA_IMPL(aria_value_min, "aria-valuemin");
|
||||
ARIA_IMPL(aria_value_now, "aria-valuenow");
|
||||
ARIA_IMPL(aria_value_text, "aria-valuetext");
|
||||
|
||||
#undef ARIA_IMPL
|
||||
|
||||
protected:
|
||||
Element(Document&, DOM::QualifiedName);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import <CSS/CSSStyleDeclaration.idl>
|
||||
#import <DOM/Attr.idl>
|
||||
#import <DOM/ARIAMixin.idl>
|
||||
#import <DOM/ChildNode.idl>
|
||||
#import <DOM/DOMTokenList.idl>
|
||||
#import <DOM/InnerHTML.idl>
|
||||
|
@ -83,3 +84,5 @@ interface Element : Node {
|
|||
Element includes ParentNode;
|
||||
Element includes ChildNode;
|
||||
Element includes InnerHTML;
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#idl_element
|
||||
Element includes ARIAMixin;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue