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

Unified Diff: Source/core/dom/TreeScopeAdopter.cpp

Issue 112953007: Make TreeScope::documentScope() return a reference and ensure m_documentScope is never NULL (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added FIXMEs Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/TreeScopeAdopter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/TreeScopeAdopter.cpp
diff --git a/Source/core/dom/TreeScopeAdopter.cpp b/Source/core/dom/TreeScopeAdopter.cpp
index 366b4af3fa15f793b06ee6ab9733cfd114fc46f2..d3832629729a537c7eab041b0b7f34d8fb9c74f9 100644
--- a/Source/core/dom/TreeScopeAdopter.cpp
+++ b/Source/core/dom/TreeScopeAdopter.cpp
@@ -44,18 +44,17 @@ void TreeScopeAdopter::moveTreeToNewScope(Node& root) const
// that element may contain stale data as changes made to it will have updated the DOMTreeVersion
// of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
// we ensure that the collection cache will be invalidated as needed when the element is moved back.
- Document* oldDocument = m_oldScope.documentScope();
- ASSERT(oldDocument);
- Document* newDocument = m_newScope.documentScope();
+ Document& oldDocument = m_oldScope.documentScope();
+ Document& newDocument = m_newScope.documentScope();
bool willMoveToNewDocument = oldDocument != newDocument;
if (willMoveToNewDocument)
- oldDocument->incDOMTreeVersion();
+ oldDocument.incDOMTreeVersion();
for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
updateTreeScope(*node);
if (willMoveToNewDocument)
- moveNodeToNewDocument(*node, *oldDocument, newDocument);
+ moveNodeToNewDocument(*node, oldDocument, newDocument);
else if (node->hasRareData()) {
NodeRareData* rareData = node->rareData();
if (rareData->nodeLists())
@@ -74,14 +73,14 @@ void TreeScopeAdopter::moveTreeToNewScope(Node& root) const
for (ShadowRoot* shadow = node->youngestShadowRoot(); shadow; shadow = shadow->olderShadowRoot()) {
shadow->setParentTreeScope(&m_newScope);
if (willMoveToNewDocument)
- moveTreeToNewDocument(*shadow, *oldDocument, newDocument);
+ moveTreeToNewDocument(*shadow, oldDocument, newDocument);
}
}
m_oldScope.guardDeref();
}
-void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument, Document* newDocument) const
+void TreeScopeAdopter::moveTreeToNewDocument(Node& root, Document& oldDocument, Document& newDocument) const
{
for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
moveNodeToNewDocument(*node, oldDocument, newDocument);
@@ -111,17 +110,17 @@ inline void TreeScopeAdopter::updateTreeScope(Node& node) const
node.setTreeScope(&m_newScope);
}
-inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDocument, Document* newDocument) const
+inline void TreeScopeAdopter::moveNodeToNewDocument(Node& node, Document& oldDocument, Document& newDocument) const
{
ASSERT(!node.inDocument() || oldDocument != newDocument);
if (node.hasRareData()) {
NodeRareData* rareData = node.rareData();
if (rareData->nodeLists())
- rareData->nodeLists()->adoptDocument(&oldDocument, newDocument);
+ rareData->nodeLists()->adoptDocument(oldDocument, newDocument);
}
- oldDocument.moveNodeIteratorsToNewDocument(&node, newDocument);
+ oldDocument.moveNodeIteratorsToNewDocument(node, newDocument);
if (node.isShadowRoot())
toShadowRoot(node).setDocumentScope(newDocument);
« no previous file with comments | « Source/core/dom/TreeScopeAdopter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698