#include "third_party/blink/renderer/core/dom/container_node.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_get_html_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_get_inner_html_options.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/css/selector_query.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/child_frame_disconnector.h"
#include "third_party/blink/renderer/core/dom/child_list_mutation_scope.h"
#include "third_party/blink/renderer/core/dom/class_collection.h"
#include "third_party/blink/renderer/core/dom/document_part_root.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatch_forbidden_scope.h"
#include "third_party/blink/renderer/core/dom/events/scoped_event_queue.h"
#include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h"
#include "third_party/blink/renderer/core/dom/name_node_list.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_child_removal_tracker.h"
#include "third_party/blink/renderer/core/dom/node_cloning_data.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/node_lists_node_data.h"
#include "third_party/blink/renderer/core/dom/node_rare_data.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/dom/part.h"
#include "third_party/blink/renderer/core/dom/part_root.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/slot_assignment_recalc_forbidden_scope.h"
#include "third_party/blink/renderer/core/dom/static_node_list.h"
#include "third_party/blink/renderer/core/dom/whitespace_attacher.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/events/mutation_event.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/html/forms/html_field_set_element.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/radio_node_list.h"
#include "third_party/blink/renderer/core/html/html_collection.h"
#include "third_party/blink/renderer/core/html/html_dialog_element.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html/html_tag_collection.h"
#include "third_party/blink/renderer/core/html/html_template_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_text_combine.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/timing/soft_navigation_heuristics.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
namespace blink {
static void DispatchChildInsertionEvents(Node&);
static void DispatchChildRemovalEvents(Node&);
namespace {
class DOMTreeMutationDetector { … };
inline bool CheckReferenceChildParent(const Node& parent,
const Node* next,
const Node* old_child,
ExceptionState& exception_state) { … }
}
static inline bool CollectChildrenAndRemoveFromOldParent(
Node& node,
NodeVector& nodes,
ExceptionState& exception_state) { … }
void ContainerNode::ParserTakeAllChildrenFrom(ContainerNode& old_parent) { … }
ContainerNode::~ContainerNode() { … }
DISABLE_CFI_PERF
bool ContainerNode::IsChildTypeAllowed(const Node& child) const { … }
bool ContainerNode::IsHostIncludingInclusiveAncestorOfThis(
const Node& new_child,
ExceptionState& exception_state) const { … }
DISABLE_CFI_PERF
bool ContainerNode::EnsurePreInsertionValidity(
const Node& new_child,
const Node* next,
const Node* old_child,
ExceptionState& exception_state) const { … }
bool ContainerNode::RecheckNodeInsertionStructuralPrereq(
const NodeVector& new_children,
const Node* next,
ExceptionState& exception_state) { … }
template <typename Functor>
void ContainerNode::InsertNodeVector(
const NodeVector& targets,
Node* next,
const Functor& mutator,
NodeVector& post_insertion_notification_targets) { … }
void ContainerNode::DidInsertNodeVector(
const NodeVector& targets,
Node* next,
const NodeVector& post_insertion_notification_targets) { … }
class ContainerNode::AdoptAndInsertBefore { … };
class ContainerNode::AdoptAndAppendChild { … };
Node* ContainerNode::InsertBefore(Node* new_child,
Node* ref_child,
ExceptionState& exception_state) { … }
Node* ContainerNode::InsertBefore(Node* new_child, Node* ref_child) { … }
void ContainerNode::InsertBeforeCommon(Node& next_child, Node& new_child) { … }
void ContainerNode::AppendChildCommon(Node& child) { … }
bool ContainerNode::CheckParserAcceptChild(const Node& new_child) const { … }
void ContainerNode::ParserInsertBefore(Node* new_child, Node& next_child) { … }
Node* ContainerNode::ReplaceChild(Node* new_child,
Node* old_child,
ExceptionState& exception_state) { … }
Node* ContainerNode::ReplaceChild(Node* new_child, Node* old_child) { … }
void ContainerNode::WillRemoveChild(Node& child) { … }
void ContainerNode::WillRemoveChildren() { … }
LayoutBox* ContainerNode::GetLayoutBoxForScrolling() const { … }
bool ContainerNode::IsReadingFlowContainer() const { … }
void ContainerNode::Trace(Visitor* visitor) const { … }
static bool ShouldMergeCombinedTextAfterRemoval(const Node& old_child) { … }
Node* ContainerNode::RemoveChild(Node* old_child,
ExceptionState& exception_state) { … }
Node* ContainerNode::RemoveChild(Node* old_child) { … }
void ContainerNode::RemoveBetween(Node* previous_child,
Node* next_child,
Node& old_child) { … }
void ContainerNode::ParserRemoveChild(Node& old_child) { … }
void ContainerNode::RemoveChildren(SubtreeModificationAction action) { … }
Node* ContainerNode::AppendChild(Node* new_child,
ExceptionState& exception_state) { … }
Node* ContainerNode::AppendChild(Node* new_child) { … }
void ContainerNode::ParserAppendChild(Node* new_child) { … }
void ContainerNode::ParserAppendChildInDocumentFragment(Node* new_child) { … }
void ContainerNode::ParserFinishedBuildingDocumentFragment() { … }
void ContainerNode::NotifyNodeAtEndOfBuildingFragmentTree(
Node& node,
const ChildrenChange& change,
bool may_contain_shadow_roots) { … }
DISABLE_CFI_PERF
void ContainerNode::NotifyNodeInserted(Node& root,
ChildrenChangeSource source) { … }
DISABLE_CFI_PERF
void ContainerNode::NotifyNodeInsertedInternal(
Node& root,
NodeVector& post_insertion_notification_targets) { … }
void ContainerNode::NotifyNodeRemoved(Node& root) { … }
void ContainerNode::RemovedFrom(ContainerNode& insertion_point) { … }
DISABLE_CFI_PERF
void ContainerNode::AttachLayoutTree(AttachContext& context) { … }
void ContainerNode::DetachLayoutTree(bool performing_reattach) { … }
void ContainerNode::ChildrenChanged(const ChildrenChange& change) { … }
bool ContainerNode::ChildrenChangedAllChildrenRemovedNeedsList() const { … }
void ContainerNode::CloneChildNodesFrom(const ContainerNode& node,
NodeCloningData& data) { … }
PhysicalRect ContainerNode::BoundingBox() const { … }
HTMLCollection* ContainerNode::children() { … }
Element* ContainerNode::firstElementChild() { … }
Element* ContainerNode::lastElementChild() { … }
unsigned ContainerNode::childElementCount() { … }
Element* ContainerNode::querySelector(const AtomicString& selectors,
ExceptionState& exception_state) { … }
StaticElementList* ContainerNode::querySelectorAll(
const AtomicString& selectors,
ExceptionState& exception_state) { … }
unsigned ContainerNode::CountChildren() const { … }
bool ContainerNode::HasOnlyText() const { … }
Element* ContainerNode::QuerySelector(const AtomicString& selectors,
ExceptionState& exception_state) { … }
Element* ContainerNode::QuerySelector(const AtomicString& selectors) { … }
StaticElementList* ContainerNode::QuerySelectorAll(
const AtomicString& selectors,
ExceptionState& exception_state) { … }
StaticElementList* ContainerNode::QuerySelectorAll(
const AtomicString& selectors) { … }
static void DispatchChildInsertionEvents(Node& child) { … }
static void DispatchChildRemovalEvents(Node& child) { … }
void ContainerNode::SetRestyleFlag(DynamicRestyleFlags mask) { … }
void ContainerNode::RecalcDescendantStyles(
const StyleRecalcChange change,
const StyleRecalcContext& style_recalc_context) { … }
void ContainerNode::RebuildLayoutTreeForChild(
Node* child,
WhitespaceAttacher& whitespace_attacher) { … }
void ContainerNode::RebuildChildrenLayoutTrees(
WhitespaceAttacher& whitespace_attacher) { … }
void ContainerNode::CheckForSiblingStyleChanges(SiblingCheckType change_type,
Element* changed_element,
Node* node_before_change,
Node* node_after_change) { … }
void ContainerNode::InvalidateNodeListCachesInAncestors(
const QualifiedName* attr_name,
Element* attribute_owner_element,
const ChildrenChange* change) { … }
HTMLCollection* ContainerNode::getElementsByTagName(
const AtomicString& qualified_name) { … }
HTMLCollection* ContainerNode::getElementsByTagNameNS(
const AtomicString& namespace_uri,
const AtomicString& local_name) { … }
NodeList* ContainerNode::getElementsByName(const AtomicString& element_name) { … }
HTMLCollection* ContainerNode::getElementsByClassName(
const AtomicString& class_names) { … }
RadioNodeList* ContainerNode::GetRadioNodeList(const AtomicString& name,
bool only_match_img_elements) { … }
String ContainerNode::FindTextInElementWith(
const AtomicString& substring,
base::FunctionRef<bool(const String&)> validity_checker) const { … }
Element* ContainerNode::getElementById(const AtomicString& id) const { … }
NodeListsNodeData& ContainerNode::EnsureNodeLists() { … }
Element* ContainerNode::GetAutofocusDelegate() const { … }
void ContainerNode::ReplaceChildren(const VectorOf<Node>& nodes,
ExceptionState& exception_state) { … }
void ContainerNode::CheckSoftNavigationHeuristicsTracking(
const Document& document,
Node& inserted_node) { … }
String ContainerNode::getInnerHTML(const GetInnerHTMLOptions* options) const { … }
String ContainerNode::getHTML(const GetHTMLOptions* options,
ExceptionState& exception_state) const { … }
}