HTMLButtonElement.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/ARIA/Roles.h>
  8. #include <LibWeb/HTML/FormAssociatedElement.h>
  9. #include <LibWeb/HTML/HTMLElement.h>
  10. namespace Web::HTML {
  11. #define ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES \
  12. __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(submit, Submit) \
  13. __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(reset, Reset) \
  14. __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(button, Button)
  15. class HTMLButtonElement final
  16. : public HTMLElement
  17. , public FormAssociatedElement {
  18. WEB_PLATFORM_OBJECT(HTMLButtonElement, HTMLElement);
  19. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLButtonElement)
  20. public:
  21. virtual ~HTMLButtonElement() override;
  22. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  23. enum class TypeAttributeState {
  24. #define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(_, state) state,
  25. ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTES
  26. #undef __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE
  27. };
  28. DeprecatedString type() const;
  29. TypeAttributeState type_state() const;
  30. void set_type(DeprecatedString const&);
  31. // ^EventTarget
  32. // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-button-element
  33. virtual bool is_focusable() const override { return true; }
  34. // ^FormAssociatedElement
  35. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  36. virtual bool is_listed() const override { return true; }
  37. // https://html.spec.whatwg.org/multipage/forms.html#category-submit
  38. virtual bool is_submittable() const override { return true; }
  39. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  40. virtual bool is_auto_capitalize_inheriting() const override { return true; }
  41. // ^HTMLElement
  42. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  43. virtual bool is_labelable() const override { return true; }
  44. // https://www.w3.org/TR/html-aria/#el-button
  45. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::button; }
  46. private:
  47. HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
  48. // ^DOM::Element
  49. virtual i32 default_tab_index_value() const override;
  50. };
  51. }