1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:07:45 +00:00

LibWeb: Replace ARIA role static FlyStrings with an enum

This replaces the FlyStrings for ARIA roles that were constructed in
a [[gnu::constructor]] with a single enum. I came across this as the
DOM inspector was crashing due to a null FlyString for an ARIA role.

After fixing that, I was confused as to why these roles were not an
enum. Looking at the spec there's a fixed list of roles and switching
from references to static strings to an enum was pretty much an
exercise in find and replace :).

No functional changes (outside of fixing the mentioned crash).
This commit is contained in:
MacDue 2023-01-29 19:12:00 +01:00 committed by Linus Groh
parent f23eba1ba8
commit 890b4d7980
59 changed files with 344 additions and 327 deletions

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/Window.h>
@ -89,13 +89,13 @@ i32 HTMLAnchorElement::default_tab_index_value() const
return 0;
}
DeprecatedFlyString HTMLAnchorElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLAnchorElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-a-no-href
if (!href().is_null())
return DOM::ARIARoleNames::link;
return DOM::ARIARoles::Role::link;
// https://www.w3.org/TR/html-aria/#el-a
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
}
}

View file

@ -53,7 +53,7 @@ private:
queue_an_element_task(source, move(steps));
}
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
};
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
#include <LibWeb/HTML/Window.h>
@ -48,13 +48,13 @@ i32 HTMLAreaElement::default_tab_index_value() const
return 0;
}
DeprecatedFlyString HTMLAreaElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLAreaElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-area-no-href
if (!href().is_null())
return DOM::ARIARoleNames::link;
return DOM::ARIARoles::Role::link;
// https://www.w3.org/TR/html-aria/#el-area
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
}
}

View file

