/src/serenity/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/JsonObjectSerializer.h> |
10 | | #include <AK/Vector.h> |
11 | | #include <LibJS/Heap/Cell.h> |
12 | | #include <LibJS/Heap/CellAllocator.h> |
13 | | #include <LibWeb/DOM/Node.h> |
14 | | #include <LibWeb/Forward.h> |
15 | | |
16 | | namespace Web::DOM { |
17 | | |
18 | | class AccessibilityTreeNode final : public JS::Cell { |
19 | | JS_CELL(AccessibilityTreeNode, JS::Cell); |
20 | | JS_DECLARE_ALLOCATOR(AccessibilityTreeNode); |
21 | | |
22 | | public: |
23 | | static JS::NonnullGCPtr<AccessibilityTreeNode> create(Document*, DOM::Node const*); |
24 | 0 | virtual ~AccessibilityTreeNode() override = default; |
25 | | |
26 | 0 | JS::GCPtr<DOM::Node const> value() const { return m_value; } |
27 | 0 | void set_value(JS::GCPtr<DOM::Node const> value) { m_value = value; } |
28 | 0 | Vector<JS::GCPtr<AccessibilityTreeNode>> children() const { return m_children; } |
29 | 0 | void append_child(AccessibilityTreeNode* child) { m_children.append(child); } |
30 | | |
31 | | void serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object, Document const&) const; |
32 | | |
33 | | protected: |
34 | | virtual void visit_edges(Visitor&) override; |
35 | | |
36 | | private: |
37 | | explicit AccessibilityTreeNode(JS::GCPtr<DOM::Node const>); |
38 | | |
39 | | JS::GCPtr<DOM::Node const> m_value; |
40 | | Vector<JS::GCPtr<AccessibilityTreeNode>> m_children; |
41 | | }; |
42 | | |
43 | | } |