 Chromium Code Reviews
 Chromium Code Reviews Issue 2842263004:
  Fix assignedNodes({flatten:true}) to return fallback content in document tree  (Closed)
    
  
    Issue 2842263004:
  Fix assignedNodes({flatten:true}) to return fallback content in document tree  (Closed) 
  | 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..7140661b46caba76b940adb952768b76d59e0d15 100644 | 
| --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp | 
| +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp | 
| @@ -77,10 +77,14 @@ const HeapVector<Member<Node>> HTMLSlotElement::assignedNodesForBinding( | 
| const HeapVector<Member<Node>> | 
| HTMLSlotElement::GetDistributedNodesForBinding() { | 
| DCHECK(!NeedsDistributionRecalc()); | 
| + return GetDistributedNodesWithFallback(); | 
| +} | 
| + | 
| +const HeapVector<Member<Node>> | 
| +HTMLSlotElement::GetDistributedNodesWithFallback() const { | 
| 
hayato
2017/05/16 07:50:07
The concept of DistributedNodes includes Fallback
 | 
| if (SupportsDistribution()) | 
| return distributed_nodes_; | 
| - | 
| - // If a slot does not support distribution, its m_distributedNodes should not | 
| + // 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,12 @@ 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 = | 
| + other.GetDistributedNodesWithFallback(); | 
| + distributed_nodes_.AppendVector(other_distributed_nodes); | 
| + | 
| + for (const auto& node : other_distributed_nodes) | 
| distributed_indices_.Set(node.Get(), index++); | 
| } |