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

Unified Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 1642503002: Implement Node.treeRoot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: third_party/WebKit/Source/core/dom/Node.cpp
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index 405626d58eee2af4fcfb56cc1c1df90f662223e0..404c3510122d9af8d674d5bc1c396dea30873d21 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -450,6 +450,15 @@ Node* Node::pseudoAwareLastChild() const
return lastChild();
}
+Node* Node::treeRoot()
+{
+ Node* node = this;
+ while (!isTreeScopeRoot(node)) {
kochi 2016/01/27 09:18:50 style nit: if the loop body is one-liner, you have
kochi 2016/01/27 09:18:50 You can get its treeroot by treeScope().rootNode()
yuzuchan 2016/01/28 06:23:56 Done.
yuzuchan 2016/01/28 06:23:56 Done.
+ node = node->parentNode();
kochi 2016/01/27 09:18:50 This doesn't work for detached tree (i.e. not in d
yuzuchan 2016/01/28 06:23:56 Done.
+ }
+ return node;
+}
+
PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node* refChild, ExceptionState& exceptionState)
{
if (isContainerNode())

Powered by Google App Engine
This is Rietveld 408576698