Commit 38d870ec authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

ContainerNode: Avoid dynamic allocation of HeapVector in ChildrenChange

Bug: 1154667
Change-Id: I65fe8ef14793a65571362b49cc5c7250f43cd30c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567168Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833378}
parent a95b8cc9
......@@ -234,7 +234,7 @@ void CharacterData::DidModifyData(const String& old_data, UpdateSource source) {
this,
previousSibling(),
nextSibling(),
nullptr};
{}};
parentNode()->ChildrenChanged(change);
}
......
......@@ -814,11 +814,8 @@ void ContainerNode::RemoveChildren(SubtreeModificationAction action) {
GetDocument().NodeChildrenWillBeRemoved(*this);
}
HeapVector<Member<Node>>* removed_nodes = nullptr;
if (ChildrenChangedAllChildrenRemovedNeedsList()) {
removed_nodes =
MakeGarbageCollected<HeapVector<Member<Node>>>(CountChildren());
}
HeapVector<Member<Node>> removed_nodes;
const bool children_changed = ChildrenChangedAllChildrenRemovedNeedsList();
{
HTMLFrameOwnerElement::PluginDisposeSuspendScope suspend_plugin_dispose;
TreeOrderedMap::RemoveScope tree_remove_scope;
......@@ -831,8 +828,8 @@ void ContainerNode::RemoveChildren(SubtreeModificationAction action) {
while (Node* child = first_child_) {
RemoveBetween(nullptr, child->nextSibling(), *child);
NotifyNodeRemoved(*child);
if (removed_nodes)
removed_nodes->push_back(child);
if (children_changed)
removed_nodes.push_back(child);
}
}
......@@ -841,7 +838,7 @@ void ContainerNode::RemoveChildren(SubtreeModificationAction action) {
nullptr,
nullptr,
nullptr,
removed_nodes};
std::move(removed_nodes)};
ChildrenChanged(change);
}
......
......@@ -318,7 +318,7 @@ class CORE_EXPORT ContainerNode : public Node {
&node,
unchanged_previous,
unchanged_next,
nullptr};
{}};
return change;
}
......@@ -333,7 +333,7 @@ class CORE_EXPORT ContainerNode : public Node {
&node,
previous_sibling,
next_sibling,
nullptr};
{}};
return change;
}
......@@ -367,9 +367,9 @@ class CORE_EXPORT ContainerNode : public Node {
// - nextSibling of the last inserted node after multiple node insertion.
Node* sibling_after_change = nullptr;
// List of removed nodes for ChildrenChangeType::kAllChildrenRemoved.
// This is available only if ChildrenChangedAllChildrenRemovedNeedsList()
// returns true.
HeapVector<Member<Node>>* removed_nodes;
// Only populated if ChildrenChangedAllChildrenRemovedNeedsList() returns
// true.
HeapVector<Member<Node>> removed_nodes;
};
// Notifies the node that it's list of children have changed (either by adding
......
......@@ -96,8 +96,7 @@ void HTMLOptGroupElement::ChildrenChanged(const ChildrenChange& change) {
if (auto* option = DynamicTo<HTMLOptionElement>(change.sibling_changed))
select->OptionRemoved(*option);
} else if (change.type == ChildrenChangeType::kAllChildrenRemoved) {
DCHECK(change.removed_nodes);
for (Node* node : *change.removed_nodes) {
for (Node* node : change.removed_nodes) {
if (auto* option = DynamicTo<HTMLOptionElement>(node))
select->OptionRemoved(*option);
}
......
......@@ -709,8 +709,7 @@ void HTMLSelectElement::ChildrenChanged(const ChildrenChange& change) {
OptionRemoved(child_option);
}
} else if (change.type == ChildrenChangeType::kAllChildrenRemoved) {
DCHECK(change.removed_nodes);
for (Node* node : *change.removed_nodes) {
for (Node* node : change.removed_nodes) {
if (auto* option = DynamicTo<HTMLOptionElement>(node)) {
OptionRemoved(*option);
} else if (auto* optgroup = DynamicTo<HTMLOptGroupElement>(node)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment