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

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

Issue 2583233002: Migrate WTF::Vector::append() to ::push_back() [part 7 of N] (Closed)
Patch Set: Created 4 years 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
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 HeapVector<Member<Node>> distributedNodes; 84 HeapVector<Member<Node>> distributedNodes;
85 Node* child = NodeTraversal::firstChild(*this); 85 Node* child = NodeTraversal::firstChild(*this);
86 while (child) { 86 while (child) {
87 if (!child->isSlotable()) { 87 if (!child->isSlotable()) {
88 child = NodeTraversal::nextSkippingChildren(*child, this); 88 child = NodeTraversal::nextSkippingChildren(*child, this);
89 continue; 89 continue;
90 } 90 }
91 if (isHTMLSlotElement(child)) { 91 if (isHTMLSlotElement(child)) {
92 child = NodeTraversal::next(*child, this); 92 child = NodeTraversal::next(*child, this);
93 } else { 93 } else {
94 distributedNodes.append(child); 94 distributedNodes.push_back(child);
95 child = NodeTraversal::nextSkippingChildren(*child, this); 95 child = NodeTraversal::nextSkippingChildren(*child, this);
96 } 96 }
97 } 97 }
98 return distributedNodes; 98 return distributedNodes;
99 } 99 }
100 100
101 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() { 101 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() {
102 DCHECK(!needsDistributionRecalc()); 102 DCHECK(!needsDistributionRecalc());
103 DCHECK(supportsDistribution() || m_distributedNodes.isEmpty()); 103 DCHECK(supportsDistribution() || m_distributedNodes.isEmpty());
104 return m_distributedNodes; 104 return m_distributedNodes;
105 } 105 }
106 106
107 void HTMLSlotElement::appendAssignedNode(Node& hostChild) { 107 void HTMLSlotElement::appendAssignedNode(Node& hostChild) {
108 DCHECK(hostChild.isSlotable()); 108 DCHECK(hostChild.isSlotable());
109 m_assignedNodes.append(&hostChild); 109 m_assignedNodes.push_back(&hostChild);
110 } 110 }
111 111
112 void HTMLSlotElement::resolveDistributedNodes() { 112 void HTMLSlotElement::resolveDistributedNodes() {
113 for (auto& node : m_assignedNodes) { 113 for (auto& node : m_assignedNodes) {
114 DCHECK(node->isSlotable()); 114 DCHECK(node->isSlotable());
115 if (isHTMLSlotElement(*node)) 115 if (isHTMLSlotElement(*node))
116 appendDistributedNodesFrom(toHTMLSlotElement(*node)); 116 appendDistributedNodesFrom(toHTMLSlotElement(*node));
117 else 117 else
118 appendDistributedNode(*node); 118 appendDistributedNode(*node);
119 119
120 if (isChildOfV1ShadowHost()) 120 if (isChildOfV1ShadowHost())
121 parentElementShadow()->setNeedsDistributionRecalc(); 121 parentElementShadow()->setNeedsDistributionRecalc();
122 } 122 }
123 } 123 }
124 124
125 void HTMLSlotElement::appendDistributedNode(Node& node) { 125 void HTMLSlotElement::appendDistributedNode(Node& node) {
126 size_t size = m_distributedNodes.size(); 126 size_t size = m_distributedNodes.size();
127 m_distributedNodes.append(&node); 127 m_distributedNodes.push_back(&node);
128 m_distributedIndices.set(&node, size); 128 m_distributedIndices.set(&node, size);
129 } 129 }
130 130
131 void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) { 131 void HTMLSlotElement::appendDistributedNodesFrom(const HTMLSlotElement& other) {
132 size_t index = m_distributedNodes.size(); 132 size_t index = m_distributedNodes.size();
133 m_distributedNodes.appendVector(other.m_distributedNodes); 133 m_distributedNodes.appendVector(other.m_distributedNodes);
134 for (const auto& node : other.m_distributedNodes) 134 for (const auto& node : other.m_distributedNodes)
135 m_distributedIndices.set(node.get(), index++); 135 m_distributedIndices.set(node.get(), index++);
136 } 136 }
137 137
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 361
362 DEFINE_TRACE(HTMLSlotElement) { 362 DEFINE_TRACE(HTMLSlotElement) {
363 visitor->trace(m_assignedNodes); 363 visitor->trace(m_assignedNodes);
364 visitor->trace(m_distributedNodes); 364 visitor->trace(m_distributedNodes);
365 visitor->trace(m_oldDistributedNodes); 365 visitor->trace(m_oldDistributedNodes);
366 visitor->trace(m_distributedIndices); 366 visitor->trace(m_distributedIndices);
367 HTMLElement::trace(visitor); 367 HTMLElement::trace(visitor);
368 } 368 }
369 369
370 } // namespace blink 370 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.cpp ('k') | third_party/WebKit/Source/core/html/HTMLTextAreaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698