| 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 16 matching lines...) Expand all Loading... |
| 27 #include "core/dom/Attr.h" | 27 #include "core/dom/Attr.h" |
| 28 #include "core/dom/NodeRareData.h" | 28 #include "core/dom/NodeRareData.h" |
| 29 #include "core/dom/NodeTraversal.h" | 29 #include "core/dom/NodeTraversal.h" |
| 30 #include "core/dom/shadow/ElementShadow.h" | 30 #include "core/dom/shadow/ElementShadow.h" |
| 31 #include "core/dom/shadow/ShadowRoot.h" | 31 #include "core/dom/shadow/ShadowRoot.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 void TreeScopeAdopter::moveTreeToNewScope(Node& root) const | 35 void TreeScopeAdopter::moveTreeToNewScope(Node& root) const |
| 36 { | 36 { |
| 37 ASSERT(needsScopeChange()); | 37 DCHECK(needsScopeChange()); |
| 38 | 38 |
| 39 #if !ENABLE(OILPAN) | 39 #if !ENABLE(OILPAN) |
| 40 oldScope().guardRef(); | 40 oldScope().guardRef(); |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 // If an element is moved from a document and then eventually back again the
collection cache for | 43 // If an element is moved from a document and then eventually back again the
collection cache for |
| 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 = oldScope().document(); | 47 Document& oldDocument = oldScope().document(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 #if !ENABLE(OILPAN) | 80 #if !ENABLE(OILPAN) |
| 81 oldScope().guardDeref(); | 81 oldScope().guardDeref(); |
| 82 #endif | 82 #endif |
| 83 } | 83 } |
| 84 | 84 |
| 85 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument,
Document& newDocument) const | 85 void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument,
Document& newDocument) const |
| 86 { | 86 { |
| 87 ASSERT(oldDocument != newDocument); | 87 DCHECK_NE(oldDocument, newDocument); |
| 88 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { | 88 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { |
| 89 moveNodeToNewDocument(node, oldDocument, newDocument); | 89 moveNodeToNewDocument(node, oldDocument, newDocument); |
| 90 | 90 |
| 91 if (!node.isElementNode()) | 91 if (!node.isElementNode()) |
| 92 continue; | 92 continue; |
| 93 Element& element = toElement(node); | 93 Element& element = toElement(node); |
| 94 | 94 |
| 95 if (HeapVector<Member<Attr>>* attrs = element.attrNodeList()) { | 95 if (HeapVector<Member<Attr>>* attrs = element.attrNodeList()) { |
| 96 for (const auto& attr : *attrs) | 96 for (const auto& attr : *attrs) |
| 97 moveTreeToNewDocument(*attr, oldDocument, newDocument); | 97 moveTreeToNewDocument(*attr, oldDocument, newDocument); |
| 98 } | 98 } |
| 99 | 99 |
| 100 for (ShadowRoot* shadow = element.youngestShadowRoot(); shadow; shadow =
shadow->olderShadowRoot()) | 100 for (ShadowRoot* shadow = element.youngestShadowRoot(); shadow; shadow =
shadow->olderShadowRoot()) |
| 101 moveTreeToNewDocument(*shadow, oldDocument, newDocument); | 101 moveTreeToNewDocument(*shadow, oldDocument, newDocument); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 #if ENABLE(ASSERT) | 105 #if DCHECK_IS_ON() |
| 106 static bool didMoveToNewDocumentWasCalled = false; | 106 static bool didMoveToNewDocumentWasCalled = false; |
| 107 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; | 107 static Document* oldDocumentDidMoveToNewDocumentWasCalledWith = 0; |
| 108 | 108 |
| 109 void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document& oldDocument
) | 109 void TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(Document& oldDocument
) |
| 110 { | 110 { |
| 111 ASSERT(!didMoveToNewDocumentWasCalled); | 111 DCHECK(!didMoveToNewDocumentWasCalled); |
| 112 ASSERT_UNUSED(oldDocument, oldDocument == oldDocumentDidMoveToNewDocumentWas
CalledWith); | 112 ASSERT_UNUSED(oldDocument, oldDocument == oldDocumentDidMoveToNewDocumentWas
CalledWith); |
| 113 didMoveToNewDocumentWasCalled = true; | 113 didMoveToNewDocumentWasCalled = true; |
| 114 } | 114 } |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 inline void TreeScopeAdopter::updateTreeScope(Node& node) const | 117 inline void TreeScopeAdopter::updateTreeScope(Node& node) const |
| 118 { | 118 { |
| 119 ASSERT(!node.isTreeScope()); | 119 DCHECK(!node.isTreeScope()); |
| 120 ASSERT(node.treeScope() == oldScope()); | 120 DCHECK(node.treeScope() == oldScope()); |
| 121 #if !ENABLE(OILPAN) | 121 #if !ENABLE(OILPAN) |
| 122 newScope().guardRef(); | 122 newScope().guardRef(); |
| 123 oldScope().guardDeref(); | 123 oldScope().guardDeref(); |
| 124 #endif | 124 #endif |
| 125 node.setTreeScope(m_newScope); | 125 node.setTreeScope(m_newScope); |
| 126 } | 126 } |
| 127 | 127 |
| 128 inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDoc
ument, Document& newDocument) const | 128 inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDoc
ument, Document& newDocument) const |
| 129 { | 129 { |
| 130 ASSERT(oldDocument != newDocument); | 130 DCHECK_NE(oldDocument, newDocument); |
| 131 | 131 |
| 132 if (node.hasRareData()) { | 132 if (node.hasRareData()) { |
| 133 NodeRareData* rareData = node.rareData(); | 133 NodeRareData* rareData = node.rareData(); |
| 134 if (rareData->nodeLists()) | 134 if (rareData->nodeLists()) |
| 135 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); | 135 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); |
| 136 } | 136 } |
| 137 | 137 |
| 138 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); | 138 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); |
| 139 | 139 |
| 140 if (node.isShadowRoot()) | 140 if (node.isShadowRoot()) |
| 141 toShadowRoot(node).setDocument(newDocument); | 141 toShadowRoot(node).setDocument(newDocument); |
| 142 | 142 |
| 143 #if ENABLE(ASSERT) | 143 #if DCHECK_IS_ON() |
| 144 didMoveToNewDocumentWasCalled = false; | 144 didMoveToNewDocumentWasCalled = false; |
| 145 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; | 145 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; |
| 146 #endif | 146 #endif |
| 147 | 147 |
| 148 node.didMoveToNewDocument(oldDocument); | 148 node.didMoveToNewDocument(oldDocument); |
| 149 ASSERT(didMoveToNewDocumentWasCalled); | 149 #if DCHECK_IS_ON() |
| 150 DCHECK(didMoveToNewDocumentWasCalled); |
| 151 #endif |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |