HTMLInputElement.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  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. class HTMLInputElement final : public FormAssociatedElement {
  11. public:
  12. using WrapperType = Bindings::HTMLInputElementWrapper;
  13. HTMLInputElement(DOM::Document&, QualifiedName);
  14. virtual ~HTMLInputElement() override;
  15. virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  16. String type() const;
  17. void set_type(String const&);
  18. String default_value() const { return attribute(HTML::AttributeNames::value); }
  19. String name() const { return attribute(HTML::AttributeNames::name); }
  20. String value() const;
  21. void set_value(String);
  22. bool checked() const { return m_checked; }
  23. enum class ChangeSource {
  24. Programmatic,
  25. User,
  26. };
  27. enum class ShouldRunActivationBehavior {
  28. No,
  29. Yes,
  30. };
  31. void set_checked(bool, ChangeSource = ChangeSource::Programmatic, ShouldRunActivationBehavior = ShouldRunActivationBehavior::Yes);
  32. bool enabled() const;
  33. void did_click_button(Badge<Layout::ButtonBox>);
  34. void did_click_checkbox(Badge<Layout::CheckBox>);
  35. void did_edit_text_node(Badge<BrowsingContext>);
  36. virtual bool is_focusable() const override;
  37. virtual void parse_attribute(FlyString const&, String const&) override;
  38. virtual void did_remove_attribute(FlyString const&) override;
  39. private:
  40. // ^DOM::Node
  41. virtual void inserted() override;
  42. virtual void removed_from(Node*) override;
  43. // ^DOM::EventTarget
  44. virtual void did_receive_focus() override;
  45. virtual void run_activation_behavior() override;
  46. void create_shadow_tree_if_needed();
  47. void run_input_activation_behavior();
  48. RefPtr<DOM::Text> m_text_node;
  49. bool m_checked { false };
  50. // https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag
  51. bool m_dirty_checkedness { false };
  52. };
  53. }