|
@@ -6,8 +6,10 @@
|
|
|
|
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
-#include <LibWeb/ARIA/Roles.h>
|
|
|
|
|
|
+#include <AK/GenericShorthands.h>
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
|
|
+#include <LibWeb/HTML/HTMLOListElement.h>
|
|
|
|
+#include <LibWeb/HTML/HTMLUListElement.h>
|
|
#include <LibWeb/WebIDL/Types.h>
|
|
#include <LibWeb/WebIDL/Types.h>
|
|
|
|
|
|
namespace Web::HTML {
|
|
namespace Web::HTML {
|
|
@@ -20,7 +22,18 @@ public:
|
|
virtual ~HTMLLIElement() override;
|
|
virtual ~HTMLLIElement() override;
|
|
|
|
|
|
// https://www.w3.org/TR/html-aria/#el-li
|
|
// https://www.w3.org/TR/html-aria/#el-li
|
|
- virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::listitem; }
|
|
|
|
|
|
+ virtual Optional<ARIA::Role> default_role() const override
|
|
|
|
+ {
|
|
|
|
+ for (auto const* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
|
|
|
|
+ if (ancestor->role_or_default() == ARIA::Role::list)
|
|
|
|
+ return ARIA::Role::listitem;
|
|
|
|
+ }
|
|
|
|
+ // https://w3c.github.io/core-aam/#roleMappingComputedRole
|
|
|
|
+ // When an element has a role but is not contained in the required context (for example, an orphaned listitem
|
|
|
|
+ // without the required accessible parent of role list), User Agents MUST ignore the role token, and return the
|
|
|
|
+ // computedrole as if the ignored role token had not been included.
|
|
|
|
+ return ARIA::Role::none;
|
|
|
|
+ }
|
|
|
|
|
|
WebIDL::Long value();
|
|
WebIDL::Long value();
|
|
void set_value(WebIDL::Long value)
|
|
void set_value(WebIDL::Long value)
|