Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 2420883002: Revert of Fix FlatTreeTraversal for a slot in a document tree (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 const HeapVector<Member<Node>> HTMLSlotElement::assignedNodesForBinding( 67 const HeapVector<Member<Node>> HTMLSlotElement::assignedNodesForBinding(
68 const AssignedNodesOptions& options) { 68 const AssignedNodesOptions& options) {
69 updateDistribution(); 69 updateDistribution();
70 if (options.hasFlatten() && options.flatten()) 70 if (options.hasFlatten() && options.flatten())
71 return getDistributedNodes(); 71 return getDistributedNodes();
72 return m_assignedNodes; 72 return m_assignedNodes;
73 } 73 }
74 74
75 void HTMLSlotElement::updateDistributedNodesManually() { 75 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() {
76 DCHECK(!supportsDistribution()); 76 DCHECK(!needsDistributionRecalc());
77 if (isInShadowTree())
78 return m_distributedNodes;
79
77 // A slot is unlikely to be used outside of a shadow tree. 80 // A slot is unlikely to be used outside of a shadow tree.
78 // We do not need to optimize this case in most cases. 81 // We do not need to optimize this case in most cases.
79 // TODO(hayato): If this path causes a performance issue, we should move 82 // TODO(hayato): If this path causes a performance issue, we should move
80 // ShadowRoot::m_slotAssignment into TreeScopreRareData-ish and 83 // ShadowRoot::m_slotAssignment into TreeScopreRareData-ish and
81 // update the distribution code so it considers a document tree too. 84 // update the distribution code so it considers a document tree too.
82 clearDistribution(); 85 clearDistribution();
83 Node* child = NodeTraversal::firstChild(*this); 86 Node* child = NodeTraversal::firstChild(*this);
84 while (child) { 87 while (child) {
85 if (!child->isSlotable()) { 88 if (!child->isSlotable()) {
86 child = NodeTraversal::nextSkippingChildren(*child, this); 89 child = NodeTraversal::nextSkippingChildren(*child, this);
87 continue; 90 continue;
88 } 91 }
89 if (isHTMLSlotElement(child)) { 92 if (isHTMLSlotElement(child)) {
90 child = NodeTraversal::next(*child, this); 93 child = NodeTraversal::next(*child, this);
91 } else { 94 } else {
92 m_distributedNodes.append(child); 95 m_distributedNodes.append(child);
93 child = NodeTraversal::nextSkippingChildren(*child, this); 96 child = NodeTraversal::nextSkippingChildren(*child, this);
94 } 97 }
95 } 98 }
96 }
97
98 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() {
99 DCHECK(!needsDistributionRecalc());
100 if (!supportsDistribution())
101 updateDistributedNodesManually();
102 return m_distributedNodes; 99 return m_distributedNodes;
103 } 100 }
104 101
105 void HTMLSlotElement::appendAssignedNode(Node& hostChild) { 102 void HTMLSlotElement::appendAssignedNode(Node& hostChild) {
106 DCHECK(hostChild.isSlotable()); 103 DCHECK(hostChild.isSlotable());
107 m_assignedNodes.append(&hostChild); 104 m_assignedNodes.append(&hostChild);
108 } 105 }
109 106
110 void HTMLSlotElement::resolveDistributedNodes() { 107 void HTMLSlotElement::resolveDistributedNodes() {
111 for (auto& node : m_assignedNodes) { 108 for (auto& node : m_assignedNodes) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 346
350 DEFINE_TRACE(HTMLSlotElement) { 347 DEFINE_TRACE(HTMLSlotElement) {
351 visitor->trace(m_assignedNodes); 348 visitor->trace(m_assignedNodes);
352 visitor->trace(m_distributedNodes); 349 visitor->trace(m_distributedNodes);
353 visitor->trace(m_oldDistributedNodes); 350 visitor->trace(m_oldDistributedNodes);
354 visitor->trace(m_distributedIndices); 351 visitor->trace(m_distributedIndices);
355 HTMLElement::trace(visitor); 352 HTMLElement::trace(visitor);
356 } 353 }
357 354
358 } // namespace blink 355 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698