HTMLButtonElement.h 1.9 KB

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