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

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

Issue 12052069: Merge 140103 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 11 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 | « Source/WebCore/dom/NodeRareData.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) 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 // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here 44 // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
45 // we ensure that the collection cache will be invalidated as needed when th e element is moved back. 45 // we ensure that the collection cache will be invalidated as needed when th e element is moved back.
46 Document* oldDocument = m_oldScope ? m_oldScope->rootNode()->document() : 0; 46 Document* oldDocument = m_oldScope ? m_oldScope->rootNode()->document() : 0;
47 Document* newDocument = m_newScope->rootNode()->document(); 47 Document* newDocument = m_newScope->rootNode()->document();
48 bool willMoveToNewDocument = oldDocument != newDocument; 48 bool willMoveToNewDocument = oldDocument != newDocument;
49 if (oldDocument && willMoveToNewDocument) 49 if (oldDocument && willMoveToNewDocument)
50 oldDocument->incDOMTreeVersion(); 50 oldDocument->incDOMTreeVersion();
51 51
52 for (Node* node = root; node; node = NodeTraversal::next(node, root)) { 52 for (Node* node = root; node; node = NodeTraversal::next(node, root)) {
53 node->setTreeScope(m_newScope); 53 node->setTreeScope(m_newScope);
54 if (node->hasRareData()) { 54 if (willMoveToNewDocument)
55 moveNodeToNewDocument(node, oldDocument, newDocument);
56 else if (node->hasRareData()) {
55 NodeRareData* rareData = node->rareData(); 57 NodeRareData* rareData = node->rareData();
56 if (rareData->nodeLists()) 58 if (rareData->nodeLists())
57 rareData->nodeLists()->adoptTreeScope(oldDocument, newDocument); 59 rareData->nodeLists()->adoptTreeScope();
58 } 60 }
59 61
60 if (willMoveToNewDocument)
61 moveNodeToNewDocument(node, oldDocument, newDocument);
62
63 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s hadow->olderShadowRoot()) { 62 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s hadow->olderShadowRoot()) {
64 shadow->setParentTreeScope(m_newScope); 63 shadow->setParentTreeScope(m_newScope);
65 if (willMoveToNewDocument) 64 if (willMoveToNewDocument)
66 moveTreeToNewDocument(shadow, oldDocument, newDocument); 65 moveTreeToNewDocument(shadow, oldDocument, newDocument);
67 } 66 }
68 } 67 }
69 } 68 }
70 69
71 void TreeScopeAdopter::moveTreeToNewDocument(Node* root, Document* oldDocument, Document* newDocument) const 70 void TreeScopeAdopter::moveTreeToNewDocument(Node* root, Document* oldDocument, Document* newDocument) const
72 { 71 {
(...skipping 13 matching lines...) Expand all
86 ASSERT(!didMoveToNewDocumentWasCalled); 85 ASSERT(!didMoveToNewDocumentWasCalled);
87 ASSERT_UNUSED(oldDocument, oldDocument == oldDocumentDidMoveToNewDocumentWas CalledWith); 86 ASSERT_UNUSED(oldDocument, oldDocument == oldDocumentDidMoveToNewDocumentWas CalledWith);
88 didMoveToNewDocumentWasCalled = true; 87 didMoveToNewDocumentWasCalled = true;
89 } 88 }
90 #endif 89 #endif
91 90
92 inline void TreeScopeAdopter::moveNodeToNewDocument(Node* node, Document* oldDoc ument, Document* newDocument) const 91 inline void TreeScopeAdopter::moveNodeToNewDocument(Node* node, Document* oldDoc ument, Document* newDocument) const
93 { 92 {
94 ASSERT(!node->inDocument() || oldDocument != newDocument); 93 ASSERT(!node->inDocument() || oldDocument != newDocument);
95 94
95 if (node->hasRareData()) {
96 NodeRareData* rareData = node->rareData();
97 if (rareData->nodeLists())
98 rareData->nodeLists()->adoptDocument(oldDocument, newDocument);
99 }
100
96 newDocument->guardRef(); 101 newDocument->guardRef();
97 if (oldDocument) 102 if (oldDocument)
98 oldDocument->moveNodeIteratorsToNewDocument(node, newDocument); 103 oldDocument->moveNodeIteratorsToNewDocument(node, newDocument);
99 104
100 node->setDocument(newDocument); 105 node->setDocument(newDocument);
101 106
102 #ifndef NDEBUG 107 #ifndef NDEBUG
103 didMoveToNewDocumentWasCalled = false; 108 didMoveToNewDocumentWasCalled = false;
104 oldDocumentDidMoveToNewDocumentWasCalledWith = oldDocument; 109 oldDocumentDidMoveToNewDocumentWasCalledWith = oldDocument;
105 #endif 110 #endif
106 111
107 node->didMoveToNewDocument(oldDocument); 112 node->didMoveToNewDocument(oldDocument);
108 ASSERT(didMoveToNewDocumentWasCalled); 113 ASSERT(didMoveToNewDocumentWasCalled);
109 114
110 if (oldDocument) 115 if (oldDocument)
111 oldDocument->guardDeref(); 116 oldDocument->guardDeref();
112 } 117 }
113 118
114 } 119 }
OLDNEW
« no previous file with comments | « Source/WebCore/dom/NodeRareData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698