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

Unified Diff: Source/core/dom/shadow/ComposedTreeTraversal.cpp

Issue 1030153002: Add ComposedTreeTraversal::lastWithin/lastWithinOrSelf (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2015-03-26T12:42 hayato's review: Change the argument const and add assertions Created 5 years, 9 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: Source/core/dom/shadow/ComposedTreeTraversal.cpp
diff --git a/Source/core/dom/shadow/ComposedTreeTraversal.cpp b/Source/core/dom/shadow/ComposedTreeTraversal.cpp
index 8966b8faf5431cd71aa70284474b6687d23da9be..b8ce9dcd46bf1155b1b4e1b88e6cb2eb20ff9e38 100644
--- a/Source/core/dom/shadow/ComposedTreeTraversal.cpp
+++ b/Source/core/dom/shadow/ComposedTreeTraversal.cpp
@@ -241,4 +241,20 @@ unsigned ComposedTreeTraversal::countChildren(const Node& node)
return count;
}
+Node* ComposedTreeTraversal::lastWithin(const Node& current)
+{
+ assertPrecondition(current);
+ Node* descendant = lastChild(current);
hayato 2015/03/26 03:48:44 Could you use travrseLastChild instead of lastChil
hajimehoshi 2015/03/26 03:56:11 Done. Besides, renamed |current| to |node| for co
+ for (Node* child = descendant; child; child = lastChild(*child))
+ descendant = child;
+ return descendant;
+}
+
+Node& ComposedTreeTraversal::lastWithinOrSelf(const Node& current)
+{
+ assertPrecondition(current);
+ Node* lastDescendant = ComposedTreeTraversal::lastWithin(current);
+ return lastDescendant ? *lastDescendant : const_cast<Node&>(current);
+}
+
} // namespace
« no previous file with comments | « Source/core/dom/shadow/ComposedTreeTraversal.h ('k') | Source/core/dom/shadow/ComposedTreeTraversalTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698