| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return PositionWithAffinityTemplate<Strategy>(); | 194 return PositionWithAffinityTemplate<Strategy>(); |
| 195 | 195 |
| 196 // Return the last position before |pos| that is in the same editable region | 196 // Return the last position before |pos| that is in the same editable region |
| 197 // as this position | 197 // as this position |
| 198 return lastEditablePositionBeforePositionInRoot(pos.position(), *highestRoot
); | 198 return lastEditablePositionBeforePositionInRoot(pos.position(), *highestRoot
); |
| 199 } | 199 } |
| 200 | 200 |
| 201 template <typename Strategy> | 201 template <typename Strategy> |
| 202 static VisiblePositionTemplate<Strategy> honorEditingBoundaryAtOrBefore(const Vi
siblePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor) | 202 static VisiblePositionTemplate<Strategy> honorEditingBoundaryAtOrBefore(const Vi
siblePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor) |
| 203 { | 203 { |
| 204 return createVisiblePosition(honorEditingBoundaryAtOrBefore(pos.toPositionWi
thAffinity(), anchor)); | 204 return createVisiblePositionDeprecated(honorEditingBoundaryAtOrBefore(pos.to
PositionWithAffinity(), anchor)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 template <typename Strategy> | 207 template <typename Strategy> |
| 208 static VisiblePositionTemplate<Strategy> honorEditingBoundaryAtOrAfter(const Vis
iblePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor) | 208 static VisiblePositionTemplate<Strategy> honorEditingBoundaryAtOrAfter(const Vis
iblePositionTemplate<Strategy>& pos, const PositionTemplate<Strategy>& anchor) |
| 209 { | 209 { |
| 210 if (pos.isNull()) | 210 if (pos.isNull()) |
| 211 return pos; | 211 return pos; |
| 212 | 212 |
| 213 ContainerNode* highestRoot = highestEditableRoot(anchor); | 213 ContainerNode* highestRoot = highestEditableRoot(anchor); |
| 214 | 214 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 309 } |
| 310 return 0; | 310 return 0; |
| 311 } | 311 } |
| 312 | 312 |
| 313 // FIXME: consolidate with code in previousLinePosition. | 313 // FIXME: consolidate with code in previousLinePosition. |
| 314 static Position previousRootInlineBoxCandidatePosition(Node* node, const Visible
Position& visiblePosition, EditableType editableType) | 314 static Position previousRootInlineBoxCandidatePosition(Node* node, const Visible
Position& visiblePosition, EditableType editableType) |
| 315 { | 315 { |
| 316 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent(), editableType); | 316 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent(), editableType); |
| 317 Node* previousNode = previousLeafWithSameEditability(node, editableType); | 317 Node* previousNode = previousLeafWithSameEditability(node, editableType); |
| 318 | 318 |
| 319 while (previousNode && (!previousNode->layoutObject() || inSameLine(createVi
siblePosition(firstPositionInOrBeforeNode(previousNode)), visiblePosition))) | 319 while (previousNode && (!previousNode->layoutObject() || inSameLine(createVi
siblePositionDeprecated(firstPositionInOrBeforeNode(previousNode)), visiblePosit
ion))) |
| 320 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); | 320 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); |
| 321 | 321 |
| 322 while (previousNode && !previousNode->isShadowRoot()) { | 322 while (previousNode && !previousNode->isShadowRoot()) { |
| 323 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita
bleType) != highestRoot) | 323 if (highestEditableRoot(firstPositionInOrBeforeNode(previousNode), edita
bleType) != highestRoot) |
| 324 break; | 324 break; |
| 325 | 325 |
| 326 Position pos = isHTMLBRElement(*previousNode) ? Position::beforeNode(pre
viousNode) : | 326 Position pos = isHTMLBRElement(*previousNode) ? Position::beforeNode(pre
viousNode) : |
| 327 Position::editingPositionOf(previousNode, caretMaxOffset(previousNod
e)); | 327 Position::editingPositionOf(previousNode, caretMaxOffset(previousNod
e)); |
| 328 | 328 |
| 329 if (isVisuallyEquivalentCandidate(pos)) | 329 if (isVisuallyEquivalentCandidate(pos)) |
| 330 return pos; | 330 return pos; |
| 331 | 331 |
| 332 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); | 332 previousNode = previousLeafWithSameEditability(previousNode, editableTyp
e); |
| 333 } | 333 } |
| 334 return Position(); | 334 return Position(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 static Position nextRootInlineBoxCandidatePosition(Node* node, const VisiblePosi
tion& visiblePosition, EditableType editableType) | 337 static Position nextRootInlineBoxCandidatePosition(Node* node, const VisiblePosi
tion& visiblePosition, EditableType editableType) |
| 338 { | 338 { |
| 339 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent(), editableType); | 339 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent(), editableType); |
| 340 Node* nextNode = nextLeafWithSameEditability(node, editableType); | 340 Node* nextNode = nextLeafWithSameEditability(node, editableType); |
| 341 while (nextNode && (!nextNode->layoutObject() || inSameLine(createVisiblePos
ition(firstPositionInOrBeforeNode(nextNode)), visiblePosition))) | 341 while (nextNode && (!nextNode->layoutObject() || inSameLine(createVisiblePos
itionDeprecated(firstPositionInOrBeforeNode(nextNode)), visiblePosition))) |
| 342 nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); | 342 nextNode = nextLeafWithSameEditability(nextNode, ContentIsEditable); |
| 343 | 343 |
| 344 while (nextNode && !nextNode->isShadowRoot()) { | 344 while (nextNode && !nextNode->isShadowRoot()) { |
| 345 if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), editableT
ype) != highestRoot) | 345 if (highestEditableRoot(firstPositionInOrBeforeNode(nextNode), editableT
ype) != highestRoot) |
| 346 break; | 346 break; |
| 347 | 347 |
| 348 Position pos; | 348 Position pos; |
| 349 pos = Position::editingPositionOf(nextNode, caretMinOffset(nextNode)); | 349 pos = Position::editingPositionOf(nextNode, caretMinOffset(nextNode)); |
| 350 | 350 |
| 351 if (isVisuallyEquivalentCandidate(pos)) | 351 if (isVisuallyEquivalentCandidate(pos)) |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (needMoreContext) { | 764 if (needMoreContext) { |
| 765 // The last search returned the beginning of the buffer and asked for | 765 // The last search returned the beginning of the buffer and asked for |
| 766 // more context, but there is no earlier text. Force a search with | 766 // more context, but there is no earlier text. Force a search with |
| 767 // what's available. | 767 // what's available. |
| 768 // TODO(xiaochengh): Do we have to search the whole string? | 768 // TODO(xiaochengh): Do we have to search the whole string? |
| 769 next = searchFunction(string.data(), string.size(), string.size() - suff
ixLength, DontHaveMoreContext, needMoreContext); | 769 next = searchFunction(string.data(), string.size(), string.size() - suff
ixLength, DontHaveMoreContext, needMoreContext); |
| 770 DCHECK(!needMoreContext); | 770 DCHECK(!needMoreContext); |
| 771 } | 771 } |
| 772 | 772 |
| 773 if (!next) | 773 if (!next) |
| 774 return createVisiblePosition(it.atEnd() ? it.startPosition() : pos); | 774 return createVisiblePositionDeprecated(it.atEnd() ? it.startPosition() :
pos); |
| 775 | 775 |
| 776 Node* node = it.startContainer(); | 776 Node* node = it.startContainer(); |
| 777 int boundaryOffset = remainingLength + next; | 777 int boundaryOffset = remainingLength + next; |
| 778 if (node->isTextNode() && boundaryOffset <= node->maxCharacterOffset()) { | 778 if (node->isTextNode() && boundaryOffset <= node->maxCharacterOffset()) { |
| 779 // The next variable contains a usable index into a text node | 779 // The next variable contains a usable index into a text node |
| 780 return createVisiblePosition(PositionTemplate<Strategy>(node, boundaryOf
fset)); | 780 return createVisiblePositionDeprecated(PositionTemplate<Strategy>(node,
boundaryOffset)); |
| 781 } | 781 } |
| 782 | 782 |
| 783 // Use the character iterator to translate the next value into a DOM | 783 // Use the character iterator to translate the next value into a DOM |
| 784 // position. | 784 // position. |
| 785 BackwardsCharacterIteratorAlgorithm<Strategy> charIt(start, end); | 785 BackwardsCharacterIteratorAlgorithm<Strategy> charIt(start, end); |
| 786 charIt.advance(string.size() - suffixLength - next); | 786 charIt.advance(string.size() - suffixLength - next); |
| 787 // TODO(yosin) charIt can get out of shadow host. | 787 // TODO(yosin) charIt can get out of shadow host. |
| 788 return createVisiblePosition(charIt.endPosition()); | 788 return createVisiblePositionDeprecated(charIt.endPosition()); |
| 789 } | 789 } |
| 790 | 790 |
| 791 template <typename Strategy> | 791 template <typename Strategy> |
| 792 static VisiblePositionTemplate<Strategy> nextBoundary(const VisiblePositionTempl
ate<Strategy>& c, BoundarySearchFunction searchFunction) | 792 static VisiblePositionTemplate<Strategy> nextBoundary(const VisiblePositionTempl
ate<Strategy>& c, BoundarySearchFunction searchFunction) |
| 793 { | 793 { |
| 794 PositionTemplate<Strategy> pos = c.deepEquivalent(); | 794 PositionTemplate<Strategy> pos = c.deepEquivalent(); |
| 795 Node* boundary = parentEditingBoundary(pos); | 795 Node* boundary = parentEditingBoundary(pos); |
| 796 if (!boundary) | 796 if (!boundary) |
| 797 return VisiblePositionTemplate<Strategy>(); | 797 return VisiblePositionTemplate<Strategy>(); |
| 798 | 798 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 // Use the character iterator to translate the next value into a DOM | 866 // Use the character iterator to translate the next value into a DOM |
| 867 // position. | 867 // position. |
| 868 CharacterIteratorAlgorithm<Strategy> charIt(searchStart, searchEnd, Text
IteratorEmitsCharactersBetweenAllVisiblePositions); | 868 CharacterIteratorAlgorithm<Strategy> charIt(searchStart, searchEnd, Text
IteratorEmitsCharactersBetweenAllVisiblePositions); |
| 869 charIt.advance(next - prefixLength - 1); | 869 charIt.advance(next - prefixLength - 1); |
| 870 pos = charIt.endPosition(); | 870 pos = charIt.endPosition(); |
| 871 | 871 |
| 872 if (charIt.characterAt(0) == '\n') { | 872 if (charIt.characterAt(0) == '\n') { |
| 873 // TODO(yosin) workaround for collapsed range (where only start | 873 // TODO(yosin) workaround for collapsed range (where only start |
| 874 // position is correct) emitted for some emitted newlines | 874 // position is correct) emitted for some emitted newlines |
| 875 // (see rdar://5192593) | 875 // (see rdar://5192593) |
| 876 const VisiblePositionTemplate<Strategy> visPos = createVisiblePositi
on(pos); | 876 const VisiblePositionTemplate<Strategy> visPos = createVisiblePositi
onDeprecated(pos); |
| 877 if (visPos.deepEquivalent() == createVisiblePosition(charIt.startPos
ition()).deepEquivalent()) { | 877 if (visPos.deepEquivalent() == createVisiblePositionDeprecated(charI
t.startPosition()).deepEquivalent()) { |
| 878 charIt.advance(1); | 878 charIt.advance(1); |
| 879 pos = charIt.startPosition(); | 879 pos = charIt.startPosition(); |
| 880 } | 880 } |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 // generate VisiblePosition, use TextAffinity::Upstream affinity if possible | 884 // generate VisiblePosition, use TextAffinity::Upstream affinity if possible |
| 885 return createVisiblePosition(pos, VP_UPSTREAM_IF_POSSIBLE); | 885 return createVisiblePositionDeprecated(pos, VP_UPSTREAM_IF_POSSIBLE); |
| 886 } | 886 } |
| 887 | 887 |
| 888 // --------- | 888 // --------- |
| 889 | 889 |
| 890 static unsigned startWordBoundary(const UChar* characters, unsigned length, unsi
gned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMor
eContext) | 890 static unsigned startWordBoundary(const UChar* characters, unsigned length, unsi
gned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMor
eContext) |
| 891 { | 891 { |
| 892 TRACE_EVENT0("blink", "startWordBoundary"); | 892 TRACE_EVENT0("blink", "startWordBoundary"); |
| 893 DCHECK(offset); | 893 DCHECK(offset); |
| 894 if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset
)) { | 894 if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset
)) { |
| 895 needMoreContext = true; | 895 needMoreContext = true; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 static PositionInFlatTreeWithAffinity startOfLine(const PositionInFlatTreeWithAf
finity& currentPosition) | 1063 static PositionInFlatTreeWithAffinity startOfLine(const PositionInFlatTreeWithAf
finity& currentPosition) |
| 1064 { | 1064 { |
| 1065 return startOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition); | 1065 return startOfLineAlgorithm<EditingInFlatTreeStrategy>(currentPosition); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 // FIXME: Rename this function to reflect the fact it ignores bidi levels. | 1068 // FIXME: Rename this function to reflect the fact it ignores bidi levels. |
| 1069 VisiblePosition startOfLine(const VisiblePosition& currentPosition) | 1069 VisiblePosition startOfLine(const VisiblePosition& currentPosition) |
| 1070 { | 1070 { |
| 1071 return createVisiblePosition(startOfLine(currentPosition.toPositionWithAffin
ity())); | 1071 return createVisiblePositionDeprecated(startOfLine(currentPosition.toPositio
nWithAffinity())); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 VisiblePositionInFlatTree startOfLine(const VisiblePositionInFlatTree& currentPo
sition) | 1074 VisiblePositionInFlatTree startOfLine(const VisiblePositionInFlatTree& currentPo
sition) |
| 1075 { | 1075 { |
| 1076 return createVisiblePosition(startOfLine(currentPosition.toPositionWithAffin
ity())); | 1076 return createVisiblePositionDeprecated(startOfLine(currentPosition.toPositio
nWithAffinity())); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 template <typename Strategy> | 1079 template <typename Strategy> |
| 1080 static PositionWithAffinityTemplate<Strategy> logicalStartOfLineAlgorithm(const
PositionWithAffinityTemplate<Strategy>& c) | 1080 static PositionWithAffinityTemplate<Strategy> logicalStartOfLineAlgorithm(const
PositionWithAffinityTemplate<Strategy>& c) |
| 1081 { | 1081 { |
| 1082 // TODO: this is the current behavior that might need to be fixed. | 1082 // TODO: this is the current behavior that might need to be fixed. |
| 1083 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. | 1083 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. |
| 1084 PositionWithAffinityTemplate<Strategy> visPos = startPositionForLine(c, UseL
ogicalOrdering); | 1084 PositionWithAffinityTemplate<Strategy> visPos = startPositionForLine(c, UseL
ogicalOrdering); |
| 1085 | 1085 |
| 1086 if (ContainerNode* editableRoot = highestEditableRoot(c.position())) { | 1086 if (ContainerNode* editableRoot = highestEditableRoot(c.position())) { |
| 1087 if (!editableRoot->contains(visPos.position().computeContainerNode())) | 1087 if (!editableRoot->contains(visPos.position().computeContainerNode())) |
| 1088 return PositionWithAffinityTemplate<Strategy>(PositionTemplate<Strat
egy>::firstPositionInNode(editableRoot)); | 1088 return PositionWithAffinityTemplate<Strategy>(PositionTemplate<Strat
egy>::firstPositionInNode(editableRoot)); |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 return honorEditingBoundaryAtOrBefore(visPos, c.position()); | 1091 return honorEditingBoundaryAtOrBefore(visPos, c.position()); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition) | 1094 VisiblePosition logicalStartOfLine(const VisiblePosition& currentPosition) |
| 1095 { | 1095 { |
| 1096 return createVisiblePosition(logicalStartOfLineAlgorithm<EditingStrategy>(cu
rrentPosition.toPositionWithAffinity())); | 1096 return createVisiblePositionDeprecated(logicalStartOfLineAlgorithm<EditingSt
rategy>(currentPosition.toPositionWithAffinity())); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 VisiblePositionInFlatTree logicalStartOfLine(const VisiblePositionInFlatTree& cu
rrentPosition) | 1099 VisiblePositionInFlatTree logicalStartOfLine(const VisiblePositionInFlatTree& cu
rrentPosition) |
| 1100 { | 1100 { |
| 1101 return createVisiblePosition(logicalStartOfLineAlgorithm<EditingInFlatTreeSt
rategy>(currentPosition.toPositionWithAffinity())); | 1101 return createVisiblePositionDeprecated(logicalStartOfLineAlgorithm<EditingIn
FlatTreeStrategy>(currentPosition.toPositionWithAffinity())); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 template <typename Strategy> | 1104 template <typename Strategy> |
| 1105 static VisiblePositionTemplate<Strategy> endPositionForLine(const VisiblePositio
nTemplate<Strategy>& c, LineEndpointComputationMode mode) | 1105 static VisiblePositionTemplate<Strategy> endPositionForLine(const VisiblePositio
nTemplate<Strategy>& c, LineEndpointComputationMode mode) |
| 1106 { | 1106 { |
| 1107 if (c.isNull()) | 1107 if (c.isNull()) |
| 1108 return VisiblePositionTemplate<Strategy>(); | 1108 return VisiblePositionTemplate<Strategy>(); |
| 1109 | 1109 |
| 1110 RootInlineBox* rootBox = RenderedPosition(c).rootBox(); | 1110 RootInlineBox* rootBox = RenderedPosition(c).rootBox(); |
| 1111 if (!rootBox) { | 1111 if (!rootBox) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 } else if (endBox->isInlineTextBox() && endNode->isTextNode()) { | 1146 } else if (endBox->isInlineTextBox() && endNode->isTextNode()) { |
| 1147 InlineTextBox* endTextBox = toInlineTextBox(endBox); | 1147 InlineTextBox* endTextBox = toInlineTextBox(endBox); |
| 1148 int endOffset = endTextBox->start(); | 1148 int endOffset = endTextBox->start(); |
| 1149 if (!endTextBox->isLineBreak()) | 1149 if (!endTextBox->isLineBreak()) |
| 1150 endOffset += endTextBox->len(); | 1150 endOffset += endTextBox->len(); |
| 1151 pos = PositionTemplate<Strategy>(toText(endNode), endOffset); | 1151 pos = PositionTemplate<Strategy>(toText(endNode), endOffset); |
| 1152 } else { | 1152 } else { |
| 1153 pos = PositionTemplate<Strategy>::afterNode(endNode); | 1153 pos = PositionTemplate<Strategy>::afterNode(endNode); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 return createVisiblePosition(pos, VP_UPSTREAM_IF_POSSIBLE); | 1156 return createVisiblePositionDeprecated(pos, VP_UPSTREAM_IF_POSSIBLE); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. | 1159 // TODO(yosin) Rename this function to reflect the fact it ignores bidi levels. |
| 1160 template <typename Strategy> | 1160 template <typename Strategy> |
| 1161 static VisiblePositionTemplate<Strategy> endOfLineAlgorithm(const VisiblePositio
nTemplate<Strategy>& currentPosition) | 1161 static VisiblePositionTemplate<Strategy> endOfLineAlgorithm(const VisiblePositio
nTemplate<Strategy>& currentPosition) |
| 1162 { | 1162 { |
| 1163 // TODO(yosin) this is the current behavior that might need to be fixed. | 1163 // TODO(yosin) this is the current behavior that might need to be fixed. |
| 1164 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. | 1164 // Please refer to https://bugs.webkit.org/show_bug.cgi?id=49107 for detail. |
| 1165 VisiblePositionTemplate<Strategy> visPos = endPositionForLine(currentPositio
n, UseInlineBoxOrdering); | 1165 VisiblePositionTemplate<Strategy> visPos = endPositionForLine(currentPositio
n, UseInlineBoxOrdering); |
| 1166 | 1166 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 // next line. For example, | 1212 // next line. For example, |
| 1213 // <div contenteditable dir="rtl" style="line-break:before-white-space">xyz | 1213 // <div contenteditable dir="rtl" style="line-break:before-white-space">xyz |
| 1214 // a xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz </div> | 1214 // a xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz </div> |
| 1215 // In this case, use the previous position of the computed logical end | 1215 // In this case, use the previous position of the computed logical end |
| 1216 // position. | 1216 // position. |
| 1217 if (!inSameLogicalLine(currentPosition, visPos)) | 1217 if (!inSameLogicalLine(currentPosition, visPos)) |
| 1218 visPos = previousPositionOf(visPos); | 1218 visPos = previousPositionOf(visPos); |
| 1219 | 1219 |
| 1220 if (ContainerNode* editableRoot = highestEditableRoot(currentPosition.deepEq
uivalent())) { | 1220 if (ContainerNode* editableRoot = highestEditableRoot(currentPosition.deepEq
uivalent())) { |
| 1221 if (!editableRoot->contains(visPos.deepEquivalent().computeContainerNode
())) | 1221 if (!editableRoot->contains(visPos.deepEquivalent().computeContainerNode
())) |
| 1222 return createVisiblePosition(PositionTemplate<Strategy>::lastPositio
nInNode(editableRoot)); | 1222 return createVisiblePositionDeprecated(PositionTemplate<Strategy>::l
astPositionInNode(editableRoot)); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 return honorEditingBoundaryAtOrAfter(visPos, currentPosition.deepEquivalent(
)); | 1225 return honorEditingBoundaryAtOrAfter(visPos, currentPosition.deepEquivalent(
)); |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 VisiblePosition logicalEndOfLine(const VisiblePosition& currentPosition) | 1228 VisiblePosition logicalEndOfLine(const VisiblePosition& currentPosition) |
| 1229 { | 1229 { |
| 1230 return logicalEndOfLineAlgorithm<EditingStrategy>(currentPosition); | 1230 return logicalEndOfLineAlgorithm<EditingStrategy>(currentPosition); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 root = box->root().prevRootBox(); | 1355 root = box->root().prevRootBox(); |
| 1356 // We want to skip zero height boxes. | 1356 // We want to skip zero height boxes. |
| 1357 // This could happen in case it is a TrailingFloatsRootInlineBox. | 1357 // This could happen in case it is a TrailingFloatsRootInlineBox. |
| 1358 if (!root || !root->logicalHeight() || !root->firstLeafChild()) | 1358 if (!root || !root->logicalHeight() || !root->firstLeafChild()) |
| 1359 root = 0; | 1359 root = 0; |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 if (!root) { | 1362 if (!root) { |
| 1363 Position position = previousRootInlineBoxCandidatePosition(node, visible
Position, editableType); | 1363 Position position = previousRootInlineBoxCandidatePosition(node, visible
Position, editableType); |
| 1364 if (position.isNotNull()) { | 1364 if (position.isNotNull()) { |
| 1365 RenderedPosition renderedPosition((createVisiblePosition(position)))
; | 1365 RenderedPosition renderedPosition((createVisiblePositionDeprecated(p
osition))); |
| 1366 root = renderedPosition.rootBox(); | 1366 root = renderedPosition.rootBox(); |
| 1367 if (!root) | 1367 if (!root) |
| 1368 return createVisiblePosition(position); | 1368 return createVisiblePositionDeprecated(position); |
| 1369 } | 1369 } |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 if (root) { | 1372 if (root) { |
| 1373 // FIXME: Can be wrong for multi-column layout and with transforms. | 1373 // FIXME: Can be wrong for multi-column layout and with transforms. |
| 1374 LayoutPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(
root, lineDirectionPoint); | 1374 LayoutPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(
root, lineDirectionPoint); |
| 1375 LineLayoutItem lineLayoutItem = root->closestLeafChildForPoint(pointInLi
ne, isEditablePosition(p))->getLineLayoutItem(); | 1375 LineLayoutItem lineLayoutItem = root->closestLeafChildForPoint(pointInLi
ne, isEditablePosition(p))->getLineLayoutItem(); |
| 1376 Node* node = lineLayoutItem.node(); | 1376 Node* node = lineLayoutItem.node(); |
| 1377 if (node && editingIgnoresContent(node)) | 1377 if (node && editingIgnoresContent(node)) |
| 1378 return VisiblePosition::inParentBeforeNode(*node); | 1378 return VisiblePosition::inParentBeforeNode(*node); |
| 1379 return createVisiblePosition(lineLayoutItem.positionForPoint(pointInLine
)); | 1379 return createVisiblePositionDeprecated(lineLayoutItem.positionForPoint(p
ointInLine)); |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 // Could not find a previous line. This means we must already be on the firs
t line. | 1382 // Could not find a previous line. This means we must already be on the firs
t line. |
| 1383 // Move to the start of the content in this block, which effectively moves u
s | 1383 // Move to the start of the content in this block, which effectively moves u
s |
| 1384 // to the start of the line we're on. | 1384 // to the start of the line we're on. |
| 1385 Element* rootElement = hasEditableStyle(*node, editableType) ? rootEditableE
lement(*node, editableType) : node->document().documentElement(); | 1385 Element* rootElement = hasEditableStyle(*node, editableType) ? rootEditableE
lement(*node, editableType) : node->document().documentElement(); |
| 1386 if (!rootElement) | 1386 if (!rootElement) |
| 1387 return VisiblePosition(); | 1387 return VisiblePosition(); |
| 1388 return VisiblePosition::firstPositionInNode(rootElement); | 1388 return VisiblePosition::firstPositionInNode(rootElement); |
| 1389 } | 1389 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1411 if (!root || !root->logicalHeight() || !root->firstLeafChild()) | 1411 if (!root || !root->logicalHeight() || !root->firstLeafChild()) |
| 1412 root = 0; | 1412 root = 0; |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 if (!root) { | 1415 if (!root) { |
| 1416 // FIXME: We need do the same in previousLinePosition. | 1416 // FIXME: We need do the same in previousLinePosition. |
| 1417 Node* child = NodeTraversal::childAt(*node, p.computeEditingOffset()); | 1417 Node* child = NodeTraversal::childAt(*node, p.computeEditingOffset()); |
| 1418 node = child ? child : &NodeTraversal::lastWithinOrSelf(*node); | 1418 node = child ? child : &NodeTraversal::lastWithinOrSelf(*node); |
| 1419 Position position = nextRootInlineBoxCandidatePosition(node, visiblePosi
tion, editableType); | 1419 Position position = nextRootInlineBoxCandidatePosition(node, visiblePosi
tion, editableType); |
| 1420 if (position.isNotNull()) { | 1420 if (position.isNotNull()) { |
| 1421 RenderedPosition renderedPosition((createVisiblePosition(position)))
; | 1421 RenderedPosition renderedPosition((createVisiblePositionDeprecated(p
osition))); |
| 1422 root = renderedPosition.rootBox(); | 1422 root = renderedPosition.rootBox(); |
| 1423 if (!root) | 1423 if (!root) |
| 1424 return createVisiblePosition(position); | 1424 return createVisiblePositionDeprecated(position); |
| 1425 } | 1425 } |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 if (root) { | 1428 if (root) { |
| 1429 // FIXME: Can be wrong for multi-column layout and with transforms. | 1429 // FIXME: Can be wrong for multi-column layout and with transforms. |
| 1430 LayoutPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(
root, lineDirectionPoint); | 1430 LayoutPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(
root, lineDirectionPoint); |
| 1431 LineLayoutItem lineLayoutItem = root->closestLeafChildForPoint(pointInLi
ne, isEditablePosition(p))->getLineLayoutItem(); | 1431 LineLayoutItem lineLayoutItem = root->closestLeafChildForPoint(pointInLi
ne, isEditablePosition(p))->getLineLayoutItem(); |
| 1432 Node* node = lineLayoutItem.node(); | 1432 Node* node = lineLayoutItem.node(); |
| 1433 if (node && editingIgnoresContent(node)) | 1433 if (node && editingIgnoresContent(node)) |
| 1434 return VisiblePosition::inParentBeforeNode(*node); | 1434 return VisiblePosition::inParentBeforeNode(*node); |
| 1435 return createVisiblePosition(lineLayoutItem.positionForPoint(pointInLine
)); | 1435 return createVisiblePositionDeprecated(lineLayoutItem.positionForPoint(p
ointInLine)); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 // Could not find a next line. This means we must already be on the last lin
e. | 1438 // Could not find a next line. This means we must already be on the last lin
e. |
| 1439 // Move to the end of the content in this block, which effectively moves us | 1439 // Move to the end of the content in this block, which effectively moves us |
| 1440 // to the end of the line we're on. | 1440 // to the end of the line we're on. |
| 1441 Element* rootElement = hasEditableStyle(*node, editableType) ? rootEditableE
lement(*node, editableType) : node->document().documentElement(); | 1441 Element* rootElement = hasEditableStyle(*node, editableType) ? rootEditableE
lement(*node, editableType) : node->document().documentElement(); |
| 1442 if (!rootElement) | 1442 if (!rootElement) |
| 1443 return VisiblePosition(); | 1443 return VisiblePosition(); |
| 1444 return VisiblePosition::lastPositionInNode(rootElement); | 1444 return VisiblePosition::lastPositionInNode(rootElement); |
| 1445 } | 1445 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 | 1592 |
| 1593 if (candidateType == PositionAnchorType::OffsetInAnchor) | 1593 if (candidateType == PositionAnchorType::OffsetInAnchor) |
| 1594 return PositionTemplate<Strategy>(candidateNode, candidateOffset); | 1594 return PositionTemplate<Strategy>(candidateNode, candidateOffset); |
| 1595 | 1595 |
| 1596 return PositionTemplate<Strategy>(candidateNode, candidateType); | 1596 return PositionTemplate<Strategy>(candidateNode, candidateType); |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 template <typename Strategy> | 1599 template <typename Strategy> |
| 1600 VisiblePositionTemplate<Strategy> startOfParagraphAlgorithm(const VisiblePositio
nTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule boundaryCrossi
ngRule) | 1600 VisiblePositionTemplate<Strategy> startOfParagraphAlgorithm(const VisiblePositio
nTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule boundaryCrossi
ngRule) |
| 1601 { | 1601 { |
| 1602 return createVisiblePosition(startOfParagraphAlgorithm(visiblePosition.deepE
quivalent(), boundaryCrossingRule)); | 1602 return createVisiblePositionDeprecated(startOfParagraphAlgorithm(visiblePosi
tion.deepEquivalent(), boundaryCrossingRule)); |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
ngRule boundaryCrossingRule) | 1605 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
ngRule boundaryCrossingRule) |
| 1606 { | 1606 { |
| 1607 return startOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule); | 1607 return startOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule); |
| 1608 } | 1608 } |
| 1609 | 1609 |
| 1610 VisiblePositionInFlatTree startOfParagraph(const VisiblePositionInFlatTree& c, E
ditingBoundaryCrossingRule boundaryCrossingRule) | 1610 VisiblePositionInFlatTree startOfParagraph(const VisiblePositionInFlatTree& c, E
ditingBoundaryCrossingRule boundaryCrossingRule) |
| 1611 { | 1611 { |
| 1612 return startOfParagraphAlgorithm<EditingInFlatTreeStrategy>(c, boundaryCross
ingRule); | 1612 return startOfParagraphAlgorithm<EditingInFlatTreeStrategy>(c, boundaryCross
ingRule); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 | 1683 |
| 1684 if (candidateType == PositionAnchorType::OffsetInAnchor) | 1684 if (candidateType == PositionAnchorType::OffsetInAnchor) |
| 1685 return PositionTemplate<Strategy>(candidateNode, candidateOffset); | 1685 return PositionTemplate<Strategy>(candidateNode, candidateOffset); |
| 1686 | 1686 |
| 1687 return PositionTemplate<Strategy>(candidateNode, candidateType); | 1687 return PositionTemplate<Strategy>(candidateNode, candidateType); |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 template <typename Strategy> | 1690 template <typename Strategy> |
| 1691 static VisiblePositionTemplate<Strategy> endOfParagraphAlgorithm(const VisiblePo
sitionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule boundaryC
rossingRule) | 1691 static VisiblePositionTemplate<Strategy> endOfParagraphAlgorithm(const VisiblePo
sitionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule boundaryC
rossingRule) |
| 1692 { | 1692 { |
| 1693 return createVisiblePosition(endOfParagraphAlgorithm(visiblePosition.deepEqu
ivalent(), boundaryCrossingRule)); | 1693 return createVisiblePositionDeprecated(endOfParagraphAlgorithm(visiblePositi
on.deepEquivalent(), boundaryCrossingRule)); |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing
Rule boundaryCrossingRule) | 1696 VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing
Rule boundaryCrossingRule) |
| 1697 { | 1697 { |
| 1698 return endOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule); | 1698 return endOfParagraphAlgorithm<EditingStrategy>(c, boundaryCrossingRule); |
| 1699 } | 1699 } |
| 1700 | 1700 |
| 1701 VisiblePositionInFlatTree endOfParagraph(const VisiblePositionInFlatTree& c, Edi
tingBoundaryCrossingRule boundaryCrossingRule) | 1701 VisiblePositionInFlatTree endOfParagraph(const VisiblePositionInFlatTree& c, Edi
tingBoundaryCrossingRule boundaryCrossingRule) |
| 1702 { | 1702 { |
| 1703 return endOfParagraphAlgorithm<EditingInFlatTreeStrategy>(c, boundaryCrossin
gRule); | 1703 return endOfParagraphAlgorithm<EditingInFlatTreeStrategy>(c, boundaryCrossin
gRule); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 | 1809 |
| 1810 // --------- | 1810 // --------- |
| 1811 | 1811 |
| 1812 template <typename Strategy> | 1812 template <typename Strategy> |
| 1813 static VisiblePositionTemplate<Strategy> startOfDocumentAlgorithm(const VisibleP
ositionTemplate<Strategy>& visiblePosition) | 1813 static VisiblePositionTemplate<Strategy> startOfDocumentAlgorithm(const VisibleP
ositionTemplate<Strategy>& visiblePosition) |
| 1814 { | 1814 { |
| 1815 Node* node = visiblePosition.deepEquivalent().anchorNode(); | 1815 Node* node = visiblePosition.deepEquivalent().anchorNode(); |
| 1816 if (!node || !node->document().documentElement()) | 1816 if (!node || !node->document().documentElement()) |
| 1817 return VisiblePositionTemplate<Strategy>(); | 1817 return VisiblePositionTemplate<Strategy>(); |
| 1818 | 1818 |
| 1819 return createVisiblePosition(PositionTemplate<Strategy>::firstPositionInNode
(node->document().documentElement())); | 1819 return createVisiblePositionDeprecated(PositionTemplate<Strategy>::firstPosi
tionInNode(node->document().documentElement())); |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 VisiblePosition startOfDocument(const VisiblePosition& c) | 1822 VisiblePosition startOfDocument(const VisiblePosition& c) |
| 1823 { | 1823 { |
| 1824 return startOfDocumentAlgorithm<EditingStrategy>(c); | 1824 return startOfDocumentAlgorithm<EditingStrategy>(c); |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 VisiblePositionInFlatTree startOfDocument(const VisiblePositionInFlatTree& c) | 1827 VisiblePositionInFlatTree startOfDocument(const VisiblePositionInFlatTree& c) |
| 1828 { | 1828 { |
| 1829 return startOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); | 1829 return startOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 template <typename Strategy> | 1832 template <typename Strategy> |
| 1833 static VisiblePositionTemplate<Strategy> endOfDocumentAlgorithm(const VisiblePos
itionTemplate<Strategy>& visiblePosition) | 1833 static VisiblePositionTemplate<Strategy> endOfDocumentAlgorithm(const VisiblePos
itionTemplate<Strategy>& visiblePosition) |
| 1834 { | 1834 { |
| 1835 Node* node = visiblePosition.deepEquivalent().anchorNode(); | 1835 Node* node = visiblePosition.deepEquivalent().anchorNode(); |
| 1836 if (!node || !node->document().documentElement()) | 1836 if (!node || !node->document().documentElement()) |
| 1837 return VisiblePositionTemplate<Strategy>(); | 1837 return VisiblePositionTemplate<Strategy>(); |
| 1838 | 1838 |
| 1839 Element* doc = node->document().documentElement(); | 1839 Element* doc = node->document().documentElement(); |
| 1840 return createVisiblePosition(PositionTemplate<Strategy>::lastPositionInNode(
doc)); | 1840 return createVisiblePositionDeprecated(PositionTemplate<Strategy>::lastPosit
ionInNode(doc)); |
| 1841 } | 1841 } |
| 1842 | 1842 |
| 1843 VisiblePosition endOfDocument(const VisiblePosition& c) | 1843 VisiblePosition endOfDocument(const VisiblePosition& c) |
| 1844 { | 1844 { |
| 1845 return endOfDocumentAlgorithm<EditingStrategy>(c); | 1845 return endOfDocumentAlgorithm<EditingStrategy>(c); |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 VisiblePositionInFlatTree endOfDocument(const VisiblePositionInFlatTree& c) | 1848 VisiblePositionInFlatTree endOfDocument(const VisiblePositionInFlatTree& c) |
| 1849 { | 1849 { |
| 1850 return endOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); | 1850 return endOfDocumentAlgorithm<EditingInFlatTreeStrategy>(c); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 return false; | 2238 return false; |
| 2239 } | 2239 } |
| 2240 | 2240 |
| 2241 VisiblePosition visiblePositionForContentsPoint(const IntPoint& contentsPoint, L
ocalFrame* frame) | 2241 VisiblePosition visiblePositionForContentsPoint(const IntPoint& contentsPoint, L
ocalFrame* frame) |
| 2242 { | 2242 { |
| 2243 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; | 2243 HitTestRequest request = HitTestRequest::Move | HitTestRequest::ReadOnly | H
itTestRequest::Active | HitTestRequest::IgnoreClipping; |
| 2244 HitTestResult result(request, contentsPoint); | 2244 HitTestResult result(request, contentsPoint); |
| 2245 frame->document()->layoutViewItem().hitTest(result); | 2245 frame->document()->layoutViewItem().hitTest(result); |
| 2246 | 2246 |
| 2247 if (Node* node = result.innerNode()) | 2247 if (Node* node = result.innerNode()) |
| 2248 return createVisiblePosition(positionRespectingEditingBoundary(frame->se
lection().selection().start(), result.localPoint(), node)); | 2248 return createVisiblePositionDeprecated(positionRespectingEditingBoundary
(frame->selection().selection().start(), result.localPoint(), node)); |
| 2249 return VisiblePosition(); | 2249 return VisiblePosition(); |
| 2250 } | 2250 } |
| 2251 | 2251 |
| 2252 // TODO(yosin): We should use |associatedLayoutObjectOf()| in "VisibleUnits.cpp" | 2252 // TODO(yosin): We should use |associatedLayoutObjectOf()| in "VisibleUnits.cpp" |
| 2253 // where it takes |LayoutObject| from |Position|. | 2253 // where it takes |LayoutObject| from |Position|. |
| 2254 // Note about ::first-letter pseudo-element: | 2254 // Note about ::first-letter pseudo-element: |
| 2255 // When an element has ::first-letter pseudo-element, first letter characters | 2255 // When an element has ::first-letter pseudo-element, first letter characters |
| 2256 // are taken from |Text| node and first letter characters are considered | 2256 // are taken from |Text| node and first letter characters are considered |
| 2257 // as content of <pseudo:first-letter>. | 2257 // as content of <pseudo:first-letter>. |
| 2258 // For following HTML, | 2258 // For following HTML, |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2818 ContainerNode* highestRoot = highestEditableRoot(anchor); | 2818 ContainerNode* highestRoot = highestEditableRoot(anchor); |
| 2819 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); | 2819 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); |
| 2820 | 2820 |
| 2821 // Return |pos| itself if the two are from the very same editable region, | 2821 // Return |pos| itself if the two are from the very same editable region, |
| 2822 // or both are non-editable. | 2822 // or both are non-editable. |
| 2823 if (highestRootOfPos == highestRoot) | 2823 if (highestRootOfPos == highestRoot) |
| 2824 return pos; | 2824 return pos; |
| 2825 | 2825 |
| 2826 // If this is not editable but |pos| has an editable root, skip to the end | 2826 // If this is not editable but |pos| has an editable root, skip to the end |
| 2827 if (!highestRoot && highestRootOfPos) | 2827 if (!highestRoot && highestRootOfPos) |
| 2828 return createVisiblePosition(PositionTemplate<Strategy>(highestRootOfPos
, PositionAnchorType::AfterAnchor).parentAnchoredEquivalent()); | 2828 return createVisiblePositionDeprecated(PositionTemplate<Strategy>(highes
tRootOfPos, PositionAnchorType::AfterAnchor).parentAnchoredEquivalent()); |
| 2829 | 2829 |
| 2830 // That must mean that |pos| is not editable. Return the next position after | 2830 // That must mean that |pos| is not editable. Return the next position after |
| 2831 // |pos| that is in the same editable region as this position | 2831 // |pos| that is in the same editable region as this position |
| 2832 DCHECK(highestRoot); | 2832 DCHECK(highestRoot); |
| 2833 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(),
*highestRoot); | 2833 return firstEditableVisiblePositionAfterPositionInRoot(pos.deepEquivalent(),
*highestRoot); |
| 2834 } | 2834 } |
| 2835 | 2835 |
| 2836 template <typename Strategy> | 2836 template <typename Strategy> |
| 2837 static UChar32 characterAfterAlgorithm(const VisiblePositionTemplate<Strategy>&
visiblePosition) | 2837 static UChar32 characterAfterAlgorithm(const VisiblePositionTemplate<Strategy>&
visiblePosition) |
| 2838 { | 2838 { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3033 } | 3033 } |
| 3034 | 3034 |
| 3035 template <typename Strategy> | 3035 template <typename Strategy> |
| 3036 VisiblePositionTemplate<Strategy> leftPositionOfAlgorithm(const VisiblePositionT
emplate<Strategy>& visiblePosition) | 3036 VisiblePositionTemplate<Strategy> leftPositionOfAlgorithm(const VisiblePositionT
emplate<Strategy>& visiblePosition) |
| 3037 { | 3037 { |
| 3038 const PositionTemplate<Strategy> pos = leftVisuallyDistinctCandidate(visible
Position); | 3038 const PositionTemplate<Strategy> pos = leftVisuallyDistinctCandidate(visible
Position); |
| 3039 // TODO(yosin) Why can't we move left from the last position in a tree? | 3039 // TODO(yosin) Why can't we move left from the last position in a tree? |
| 3040 if (pos.atStartOfTree() || pos.atEndOfTree()) | 3040 if (pos.atStartOfTree() || pos.atEndOfTree()) |
| 3041 return VisiblePositionTemplate<Strategy>(); | 3041 return VisiblePositionTemplate<Strategy>(); |
| 3042 | 3042 |
| 3043 const VisiblePositionTemplate<Strategy> left = createVisiblePosition(pos); | 3043 const VisiblePositionTemplate<Strategy> left = createVisiblePositionDeprecat
ed(pos); |
| 3044 DCHECK_NE(left.deepEquivalent(), visiblePosition.deepEquivalent()); | 3044 DCHECK_NE(left.deepEquivalent(), visiblePosition.deepEquivalent()); |
| 3045 | 3045 |
| 3046 return directionOfEnclosingBlock(left.deepEquivalent()) == LTR ? honorEditin
gBoundaryAtOrBefore(left, visiblePosition.deepEquivalent()) : honorEditingBounda
ryAtOrAfter(left, visiblePosition.deepEquivalent()); | 3046 return directionOfEnclosingBlock(left.deepEquivalent()) == LTR ? honorEditin
gBoundaryAtOrBefore(left, visiblePosition.deepEquivalent()) : honorEditingBounda
ryAtOrAfter(left, visiblePosition.deepEquivalent()); |
| 3047 } | 3047 } |
| 3048 | 3048 |
| 3049 VisiblePosition leftPositionOf(const VisiblePosition& visiblePosition) | 3049 VisiblePosition leftPositionOf(const VisiblePosition& visiblePosition) |
| 3050 { | 3050 { |
| 3051 return leftPositionOfAlgorithm<EditingStrategy>(visiblePosition); | 3051 return leftPositionOfAlgorithm<EditingStrategy>(visiblePosition); |
| 3052 } | 3052 } |
| 3053 | 3053 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3211 } | 3211 } |
| 3212 | 3212 |
| 3213 template <typename Strategy> | 3213 template <typename Strategy> |
| 3214 static VisiblePositionTemplate<Strategy> rightPositionOfAlgorithm(const VisibleP
ositionTemplate<Strategy>& visiblePosition) | 3214 static VisiblePositionTemplate<Strategy> rightPositionOfAlgorithm(const VisibleP
ositionTemplate<Strategy>& visiblePosition) |
| 3215 { | 3215 { |
| 3216 const PositionTemplate<Strategy> pos = rightVisuallyDistinctCandidate(visibl
ePosition); | 3216 const PositionTemplate<Strategy> pos = rightVisuallyDistinctCandidate(visibl
ePosition); |
| 3217 // FIXME: Why can't we move left from the last position in a tree? | 3217 // FIXME: Why can't we move left from the last position in a tree? |
| 3218 if (pos.atStartOfTree() || pos.atEndOfTree()) | 3218 if (pos.atStartOfTree() || pos.atEndOfTree()) |
| 3219 return VisiblePositionTemplate<Strategy>(); | 3219 return VisiblePositionTemplate<Strategy>(); |
| 3220 | 3220 |
| 3221 const VisiblePositionTemplate<Strategy> right = createVisiblePosition(pos); | 3221 const VisiblePositionTemplate<Strategy> right = createVisiblePositionDepreca
ted(pos); |
| 3222 DCHECK_NE(right.deepEquivalent(), visiblePosition.deepEquivalent()); | 3222 DCHECK_NE(right.deepEquivalent(), visiblePosition.deepEquivalent()); |
| 3223 | 3223 |
| 3224 return directionOfEnclosingBlock(right.deepEquivalent()) == LTR ? honorEditi
ngBoundaryAtOrAfter(right, visiblePosition.deepEquivalent()) : honorEditingBound
aryAtOrBefore(right, visiblePosition.deepEquivalent()); | 3224 return directionOfEnclosingBlock(right.deepEquivalent()) == LTR ? honorEditi
ngBoundaryAtOrAfter(right, visiblePosition.deepEquivalent()) : honorEditingBound
aryAtOrBefore(right, visiblePosition.deepEquivalent()); |
| 3225 } | 3225 } |
| 3226 | 3226 |
| 3227 VisiblePosition rightPositionOf(const VisiblePosition& visiblePosition) | 3227 VisiblePosition rightPositionOf(const VisiblePosition& visiblePosition) |
| 3228 { | 3228 { |
| 3229 return rightPositionOfAlgorithm<EditingStrategy>(visiblePosition); | 3229 return rightPositionOfAlgorithm<EditingStrategy>(visiblePosition); |
| 3230 } | 3230 } |
| 3231 | 3231 |
| 3232 VisiblePositionInFlatTree rightPositionOf(const VisiblePositionInFlatTree& visib
lePosition) | 3232 VisiblePositionInFlatTree rightPositionOf(const VisiblePositionInFlatTree& visib
lePosition) |
| 3233 { | 3233 { |
| 3234 return rightPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePosition); | 3234 return rightPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePosition); |
| 3235 } | 3235 } |
| 3236 | 3236 |
| 3237 template <typename Strategy> | 3237 template <typename Strategy> |
| 3238 static VisiblePositionTemplate<Strategy> nextPositionOfAlgorithm(const VisiblePo
sitionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule rule) | 3238 static VisiblePositionTemplate<Strategy> nextPositionOfAlgorithm(const VisiblePo
sitionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule rule) |
| 3239 { | 3239 { |
| 3240 const VisiblePositionTemplate<Strategy> next = createVisiblePosition(nextVis
uallyDistinctCandidate(visiblePosition.deepEquivalent()), visiblePosition.affini
ty()); | 3240 const VisiblePositionTemplate<Strategy> next = createVisiblePositionDeprecat
ed(nextVisuallyDistinctCandidate(visiblePosition.deepEquivalent()), visiblePosit
ion.affinity()); |
| 3241 | 3241 |
| 3242 switch (rule) { | 3242 switch (rule) { |
| 3243 case CanCrossEditingBoundary: | 3243 case CanCrossEditingBoundary: |
| 3244 return next; | 3244 return next; |
| 3245 case CannotCrossEditingBoundary: | 3245 case CannotCrossEditingBoundary: |
| 3246 return honorEditingBoundaryAtOrAfter(next, visiblePosition.deepEquivalen
t()); | 3246 return honorEditingBoundaryAtOrAfter(next, visiblePosition.deepEquivalen
t()); |
| 3247 case CanSkipOverEditingBoundary: | 3247 case CanSkipOverEditingBoundary: |
| 3248 return skipToEndOfEditingBoundary(next, visiblePosition.deepEquivalent()
); | 3248 return skipToEndOfEditingBoundary(next, visiblePosition.deepEquivalent()
); |
| 3249 } | 3249 } |
| 3250 NOTREACHED(); | 3250 NOTREACHED(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3270 ContainerNode* highestRoot = highestEditableRoot(anchor); | 3270 ContainerNode* highestRoot = highestEditableRoot(anchor); |
| 3271 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); | 3271 ContainerNode* highestRootOfPos = highestEditableRoot(pos.deepEquivalent()); |
| 3272 | 3272 |
| 3273 // Return |pos| itself if the two are from the very same editable region, or | 3273 // Return |pos| itself if the two are from the very same editable region, or |
| 3274 // both are non-editable. | 3274 // both are non-editable. |
| 3275 if (highestRootOfPos == highestRoot) | 3275 if (highestRootOfPos == highestRoot) |
| 3276 return pos; | 3276 return pos; |
| 3277 | 3277 |
| 3278 // If this is not editable but |pos| has an editable root, skip to the start | 3278 // If this is not editable but |pos| has an editable root, skip to the start |
| 3279 if (!highestRoot && highestRootOfPos) | 3279 if (!highestRoot && highestRootOfPos) |
| 3280 return createVisiblePosition(previousVisuallyDistinctCandidate(PositionT
emplate<Strategy>(highestRootOfPos, PositionAnchorType::BeforeAnchor).parentAnch
oredEquivalent())); | 3280 return createVisiblePositionDeprecated(previousVisuallyDistinctCandidate
(PositionTemplate<Strategy>(highestRootOfPos, PositionAnchorType::BeforeAnchor).
parentAnchoredEquivalent())); |
| 3281 | 3281 |
| 3282 // That must mean that |pos| is not editable. Return the last position | 3282 // That must mean that |pos| is not editable. Return the last position |
| 3283 // before |pos| that is in the same editable region as this position | 3283 // before |pos| that is in the same editable region as this position |
| 3284 DCHECK(highestRoot); | 3284 DCHECK(highestRoot); |
| 3285 return lastEditableVisiblePositionBeforePositionInRoot(pos.deepEquivalent(),
*highestRoot); | 3285 return lastEditableVisiblePositionBeforePositionInRoot(pos.deepEquivalent(),
*highestRoot); |
| 3286 } | 3286 } |
| 3287 | 3287 |
| 3288 template <typename Strategy> | 3288 template <typename Strategy> |
| 3289 static VisiblePositionTemplate<Strategy> previousPositionOfAlgorithm(const Visib
lePositionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule rule) | 3289 static VisiblePositionTemplate<Strategy> previousPositionOfAlgorithm(const Visib
lePositionTemplate<Strategy>& visiblePosition, EditingBoundaryCrossingRule rule) |
| 3290 { | 3290 { |
| 3291 const PositionTemplate<Strategy> pos = previousVisuallyDistinctCandidate(vis
iblePosition.deepEquivalent()); | 3291 const PositionTemplate<Strategy> pos = previousVisuallyDistinctCandidate(vis
iblePosition.deepEquivalent()); |
| 3292 | 3292 |
| 3293 // return null visible position if there is no previous visible position | 3293 // return null visible position if there is no previous visible position |
| 3294 if (pos.atStartOfTree()) | 3294 if (pos.atStartOfTree()) |
| 3295 return VisiblePositionTemplate<Strategy>(); | 3295 return VisiblePositionTemplate<Strategy>(); |
| 3296 | 3296 |
| 3297 // we should always be able to make the affinity |TextAffinity::Downstream|, | 3297 // we should always be able to make the affinity |TextAffinity::Downstream|, |
| 3298 // because going previous from an |TextAffinity::Upstream| position can | 3298 // because going previous from an |TextAffinity::Upstream| position can |
| 3299 // never yield another |TextAffinity::Upstream position| (unless line wrap | 3299 // never yield another |TextAffinity::Upstream position| (unless line wrap |
| 3300 // length is 0!). | 3300 // length is 0!). |
| 3301 const VisiblePositionTemplate<Strategy> prev = createVisiblePosition(pos); | 3301 const VisiblePositionTemplate<Strategy> prev = createVisiblePositionDeprecat
ed(pos); |
| 3302 if (prev.deepEquivalent() == visiblePosition.deepEquivalent()) | 3302 if (prev.deepEquivalent() == visiblePosition.deepEquivalent()) |
| 3303 return VisiblePositionTemplate<Strategy>(); | 3303 return VisiblePositionTemplate<Strategy>(); |
| 3304 | 3304 |
| 3305 switch (rule) { | 3305 switch (rule) { |
| 3306 case CanCrossEditingBoundary: | 3306 case CanCrossEditingBoundary: |
| 3307 return prev; | 3307 return prev; |
| 3308 case CannotCrossEditingBoundary: | 3308 case CannotCrossEditingBoundary: |
| 3309 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivale
nt()); | 3309 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivale
nt()); |
| 3310 case CanSkipOverEditingBoundary: | 3310 case CanSkipOverEditingBoundary: |
| 3311 return skipToStartOfEditingBoundary(prev, visiblePosition.deepEquivalent
()); | 3311 return skipToStartOfEditingBoundary(prev, visiblePosition.deepEquivalent
()); |
| 3312 } | 3312 } |
| 3313 | 3313 |
| 3314 NOTREACHED(); | 3314 NOTREACHED(); |
| 3315 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent()
); | 3315 return honorEditingBoundaryAtOrBefore(prev, visiblePosition.deepEquivalent()
); |
| 3316 } | 3316 } |
| 3317 | 3317 |
| 3318 VisiblePosition previousPositionOf(const VisiblePosition& visiblePosition, Editi
ngBoundaryCrossingRule rule) | 3318 VisiblePosition previousPositionOf(const VisiblePosition& visiblePosition, Editi
ngBoundaryCrossingRule rule) |
| 3319 { | 3319 { |
| 3320 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); | 3320 return previousPositionOfAlgorithm<EditingStrategy>(visiblePosition, rule); |
| 3321 } | 3321 } |
| 3322 | 3322 |
| 3323 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) | 3323 VisiblePositionInFlatTree previousPositionOf(const VisiblePositionInFlatTree& vi
siblePosition, EditingBoundaryCrossingRule rule) |
| 3324 { | 3324 { |
| 3325 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); | 3325 return previousPositionOfAlgorithm<EditingInFlatTreeStrategy>(visiblePositio
n, rule); |
| 3326 } | 3326 } |
| 3327 | 3327 |
| 3328 } // namespace blink | 3328 } // namespace blink |
| OLD | NEW |