| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (willMoveToNewDocument) | 75 if (willMoveToNewDocument) |
| 76 moveTreeToNewDocument(*shadow, oldDocument, newDocument); | 76 moveTreeToNewDocument(*shadow, oldDocument, newDocument); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 m_oldScope.guardDeref(); | 80 m_oldScope.guardDeref(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument,
Document& newDocument) const | 83 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument,
Document& newDocument) const |
| 84 { | 84 { |
| 85 ASSERT(oldDocument != newDocument); |
| 85 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { | 86 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { |
| 86 moveNodeToNewDocument(*node, oldDocument, newDocument); | 87 moveNodeToNewDocument(*node, oldDocument, newDocument); |
| 87 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s
hadow->olderShadowRoot()) | 88 for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = s
hadow->olderShadowRoot()) |
| 88 moveTreeToNewDocument(*shadow, oldDocument, newDocument); | 89 moveTreeToNewDocument(*shadow, oldDocument, newDocument); |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 | 92 |
| 92 #ifndef NDEBUG | 93 #ifndef NDEBUG |
| 93 static bool didMoveToNewDocumentWasCalled = false; | 94 static bool didMoveToNewDocumentWasCalled = false; |
| 94 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; | 95 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 105 { | 106 { |
| 106 ASSERT(!node.isTreeScope()); | 107 ASSERT(!node.isTreeScope()); |
| 107 ASSERT(node.treeScope() == m_oldScope); | 108 ASSERT(node.treeScope() == m_oldScope); |
| 108 m_newScope.guardRef(); | 109 m_newScope.guardRef(); |
| 109 m_oldScope.guardDeref(); | 110 m_oldScope.guardDeref(); |
| 110 node.setTreeScope(&m_newScope); | 111 node.setTreeScope(&m_newScope); |
| 111 } | 112 } |
| 112 | 113 |
| 113 inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDoc
ument, Document& newDocument) const | 114 inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDoc
ument, Document& newDocument) const |
| 114 { | 115 { |
| 115 ASSERT(!node.inDocument() || oldDocument != newDocument); | 116 ASSERT(oldDocument != newDocument); |
| 116 | 117 |
| 117 if (node.hasRareData()) { | 118 if (node.hasRareData()) { |
| 118 NodeRareData* rareData = node.rareData(); | 119 NodeRareData* rareData = node.rareData(); |
| 119 if (rareData->nodeLists()) | 120 if (rareData->nodeLists()) |
| 120 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); | 121 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); |
| 121 } | 122 } |
| 122 | 123 |
| 123 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); | 124 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); |
| 124 | 125 |
| 125 if (node.isShadowRoot()) | 126 if (node.isShadowRoot()) |
| 126 toShadowRoot(node).setDocument(newDocument); | 127 toShadowRoot(node).setDocument(newDocument); |
| 127 | 128 |
| 128 #ifndef NDEBUG | 129 #ifndef NDEBUG |
| 129 didMoveToNewDocumentWasCalled = false; | 130 didMoveToNewDocumentWasCalled = false; |
| 130 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; | 131 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; |
| 131 #endif | 132 #endif |
| 132 | 133 |
| 133 node.didMoveToNewDocument(oldDocument); | 134 node.didMoveToNewDocument(oldDocument); |
| 134 ASSERT(didMoveToNewDocumentWasCalled); | 135 ASSERT(didMoveToNewDocumentWasCalled); |
| 135 } | 136 } |
| 136 | 137 |
| 137 } | 138 } |
| OLD | NEW |