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

Side by Side Diff: Source/core/dom/TreeScopeAdopter.cpp

Issue 67473002: Have ElementTraversal / NodeTraversal's next() methods take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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 | « Source/core/dom/TreeScope.cpp ('k') | Source/core/dom/VisitedLinkState.cpp » ('j') | 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) 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 r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // that element may contain stale data as changes made to it will have updat ed the DOMTreeVersion 44 // that element may contain stale data as changes made to it will have updat ed the DOMTreeVersion
45 // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here 45 // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
46 // we ensure that the collection cache will be invalidated as needed when th e element is moved back. 46 // we ensure that the collection cache will be invalidated as needed when th e element is moved back.
47 Document* oldDocument = m_oldScope.documentScope(); 47 Document* oldDocument = m_oldScope.documentScope();
48 ASSERT(oldDocument); 48 ASSERT(oldDocument);
49 Document* newDocument = m_newScope.documentScope(); 49 Document* newDocument = m_newScope.documentScope();
50 bool willMoveToNewDocument = oldDocument != newDocument; 50 bool willMoveToNewDocument = oldDocument != newDocument;
51 if (willMoveToNewDocument) 51 if (willMoveToNewDocument)
52 oldDocument->incDOMTreeVersion(); 52 oldDocument->incDOMTreeVersion();
53 53
54 for (Node* node = &root; node; node = NodeTraversal::next(node, &root)) { 54 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
55 updateTreeScope(*node); 55 updateTreeScope(*node);
56 56
57 if (willMoveToNewDocument) 57 if (willMoveToNewDocument)
58 moveNodeToNewDocument(*node, *oldDocument, newDocument); 58 moveNodeToNewDocument(*node, *oldDocument, newDocument);
59 else if (node->hasRareData()) { 59 else if (node->hasRareData()) {
60 NodeRareData* rareData = node->rareData(); 60 NodeRareData* rareData = node->rareData();
61 if (rareData->nodeLists()) 61 if (rareData->nodeLists())
62 rareData->nodeLists()->adoptTreeScope(); 62 rareData->nodeLists()->adoptTreeScope();
63 } 63 }
64 64
(...skipping 11 matching lines...) Expand all
76 if (willMoveToNewDocument) 76 if (willMoveToNewDocument)
77 moveTreeToNewDocument(*shadow, *oldDocument, newDocument); 77 moveTreeToNewDocument(*shadow, *oldDocument, newDocument);
78 } 78 }
79 } 79 }
80 80
81 m_oldScope.guardDeref(); 81 m_oldScope.guardDeref();
82 } 82 }
83 83
84 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument, Document* newDocument) const 84 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument, Document* newDocument) const
85 { 85 {
86 for (Node* node = &root; node; node = NodeTraversal::next(node, &root)) { 86 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
87 moveNodeToNewDocument(*node, oldDocument, newDocument); 87 moveNodeToNewDocument(*node, oldDocument, newDocument);
88 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s hadow->olderShadowRoot()) 88 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s hadow->olderShadowRoot())
89 moveTreeToNewDocument(*shadow, oldDocument, newDocument); 89 moveTreeToNewDocument(*shadow, oldDocument, newDocument);
90 } 90 }
91 } 91 }
92 92
93 #ifndef NDEBUG 93 #ifndef NDEBUG
94 static bool didMoveToNewDocumentWasCalled = false; 94 static bool didMoveToNewDocumentWasCalled = false;
95 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; 95 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0;
96 96
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 #ifndef NDEBUG 129 #ifndef NDEBUG
130 didMoveToNewDocumentWasCalled = false; 130 didMoveToNewDocumentWasCalled = false;
131 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; 131 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument;
132 #endif 132 #endif
133 133
134 node.didMoveToNewDocument(oldDocument); 134 node.didMoveToNewDocument(oldDocument);
135 ASSERT(didMoveToNewDocumentWasCalled); 135 ASSERT(didMoveToNewDocumentWasCalled);
136 } 136 }
137 137
138 } 138 }
OLDNEW
« no previous file with comments | « Source/core/dom/TreeScope.cpp ('k') | Source/core/dom/VisitedLinkState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698