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

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

Issue 54273007: Use more references in ContainerNode code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix crashes Created 7 years, 1 month 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
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 91ccba3bdbc43f447e3c32eefdeb4e6c043bfc44..8d6881ac7f6adad3de2b6018355627de1f6e08bb 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -3008,13 +3008,9 @@ bool Document::childTypeAllowed(NodeType type) const
return false;
}
-bool Document::canReplaceChild(Node* newChild, Node* oldChild)
+bool Document::canReplaceChild(Node& newChild, Node& oldChild)
{
- if (!oldChild)
- // ContainerNode::replaceChild will raise a NotFoundError.
- return true;
-
- if (oldChild->nodeType() == newChild->nodeType())
+ if (oldChild.nodeType() == newChild.nodeType())
return true;
int numDoctypes = 0;
@@ -3039,8 +3035,8 @@ bool Document::canReplaceChild(Node* newChild, Node* oldChild)
}
// Then, see how many doctypes and elements might be added by the new child.
- if (newChild->nodeType() == DOCUMENT_FRAGMENT_NODE) {
- for (Node* c = newChild->firstChild(); c; c = c->nextSibling()) {
+ if (newChild.nodeType() == DOCUMENT_FRAGMENT_NODE) {
+ for (Node* c = newChild.firstChild(); c; c = c->nextSibling()) {
switch (c->nodeType()) {
case ATTRIBUTE_NODE:
case CDATA_SECTION_NODE:
@@ -3063,7 +3059,7 @@ bool Document::canReplaceChild(Node* newChild, Node* oldChild)
}
}
} else {
- switch (newChild->nodeType()) {
+ switch (newChild.nodeType()) {
case ATTRIBUTE_NODE:
case CDATA_SECTION_NODE:
case DOCUMENT_FRAGMENT_NODE:
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Node.h » ('j') | Source/core/dom/Node.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698