@ -42,7 +42,7 @@ private:
queue_an_element_task(source, move(steps));
}
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
};
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/WindowEventHandlers.h>
@ -24,7 +24,7 @@ public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
// https://www.w3.org/TR/html-aria/#el-body
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::generic; };
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::generic; };
private:
HTMLBodyElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
@ -57,7 +57,7 @@ public:
virtual bool is_labelable() const override { return true; }
// https://www.w3.org/TR/html-aria/#el-button
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::button; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::button; }
private:
HTMLButtonElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLDataElement() override;
// https://www.w3.org/TR/html-aria/#el-data
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::generic; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::generic; }
private:
HTMLDataElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -17,7 +17,7 @@ class HTMLDataListElement final : public HTMLElement {
public:
virtual ~HTMLDataListElement() override;
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::listbox; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::listbox; }
private:
HTMLDataListElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLDetailsElement() override;
// https://www.w3.org/TR/html-aria/#el-details
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::group; };
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::group; };
private:
HTMLDetailsElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLDialogElement() override;
// https://www.w3.org/TR/html-aria/#el-dialog
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::dialog; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::dialog; }
private:
HTMLDialogElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLDivElement() override;
// https://www.w3.org/TR/html-aria/#el-div
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::generic; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::generic; }
private:
HTMLDivElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#include <AK/StringBuilder.h>
#include <LibJS/Interpreter.h>
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/IDLEventListener.h>
#include <LibWeb/DOM/ShadowRoot.h>
@ -329,86 +329,86 @@ void HTMLElement::blur()
// User agents may selectively or uniformly ignore calls to this method for usability reasons.
}
DeprecatedFlyString HTMLElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-article
if (local_name() == TagNames::article)
return DOM::ARIARoleNames::article;
return DOM::ARIARoles::Role::article;
// https://www.w3.org/TR/html-aria/#el-aside
if (local_name() == TagNames::aside)
return DOM::ARIARoleNames::complementary;
return DOM::ARIARoles::Role::complementary;
// https://www.w3.org/TR/html-aria/#el-b
if (local_name() == TagNames::b)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
// https://www.w3.org/TR/html-aria/#el-bdi
if (local_name() == TagNames::bdi)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
// https://www.w3.org/TR/html-aria/#el-bdo
if (local_name() == TagNames::bdo)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
// https://www.w3.org/TR/html-aria/#el-code
if (local_name() == TagNames::code)
return DOM::ARIARoleNames::code;
return DOM::ARIARoles::Role::code;
// https://www.w3.org/TR/html-aria/#el-dfn
if (local_name() == TagNames::dfn)
return DOM::ARIARoleNames::term;
return DOM::ARIARoles::Role::term;
// https://www.w3.org/TR/html-aria/#el-em
if (local_name() == TagNames::em)
return DOM::ARIARoleNames::emphasis;
return DOM::ARIARoles::Role::emphasis;
// https://www.w3.org/TR/html-aria/#el-figure
if (local_name() == TagNames::figure)
return DOM::ARIARoleNames::figure;
return DOM::ARIARoles::Role::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;
return DOM::ARIARoles::Role::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;
return DOM::ARIARoles::Role::generic;
}
// https://www.w3.org/TR/html-aria/#el-hgroup
if (local_name() == TagNames::hgroup)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
// https://www.w3.org/TR/html-aria/#el-i
if (local_name() == TagNames::i)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
// https://www.w3.org/TR/html-aria/#el-main
if (local_name() == TagNames::main)
return DOM::ARIARoleNames::main;
return DOM::ARIARoles::Role::main;
// https://www.w3.org/TR/html-aria/#el-nav
if (local_name() == TagNames::nav)
return DOM::ARIARoleNames::navigation;
return DOM::ARIARoles::Role::navigation;
// https://www.w3.org/TR/html-aria/#el-samp
if (local_name() == TagNames::samp)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::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;
return DOM::ARIARoles::Role::region;
}
// https://www.w3.org/TR/html-aria/#el-small
if (local_name() == TagNames::small)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
// https://www.w3.org/TR/html-aria/#el-strong
if (local_name() == TagNames::strong)
return DOM::ARIARoleNames::strong;
return DOM::ARIARoles::Role::strong;
// https://www.w3.org/TR/html-aria/#el-sub
if (local_name() == TagNames::sub)
return DOM::ARIARoleNames::subscript;
return DOM::ARIARoles::Role::subscript;
// https://www.w3.org/TR/html-aria/#el-summary
if (local_name() == TagNames::summary)
return DOM::ARIARoleNames::button;
return DOM::ARIARoles::Role::button;
// https://www.w3.org/TR/html-aria/#el-sup
if (local_name() == TagNames::sup)
return DOM::ARIARoleNames::superscript;
return DOM::ARIARoles::Role::superscript;
// https://www.w3.org/TR/html-aria/#el-u
if (local_name() == TagNames::u)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
return {};
}

View file

@ -59,7 +59,7 @@ public:
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const { return false; }
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
protected:
HTMLElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
@ -36,7 +36,7 @@ public:
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::group; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::group; }
private:
HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
@ -38,7 +38,7 @@ public:
unsigned length() const;
// https://www.w3.org/TR/html-aria/#el-form
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::form; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::form; }
private:
HTMLFormElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLHRElement() override;
// https://www.w3.org/TR/html-aria/#el-hr
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::separator; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::separator; }
private:
HTMLHRElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -20,7 +20,8 @@ public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
// https://www.w3.org/TR/html-aria/#el-h1-h6
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::heading; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::heading; }
virtual DeprecatedString aria_level() const override
{
// TODO: aria-level = the number in the element's tag name

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -20,7 +20,7 @@ public:
bool should_use_body_background_properties() const;
// https://www.w3.org/TR/html-aria/#el-html
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::document; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::document; }
private:
HTMLHtmlElement(DOM::Document&, DOM::QualifiedName);

View file

@ -7,7 +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/ARIARoles.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/EventNames.h>
@ -202,14 +202,14 @@ bool HTMLImageElement::complete() const
return false;
}
DeprecatedFlyString HTMLImageElement::default_role() const
Optional<DOM::ARIARoles::Role> 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;
return DOM::ARIARoles::Role::img;
// https://www.w3.org/TR/html-aria/#el-img-empty-alt
return DOM::ARIARoleNames::presentation;
return DOM::ARIARoles::Role::presentation;
}
}

View file

@ -43,7 +43,7 @@ public:
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
bool complete() const;
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
HTMLImageElement(DOM::Document&, DOM::QualifiedName);

View file

@ -870,32 +870,32 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_selection_range(u32 start, u32 e
return {};
}
DeprecatedFlyString HTMLInputElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLInputElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-input-button
if (type_state() == TypeAttributeState::Button)
return DOM::ARIARoleNames::button;
return DOM::ARIARoles::Role::button;
// https://www.w3.org/TR/html-aria/#el-input-checkbox
if (type_state() == TypeAttributeState::Checkbox)
return DOM::ARIARoleNames::checkbox;
return DOM::ARIARoles::Role::checkbox;
// https://www.w3.org/TR/html-aria/#el-input-email
if (type_state() == TypeAttributeState::Email && attribute("list").is_null())
return DOM::ARIARoleNames::textbox;
return DOM::ARIARoles::Role::textbox;
// https://www.w3.org/TR/html-aria/#el-input-image
if (type_state() == TypeAttributeState::ImageButton)
return DOM::ARIARoleNames::button;
return DOM::ARIARoles::Role::button;
// https://www.w3.org/TR/html-aria/#el-input-number
if (type_state() == TypeAttributeState::Number)
return DOM::ARIARoleNames::spinbutton;
return DOM::ARIARoles::Role::spinbutton;
// https://www.w3.org/TR/html-aria/#el-input-radio
if (type_state() == TypeAttributeState::RadioButton)
return DOM::ARIARoleNames::radio;
return DOM::ARIARoles::Role::radio;
// https://www.w3.org/TR/html-aria/#el-input-range
if (type_state() == TypeAttributeState::Range)
return DOM::ARIARoleNames::slider;
return DOM::ARIARoles::Role::slider;
// https://www.w3.org/TR/html-aria/#el-input-reset
if (type_state() == TypeAttributeState::ResetButton)
return DOM::ARIARoleNames::button;
return DOM::ARIARoles::Role::button;
// https://www.w3.org/TR/html-aria/#el-input-text-list
if ((type_state() == TypeAttributeState::Text
|| type_state() == TypeAttributeState::Search
@ -903,22 +903,22 @@ DeprecatedFlyString HTMLInputElement::default_role() const
|| type_state() == TypeAttributeState::URL
|| type_state() == TypeAttributeState::Email)
&& !attribute("list").is_null())
return DOM::ARIARoleNames::combobox;
return DOM::ARIARoles::Role::combobox;
// https://www.w3.org/TR/html-aria/#el-input-search
if (type_state() == TypeAttributeState::Search && attribute("list").is_null())
return DOM::ARIARoleNames::textbox;
return DOM::ARIARoles::Role::textbox;
// https://www.w3.org/TR/html-aria/#el-input-submit
if (type_state() == TypeAttributeState::SubmitButton)
return DOM::ARIARoleNames::button;
return DOM::ARIARoles::Role::button;
// https://www.w3.org/TR/html-aria/#el-input-tel
if (type_state() == TypeAttributeState::Telephone)
return DOM::ARIARoleNames::textbox;
return DOM::ARIARoles::Role::textbox;
// https://www.w3.org/TR/html-aria/#el-input-text
if (type_state() == TypeAttributeState::Text && attribute("list").is_null())
return DOM::ARIARoleNames::textbox;
return DOM::ARIARoles::Role::textbox;
// https://www.w3.org/TR/html-aria/#el-input-url
if (type_state() == TypeAttributeState::URL && attribute("list").is_null())
return DOM::ARIARoleNames::textbox;
return DOM::ARIARoles::Role::textbox;
// https://www.w3.org/TR/html-aria/#el-input-color
// https://www.w3.org/TR/html-aria/#el-input-date

