mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:47:46 +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
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
|
@ -84,4 +85,13 @@ i32 HTMLAnchorElement::default_tab_index_value() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
FlyString HTMLAnchorElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-a-no-href
|
||||
if (!href().is_null())
|
||||
return DOM::ARIARoleNames::link;
|
||||
// https://www.w3.org/TR/html-aria/#el-a
|
||||
return DOM::ARIARoleNames::generic;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ private:
|
|||
{
|
||||
queue_an_element_task(source, move(steps));
|
||||
}
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLAreaElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
|
@ -42,4 +43,13 @@ i32 HTMLAreaElement::default_tab_index_value() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
FlyString HTMLAreaElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-area-no-href
|
||||
if (!href().is_null())
|
||||
return DOM::ARIARoleNames::link;
|
||||
// https://www.w3.org/TR/html-aria/#el-area
|
||||
return DOM::ARIARoleNames::generic;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ private:
|
|||
{
|
||||
queue_an_element_task(source, move(steps));
|
||||
}
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/HTML/WindowEventHandlers.h>
|
||||
|
||||
|
@ -22,6 +23,9 @@ public:
|
|||
virtual void parse_attribute(FlyString const&, DeprecatedString const&) override;
|
||||
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-body
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::generic; };
|
||||
|
||||
private:
|
||||
HTMLBodyElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
|
@ -53,6 +54,9 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
||||
virtual bool is_labelable() const override { return true; }
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-button
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::button; }
|
||||
|
||||
private:
|
||||
HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLDataElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLDataElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-data
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::generic; }
|
||||
|
||||
private:
|
||||
HTMLDataElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,8 @@ class HTMLDataListElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLDataListElement() override;
|
||||
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::listbox; }
|
||||
|
||||
private:
|
||||
HTMLDataListElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLDetailsElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLDetailsElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-details
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::group; };
|
||||
|
||||
private:
|
||||
HTMLDetailsElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLDialogElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLDialogElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-dialog
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::dialog; }
|
||||
|
||||
private:
|
||||
HTMLDialogElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLDivElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLDivElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-div
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::generic; }
|
||||
|
||||
private:
|
||||
HTMLDivElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/IDLEventListener.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
|
@ -327,4 +328,88 @@ void HTMLElement::blur()
|
|||
// User agents may selectively or uniformly ignore calls to this method for usability reasons.
|
||||
}
|
||||
|
||||
FlyString HTMLElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-article
|
||||
if (local_name() == TagNames::article)
|
||||
return DOM::ARIARoleNames::article;
|
||||
// https://www.w3.org/TR/html-aria/#el-aside
|
||||
if (local_name() == TagNames::aside)
|
||||
return DOM::ARIARoleNames::complementary;
|
||||
// https://www.w3.org/TR/html-aria/#el-b
|
||||
if (local_name() == TagNames::b)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-bdi
|
||||
if (local_name() == TagNames::bdi)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-bdo
|
||||
if (local_name() == TagNames::bdo)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-code
|
||||
if (local_name() == TagNames::code)
|
||||
return DOM::ARIARoleNames::code;
|
||||
// https://www.w3.org/TR/html-aria/#el-dfn
|
||||
if (local_name() == TagNames::dfn)
|
||||
return DOM::ARIARoleNames::term;
|
||||
// https://www.w3.org/TR/html-aria/#el-em
|
||||
if (local_name() == TagNames::em)
|
||||
return DOM::ARIARoleNames::emphasis;
|
||||
// https://www.w3.org/TR/html-aria/#el-figure
|
||||
if (local_name() == TagNames::figure)
|
||||
return DOM::ARIARoleNames::figure;
|
||||
// https://www.w3.org/TR/html-aria/#el-footer
|
||||
if (local_name() == TagNames::footer) {
|
||||
// TODO: If not a descendant of an article, aside, main, nav or section element, or an element with role=article, complementary, main, navigation or region then role=contentinfo
|
||||
// Otherwise, role=generic
|
||||
return DOM::ARIARoleNames::generic;
|
||||
}
|
||||
// https://www.w3.org/TR/html-aria/#el-header
|
||||
if (local_name() == TagNames::header) {
|
||||
// TODO: If not a descendant of an article, aside, main, nav or section element, or an element with role=article, complementary, main, navigation or region then role=banner
|
||||
// Otherwise, role=generic
|
||||
return DOM::ARIARoleNames::generic;
|
||||
}
|
||||
// https://www.w3.org/TR/html-aria/#el-hgroup
|
||||
if (local_name() == TagNames::hgroup)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-i
|
||||
if (local_name() == TagNames::i)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-main
|
||||
if (local_name() == TagNames::main)
|
||||
return DOM::ARIARoleNames::main;
|
||||
// https://www.w3.org/TR/html-aria/#el-nav
|
||||
if (local_name() == TagNames::nav)
|
||||
return DOM::ARIARoleNames::navigation;
|
||||
// https://www.w3.org/TR/html-aria/#el-samp
|
||||
if (local_name() == TagNames::samp)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-section
|
||||
if (local_name() == TagNames::section) {
|
||||
// TODO: role=region if the section element has an accessible name
|
||||
// Otherwise, no corresponding role
|
||||
return DOM::ARIARoleNames::region;
|
||||
}
|
||||
// https://www.w3.org/TR/html-aria/#el-small
|
||||
if (local_name() == TagNames::small)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
// https://www.w3.org/TR/html-aria/#el-strong
|
||||
if (local_name() == TagNames::strong)
|
||||
return DOM::ARIARoleNames::strong;
|
||||
// https://www.w3.org/TR/html-aria/#el-sub
|
||||
if (local_name() == TagNames::sub)
|
||||
return DOM::ARIARoleNames::subscript;
|
||||
// https://www.w3.org/TR/html-aria/#el-summary
|
||||
if (local_name() == TagNames::summary)
|
||||
return DOM::ARIARoleNames::button;
|
||||
// https://www.w3.org/TR/html-aria/#el-sup
|
||||
if (local_name() == TagNames::sup)
|
||||
return DOM::ARIARoleNames::superscript;
|
||||
// https://www.w3.org/TR/html-aria/#el-u
|
||||
if (local_name() == TagNames::u)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
||||
virtual bool is_labelable() const { return false; }
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
protected:
|
||||
HTMLElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
|
@ -35,6 +36,8 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
|
||||
virtual bool is_auto_capitalize_inheriting() const override { return true; }
|
||||
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::group; }
|
||||
|
||||
private:
|
||||
HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
|
||||
|
@ -36,6 +37,9 @@ public:
|
|||
JS::NonnullGCPtr<DOM::HTMLCollection> elements() const;
|
||||
unsigned length() const;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-form
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::form; }
|
||||
|
||||
private:
|
||||
HTMLFormElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLHRElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLHRElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-hr
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::separator; }
|
||||
|
||||
private:
|
||||
HTMLHRElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -18,6 +19,14 @@ public:
|
|||
|
||||
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-h1-h6
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::heading; }
|
||||
virtual DeprecatedString aria_level() const override
|
||||
{
|
||||
// TODO: aria-level = the number in the element's tag name
|
||||
return get_attribute("aria-level");
|
||||
}
|
||||
|
||||
private:
|
||||
HTMLHeadingElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -18,6 +19,9 @@ public:
|
|||
|
||||
bool should_use_body_background_properties() const;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-html
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::document; }
|
||||
|
||||
private:
|
||||
HTMLHtmlElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
|
@ -197,4 +198,14 @@ bool HTMLImageElement::complete() const
|
|||
return false;
|
||||
}
|
||||
|
||||
FlyString HTMLImageElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-img
|
||||
// https://www.w3.org/TR/html-aria/#el-img-no-alt
|
||||
if (alt().is_null() || !alt().is_empty())
|
||||
return DOM::ARIARoleNames::img;
|
||||
// https://www.w3.org/TR/html-aria/#el-img-empty-alt
|
||||
return DOM::ARIARoleNames::presentation;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
|
||||
bool complete() const;
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
HTMLImageElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -866,4 +866,66 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_selection_range(u32 start, u32 e
|
|||
return {};
|
||||
}
|
||||
|
||||
FlyString HTMLInputElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-input-button
|
||||
if (type_state() == TypeAttributeState::Button)
|
||||
return DOM::ARIARoleNames::button;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-checkbox
|
||||
if (type_state() == TypeAttributeState::Checkbox)
|
||||
return DOM::ARIARoleNames::checkbox;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-email
|
||||
if (type_state() == TypeAttributeState::Email && attribute("list").is_null())
|
||||
return DOM::ARIARoleNames::textbox;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-image
|
||||
if (type_state() == TypeAttributeState::ImageButton)
|
||||
return DOM::ARIARoleNames::button;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-number
|
||||
if (type_state() == TypeAttributeState::Number)
|
||||
return DOM::ARIARoleNames::spinbutton;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-radio
|
||||
if (type_state() == TypeAttributeState::RadioButton)
|
||||
return DOM::ARIARoleNames::radio;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-range
|
||||
if (type_state() == TypeAttributeState::Range)
|
||||
return DOM::ARIARoleNames::slider;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-reset
|
||||
if (type_state() == TypeAttributeState::ResetButton)
|
||||
return DOM::ARIARoleNames::button;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-text-list
|
||||
if ((type_state() == TypeAttributeState::Text
|
||||
|| type_state() == TypeAttributeState::Search
|
||||
|| type_state() == TypeAttributeState::Telephone
|
||||
|| type_state() == TypeAttributeState::URL
|
||||
|| type_state() == TypeAttributeState::Email)
|
||||
&& !attribute("list").is_null())
|
||||
return DOM::ARIARoleNames::combobox;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-search
|
||||
if (type_state() == TypeAttributeState::Search && attribute("list").is_null())
|
||||
return DOM::ARIARoleNames::textbox;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-submit
|
||||
if (type_state() == TypeAttributeState::SubmitButton)
|
||||
return DOM::ARIARoleNames::button;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-tel
|
||||
if (type_state() == TypeAttributeState::Telephone)
|
||||
return DOM::ARIARoleNames::textbox;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-text
|
||||
if (type_state() == TypeAttributeState::Text && attribute("list").is_null())
|
||||
return DOM::ARIARoleNames::textbox;
|
||||
// https://www.w3.org/TR/html-aria/#el-input-url
|
||||
if (type_state() == TypeAttributeState::URL && attribute("list").is_null())
|
||||
return DOM::ARIARoleNames::textbox;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-input-color
|
||||
// https://www.w3.org/TR/html-aria/#el-input-date
|
||||
// https://www.w3.org/TR/html-aria/#el-input-datetime-local
|
||||
// https://www.w3.org/TR/html-aria/#el-input-file
|
||||
// https://www.w3.org/TR/html-aria/#el-input-hidden
|
||||
// https://www.w3.org/TR/html-aria/#el-input-month
|
||||
// https://www.w3.org/TR/html-aria/#el-input-password
|
||||
// https://www.w3.org/TR/html-aria/#el-input-time
|
||||
// https://www.w3.org/TR/html-aria/#el-input-week
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -120,6 +120,8 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
||||
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLLIElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLLIElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-li
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::listitem; };
|
||||
|
||||
private:
|
||||
HTMLLIElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLMenuElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLMenuElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-menu
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::list; }
|
||||
|
||||
private:
|
||||
HTMLMenuElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -21,6 +22,9 @@ public:
|
|||
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
||||
virtual bool is_labelable() const override { return true; }
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-meter
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::meter; }
|
||||
|
||||
private:
|
||||
HTMLMeterElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/HTMLModElement.h>
|
||||
|
||||
|
@ -17,4 +18,15 @@ HTMLModElement::HTMLModElement(DOM::Document& document, DOM::QualifiedName quali
|
|||
|
||||
HTMLModElement::~HTMLModElement() = default;
|
||||
|
||||
FlyString HTMLModElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-del
|
||||
if (local_name() == TagNames::del)
|
||||
return DOM::ARIARoleNames::deletion;
|
||||
// https://www.w3.org/TR/html-aria/#el-ins
|
||||
if (local_name() == TagNames::ins)
|
||||
return DOM::ARIARoleNames::insertion;
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,8 @@ class HTMLModElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLModElement() override;
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
HTMLModElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLOListElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLOListElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-ol
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::list; }
|
||||
|
||||
private:
|
||||
HTMLOListElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLOptGroupElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLOptGroupElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-optgroup
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::group; }
|
||||
|
||||
private:
|
||||
HTMLOptGroupElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/HTMLOptGroupElement.h>
|
||||
|
@ -140,4 +141,11 @@ bool HTMLOptionElement::disabled() const
|
|||
|| (parent() && is<HTMLOptGroupElement>(parent()) && static_cast<HTMLOptGroupElement const&>(*parent()).has_attribute(AttributeNames::disabled));
|
||||
}
|
||||
|
||||
FlyString HTMLOptionElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-option
|
||||
// TODO: Only an option element that is in a list of options or that represents a suggestion in a datalist should return option
|
||||
return DOM::ARIARoleNames::option;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
|
||||
bool disabled() const;
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
friend class Bindings::OptionConstructor;
|
||||
friend class HTMLSelectElement;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
|
@ -43,6 +44,9 @@ public:
|
|||
|
||||
virtual void reset_algorithm() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-output
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::status; }
|
||||
|
||||
private:
|
||||
HTMLOutputElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -18,6 +19,9 @@ public:
|
|||
|
||||
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-p
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::paragraph; }
|
||||
|
||||
private:
|
||||
HTMLParagraphElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLPreElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLPreElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-pre
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::generic; }
|
||||
|
||||
private:
|
||||
HTMLPreElement(DOM::Document&, DOM::QualifiedName);
|
||||
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -32,6 +33,9 @@ public:
|
|||
|
||||
bool using_system_appearance() const;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-progress
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::progressbar; }
|
||||
|
||||
private:
|
||||
HTMLProgressElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLQuoteElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -17,4 +19,15 @@ HTMLQuoteElement::HTMLQuoteElement(DOM::Document& document, DOM::QualifiedName q
|
|||
|
||||
HTMLQuoteElement::~HTMLQuoteElement() = default;
|
||||
|
||||
FlyString HTMLQuoteElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-blockquote
|
||||
if (local_name() == TagNames::blockquote)
|
||||
return DOM::ARIARoleNames::blockquote;
|
||||
// https://www.w3.org/TR/html-aria/#el-q
|
||||
if (local_name() == TagNames::q)
|
||||
return DOM::ARIARoleNames::generic;
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ class HTMLQuoteElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLQuoteElement() override;
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
HTMLQuoteElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -156,4 +156,18 @@ DeprecatedString const& HTMLSelectElement::type() const
|
|||
return select_multiple;
|
||||
}
|
||||
|
||||
FlyString HTMLSelectElement::default_role() const
|
||||
{
|
||||
// https://www.w3.org/TR/html-aria/#el-select-multiple-or-size-greater-1
|
||||
if (has_attribute("multiple"))
|
||||
return DOM::ARIARoleNames::listbox;
|
||||
if (has_attribute("size")) {
|
||||
auto size_attribute = attribute("size").to_int();
|
||||
if (size_attribute.has_value() && size_attribute.value() > 1)
|
||||
return DOM::ARIARoleNames::listbox;
|
||||
}
|
||||
// https://www.w3.org/TR/html-aria/#el-select
|
||||
return DOM::ARIARoleNames::combobox;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
|
||||
DeprecatedString const& type() const;
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLSpanElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLSpanElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-span
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::generic; }
|
||||
|
||||
private:
|
||||
HTMLSpanElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -18,6 +19,9 @@ public:
|
|||
|
||||
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-caption
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::caption; }
|
||||
|
||||
private:
|
||||
HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -69,4 +69,19 @@ void HTMLTableCellElement::set_row_span(unsigned int value)
|
|||
MUST(set_attribute(HTML::AttributeNames::rowspan, DeprecatedString::number(value)));
|
||||
}
|
||||
|
||||
FlyString HTMLTableCellElement::default_role() const
|
||||
{
|
||||
// TODO: For td:
|
||||
// role=cell if the ancestor table element is exposed as a role=table
|
||||
// role=gridcell if the ancestor table element is exposed as a role=grid or treegrid
|
||||
// No corresponding role if the ancestor table element is not exposed as a role=table, grid or treegrid
|
||||
// For th:
|
||||
// role=columnheader, rowheader or cell if the ancestor table element is exposed as a role=table
|
||||
// role=columnheader, rowheader or gridcell if the ancestor table element is exposed as a role=grid or treegrid
|
||||
// No corresponding role if the ancestor table element is not exposed as a role=table, grid or treegrid
|
||||
// https://www.w3.org/TR/html-aria/#el-td
|
||||
// https://www.w3.org/TR/html-aria/#el-th
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ public:
|
|||
void set_col_span(unsigned);
|
||||
void set_row_span(unsigned);
|
||||
|
||||
virtual FlyString default_role() const override;
|
||||
|
||||
private:
|
||||
HTMLTableCellElement(DOM::Document&, DOM::QualifiedName);
|
||||
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||
|
|
|
@ -42,6 +42,9 @@ public:
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index);
|
||||
WebIDL::ExceptionOr<void> delete_row(long index);
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-table
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::table; }
|
||||
|
||||
private:
|
||||
HTMLTableElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -23,6 +24,9 @@ public:
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableCellElement>> insert_cell(i32 index);
|
||||
WebIDL::ExceptionOr<void> delete_cell(i32 index);
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-tr
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::row; }
|
||||
|
||||
private:
|
||||
HTMLTableRowElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -21,6 +22,11 @@ public:
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index);
|
||||
WebIDL::ExceptionOr<void> delete_row(long index);
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-tbody
|
||||
// https://www.w3.org/TR/html-aria/#el-tfoot
|
||||
// https://www.w3.org/TR/html-aria/#el-thead
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::rowgroup; }
|
||||
|
||||
private:
|
||||
HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
|
@ -50,6 +51,9 @@ public:
|
|||
|
||||
virtual void reset_algorithm() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-textarea
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::textbox; }
|
||||
|
||||
private:
|
||||
HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLTimeElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLTimeElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-time
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::time; }
|
||||
|
||||
private:
|
||||
HTMLTimeElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/ARIARoleNames.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -16,6 +17,9 @@ class HTMLUListElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLUListElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-ul
|
||||
virtual FlyString default_role() const override { return DOM::ARIARoleNames::list; }
|
||||
|
||||
private:
|
||||
HTMLUListElement(DOM::Document&, DOM::QualifiedName);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue