Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| index beb514fe4849554b3b0eb6c31fa82de33399386d..54b865689c736d2b9fe23428957452583b2cb41f 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp |
| @@ -79,8 +79,12 @@ HTMLSlotElement::GetDistributedNodesForBinding() { |
| DCHECK(!NeedsDistributionRecalc()); |
| if (SupportsDistribution()) |
| return distributed_nodes_; |
| + return GetDistributedNodesInNonShadowTree(); |
| +} |
| - // If a slot does not support distribution, its m_distributedNodes should not |
| +const HeapVector<Member<Node>> |
| +HTMLSlotElement::GetDistributedNodesInNonShadowTree() const { |
| + // If a slot does not support distribution, its distributed_nodes_ should not |
| // be used. Instead, calculate distribution manually here. This happens only |
| // in a slot in non-shadow trees, so its assigned nodes are always empty. |
| HeapVector<Member<Node>> distributed_nodes; |
| @@ -132,8 +136,13 @@ void HTMLSlotElement::AppendDistributedNode(Node& node) { |
| void HTMLSlotElement::AppendDistributedNodesFrom(const HTMLSlotElement& other) { |
| size_t index = distributed_nodes_.size(); |
| - distributed_nodes_.AppendVector(other.distributed_nodes_); |
| - for (const auto& node : other.distributed_nodes_) |
| + |
| + const HeapVector<Member<Node>>& other_distributed_nodes = |
|
hayato
2017/05/16 04:22:32
Avoid this temporary vector being allocated. It lo
hayato
2017/05/16 04:26:44
Ah, it is a reference, and being used in L145. Ign
kochi
2017/05/16 06:06:21
Acknowledged.
|
| + other.SupportsDistribution() ? other.distributed_nodes_ |
| + : other.GetDistributedNodesInNonShadowTree(); |
|
hayato
2017/05/16 04:22:32
As I mentioned before, I prefer more logical name
kochi
2017/05/16 06:06:21
I thought "InNonShadowTree()" is logical in that i
|
| + distributed_nodes_.AppendVector(other_distributed_nodes); |
| + |
| + for (const auto& node : other_distributed_nodes) |
| distributed_indices_.Set(node.Get(), index++); |
| } |