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

Unified Diff: Source/core/editing/EditingUtilities.cpp

Issue 1316063002: Introduce firstEditablePositionAfterPositionInRoot() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-26T17:01:44 Created 5 years, 4 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/editing/EditingUtilities.cpp
diff --git a/Source/core/editing/EditingUtilities.cpp b/Source/core/editing/EditingUtilities.cpp
index bd66ce3e735e63ea449b5cd882471fcbd91410e0..4966214d2a07bc5a6b22587e50ebdb464a2b4cf8 100644
--- a/Source/core/editing/EditingUtilities.cpp
+++ b/Source/core/editing/EditingUtilities.cpp
@@ -454,27 +454,43 @@ PositionInComposedTree previousVisuallyDistinctCandidate(const PositionInCompose
VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot)
{
+ return VisiblePosition(firstEditablePositionAfterPositionInRoot(position, highestRoot));
+}
+
+template <typename Strategy>
+PositionAlgorithm<Strategy> firstEditablePositionAfterPositionInRootAlgorithm(const PositionAlgorithm<Strategy>& position, Node* highestRoot)
+{
// position falls before highestRoot.
- if (comparePositions(position, firstPositionInNode(highestRoot)) == -1 && highestRoot->hasEditableStyle())
- return VisiblePosition(firstPositionInNode(highestRoot));
+ if (position.compareTo(PositionAlgorithm<Strategy>::firstPositionInNode(highestRoot)) == -1 && highestRoot->hasEditableStyle())
+ return PositionAlgorithm<Strategy>::firstPositionInNode(highestRoot);
- Position editablePosition = position;
+ PositionAlgorithm<Strategy> editablePosition = position;
if (position.anchorNode()->treeScope() != highestRoot->treeScope()) {
Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(editablePosition.anchorNode());
if (!shadowAncestor)
- return VisiblePosition();
+ return PositionAlgorithm<Strategy>();
- editablePosition = positionAfterNode(shadowAncestor);
+ editablePosition = PositionAlgorithm<Strategy>::afterNode(shadowAncestor);
}
while (editablePosition.anchorNode() && !isEditablePosition(editablePosition) && editablePosition.anchorNode()->isDescendantOf(highestRoot))
- editablePosition = isAtomicNode(editablePosition.anchorNode()) ? positionInParentAfterNode(*editablePosition.anchorNode()) : nextVisuallyDistinctCandidate(editablePosition);
+ editablePosition = isAtomicNode(editablePosition.anchorNode()) ? PositionAlgorithm<Strategy>::inParentAfterNode(*editablePosition.anchorNode()) : nextVisuallyDistinctCandidate(editablePosition);
if (editablePosition.anchorNode() && editablePosition.anchorNode() != highestRoot && !editablePosition.anchorNode()->isDescendantOf(highestRoot))
- return VisiblePosition();
+ return PositionAlgorithm<Strategy>();
- return VisiblePosition(editablePosition);
+ return editablePosition;
+}
+
+Position firstEditablePositionAfterPositionInRoot(const Position& position, Node* highestRoot)
+{
+ return firstEditablePositionAfterPositionInRootAlgorithm<EditingStrategy>(position, highestRoot);
+}
+
+PositionInComposedTree firstEditablePositionAfterPositionInRoot(const PositionInComposedTree& position, Node* highestRoot)
+{
+ return firstEditablePositionAfterPositionInRootAlgorithm<EditingInComposedTreeStrategy>(position, highestRoot);
}
VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position& position, ContainerNode* highestRoot)

Powered by Google App Engine
This is Rietveld 408576698