| Index: Source/core/editing/htmlediting.cpp
|
| diff --git a/Source/core/editing/htmlediting.cpp b/Source/core/editing/htmlediting.cpp
|
| index 5931c1f11ca9c7c35860319ffbe13b96b61f26ee..92908f769e5911808fa7392c593488c1fda0fcff 100644
|
| --- a/Source/core/editing/htmlediting.cpp
|
| +++ b/Source/core/editing/htmlediting.cpp
|
| @@ -210,15 +210,22 @@ Element* unsplittableElementForPosition(const Position& p)
|
| return editableRootForPosition(p);
|
| }
|
|
|
| -Position nextCandidate(const Position& position)
|
| +template <typename Strategy>
|
| +typename Strategy::PositionType nextCandidateAlgorithm(const typename Strategy::PositionType& position)
|
| {
|
| - PositionIterator p(position);
|
| + using PositionType = typename Strategy::PositionType;
|
| + typename Strategy::PositionIteratorType p(position);
|
| while (!p.atEnd()) {
|
| p.increment();
|
| if (p.isCandidate())
|
| return p;
|
| }
|
| - return Position();
|
| + return PositionType();
|
| +}
|
| +
|
| +Position nextCandidate(const Position& position)
|
| +{
|
| + return nextCandidateAlgorithm<EditingStrategy>(position);
|
| }
|
|
|
| Position nextVisuallyDistinctCandidate(const Position& position)
|
| @@ -233,27 +240,40 @@ Position nextVisuallyDistinctCandidate(const Position& position)
|
| return Position();
|
| }
|
|
|
| -Position previousCandidate(const Position& position)
|
| +template <typename Strategy>
|
| +typename Strategy::PositionType previousCandidateAlgorithm(const typename Strategy::PositionType& position)
|
| {
|
| - PositionIterator p(position);
|
| + using PositionType = typename Strategy::PositionType;
|
| + typename Strategy::PositionIteratorType p(position);
|
| while (!p.atStart()) {
|
| p.decrement();
|
| if (p.isCandidate())
|
| return p;
|
| }
|
| - return Position();
|
| + return PositionType();
|
| }
|
|
|
| -Position previousVisuallyDistinctCandidate(const Position& position)
|
| +Position previousCandidate(const Position& position)
|
| {
|
| - Position p = position;
|
| - Position downstreamStart = p.downstream();
|
| + return previousCandidateAlgorithm<EditingStrategy>(position);
|
| +}
|
| +
|
| +template <typename PositionType>
|
| +PositionType previousVisuallyDistinctCandidateAlgorithm(const PositionType& position)
|
| +{
|
| + PositionType p = position;
|
| + PositionType downstreamStart = p.downstream();
|
| while (!p.atStartOfTree()) {
|
| p = p.previous(Character);
|
| if (p.isCandidate() && p.downstream() != downstreamStart)
|
| return p;
|
| }
|
| - return Position();
|
| + return PositionType();
|
| +}
|
| +
|
| +Position previousVisuallyDistinctCandidate(const Position& position)
|
| +{
|
| + return previousVisuallyDistinctCandidateAlgorithm<Position>(position);
|
| }
|
|
|
| VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position& position, ContainerNode* highestRoot)
|
| @@ -286,30 +306,36 @@ VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&
|
| return VisiblePosition(lastEditablePositionBeforePositionInRoot(position, highestRoot));
|
| }
|
|
|
| -Position lastEditablePositionBeforePositionInRoot(const Position& position, Node* highestRoot)
|
| +template <typename PositionType>
|
| +PositionType lastEditablePositionBeforePositionInRootAlgorithm(const PositionType& position, Node* highestRoot)
|
| {
|
| // When position falls after highestRoot, the result is easy to compute.
|
| - if (comparePositions(position, lastPositionInNode(highestRoot)) == 1)
|
| - return lastPositionInNode(highestRoot);
|
| + if (position.compareTo(PositionType::lastPositionInNode(highestRoot)) == 1)
|
| + return PositionType::lastPositionInNode(highestRoot);
|
|
|
| - Position editablePosition = position;
|
| + PositionType editablePosition = position;
|
|
|
| if (position.deprecatedNode()->treeScope() != highestRoot->treeScope()) {
|
| Node* shadowAncestor = highestRoot->treeScope().ancestorInThisScope(editablePosition.deprecatedNode());
|
| if (!shadowAncestor)
|
| - return Position();
|
| + return PositionType();
|
|
|
| - editablePosition = firstPositionInOrBeforeNode(shadowAncestor);
|
| + editablePosition = PositionType::firstPositionInOrBeforeNode(shadowAncestor);
|
| }
|
|
|
| while (editablePosition.deprecatedNode() && !isEditablePosition(editablePosition) && editablePosition.deprecatedNode()->isDescendantOf(highestRoot))
|
| - editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? positionInParentBeforeNode(*editablePosition.deprecatedNode()) : previousVisuallyDistinctCandidate(editablePosition);
|
| + editablePosition = isAtomicNode(editablePosition.deprecatedNode()) ? PositionType::inParentBeforeNode(*editablePosition.deprecatedNode()) : previousVisuallyDistinctCandidate(editablePosition);
|
|
|
| if (editablePosition.deprecatedNode() && editablePosition.deprecatedNode() != highestRoot && !editablePosition.deprecatedNode()->isDescendantOf(highestRoot))
|
| - return Position();
|
| + return PositionType();
|
| return editablePosition;
|
| }
|
|
|
| +Position lastEditablePositionBeforePositionInRoot(const Position& position, Node* highestRoot)
|
| +{
|
| + return lastEditablePositionBeforePositionInRootAlgorithm<Position>(position, highestRoot);
|
| +}
|
| +
|
| // FIXME: The method name, comment, and code say three different things here!
|
| // Whether or not content before and after this node will collapse onto the same line as it.
|
| bool isBlock(const Node* node)
|
|
|