HTMLLIElement.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/GenericShorthands.h>
  8. #include <LibWeb/HTML/HTMLElement.h>
  9. #include <LibWeb/HTML/HTMLOListElement.h>
  10. #include <LibWeb/HTML/HTMLUListElement.h>
  11. #include <LibWeb/WebIDL/Types.h>
  12. namespace Web::HTML {
  13. class HTMLLIElement final : public HTMLElement {
  14. WEB_PLATFORM_OBJECT(HTMLLIElement, HTMLElement);
  15. GC_DECLARE_ALLOCATOR(HTMLLIElement);
  16. public:
  17. virtual ~HTMLLIElement() override;
  18. // https://www.w3.org/TR/html-aria/#el-li
  19. virtual Optional<ARIA::Role> default_role() const override
  20. {
  21. for (auto const* ancestor = parent_element(); ancestor; ancestor = ancestor->parent_element()) {
  22. if (ancestor->role_or_default() == ARIA::Role::list)
  23. return ARIA::Role::listitem;
  24. }
  25. // https://w3c.github.io/core-aam/#roleMappingComputedRole
  26. // When an element has a role but is not contained in the required context (for example, an orphaned listitem
  27. // without the required accessible parent of role list), User Agents MUST ignore the role token, and return the
  28. // computedrole as if the ignored role token had not been included.
  29. return ARIA::Role::none;
  30. }
  31. WebIDL::Long value();
  32. void set_value(WebIDL::Long value)
  33. {
  34. set_attribute(AttributeNames::value, String::number(value)).release_value_but_fixme_should_propagate_errors();
  35. }
  36. private:
  37. HTMLLIElement(DOM::Document&, DOM::QualifiedName);
  38. virtual void initialize(JS::Realm&) override;
  39. };
  40. }