/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2020, the SerenityOS developers. |
3 | | * Copyright (c) 2024, Sam Atkins <sam@ladybird.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/HTMLElement.h> |
12 | | #include <LibWeb/HTML/ToggleTaskTracker.h> |
13 | | |
14 | | namespace Web::HTML { |
15 | | |
16 | | class HTMLDialogElement final : public HTMLElement { |
17 | | WEB_PLATFORM_OBJECT(HTMLDialogElement, HTMLElement); |
18 | | JS_DECLARE_ALLOCATOR(HTMLDialogElement); |
19 | | |
20 | | public: |
21 | | virtual ~HTMLDialogElement() override; |
22 | | |
23 | | virtual void removed_from(Node*) override; |
24 | | |
25 | | String return_value() const; |
26 | | void set_return_value(String); |
27 | | |
28 | | WebIDL::ExceptionOr<void> show(); |
29 | | WebIDL::ExceptionOr<void> show_modal(); |
30 | | void close(Optional<String> return_value); |
31 | | |
32 | | // https://www.w3.org/TR/html-aria/#el-dialog |
33 | 0 | virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::dialog; } |
34 | | |
35 | 0 | bool is_modal() const { return m_is_modal; } |
36 | | |
37 | | private: |
38 | | HTMLDialogElement(DOM::Document&, DOM::QualifiedName); |
39 | | |
40 | | virtual void initialize(JS::Realm&) override; |
41 | | virtual void visit_edges(Cell::Visitor&) override; |
42 | | |
43 | | void queue_a_dialog_toggle_event_task(String old_state, String new_state); |
44 | | |
45 | | void close_the_dialog(Optional<String> result); |
46 | | |
47 | | void run_dialog_focusing_steps(); |
48 | | |
49 | | String m_return_value; |
50 | | bool m_is_modal { false }; |
51 | | JS::GCPtr<CloseWatcher> m_close_watcher; |
52 | | |
53 | | // https://html.spec.whatwg.org/multipage/interactive-elements.html#dialog-toggle-task-tracker |
54 | | Optional<ToggleTaskTracker> m_dialog_toggle_task_tracker; |
55 | | }; |
56 | | |
57 | | } |