FormAssociatedElement.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/WeakPtr.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/HTML/HTMLElement.h>
  10. namespace Web::HTML {
  11. class FormAssociatedElement : public HTMLElement {
  12. public:
  13. HTMLFormElement* form() { return m_form; }
  14. HTMLFormElement const* form() const { return m_form; }
  15. void set_form(HTMLFormElement*);
  16. bool enabled() const;
  17. void set_parser_inserted(Badge<HTMLParser>) { m_parser_inserted = true; }
  18. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  19. virtual bool is_listed() const { return false; }
  20. // https://html.spec.whatwg.org/multipage/forms.html#category-submit
  21. virtual bool is_submittable() const { return false; }
  22. // https://html.spec.whatwg.org/multipage/forms.html#category-reset
  23. virtual bool is_resettable() const { return false; }
  24. // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
  25. virtual bool is_auto_capitalize_inheriting() const { return false; }
  26. protected:
  27. FormAssociatedElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  28. : HTMLElement(document, move(qualified_name))
  29. {
  30. }
  31. virtual ~FormAssociatedElement() = default;
  32. private:
  33. WeakPtr<HTMLFormElement> m_form;
  34. // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#parser-inserted-flag
  35. bool m_parser_inserted { false };
  36. void reset_form_owner();
  37. // ^DOM::Node
  38. virtual void inserted() override;
  39. virtual void removed_from(DOM::Node*) override;
  40. };
  41. }