forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.h
More file actions
566 lines (445 loc) · 24 KB
/
Copy pathNode.h
File metadata and controls
566 lines (445 loc) · 24 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
/*
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/DistinctNumeric.h>
#include <AK/FlyString.h>
#include <AK/Function.h>
#include <AK/GenericShorthands.h>
#include <AK/RefPtr.h>
#include <AK/TypeCasts.h>
#include <AK/Utf16FlyString.h>
#include <AK/Utf16View.h>
#include <AK/Vector.h>
#include <LibWeb/Bindings/Node.h>
#include <LibWeb/CSS/InvalidationSet.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/DOM/FragmentSerializationMode.h>
#include <LibWeb/DOM/NodeType.h>
#include <LibWeb/DOM/Slottable.h>
#include <LibWeb/DOM/StyleInvalidationReason.h>
#include <LibWeb/Export.h>
#include <LibWeb/InvalidateDisplayList.h>
#include <LibWeb/TraversalDecision.h>
#include <LibWeb/TreeNode.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM {
class Document;
}
namespace Web::CSS {
class StyleScope;
}
namespace Web::DOM {
enum class NameOrDescription {
Name,
Description
};
enum class IsDescendant {
No,
Yes,
};
enum class ShouldComputeRole {
No,
Yes,
};
#define ENUMERATE_SET_NEEDS_LAYOUT_REASONS(X) \
X(CharacterDataReplaceData) \
X(FinalizeACrossDocumentNavigation) \
X(GeneratedContentImageFinishedLoading) \
X(HTMLCanvasElementWidthOrHeightChange) \
X(HTMLImageElementReactToChangesInTheEnvironment) \
X(HTMLImageElementUpdateTheImageData) \
X(HTMLVideoElementNaturalDimensionsChanged) \
X(HTMLVideoElementSetVideoTrack) \
X(KeyframeEffect) \
X(LayoutTreeUpdate) \
X(NavigableSetViewportSize) \
X(SVGGraphicsElementTransformChange) \
X(SVGImageElementFetchTheDocument) \
X(SVGImageFilterFetch) \
X(SVGViewBoxChange) \
X(StyleChange)
enum class SetNeedsLayoutReason {
#define ENUMERATE_SET_NEEDS_LAYOUT_REASON(e) e,
ENUMERATE_SET_NEEDS_LAYOUT_REASONS(ENUMERATE_SET_NEEDS_LAYOUT_REASON)
#undef ENUMERATE_SET_NEEDS_LAYOUT_REASON
};
[[nodiscard]] StringView to_string(SetNeedsLayoutReason);
#define ENUMERATE_SET_NEEDS_LAYOUT_TREE_UPDATE_REASONS(X) \
X(CharacterDataReplaceData) \
X(ElementSetInnerHTML) \
X(ElementSetShadowRoot) \
X(DetailsElementOpenedOrClosed) \
X(HTMLInputElementSrcAttribute) \
X(HTMLOListElementOrdinalValues) \
X(HTMLObjectElementUpdateLayoutAndChildObjects) \
X(KeyframeEffect) \
X(NodeInsertBefore) \
X(NodeInsertBeforeWithDisplayContents) \
X(NodeRemove) \
X(NodeSetTextContent) \
X(None) \
X(ShadowRootSetInnerHTML) \
X(StyleChange)
enum class SetNeedsLayoutTreeUpdateReason {
#define ENUMERATE_SET_NEEDS_LAYOUT_TREE_UPDATE_REASON(e) e,
ENUMERATE_SET_NEEDS_LAYOUT_TREE_UPDATE_REASONS(ENUMERATE_SET_NEEDS_LAYOUT_TREE_UPDATE_REASON)
#undef ENUMERATE_SET_NEEDS_LAYOUT_TREE_UPDATE_REASON
};
[[nodiscard]] StringView to_string(SetNeedsLayoutTreeUpdateReason);
class WEB_API Node : public EventTarget
, public TreeNode<Node> {
WEB_PLATFORM_OBJECT(Node, EventTarget);
public:
static constexpr bool OVERRIDES_FINALIZE = true;
ParentNode* parent_or_shadow_host();
ParentNode const* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); }
Node const* parent_or_shadow_host_node() const;
Element* parent_or_shadow_host_element();
Element const* parent_or_shadow_host_element() const { return const_cast<Node*>(this)->parent_or_shadow_host_element(); }
ParentNode* flat_tree_parent();
ParentNode const* flat_tree_parent() const { return const_cast<Node*>(this)->flat_tree_parent(); }
Element* flat_tree_parent_element();
Element const* flat_tree_parent_element() const { return const_cast<Node*>(this)->flat_tree_parent_element(); }
virtual ~Node();
NodeType type() const { return m_type; }
bool is_element() const { return type() == NodeType::ELEMENT_NODE; }
bool is_text() const { return type() == NodeType::TEXT_NODE || type() == NodeType::CDATA_SECTION_NODE; }
bool is_exclusive_text() const { return type() == NodeType::TEXT_NODE; }
bool is_document() const { return type() == NodeType::DOCUMENT_NODE; }
bool is_document_type() const { return type() == NodeType::DOCUMENT_TYPE_NODE; }
bool is_comment() const { return type() == NodeType::COMMENT_NODE; }
bool is_character_data() const { return first_is_one_of(type(), NodeType::TEXT_NODE, NodeType::COMMENT_NODE, NodeType::CDATA_SECTION_NODE, NodeType::PROCESSING_INSTRUCTION_NODE); }
bool is_document_fragment() const { return type() == NodeType::DOCUMENT_FRAGMENT_NODE; }
bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); }
bool is_slottable() const { return is_element() || is_text() || is_cdata_section(); }
bool is_attribute() const { return type() == NodeType::ATTRIBUTE_NODE; }
bool is_cdata_section() const { return type() == NodeType::CDATA_SECTION_NODE; }
virtual bool is_shadow_root() const { return false; }
virtual bool requires_svg_container() const { return false; }
virtual bool is_svg_container() const { return false; }
virtual bool is_svg_element() const { return false; }
virtual bool is_svg_graphics_element() const { return false; }
virtual bool is_svg_mask_element() const { return false; }
virtual bool is_svg_script_element() const { return false; }
virtual bool is_svg_style_element() const { return false; }
virtual bool is_svg_svg_element() const { return false; }
virtual bool is_svg_switch_element() const { return false; }
virtual bool is_svg_symbol_element() const { return false; }
virtual bool is_svg_use_element() const { return false; }
virtual bool is_svg_view_element() const { return false; }
virtual bool is_svg_a_element() const { return false; }
virtual bool is_svg_g_element() const { return false; }
virtual bool is_svg_foreign_object_element() const { return false; }
virtual bool is_svg_gradient_element() const { return false; }
virtual bool is_svg_pattern_element() const { return false; }
virtual bool is_svg_clip_path_element() const { return false; }
virtual bool is_svg_image_element() const { return false; }
virtual bool is_svg_text_content_element() const { return false; }
bool in_a_document_tree() const;
// NOTE: This is intended for the JS bindings.
u16 node_type() const { return (u16)m_type; }
bool is_editable() const;
bool is_editing_host() const;
bool is_editable_or_editing_host() const { return is_editable() || is_editing_host(); }
GC::Ptr<Node> editing_host();
bool in_editable_subtree() const { return m_in_editable_subtree; }
void recompute_editable_subtree_flag();
virtual bool is_dom_node() const final { return true; }
virtual bool is_html_element() const { return false; }
virtual bool is_html_html_element() const { return false; }
virtual bool is_html_anchor_element() const { return false; }
virtual bool is_html_area_element() const { return false; }
virtual bool is_html_base_element() const { return false; }
virtual bool is_html_body_element() const { return false; }
virtual bool is_html_head_element() const { return false; }
virtual bool is_html_heading_element() const { return false; }
virtual bool is_html_input_element() const { return false; }
virtual bool is_html_link_element() const { return false; }
virtual bool is_html_media_element() const { return false; }
virtual bool is_html_optgroup_element() const { return false; }
virtual bool is_html_option_element() const { return false; }
virtual bool is_html_progress_element() const { return false; }
virtual bool is_html_script_element() const { return false; }
virtual bool is_html_select_element() const { return false; }
virtual bool is_html_style_element() const { return false; }
virtual bool is_html_template_element() const { return false; }
virtual bool is_html_table_element() const { return false; }
virtual bool is_html_table_section_element() const { return false; }
virtual bool is_html_table_row_element() const { return false; }
virtual bool is_html_table_cell_element() const { return false; }
virtual bool is_html_title_element() const { return false; }
virtual bool is_html_br_element() const { return false; }
virtual bool is_html_button_element() const { return false; }
virtual bool is_html_slot_element() const { return false; }
virtual bool is_html_embed_element() const { return false; }
virtual bool is_html_object_element() const { return false; }
virtual bool is_html_canvas_element() const { return false; }
virtual bool is_html_form_element() const { return false; }
virtual bool is_html_image_element() const { return false; }
virtual bool is_html_video_element() const { return false; }
virtual bool is_html_iframe_element() const { return false; }
virtual bool is_html_div_element() const { return false; }
virtual bool is_html_span_element() const { return false; }
virtual bool is_html_textarea_element() const { return false; }
virtual bool is_html_frameset_element() const { return false; }
virtual bool is_html_fieldset_element() const { return false; }
virtual bool is_html_li_element() const { return false; }
virtual bool is_html_menu_element() const { return false; }
virtual bool is_html_olist_element() const { return false; }
virtual bool is_html_ulist_element() const { return false; }
ALWAYS_INLINE bool is_html_ol_ul_menu_element() const
{
return is_html_olist_element() || is_html_ulist_element() || is_html_menu_element();
}
virtual bool is_navigable_container() const { return false; }
virtual bool is_lazy_loading() const { return false; }
WebIDL::ExceptionOr<GC::Ref<Node>> pre_insert(GC::Ref<Node>, GC::Ptr<Node>);
WebIDL::ExceptionOr<GC::Ref<Node>> pre_remove(GC::Ref<Node>);
WebIDL::ExceptionOr<GC::Ref<Node>> append_child(GC::Ref<Node>);
WebIDL::ExceptionOr<GC::Ref<Node>> remove_child(GC::Ref<Node>);
void insert_before(GC::Ref<Node> node, GC::Ptr<Node> child, bool suppress_observers = false);
void remove(bool suppress_observers = false);
void remove_all_children(bool suppress_observers = false);
enum DocumentPosition : u16 {
DOCUMENT_POSITION_EQUAL = 0,
DOCUMENT_POSITION_DISCONNECTED = 1,
DOCUMENT_POSITION_PRECEDING = 2,
DOCUMENT_POSITION_FOLLOWING = 4,
DOCUMENT_POSITION_CONTAINS = 8,
DOCUMENT_POSITION_CONTAINED_BY = 16,
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32,
};
u16 compare_document_position(GC::Ptr<Node> other);
WebIDL::ExceptionOr<GC::Ref<Node>> replace_child(GC::Ref<Node> node, GC::Ref<Node> child);
WebIDL::ExceptionOr<GC::Ref<Node>> clone_node(GC::Ptr<Document> document = nullptr, bool subtree = false, GC::Ptr<Node> parent = nullptr, GC::Ptr<HTML::CustomElementRegistry> fallback_registry = nullptr) const;
WebIDL::ExceptionOr<GC::Ref<Node>> clone_single_node(Document&, GC::Ptr<HTML::CustomElementRegistry> fallback_registry) const;
WebIDL::ExceptionOr<GC::Ref<Node>> clone_node_binding(bool subtree);
WebIDL::ExceptionOr<void> move_node(Node& new_parent, Node* child);
// NOTE: This is intended for the JS bindings.
bool has_child_nodes() const { return has_children(); }
GC::Ref<NodeList> child_nodes();
Vector<GC::Root<Node>> children_as_vector() const;
virtual Utf16FlyString node_name() const = 0;
String base_uri() const;
virtual Optional<Utf16String> alternative_text() const;
Utf16String descendant_text_content() const;
Optional<Utf16String> text_content() const;
WebIDL::ExceptionOr<void> set_text_content(Optional<Utf16String> const&);
WebIDL::ExceptionOr<void> normalize();
Optional<Utf16String> node_value() const;
WebIDL::ExceptionOr<void> set_node_value(Optional<Utf16String> const&);
GC::Ptr<HTML::LocalNavigable> navigable() const;
Document& document() { return *m_document; }
Document const& document() const { return *m_document; }
GC::Ptr<Document> owner_document() const;
HTML::HTMLAnchorElement const* enclosing_link_element() const;
HTML::HTMLElement const* enclosing_html_element() const;
HTML::HTMLElement const* enclosing_html_element_with_attribute(Utf16FlyString const&) const;
Utf16String child_text_content() const;
Node& shadow_including_root();
Node const& shadow_including_root() const
{
return const_cast<Node*>(this)->shadow_including_root();
}
bool is_closed_shadow_hidden_from(Node const&) const;
bool is_connected() const { return m_is_connected; }
void set_is_connected(bool is_connected) { m_is_connected = is_connected; }
bool inside_blocking_wheel_event_handler() const { return m_inside_blocking_wheel_event_handler; }
void update_inside_blocking_wheel_event_handler_state();
void update_inside_blocking_wheel_event_handler_state_for_subtree();
[[nodiscard]] bool is_browsing_context_connected() const;
Node* parent_node() { return parent(); }
Node const* parent_node() const { return parent(); }
GC::Ptr<Element> parent_element();
GC::Ptr<Element const> parent_element() const;
MUST_UPCALL virtual void inserted();
virtual void post_connection();
enum class IsSubtreeRoot : u8 {
No,
Yes,
};
MUST_UPCALL virtual void removed_from(IsSubtreeRoot, Node* old_ancestor, Node& old_root);
MUST_UPCALL virtual void moved_from(IsSubtreeRoot, GC::Ptr<Node> old_ancestor);
struct ChildrenChangedMetadata {
enum class Type {
Inserted,
Removal,
Mutation,
};
Type type {};
GC::Ref<Node> node;
};
// FIXME: It would be good if we could always provide this metadata for use in optimizations.
virtual void children_changed(ChildrenChangedMetadata const&) { }
virtual void adopted_from(Document&) { }
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const { return {}; }
Layout::Node const* layout_node() const;
Layout::Node* layout_node();
Layout::Node const* unsafe_layout_node() const { return m_layout_node.ptr(); }
Layout::Node* unsafe_layout_node() { return m_layout_node.ptr(); }
RefPtr<Painting::Paintable const> paintable_box() const;
RefPtr<Painting::Paintable> paintable_box();
RefPtr<Painting::Paintable const> paintable() const;
RefPtr<Painting::Paintable> paintable();
RefPtr<Painting::Paintable const> unsafe_paintable_box() const;
RefPtr<Painting::Paintable> unsafe_paintable_box();
RefPtr<Painting::Paintable const> unsafe_paintable() const;
RefPtr<Painting::Paintable> unsafe_paintable();
void set_paintable(WeakPtr<Painting::Paintable>);
void clear_paintable();
void set_needs_repaint(InvalidateDisplayList = InvalidateDisplayList::Yes);
void set_needs_layout_update(SetNeedsLayoutReason);
void clear_layout_node_and_paintable(Badge<Document>);
void set_layout_node(Badge<Layout::Node>, Layout::Node&);
void detach_layout_node(Badge<Layout::TreeBuilder>);
virtual bool is_child_allowed(Node const&) const { return true; }
[[nodiscard]] bool needs_layout_tree_update() const { return m_needs_layout_tree_update; }
void set_needs_layout_tree_update(bool, SetNeedsLayoutTreeUpdateReason);
[[nodiscard]] bool child_needs_layout_tree_update() const { return m_child_needs_layout_tree_update; }
void set_child_needs_layout_tree_update(bool b) { m_child_needs_layout_tree_update = b; }
bool needs_style_update() const { return m_needs_style_update; }
void set_needs_style_update(bool);
void set_needs_style_update_internal(bool) { m_needs_style_update = true; }
bool child_needs_style_update() const { return m_child_needs_style_update; }
void set_child_needs_style_update(bool b) { m_child_needs_style_update = b; }
[[nodiscard]] bool entire_subtree_needs_style_update() const { return m_entire_subtree_needs_style_update; }
void set_entire_subtree_needs_style_update(bool b) { m_entire_subtree_needs_style_update = b; }
[[nodiscard]] bool children_may_depend_on_non_inherited_property_inheritance() const { return m_children_may_depend_on_non_inherited_property_inheritance; }
void set_children_may_depend_on_non_inherited_property_inheritance() { m_children_may_depend_on_non_inherited_property_inheritance = true; }
void invalidate_style(StyleInvalidationReason);
void invalidate_style(StyleInvalidationReason, Vector<CSS::InvalidationSet::Property> const&, StyleInvalidationOptions);
CSS::StyleScope& style_scope();
CSS::StyleScope const& style_scope() const { return const_cast<Node*>(this)->style_scope(); }
void for_each_style_scope_which_may_observe_the_node(Function<void(CSS::StyleScope&)> const&);
void set_document(Badge<Document, NamedNodeMap>, Document&);
virtual EventTarget* get_parent(Event const&) override;
template<typename T>
bool fast_is() const = delete;
template<typename T>
T* fast_as() = delete;
template<typename T>
T const* fast_as() const = delete;
enum class ChildrenToExclude : u8 {
None,
Child,
AllChildren,
};
WebIDL::ExceptionOr<void> ensure_pre_insert_validity(JS::Realm&, GC::Ref<Node> node, GC::Ptr<Node> child, ChildrenToExclude children_to_exclude) const;
bool is_host_including_inclusive_ancestor_of(Node const&) const;
bool is_scripting_enabled() const;
bool is_scripting_disabled() const;
// Used for dumping the DOM Tree
void serialize_tree_as_json(JsonObjectSerializer<StringBuilder>&) const;
IterationDecision serialize_child_as_json(JsonArraySerializer<StringBuilder>& children_array, Node const& child) const;
bool is_shadow_including_descendant_of(Node const&) const;
bool is_shadow_including_inclusive_descendant_of(Node const&) const;
bool is_shadow_including_ancestor_of(Node const&) const;
bool is_shadow_including_inclusive_ancestor_of(Node const&) const;
[[nodiscard]] UniqueNodeID unique_id() const { return m_unique_id; }
static Node* from_unique_id(UniqueNodeID);
WebIDL::ExceptionOr<Utf16String> serialize_fragment(HTML::RequireWellFormed, FragmentSerializationMode = FragmentSerializationMode::Inner) const;
WebIDL::ExceptionOr<void> unsafely_set_html(Variant<GC::Ref<Element>, GC::Ref<DocumentFragment>>, Utf16View);
void replace_all(GC::Ptr<Node>);
void string_replace_all(Utf16String);
bool is_same_node(Node const*) const;
bool is_equal_node(Node const*) const;
GC::Ref<Node> get_root_node(Bindings::GetRootNodeOptions const& options = {});
bool is_uninteresting_whitespace_node() const;
String debug_description() const;
size_t length() const;
auto& registered_observer_list() { return m_registered_observer_list; }
auto const& registered_observer_list() const { return m_registered_observer_list; }
void add_registered_observer(RegisteredObserver&);
void queue_mutation_record(FlyString const& type, Optional<Utf16FlyString> const& attribute_name, Optional<Utf16FlyString> const& attribute_namespace, Optional<Utf16String> const& old_value, Vector<GC::Root<Node>> added_nodes, Vector<GC::Root<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling);
// https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant
template<typename Callback>
TraversalDecision for_each_shadow_including_inclusive_descendant(Callback);
// https://dom.spec.whatwg.org/#concept-shadow-including-descendant
template<typename Callback>
TraversalDecision for_each_shadow_including_descendant(Callback);
Slottable as_slottable();
template<typename U, typename Callback>
WebIDL::ExceptionOr<void> for_each_child_of_type_fallible(Callback callback)
{
for (auto* node = first_child(); node; node = node->next_sibling()) {
if (auto* maybe_node_of_type = as_if<U>(node)) {
if (TRY(callback(*maybe_node_of_type)) == IterationDecision::Break)
return {};
}
}
return {};
}
template<typename U>
U const* first_flat_tree_ancestor_of_type() const
{
return const_cast<Node*>(this)->template first_flat_tree_ancestor_of_type<U>();
}
template<typename U>
U* first_flat_tree_ancestor_of_type();
template<typename Predicate>
requires requires(Predicate& predicate, Node const& node) { { predicate(node) } -> ConvertibleTo<bool>; }
Node const* find_in_shadow_including_ancestry(Predicate&& predicate) const
{
for (Node const* it = this; it; it = it->parent_or_shadow_host_node()) {
if (predicate(*it))
return it;
}
return nullptr;
}
ErrorOr<Utf16String> accessible_name(Document const&, ShouldComputeRole = ShouldComputeRole::Yes) const;
ErrorOr<Utf16String> accessible_description(Document const&) const;
Optional<Utf16String> locate_a_namespace(Optional<Utf16String> const& prefix) const;
Optional<Utf16String> lookup_namespace_uri(Optional<Utf16String> prefix) const;
Optional<Utf16String> lookup_prefix(Optional<Utf16String> namespace_) const;
bool is_default_namespace(Optional<Utf16String> namespace_) const;
Vector<Utf16FlyString> get_in_scope_prefixes() const;
bool is_inert() const;
bool has_inclusive_ancestor_with_display_none_ignoring_animations() const;
bool has_inclusive_ancestor_with_event_listener(FlyString const& type) const;
GC::Ptr<ShadowRoot> containing_shadow_root();
GC::Ptr<ShadowRoot const> containing_shadow_root() const
{
return const_cast<Node*>(this)->containing_shadow_root();
}
protected:
Node(JS::Realm&, Document&, NodeType);
Node(Document&, NodeType);
void set_document(Document&);
virtual void visit_edges(Cell::Visitor&) override;
virtual void finalize() override;
virtual size_t external_memory_size() const override;
GC::Ptr<Document> m_document;
WeakPtr<Layout::Node> m_layout_node;
WeakPtr<Painting::Paintable> m_paintable;
NodeType m_type { NodeType::INVALID };
bool m_needs_layout_tree_update { false };
bool m_child_needs_layout_tree_update { false };
bool m_needs_style_update { false };
bool m_child_needs_style_update { false };
bool m_entire_subtree_needs_style_update { false };
bool m_children_may_depend_on_non_inherited_property_inheritance { false };
bool m_in_editable_subtree { false };
bool m_is_connected { false };
bool m_inside_blocking_wheel_event_handler { false };
UniqueNodeID m_unique_id;
// https://dom.spec.whatwg.org/#registered-observer-list
// "Nodes have a strong reference to registered observers in their registered observer list." https://dom.spec.whatwg.org/#garbage-collection
OwnPtr<Vector<GC::Ref<RegisteredObserver>>> m_registered_observer_list;
void build_accessibility_tree(AccessibilityTreeNode& parent);
ErrorOr<Utf16String> name_or_description(NameOrDescription, Document const&, HashTable<UniqueNodeID>&, IsDescendant = IsDescendant::No, ShouldComputeRole = ShouldComputeRole::Yes) const;
private:
void queue_tree_mutation_record(Vector<GC::Root<Node>> added_nodes, Vector<GC::Root<Node>> removed_nodes, Node* previous_sibling, Node* next_sibling);
void live_range_pre_remove();
void insert_before_impl(GC::Ref<Node>, GC::Ptr<Node> child);
void append_child_impl(GC::Ref<Node>);
void remove_child_impl(GC::Ref<Node>);
void clear_layout_node_paintables();
static Optional<Utf16View> first_valid_id(Utf16View, Document const&);
GC::Ptr<NodeList> m_child_nodes;
};
}
template<>
inline bool JS::Object::fast_is<Web::DOM::Node>() const { return is_dom_node(); }