| 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)
|
|
|