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 | 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 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 DCHECK(!node.isTreeScope()); | 121 DCHECK(!node.isTreeScope()); |
122 DCHECK(node.treeScope() == oldScope()); | 122 DCHECK(node.treeScope() == oldScope()); |
123 node.setTreeScope(m_newScope); | 123 node.setTreeScope(m_newScope); |
124 } | 124 } |
125 | 125 |
126 inline void TreeScopeAdopter::moveNodeToNewDocument( | 126 inline void TreeScopeAdopter::moveNodeToNewDocument( |
127 Node& node, | 127 Node& node, |
128 Document& oldDocument, | 128 Document& oldDocument, |
129 Document& newDocument) const { | 129 Document& newDocument) const { |
130 DCHECK_NE(oldDocument, newDocument); | 130 DCHECK_NE(oldDocument, newDocument); |
| 131 // Note: at the start of this function, node.document() may already have |
| 132 // changed to match |newDocument|, which is why |oldDocument| is passed in. |
131 | 133 |
132 if (node.hasRareData()) { | 134 if (node.hasRareData()) { |
133 NodeRareData* rareData = node.rareData(); | 135 NodeRareData* rareData = node.rareData(); |
134 if (rareData->nodeLists()) | 136 if (rareData->nodeLists()) |
135 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); | 137 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); |
136 } | 138 } |
137 | 139 |
| 140 node.willMoveToNewDocument(oldDocument, newDocument); |
138 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); | 141 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); |
139 | 142 |
140 if (node.getCustomElementState() == CustomElementState::Custom) { | 143 if (node.getCustomElementState() == CustomElementState::Custom) { |
141 Element& element = toElement(node); | 144 Element& element = toElement(node); |
142 CustomElement::enqueueAdoptedCallback(&element, &oldDocument, &newDocument); | 145 CustomElement::enqueueAdoptedCallback(&element, &oldDocument, &newDocument); |
143 } | 146 } |
144 | 147 |
145 if (node.isShadowRoot()) | 148 if (node.isShadowRoot()) |
146 toShadowRoot(node).setDocument(newDocument); | 149 toShadowRoot(node).setDocument(newDocument); |
147 | 150 |
148 #if DCHECK_IS_ON() | 151 #if DCHECK_IS_ON() |
149 didMoveToNewDocumentWasCalled = false; | 152 didMoveToNewDocumentWasCalled = false; |
150 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; | 153 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; |
151 #endif | 154 #endif |
152 | 155 |
153 node.didMoveToNewDocument(oldDocument); | 156 node.didMoveToNewDocument(oldDocument); |
154 #if DCHECK_IS_ON() | 157 #if DCHECK_IS_ON() |
155 DCHECK(didMoveToNewDocumentWasCalled); | 158 DCHECK(didMoveToNewDocumentWasCalled); |
156 #endif | 159 #endif |
157 } | 160 } |
158 | 161 |
159 } // namespace blink | 162 } // namespace blink |
OLD | NEW |