View file

@ -120,7 +120,7 @@ public:
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
HTMLInputElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLLIElement() override;
// https://www.w3.org/TR/html-aria/#el-li
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::listitem; };
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::listitem; };
private:
HTMLLIElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLMenuElement() override;
// https://www.w3.org/TR/html-aria/#el-menu
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::list; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::list; }
private:
HTMLMenuElement(DOM::Document&, DOM::QualifiedName);

View file

@ -7,7 +7,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -23,7 +23,7 @@ public:
virtual bool is_labelable() const override { return true; }
// https://www.w3.org/TR/html-aria/#el-meter
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::meter; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::meter; }
private:
HTMLMeterElement(DOM::Document&, DOM::QualifiedName);

View file

@ -23,14 +23,14 @@ void HTMLModElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLModElementPrototype>(realm, "HTMLModElement"));
}
DeprecatedFlyString HTMLModElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLModElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-del
if (local_name() == TagNames::del)
return DOM::ARIARoleNames::deletion;
return DOM::ARIARoles::Role::deletion;
// https://www.w3.org/TR/html-aria/#el-ins
if (local_name() == TagNames::ins)
return DOM::ARIARoleNames::insertion;
return DOM::ARIARoles::Role::insertion;
VERIFY_NOT_REACHED();
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -17,7 +17,7 @@ class HTMLModElement final : public HTMLElement {
public:
virtual ~HTMLModElement() override;
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
HTMLModElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLOListElement() override;
// https://www.w3.org/TR/html-aria/#el-ol
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::list; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::list; }
private:
HTMLOListElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLOptGroupElement() override;
// https://www.w3.org/TR/html-aria/#el-optgroup
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::group; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::group; }
private:
HTMLOptGroupElement(DOM::Document&, DOM::QualifiedName);

View file

@ -7,7 +7,7 @@
#include <AK/StringBuilder.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/HTMLOptGroupElement.h>
@ -146,11 +146,11 @@ bool HTMLOptionElement::disabled() const
|| (parent() && is<HTMLOptGroupElement>(parent()) && static_cast<HTMLOptGroupElement const&>(*parent()).has_attribute(AttributeNames::disabled));
}
DeprecatedFlyString HTMLOptionElement::default_role() const
Optional<DOM::ARIARoles::Role> 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;
return DOM::ARIARoles::Role::option;
}
}

View file

@ -30,7 +30,7 @@ public:
bool disabled() const;
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
friend class Bindings::OptionConstructor;

View file

@ -7,7 +7,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
@ -45,7 +45,7 @@ public:
virtual void reset_algorithm() override;
// https://www.w3.org/TR/html-aria/#el-output
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::status; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::status; }
private:
HTMLOutputElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -20,7 +20,7 @@ public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
// https://www.w3.org/TR/html-aria/#el-p
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::paragraph; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::paragraph; }
private:
HTMLParagraphElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLPreElement() override;
// https://www.w3.org/TR/html-aria/#el-pre
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::generic; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::generic; }
private:
HTMLPreElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -34,7 +34,7 @@ public:
bool using_system_appearance() const;
// https://www.w3.org/TR/html-aria/#el-progress
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::progressbar; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::progressbar; }
private:
HTMLProgressElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#include <AK/Assertions.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLQuoteElement.h>
namespace Web::HTML {
@ -24,14 +24,14 @@ void HTMLQuoteElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLQuoteElementPrototype>(realm, "HTMLQuoteElement"));
}
DeprecatedFlyString HTMLQuoteElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLQuoteElement::default_role() const
{
// https://www.w3.org/TR/html-aria/#el-blockquote
if (local_name() == TagNames::blockquote)
return DOM::ARIARoleNames::blockquote;
return DOM::ARIARoles::Role::blockquote;
// https://www.w3.org/TR/html-aria/#el-q
if (local_name() == TagNames::q)
return DOM::ARIARoleNames::generic;
return DOM::ARIARoles::Role::generic;
VERIFY_NOT_REACHED();
}

