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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2574773002: Migrate WTF::Vector::append() to ::push_back() [part 4 of N] (Closed)
Patch Set: rebase 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 if (!start1 || !start2) { 1359 if (!start1 || !start2) {
1360 unsigned short direction = (this > otherNode) ? kDocumentPositionPreceding 1360 unsigned short direction = (this > otherNode) ? kDocumentPositionPreceding
1361 : kDocumentPositionFollowing; 1361 : kDocumentPositionFollowing;
1362 return kDocumentPositionDisconnected | 1362 return kDocumentPositionDisconnected |
1363 kDocumentPositionImplementationSpecific | direction; 1363 kDocumentPositionImplementationSpecific | direction;
1364 } 1364 }
1365 1365
1366 HeapVector<Member<const Node>, 16> chain1; 1366 HeapVector<Member<const Node>, 16> chain1;
1367 HeapVector<Member<const Node>, 16> chain2; 1367 HeapVector<Member<const Node>, 16> chain2;
1368 if (attr1) 1368 if (attr1)
1369 chain1.append(attr1); 1369 chain1.push_back(attr1);
1370 if (attr2) 1370 if (attr2)
1371 chain2.append(attr2); 1371 chain2.push_back(attr2);
1372 1372
1373 if (attr1 && attr2 && start1 == start2 && start1) { 1373 if (attr1 && attr2 && start1 == start2 && start1) {
1374 // We are comparing two attributes on the same node. Crawl our attribute map 1374 // We are comparing two attributes on the same node. Crawl our attribute map
1375 // and see which one we hit first. 1375 // and see which one we hit first.
1376 const Element* owner1 = attr1->ownerElement(); 1376 const Element* owner1 = attr1->ownerElement();
1377 AttributeCollection attributes = owner1->attributes(); 1377 AttributeCollection attributes = owner1->attributes();
1378 for (const Attribute& attr : attributes) { 1378 for (const Attribute& attr : attributes) {
1379 // If neither of the two determining nodes is a child node and nodeType is 1379 // If neither of the two determining nodes is a child node and nodeType is
1380 // the same for both determining nodes, then an implementation-dependent 1380 // the same for both determining nodes, then an implementation-dependent
1381 // order between the determining nodes is returned. This order is stable 1381 // order between the determining nodes is returned. This order is stable
(...skipping 24 matching lines...) Expand all
1406 unsigned short direction = (this > otherNode) ? kDocumentPositionPreceding 1406 unsigned short direction = (this > otherNode) ? kDocumentPositionPreceding
1407 : kDocumentPositionFollowing; 1407 : kDocumentPositionFollowing;
1408 return kDocumentPositionDisconnected | 1408 return kDocumentPositionDisconnected |
1409 kDocumentPositionImplementationSpecific | direction; 1409 kDocumentPositionImplementationSpecific | direction;
1410 } 1410 }
1411 1411
1412 // We need to find a common ancestor container, and then compare the indices 1412 // We need to find a common ancestor container, and then compare the indices
1413 // of the two immediate children. 1413 // of the two immediate children.
1414 const Node* current; 1414 const Node* current;
1415 for (current = start1; current; current = current->parentOrShadowHostNode()) 1415 for (current = start1; current; current = current->parentOrShadowHostNode())
1416 chain1.append(current); 1416 chain1.push_back(current);
1417 for (current = start2; current; current = current->parentOrShadowHostNode()) 1417 for (current = start2; current; current = current->parentOrShadowHostNode())
1418 chain2.append(current); 1418 chain2.push_back(current);
1419 1419
1420 unsigned index1 = chain1.size(); 1420 unsigned index1 = chain1.size();
1421 unsigned index2 = chain2.size(); 1421 unsigned index2 = chain2.size();
1422 1422
1423 // If the two elements don't have a common root, they're not in the same tree. 1423 // If the two elements don't have a common root, they're not in the same tree.
1424 if (chain1[index1 - 1] != chain2[index2 - 1]) { 1424 if (chain1[index1 - 1] != chain2[index2 - 1]) {
1425 unsigned short direction = (this > otherNode) ? kDocumentPositionPreceding 1425 unsigned short direction = (this > otherNode) ? kDocumentPositionPreceding
1426 : kDocumentPositionFollowing; 1426 : kDocumentPositionFollowing;
1427 return kDocumentPositionDisconnected | 1427 return kDocumentPositionDisconnected |
1428 kDocumentPositionImplementationSpecific | direction; 1428 kDocumentPositionImplementationSpecific | direction;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 } 1571 }
1572 1572
1573 String Node::toFlatTreeStringForThis() const { 1573 String Node::toFlatTreeStringForThis() const {
1574 return toMarkedFlatTreeString(this, "*"); 1574 return toMarkedFlatTreeString(this, "*");
1575 } 1575 }
1576 1576
1577 void Node::printNodePathTo(std::ostream& stream) const { 1577 void Node::printNodePathTo(std::ostream& stream) const {
1578 HeapVector<Member<const Node>, 16> chain; 1578 HeapVector<Member<const Node>, 16> chain;
1579 const Node* node = this; 1579 const Node* node = this;
1580 while (node->parentOrShadowHostNode()) { 1580 while (node->parentOrShadowHostNode()) {
1581 chain.append(node); 1581 chain.push_back(node);
1582 node = node->parentOrShadowHostNode(); 1582 node = node->parentOrShadowHostNode();
1583 } 1583 }
1584 for (unsigned index = chain.size(); index > 0; --index) { 1584 for (unsigned index = chain.size(); index > 0; --index) {
1585 const Node* node = chain[index - 1]; 1585 const Node* node = chain[index - 1];
1586 if (node->isShadowRoot()) { 1586 if (node->isShadowRoot()) {
1587 int count = 0; 1587 int count = 0;
1588 for (const ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot(); 1588 for (const ShadowRoot* shadowRoot = toShadowRoot(node)->olderShadowRoot();
1589 shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) 1589 shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
1590 ++count; 1590 ++count;
1591 stream << "/#shadow-root[" << count << "]"; 1591 stream << "/#shadow-root[" << count << "]";
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 2287
2288 StaticNodeList* Node::getDestinationInsertionPoints() { 2288 StaticNodeList* Node::getDestinationInsertionPoints() {
2289 updateDistribution(); 2289 updateDistribution();
2290 HeapVector<Member<InsertionPoint>, 8> insertionPoints; 2290 HeapVector<Member<InsertionPoint>, 8> insertionPoints;
2291 collectDestinationInsertionPoints(*this, insertionPoints); 2291 collectDestinationInsertionPoints(*this, insertionPoints);
2292 HeapVector<Member<Node>> filteredInsertionPoints; 2292 HeapVector<Member<Node>> filteredInsertionPoints;
2293 for (const auto& insertionPoint : insertionPoints) { 2293 for (const auto& insertionPoint : insertionPoints) {
2294 DCHECK(insertionPoint->containingShadowRoot()); 2294 DCHECK(insertionPoint->containingShadowRoot());
2295 if (!insertionPoint->containingShadowRoot()->isOpenOrV0()) 2295 if (!insertionPoint->containingShadowRoot()->isOpenOrV0())
2296 break; 2296 break;
2297 filteredInsertionPoints.append(insertionPoint); 2297 filteredInsertionPoints.push_back(insertionPoint);
2298 } 2298 }
2299 return StaticNodeList::adopt(filteredInsertionPoints); 2299 return StaticNodeList::adopt(filteredInsertionPoints);
2300 } 2300 }
2301 2301
2302 HTMLSlotElement* Node::assignedSlot() const { 2302 HTMLSlotElement* Node::assignedSlot() const {
2303 // assignedSlot doesn't need to call updateDistribution(). 2303 // assignedSlot doesn't need to call updateDistribution().
2304 DCHECK(!isPseudoElement()); 2304 DCHECK(!isPseudoElement());
2305 if (ShadowRoot* root = v1ShadowRootOfParent()) 2305 if (ShadowRoot* root = v1ShadowRootOfParent())
2306 return root->ensureSlotAssignment().findSlot(*this); 2306 return root->ensureSlotAssignment().findSlot(*this);
2307 return nullptr; 2307 return nullptr;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 if (node) { 2542 if (node) {
2543 std::stringstream stream; 2543 std::stringstream stream;
2544 node->printNodePathTo(stream); 2544 node->printNodePathTo(stream);
2545 LOG(INFO) << stream.str(); 2545 LOG(INFO) << stream.str();
2546 } else { 2546 } else {
2547 LOG(INFO) << "Cannot showNodePath for <null>"; 2547 LOG(INFO) << "Cannot showNodePath for <null>";
2548 } 2548 }
2549 } 2549 }
2550 2550
2551 #endif 2551 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/MutationObserver.cpp ('k') | third_party/WebKit/Source/core/dom/NodeRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698