/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, the SerenityOS developers. |
3 | | * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org> |
4 | | * |
5 | | * SPDX-License-Identifier: BSD-2-Clause |
6 | | */ |
7 | | |
8 | | #pragma once |
9 | | |
10 | | #include <LibWeb/ARIA/Roles.h> |
11 | | #include <LibWeb/HTML/FormAssociatedElement.h> |
12 | | #include <LibWeb/HTML/HTMLElement.h> |
13 | | |
14 | | namespace Web::HTML { |
15 | | |
16 | | class HTMLOutputElement final |
17 | | : public HTMLElement |
18 | | , public FormAssociatedElement { |
19 | | WEB_PLATFORM_OBJECT(HTMLOutputElement, HTMLElement); |
20 | | JS_DECLARE_ALLOCATOR(HTMLOutputElement); |
21 | | FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLOutputElement) |
22 | | |
23 | | public: |
24 | | virtual ~HTMLOutputElement() override; |
25 | | |
26 | | JS::NonnullGCPtr<DOM::DOMTokenList> html_for(); |
27 | | |
28 | | String const& type() const |
29 | 0 | { |
30 | 0 | static String const output = "output"_string; |
31 | 0 | return output; |
32 | 0 | } |
33 | | |
34 | | String default_value() const; |
35 | | void set_default_value(String const&); |
36 | | |
37 | | String value() const override; |
38 | | void set_value(String const&); |
39 | | |
40 | | // ^FormAssociatedElement |
41 | | // https://html.spec.whatwg.org/multipage/forms.html#category-listed |
42 | 0 | virtual bool is_listed() const override { return true; } |
43 | | |
44 | | // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize |
45 | 0 | virtual bool is_resettable() const override { return true; } |
46 | | |
47 | | // https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize |
48 | 0 | virtual bool is_auto_capitalize_inheriting() const override { return true; } |
49 | | |
50 | | // ^HTMLElement |
51 | | // https://html.spec.whatwg.org/multipage/forms.html#category-label |
52 | 0 | virtual bool is_labelable() const override { return true; } |
53 | | |
54 | | virtual void reset_algorithm() override; |
55 | | virtual void clear_algorithm() override; |
56 | | |
57 | | // https://www.w3.org/TR/html-aria/#el-output |
58 | 0 | virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::status; } |
59 | | |
60 | | private: |
61 | | HTMLOutputElement(DOM::Document&, DOM::QualifiedName); |
62 | | |
63 | | virtual void initialize(JS::Realm&) override; |
64 | | virtual void visit_edges(Cell::Visitor& visitor) override; |
65 | | |
66 | | virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& value) override; |
67 | | |
68 | | JS::GCPtr<DOM::DOMTokenList> m_html_for; |
69 | | |
70 | | Optional<String> m_default_value_override {}; |
71 | | }; |
72 | | |
73 | | } |