summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
blob: d6e50979ff413babe6e05d056198b27140e69543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>

namespace Web::HTML {

class HTMLInputElement final
    : public HTMLElement
    , public FormAssociatedElement {
public:
    using WrapperType = Bindings::HTMLInputElementWrapper;

    HTMLInputElement(DOM::Document&, QualifiedName);
    virtual ~HTMLInputElement() override;

    virtual RefPtr<Layout::Node> create_layout_node() override;

    String type() const { return attribute(HTML::AttributeNames::type); }
    String default_value() const { return attribute(HTML::AttributeNames::value); }
    String name() const { return attribute(HTML::AttributeNames::name); }

    String value() const;
    void set_value(String);

    bool checked() const { return m_checked; }
    void set_checked(bool);

    bool enabled() const;

    void did_click_button(Badge<Layout::ButtonBox>);

private:
    // ^DOM::Node
    virtual void inserted() override;
    virtual void removed_from(Node*) override;

    // ^HTML::FormAssociatedElement
    virtual HTMLElement& form_associated_element_to_html_element() override { return *this; }

    void create_shadow_tree_if_needed();

    RefPtr<DOM::Text> m_text_node;
    bool m_checked { false };
};

}