View file

@ -16,7 +16,7 @@ class HTMLQuoteElement final : public HTMLElement {
public:
virtual ~HTMLQuoteElement() override;
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
HTMLQuoteElement(DOM::Document&, DOM::QualifiedName);

View file

@ -161,18 +161,18 @@ DeprecatedString const& HTMLSelectElement::type() const
return select_multiple;
}
DeprecatedFlyString HTMLSelectElement::default_role() const
Optional<DOM::ARIARoles::Role> 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;
return DOM::ARIARoles::Role::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;
return DOM::ARIARoles::Role::listbox;
}
// https://www.w3.org/TR/html-aria/#el-select
return DOM::ARIARoleNames::combobox;
return DOM::ARIARoles::Role::combobox;
}
}

View file

@ -60,7 +60,7 @@ public:
DeprecatedString const& type() const;
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
HTMLSelectElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLSpanElement() override;
// https://www.w3.org/TR/html-aria/#el-span
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::generic; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::generic; }
private:
HTMLSpanElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -20,7 +20,7 @@ public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
// https://www.w3.org/TR/html-aria/#el-caption
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::caption; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::caption; }
private:
HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName);

View file

@ -74,7 +74,7 @@ void HTMLTableCellElement::set_row_span(unsigned int value)
MUST(set_attribute(HTML::AttributeNames::rowspan, DeprecatedString::number(value)));
}
DeprecatedFlyString HTMLTableCellElement::default_role() const
Optional<DOM::ARIARoles::Role> HTMLTableCellElement::default_role() const
{
// TODO: For td:
// role=cell if the ancestor table element is exposed as a role=table

View file

@ -22,7 +22,7 @@ public:
void set_col_span(unsigned);
void set_row_span(unsigned);
virtual DeprecatedFlyString default_role() const override;
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
private:
HTMLTableCellElement(DOM::Document&, DOM::QualifiedName);

View file

@ -43,7 +43,7 @@ public:
WebIDL::ExceptionOr<void> delete_row(long index);
// https://www.w3.org/TR/html-aria/#el-table
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::table; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::table; }
private:
HTMLTableElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -25,7 +25,7 @@ public:
WebIDL::ExceptionOr<void> delete_cell(i32 index);
// https://www.w3.org/TR/html-aria/#el-tr
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::row; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::row; }
private:
HTMLTableRowElement(DOM::Document&, DOM::QualifiedName);

View file

@ -7,7 +7,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -25,7 +25,7 @@ public:
// 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 DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::rowgroup; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::rowgroup; }
private:
HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName);

View file

@ -7,7 +7,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
@ -52,7 +52,7 @@ public:
virtual void reset_algorithm() override;
// https://www.w3.org/TR/html-aria/#el-textarea
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::textbox; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::textbox; }
private:
HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLTimeElement() override;
// https://www.w3.org/TR/html-aria/#el-time
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::time; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::time; }
private:
HTMLTimeElement(DOM::Document&, DOM::QualifiedName);

View file

@ -6,7 +6,7 @@
#pragma once
#include <LibWeb/DOM/ARIARoleNames.h>
#include <LibWeb/DOM/ARIARoles.h>
#include <LibWeb/HTML/HTMLElement.h>
namespace Web::HTML {
@ -18,7 +18,7 @@ public:
virtual ~HTMLUListElement() override;
// https://www.w3.org/TR/html-aria/#el-ul
virtual DeprecatedFlyString default_role() const override { return DOM::ARIARoleNames::list; }
virtual Optional<DOM::ARIARoles::Role> default_role() const override { return DOM::ARIARoles::Role::list; }
private:
HTMLUListElement(DOM::Document&, DOM::QualifiedName);