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

Unified Diff: Source/core/dom/Node.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/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 19b0e0bb2dafaf892c15cce83479b17eb2fff873..8fdeee786c6043a4c3e045666c81a7e887394d20 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -917,16 +917,17 @@ bool Node::containsIncludingShadowDOM(const Node* node) const
return false;
}
-bool Node::containsIncludingHostElements(const Node* node) const
+bool Node::containsIncludingHostElements(const Node& node) const
{
- while (node) {
- if (node == this)
+ const Node* current = &node;
+ do {
+ if (current == this)
return true;
- if (node->isDocumentFragment() && toDocumentFragment(node)->isTemplateContent())
- node = static_cast<const TemplateContentDocumentFragment*>(node)->host();
+ if (current->isDocumentFragment() && toDocumentFragment(current)->isTemplateContent())
+ current = static_cast<const TemplateContentDocumentFragment*>(current)->host();
else
- node = node->parentOrShadowHostNode();
- }
+ current = current->parentOrShadowHostNode();
+ } while (current);
return false;
}

Powered by Google App Engine
This is Rietveld 408576698