| 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 12eec94cb5b617d39bc22179f0aaa73672cff0c4..fa0c675f8bd2a84cde0b4047402d49da0dfd8cd8 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
|
| @@ -70,19 +70,25 @@ const HeapVector<Member<Node>> HTMLSlotElement::assignedNodesForBinding(
|
| const AssignedNodesOptions& options) {
|
| UpdateDistribution();
|
| if (options.hasFlatten() && options.flatten())
|
| - return GetDistributedNodesForBinding();
|
| + return GetDistributedNodes();
|
| return assigned_nodes_;
|
| }
|
|
|
| -const HeapVector<Member<Node>>
|
| -HTMLSlotElement::GetDistributedNodesForBinding() {
|
| +const HeapVector<Member<Node>> HTMLSlotElement::GetDistributedNodes() const {
|
| DCHECK(!NeedsDistributionRecalc());
|
| + DCHECK(SupportsDistribution() || distributed_nodes_.IsEmpty());
|
| if (SupportsDistribution())
|
| return distributed_nodes_;
|
| + // If a slot does not support distribution, its distributed_nodes_ is not
|
| + // pre-calculated and empty. Instead, return fallback content for this slot.
|
| + // This happens only in a slot in non-shadow trees, so its assigned nodes
|
| + // are always empty.
|
| + return GetFallbackContent();
|
| +}
|
|
|
| - // If a slot does not support distribution, its m_distributedNodes 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.
|
| +const HeapVector<Member<Node>>
|
| +HTMLSlotElement::GetFallbackContent() const {
|
| + DCHECK(!SupportsDistribution() && distributed_nodes_.IsEmpty());
|
| HeapVector<Member<Node>> distributed_nodes;
|
| Node* child = NodeTraversal::FirstChild(*this);
|
| while (child) {
|
| @@ -100,12 +106,6 @@ HTMLSlotElement::GetDistributedNodesForBinding() {
|
| return distributed_nodes;
|
| }
|
|
|
| -const HeapVector<Member<Node>>& HTMLSlotElement::GetDistributedNodes() {
|
| - DCHECK(!NeedsDistributionRecalc());
|
| - DCHECK(SupportsDistribution() || distributed_nodes_.IsEmpty());
|
| - return distributed_nodes_;
|
| -}
|
| -
|
| void HTMLSlotElement::AppendAssignedNode(Node& host_child) {
|
| DCHECK(host_child.IsSlotable());
|
| assigned_nodes_.push_back(&host_child);
|
| @@ -132,8 +132,11 @@ 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 =
|
| + SupportsDistribution() ? other.distributed_nodes_ :
|
| + other.GetFallbackContent();
|
| + distributed_nodes_.AppendVector(other_distributed_nodes);
|
| + for (const auto& node : other_distributed_nodes)
|
| distributed_indices_.Set(node.Get(), index++);
|
| }
|
|
|
|
|