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

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

Issue 1190303002: Introduce Position::nodeAsRangeLastNode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: reviews Created 5 years, 6 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/Position.h ('k') | Source/core/dom/PositionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Position.cpp
diff --git a/Source/core/dom/Position.cpp b/Source/core/dom/Position.cpp
index cbb1e1ed590b43906b54a9ec21e46e5ba0e69d7a..851407716b77748218f4557be5b50b7315d7e118 100644
--- a/Source/core/dom/Position.cpp
+++ b/Source/core/dom/Position.cpp
@@ -320,6 +320,16 @@ Node* PositionAlgorithm<Strategy>::nodeAsRangeFirstNode() const
return Strategy::nextSkippingChildren(*m_anchorNode);
}
+template <typename Strategy>
+Node* PositionAlgorithm<Strategy>::nodeAsRangeLastNode() const
+{
+ if (isNull())
+ return nullptr;
+ if (Node* pastLastNode = nodeAsRangePastLastNode())
+ return Strategy::previous(*pastLastNode);
+ return &Strategy::lastWithinOrSelf(*containerNode());
+}
+
// An implementation of |Range::pastLastNode()|.
template <typename Strategy>
Node* PositionAlgorithm<Strategy>::nodeAsRangePastLastNode() const
« no previous file with comments | « Source/core/dom/Position.h ('k') | Source/core/dom/PositionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698