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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 needMoreContext = true; | 655 needMoreContext = true; |
656 return 0; | 656 return 0; |
657 } | 657 } |
658 needMoreContext = false; | 658 needMoreContext = false; |
659 int start, end; | 659 int start, end; |
660 U16_BACK_1(characters, 0, offset); | 660 U16_BACK_1(characters, 0, offset); |
661 findWordBoundary(characters, length, offset, &start, &end); | 661 findWordBoundary(characters, length, offset, &start, &end); |
662 return start; | 662 return start; |
663 } | 663 } |
664 | 664 |
665 VisiblePosition startOfWord(const VisiblePosition &c, EWordSide side) | 665 VisiblePosition startOfWord(const VisiblePosition& c, EWordSide side) |
666 { | 666 { |
667 // FIXME: This returns a null VP for c at the start of the document | 667 // FIXME: This returns a null VP for c at the start of the document |
668 // and side == LeftWordIfOnBoundary | 668 // and side == LeftWordIfOnBoundary |
669 VisiblePosition p = c; | 669 VisiblePosition p = c; |
670 if (side == RightWordIfOnBoundary) { | 670 if (side == RightWordIfOnBoundary) { |
671 // at paragraph end, the startofWord is the current position | 671 // at paragraph end, the startofWord is the current position |
672 if (isEndOfParagraph(c)) | 672 if (isEndOfParagraph(c)) |
673 return c; | 673 return c; |
674 | 674 |
675 p = c.next(); | 675 p = c.next(); |
676 if (p.isNull()) | 676 if (p.isNull()) |
677 return c; | 677 return c; |
678 } | 678 } |
679 return previousBoundary(p, startWordBoundary); | 679 return previousBoundary(p, startWordBoundary); |
680 } | 680 } |
681 | 681 |
682 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign
ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC
ontext) | 682 static unsigned endWordBoundary(const UChar* characters, unsigned length, unsign
ed offset, BoundarySearchContextAvailability mayHaveMoreContext, bool& needMoreC
ontext) |
683 { | 683 { |
684 ASSERT(offset <= length); | 684 ASSERT(offset <= length); |
685 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset,
length - offset) == static_cast<int>(length - offset)) { | 685 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset,
length - offset) == static_cast<int>(length - offset)) { |
686 needMoreContext = true; | 686 needMoreContext = true; |
687 return length; | 687 return length; |
688 } | 688 } |
689 needMoreContext = false; | 689 needMoreContext = false; |
690 return findWordEndBoundary(characters, length, offset); | 690 return findWordEndBoundary(characters, length, offset); |
691 } | 691 } |
692 | 692 |
693 VisiblePosition endOfWord(const VisiblePosition &c, EWordSide side) | 693 VisiblePosition endOfWord(const VisiblePosition& c, EWordSide side) |
694 { | 694 { |
695 VisiblePosition p = c; | 695 VisiblePosition p = c; |
696 if (side == LeftWordIfOnBoundary) { | 696 if (side == LeftWordIfOnBoundary) { |
697 if (isStartOfParagraph(c)) | 697 if (isStartOfParagraph(c)) |
698 return c; | 698 return c; |
699 | 699 |
700 p = c.previous(); | 700 p = c.previous(); |
701 if (p.isNull()) | 701 if (p.isNull()) |
702 return c; | 702 return c; |
703 } else if (isEndOfParagraph(c)) { | 703 } else if (isEndOfParagraph(c)) { |
704 return c; | 704 return c; |
705 } | 705 } |
706 | 706 |
707 return nextBoundary(p, endWordBoundary); | 707 return nextBoundary(p, endWordBoundary); |
708 } | 708 } |
709 | 709 |
710 static unsigned previousWordPositionBoundary(const UChar* characters, unsigned l
ength, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bo
ol& needMoreContext) | 710 static unsigned previousWordPositionBoundary(const UChar* characters, unsigned l
ength, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bo
ol& needMoreContext) |
711 { | 711 { |
712 if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset
)) { | 712 if (mayHaveMoreContext && !startOfLastWordBoundaryContext(characters, offset
)) { |
713 needMoreContext = true; | 713 needMoreContext = true; |
714 return 0; | 714 return 0; |
715 } | 715 } |
716 needMoreContext = false; | 716 needMoreContext = false; |
717 return findNextWordFromIndex(characters, length, offset, false); | 717 return findNextWordFromIndex(characters, length, offset, false); |
718 } | 718 } |
719 | 719 |
720 VisiblePosition previousWordPosition(const VisiblePosition &c) | 720 VisiblePosition previousWordPosition(const VisiblePosition& c) |
721 { | 721 { |
722 VisiblePosition prev = previousBoundary(c, previousWordPositionBoundary); | 722 VisiblePosition prev = previousBoundary(c, previousWordPositionBoundary); |
723 return c.honorEditingBoundaryAtOrBefore(prev); | 723 return c.honorEditingBoundaryAtOrBefore(prev); |
724 } | 724 } |
725 | 725 |
726 static unsigned nextWordPositionBoundary(const UChar* characters, unsigned lengt
h, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool&
needMoreContext) | 726 static unsigned nextWordPositionBoundary(const UChar* characters, unsigned lengt
h, unsigned offset, BoundarySearchContextAvailability mayHaveMoreContext, bool&
needMoreContext) |
727 { | 727 { |
728 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset,
length - offset) == static_cast<int>(length - offset)) { | 728 if (mayHaveMoreContext && endOfFirstWordBoundaryContext(characters + offset,
length - offset) == static_cast<int>(length - offset)) { |
729 needMoreContext = true; | 729 needMoreContext = true; |
730 return length; | 730 return length; |
731 } | 731 } |
732 needMoreContext = false; | 732 needMoreContext = false; |
733 return findNextWordFromIndex(characters, length, offset, true); | 733 return findNextWordFromIndex(characters, length, offset, true); |
734 } | 734 } |
735 | 735 |
736 VisiblePosition nextWordPosition(const VisiblePosition &c) | 736 VisiblePosition nextWordPosition(const VisiblePosition& c) |
737 { | 737 { |
738 VisiblePosition next = nextBoundary(c, nextWordPositionBoundary); | 738 VisiblePosition next = nextBoundary(c, nextWordPositionBoundary); |
739 return c.honorEditingBoundaryAtOrAfter(next); | 739 return c.honorEditingBoundaryAtOrAfter(next); |
740 } | 740 } |
741 | 741 |
742 // --------- | 742 // --------- |
743 | 743 |
744 enum LineEndpointComputationMode { UseLogicalOrdering, UseInlineBoxOrdering }; | 744 enum LineEndpointComputationMode { UseLogicalOrdering, UseInlineBoxOrdering }; |
745 template <typename Strategy> | 745 template <typename Strategy> |
746 static PositionWithAffinityTemplate<Strategy> startPositionForLine(const Positio
nWithAffinityTemplate<Strategy>& c, LineEndpointComputationMode mode) | 746 static PositionWithAffinityTemplate<Strategy> startPositionForLine(const Positio
nWithAffinityTemplate<Strategy>& c, LineEndpointComputationMode mode) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 bool inSameLine(const PositionInComposedTreeWithAffinity& position1, const Posit
ionInComposedTreeWithAffinity& position2) | 952 bool inSameLine(const PositionInComposedTreeWithAffinity& position1, const Posit
ionInComposedTreeWithAffinity& position2) |
953 { | 953 { |
954 return inSameLineAlgorithm<EditingInComposedTreeStrategy>(position1, positio
n2); | 954 return inSameLineAlgorithm<EditingInComposedTreeStrategy>(position1, positio
n2); |
955 } | 955 } |
956 | 956 |
957 bool inSameLine(const VisiblePosition& position1, const VisiblePosition& positio
n2) | 957 bool inSameLine(const VisiblePosition& position1, const VisiblePosition& positio
n2) |
958 { | 958 { |
959 return inSameLine(position1.toPositionWithAffinity(), position2.toPositionWi
thAffinity()); | 959 return inSameLine(position1.toPositionWithAffinity(), position2.toPositionWi
thAffinity()); |
960 } | 960 } |
961 | 961 |
962 bool isStartOfLine(const VisiblePosition &p) | 962 bool isStartOfLine(const VisiblePosition& p) |
963 { | 963 { |
964 return p.isNotNull() && p.deepEquivalent() == startOfLine(p).deepEquivalent(
); | 964 return p.isNotNull() && p.deepEquivalent() == startOfLine(p).deepEquivalent(
); |
965 } | 965 } |
966 | 966 |
967 bool isEndOfLine(const VisiblePosition &p) | 967 bool isEndOfLine(const VisiblePosition& p) |
968 { | 968 { |
969 return p.isNotNull() && p.deepEquivalent() == endOfLine(p).deepEquivalent(); | 969 return p.isNotNull() && p.deepEquivalent() == endOfLine(p).deepEquivalent(); |
970 } | 970 } |
971 | 971 |
972 bool isLogicalEndOfLine(const VisiblePosition &p) | 972 bool isLogicalEndOfLine(const VisiblePosition& p) |
973 { | 973 { |
974 return p.isNotNull() && p.deepEquivalent() == logicalEndOfLine(p).deepEquiva
lent(); | 974 return p.isNotNull() && p.deepEquivalent() == logicalEndOfLine(p).deepEquiva
lent(); |
975 } | 975 } |
976 | 976 |
977 static inline LayoutPoint absoluteLineDirectionPointToLocalPointInBlock(RootInli
neBox* root, LayoutUnit lineDirectionPoint) | 977 static inline LayoutPoint absoluteLineDirectionPointToLocalPointInBlock(RootInli
neBox* root, LayoutUnit lineDirectionPoint) |
978 { | 978 { |
979 ASSERT(root); | 979 ASSERT(root); |
980 LayoutBlockFlow& containingBlock = root->block(); | 980 LayoutBlockFlow& containingBlock = root->block(); |
981 FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint()
); | 981 FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint()
); |
982 if (containingBlock.hasOverflowClip()) | 982 if (containingBlock.hasOverflowClip()) |
983 absoluteBlockPoint -= containingBlock.scrolledContentOffset(); | 983 absoluteBlockPoint -= containingBlock.scrolledContentOffset(); |
984 | 984 |
985 if (root->block().isHorizontalWritingMode()) | 985 if (root->block().isHorizontalWritingMode()) |
986 return LayoutPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->bl
ockDirectionPointInLine()); | 986 return LayoutPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->bl
ockDirectionPointInLine()); |
987 | 987 |
988 return LayoutPoint(root->blockDirectionPointInLine(), lineDirectionPoint - a
bsoluteBlockPoint.y()); | 988 return LayoutPoint(root->blockDirectionPointInLine(), lineDirectionPoint - a
bsoluteBlockPoint.y()); |
989 } | 989 } |
990 | 990 |
991 VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, Lay
outUnit lineDirectionPoint, EditableType editableType) | 991 VisiblePosition previousLinePosition(const VisiblePosition& visiblePosition, Lay
outUnit lineDirectionPoint, EditableType editableType) |
992 { | 992 { |
993 Position p = visiblePosition.deepEquivalent(); | 993 Position p = visiblePosition.deepEquivalent(); |
994 Node* node = p.anchorNode(); | 994 Node* node = p.anchorNode(); |
995 | 995 |
996 if (!node) | 996 if (!node) |
997 return VisiblePosition(); | 997 return VisiblePosition(); |
998 | 998 |
999 node->document().updateLayoutIgnorePendingStylesheets(); | 999 node->document().updateLayoutIgnorePendingStylesheets(); |
1000 | 1000 |
1001 LayoutObject* layoutObject = node->layoutObject(); | 1001 LayoutObject* layoutObject = node->layoutObject(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 | 1034 |
1035 // Could not find a previous line. This means we must already be on the firs
t line. | 1035 // Could not find a previous line. This means we must already be on the firs
t line. |
1036 // Move to the start of the content in this block, which effectively moves u
s | 1036 // Move to the start of the content in this block, which effectively moves u
s |
1037 // to the start of the line we're on. | 1037 // to the start of the line we're on. |
1038 Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEdit
ableElement(editableType) : node->document().documentElement(); | 1038 Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEdit
ableElement(editableType) : node->document().documentElement(); |
1039 if (!rootElement) | 1039 if (!rootElement) |
1040 return VisiblePosition(); | 1040 return VisiblePosition(); |
1041 return VisiblePosition(firstPositionInNode(rootElement)); | 1041 return VisiblePosition(firstPositionInNode(rootElement)); |
1042 } | 1042 } |
1043 | 1043 |
1044 VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, LayoutU
nit lineDirectionPoint, EditableType editableType) | 1044 VisiblePosition nextLinePosition(const VisiblePosition& visiblePosition, LayoutU
nit lineDirectionPoint, EditableType editableType) |
1045 { | 1045 { |
1046 Position p = visiblePosition.deepEquivalent(); | 1046 Position p = visiblePosition.deepEquivalent(); |
1047 Node* node = p.anchorNode(); | 1047 Node* node = p.anchorNode(); |
1048 | 1048 |
1049 if (!node) | 1049 if (!node) |
1050 return VisiblePosition(); | 1050 return VisiblePosition(); |
1051 | 1051 |
1052 node->document().updateLayoutIgnorePendingStylesheets(); | 1052 node->document().updateLayoutIgnorePendingStylesheets(); |
1053 | 1053 |
1054 LayoutObject* layoutObject = node->layoutObject(); | 1054 LayoutObject* layoutObject = node->layoutObject(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 | 1099 |
1100 // --------- | 1100 // --------- |
1101 | 1101 |
1102 static unsigned startSentenceBoundary(const UChar* characters, unsigned length,
unsigned, BoundarySearchContextAvailability, bool&) | 1102 static unsigned startSentenceBoundary(const UChar* characters, unsigned length,
unsigned, BoundarySearchContextAvailability, bool&) |
1103 { | 1103 { |
1104 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); | 1104 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); |
1105 // FIXME: The following function can return -1; we don't handle that. | 1105 // FIXME: The following function can return -1; we don't handle that. |
1106 return iterator->preceding(length); | 1106 return iterator->preceding(length); |
1107 } | 1107 } |
1108 | 1108 |
1109 VisiblePosition startOfSentence(const VisiblePosition &c) | 1109 VisiblePosition startOfSentence(const VisiblePosition& c) |
1110 { | 1110 { |
1111 return previousBoundary(c, startSentenceBoundary); | 1111 return previousBoundary(c, startSentenceBoundary); |
1112 } | 1112 } |
1113 | 1113 |
1114 static unsigned endSentenceBoundary(const UChar* characters, unsigned length, un
signed, BoundarySearchContextAvailability, bool&) | 1114 static unsigned endSentenceBoundary(const UChar* characters, unsigned length, un
signed, BoundarySearchContextAvailability, bool&) |
1115 { | 1115 { |
1116 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); | 1116 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); |
1117 return iterator->next(); | 1117 return iterator->next(); |
1118 } | 1118 } |
1119 | 1119 |
1120 // FIXME: This includes the space after the punctuation that marks the end of th
e sentence. | 1120 // FIXME: This includes the space after the punctuation that marks the end of th
e sentence. |
1121 VisiblePosition endOfSentence(const VisiblePosition &c) | 1121 VisiblePosition endOfSentence(const VisiblePosition& c) |
1122 { | 1122 { |
1123 return nextBoundary(c, endSentenceBoundary); | 1123 return nextBoundary(c, endSentenceBoundary); |
1124 } | 1124 } |
1125 | 1125 |
1126 static unsigned previousSentencePositionBoundary(const UChar* characters, unsign
ed length, unsigned, BoundarySearchContextAvailability, bool&) | 1126 static unsigned previousSentencePositionBoundary(const UChar* characters, unsign
ed length, unsigned, BoundarySearchContextAvailability, bool&) |
1127 { | 1127 { |
1128 // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's
not right. | 1128 // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's
not right. |
1129 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); | 1129 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); |
1130 // FIXME: The following function can return -1; we don't handle that. | 1130 // FIXME: The following function can return -1; we don't handle that. |
1131 return iterator->preceding(length); | 1131 return iterator->preceding(length); |
1132 } | 1132 } |
1133 | 1133 |
1134 VisiblePosition previousSentencePosition(const VisiblePosition &c) | 1134 VisiblePosition previousSentencePosition(const VisiblePosition& c) |
1135 { | 1135 { |
1136 VisiblePosition prev = previousBoundary(c, previousSentencePositionBoundary)
; | 1136 VisiblePosition prev = previousBoundary(c, previousSentencePositionBoundary)
; |
1137 return c.honorEditingBoundaryAtOrBefore(prev); | 1137 return c.honorEditingBoundaryAtOrBefore(prev); |
1138 } | 1138 } |
1139 | 1139 |
1140 static unsigned nextSentencePositionBoundary(const UChar* characters, unsigned l
ength, unsigned, BoundarySearchContextAvailability, bool&) | 1140 static unsigned nextSentencePositionBoundary(const UChar* characters, unsigned l
ength, unsigned, BoundarySearchContextAvailability, bool&) |
1141 { | 1141 { |
1142 // FIXME: This is identical to endSentenceBoundary. This isn't right, it nee
ds to | 1142 // FIXME: This is identical to endSentenceBoundary. This isn't right, it nee
ds to |
1143 // move to the equivlant position in the following sentence. | 1143 // move to the equivlant position in the following sentence. |
1144 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); | 1144 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); |
1145 return iterator->following(0); | 1145 return iterator->following(0); |
1146 } | 1146 } |
1147 | 1147 |
1148 VisiblePosition nextSentencePosition(const VisiblePosition &c) | 1148 VisiblePosition nextSentencePosition(const VisiblePosition& c) |
1149 { | 1149 { |
1150 VisiblePosition next = nextBoundary(c, nextSentencePositionBoundary); | 1150 VisiblePosition next = nextBoundary(c, nextSentencePositionBoundary); |
1151 return c.honorEditingBoundaryAtOrAfter(next); | 1151 return c.honorEditingBoundaryAtOrAfter(next); |
1152 } | 1152 } |
1153 | 1153 |
1154 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
ngRule boundaryCrossingRule) | 1154 VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
ngRule boundaryCrossingRule) |
1155 { | 1155 { |
1156 Position p = c.deepEquivalent(); | 1156 Position p = c.deepEquivalent(); |
1157 Node* startNode = p.anchorNode(); | 1157 Node* startNode = p.anchorNode(); |
1158 | 1158 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 n = NodeTraversal::previousPostOrder(*n, startBlock); | 1219 n = NodeTraversal::previousPostOrder(*n, startBlock); |
1220 } | 1220 } |
1221 } | 1221 } |
1222 | 1222 |
1223 if (type == PositionAnchorType::OffsetInAnchor) | 1223 if (type == PositionAnchorType::OffsetInAnchor) |
1224 return VisiblePosition(Position(node, offset)); | 1224 return VisiblePosition(Position(node, offset)); |
1225 | 1225 |
1226 return VisiblePosition(Position(node, type)); | 1226 return VisiblePosition(Position(node, type)); |
1227 } | 1227 } |
1228 | 1228 |
1229 VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing
Rule boundaryCrossingRule) | 1229 VisiblePosition endOfParagraph(const VisiblePosition& c, EditingBoundaryCrossing
Rule boundaryCrossingRule) |
1230 { | 1230 { |
1231 if (c.isNull()) | 1231 if (c.isNull()) |
1232 return VisiblePosition(); | 1232 return VisiblePosition(); |
1233 | 1233 |
1234 Position p = c.deepEquivalent(); | 1234 Position p = c.deepEquivalent(); |
1235 Node* startNode = p.anchorNode(); | 1235 Node* startNode = p.anchorNode(); |
1236 | 1236 |
1237 if (isRenderedAsNonInlineTableImageOrHR(startNode)) | 1237 if (isRenderedAsNonInlineTableImageOrHR(startNode)) |
1238 return VisiblePosition(positionAfterNode(startNode)); | 1238 return VisiblePosition(positionAfterNode(startNode)); |
1239 | 1239 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 { | 1307 { |
1308 VisiblePosition paragraphEnd(endOfParagraph(visiblePosition, CanSkipOverEdit
ingBoundary)); | 1308 VisiblePosition paragraphEnd(endOfParagraph(visiblePosition, CanSkipOverEdit
ingBoundary)); |
1309 VisiblePosition afterParagraphEnd(paragraphEnd.next(CannotCrossEditingBounda
ry)); | 1309 VisiblePosition afterParagraphEnd(paragraphEnd.next(CannotCrossEditingBounda
ry)); |
1310 // The position after the last position in the last cell of a table | 1310 // The position after the last position in the last cell of a table |
1311 // is not the start of the next paragraph. | 1311 // is not the start of the next paragraph. |
1312 if (isFirstPositionAfterTable(afterParagraphEnd)) | 1312 if (isFirstPositionAfterTable(afterParagraphEnd)) |
1313 return afterParagraphEnd.next(CannotCrossEditingBoundary); | 1313 return afterParagraphEnd.next(CannotCrossEditingBoundary); |
1314 return afterParagraphEnd; | 1314 return afterParagraphEnd; |
1315 } | 1315 } |
1316 | 1316 |
1317 bool inSameParagraph(const VisiblePosition &a, const VisiblePosition &b, Editing
BoundaryCrossingRule boundaryCrossingRule) | 1317 bool inSameParagraph(const VisiblePosition& a, const VisiblePosition& b, Editing
BoundaryCrossingRule boundaryCrossingRule) |
1318 { | 1318 { |
1319 return a.isNotNull() && startOfParagraph(a, boundaryCrossingRule).deepEquiva
lent() == startOfParagraph(b, boundaryCrossingRule).deepEquivalent(); | 1319 return a.isNotNull() && startOfParagraph(a, boundaryCrossingRule).deepEquiva
lent() == startOfParagraph(b, boundaryCrossingRule).deepEquivalent(); |
1320 } | 1320 } |
1321 | 1321 |
1322 bool isStartOfParagraph(const VisiblePosition &pos, EditingBoundaryCrossingRule
boundaryCrossingRule) | 1322 bool isStartOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule
boundaryCrossingRule) |
1323 { | 1323 { |
1324 return pos.isNotNull() && pos.deepEquivalent() == startOfParagraph(pos, boun
daryCrossingRule).deepEquivalent(); | 1324 return pos.isNotNull() && pos.deepEquivalent() == startOfParagraph(pos, boun
daryCrossingRule).deepEquivalent(); |
1325 } | 1325 } |
1326 | 1326 |
1327 bool isEndOfParagraph(const VisiblePosition &pos, EditingBoundaryCrossingRule bo
undaryCrossingRule) | 1327 bool isEndOfParagraph(const VisiblePosition& pos, EditingBoundaryCrossingRule bo
undaryCrossingRule) |
1328 { | 1328 { |
1329 return pos.isNotNull() && pos.deepEquivalent() == endOfParagraph(pos, bounda
ryCrossingRule).deepEquivalent(); | 1329 return pos.isNotNull() && pos.deepEquivalent() == endOfParagraph(pos, bounda
ryCrossingRule).deepEquivalent(); |
1330 } | 1330 } |
1331 | 1331 |
1332 VisiblePosition previousParagraphPosition(const VisiblePosition& p, LayoutUnit x
) | 1332 VisiblePosition previousParagraphPosition(const VisiblePosition& p, LayoutUnit x
) |
1333 { | 1333 { |
1334 VisiblePosition pos = p; | 1334 VisiblePosition pos = p; |
1335 do { | 1335 do { |
1336 VisiblePosition n = previousLinePosition(pos, x); | 1336 VisiblePosition n = previousLinePosition(pos, x); |
1337 if (n.isNull() || n.deepEquivalent() == pos.deepEquivalent()) | 1337 if (n.isNull() || n.deepEquivalent() == pos.deepEquivalent()) |
(...skipping 24 matching lines...) Expand all Loading... |
1362 return startBlock ? VisiblePosition(firstPositionInNode(startBlock)) : Visib
lePosition(); | 1362 return startBlock ? VisiblePosition(firstPositionInNode(startBlock)) : Visib
lePosition(); |
1363 } | 1363 } |
1364 | 1364 |
1365 VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda
ryCrossingRule rule) | 1365 VisiblePosition endOfBlock(const VisiblePosition& visiblePosition, EditingBounda
ryCrossingRule rule) |
1366 { | 1366 { |
1367 Position position = visiblePosition.deepEquivalent(); | 1367 Position position = visiblePosition.deepEquivalent(); |
1368 Element* endBlock = position.computeContainerNode() ? enclosingBlock(positio
n.computeContainerNode(), rule) : 0; | 1368 Element* endBlock = position.computeContainerNode() ? enclosingBlock(positio
n.computeContainerNode(), rule) : 0; |
1369 return endBlock ? VisiblePosition(lastPositionInNode(endBlock)) : VisiblePos
ition(); | 1369 return endBlock ? VisiblePosition(lastPositionInNode(endBlock)) : VisiblePos
ition(); |
1370 } | 1370 } |
1371 | 1371 |
1372 bool inSameBlock(const VisiblePosition &a, const VisiblePosition &b) | 1372 bool inSameBlock(const VisiblePosition& a, const VisiblePosition& b) |
1373 { | 1373 { |
1374 return !a.isNull() && enclosingBlock(a.deepEquivalent().computeContainerNode
()) == enclosingBlock(b.deepEquivalent().computeContainerNode()); | 1374 return !a.isNull() && enclosingBlock(a.deepEquivalent().computeContainerNode
()) == enclosingBlock(b.deepEquivalent().computeContainerNode()); |
1375 } | 1375 } |
1376 | 1376 |
1377 bool isStartOfBlock(const VisiblePosition &pos) | 1377 bool isStartOfBlock(const VisiblePosition& pos) |
1378 { | 1378 { |
1379 return pos.isNotNull() && pos.deepEquivalent() == startOfBlock(pos, CanCross
EditingBoundary).deepEquivalent(); | 1379 return pos.isNotNull() && pos.deepEquivalent() == startOfBlock(pos, CanCross
EditingBoundary).deepEquivalent(); |
1380 } | 1380 } |
1381 | 1381 |
1382 bool isEndOfBlock(const VisiblePosition &pos) | 1382 bool isEndOfBlock(const VisiblePosition& pos) |
1383 { | 1383 { |
1384 return pos.isNotNull() && pos.deepEquivalent() == endOfBlock(pos, CanCrossEd
itingBoundary).deepEquivalent(); | 1384 return pos.isNotNull() && pos.deepEquivalent() == endOfBlock(pos, CanCrossEd
itingBoundary).deepEquivalent(); |
1385 } | 1385 } |
1386 | 1386 |
1387 // --------- | 1387 // --------- |
1388 | 1388 |
1389 VisiblePosition startOfDocument(const Node* node) | 1389 VisiblePosition startOfDocument(const Node* node) |
1390 { | 1390 { |
1391 if (!node || !node->document().documentElement()) | 1391 if (!node || !node->document().documentElement()) |
1392 return VisiblePosition(); | 1392 return VisiblePosition(); |
1393 | 1393 |
1394 return VisiblePosition(firstPositionInNode(node->document().documentElement(
))); | 1394 return VisiblePosition(firstPositionInNode(node->document().documentElement(
))); |
1395 } | 1395 } |
1396 | 1396 |
1397 VisiblePosition startOfDocument(const VisiblePosition &c) | 1397 VisiblePosition startOfDocument(const VisiblePosition& c) |
1398 { | 1398 { |
1399 return startOfDocument(c.deepEquivalent().anchorNode()); | 1399 return startOfDocument(c.deepEquivalent().anchorNode()); |
1400 } | 1400 } |
1401 | 1401 |
1402 VisiblePosition endOfDocument(const Node* node) | 1402 VisiblePosition endOfDocument(const Node* node) |
1403 { | 1403 { |
1404 if (!node || !node->document().documentElement()) | 1404 if (!node || !node->document().documentElement()) |
1405 return VisiblePosition(); | 1405 return VisiblePosition(); |
1406 | 1406 |
1407 Element* doc = node->document().documentElement(); | 1407 Element* doc = node->document().documentElement(); |
1408 return VisiblePosition(lastPositionInNode(doc)); | 1408 return VisiblePosition(lastPositionInNode(doc)); |
1409 } | 1409 } |
1410 | 1410 |
1411 VisiblePosition endOfDocument(const VisiblePosition &c) | 1411 VisiblePosition endOfDocument(const VisiblePosition& c) |
1412 { | 1412 { |
1413 return endOfDocument(c.deepEquivalent().anchorNode()); | 1413 return endOfDocument(c.deepEquivalent().anchorNode()); |
1414 } | 1414 } |
1415 | 1415 |
1416 bool isStartOfDocument(const VisiblePosition &p) | 1416 bool isStartOfDocument(const VisiblePosition& p) |
1417 { | 1417 { |
1418 return p.isNotNull() && p.previous(CanCrossEditingBoundary).isNull(); | 1418 return p.isNotNull() && p.previous(CanCrossEditingBoundary).isNull(); |
1419 } | 1419 } |
1420 | 1420 |
1421 bool isEndOfDocument(const VisiblePosition &p) | 1421 bool isEndOfDocument(const VisiblePosition& p) |
1422 { | 1422 { |
1423 return p.isNotNull() && p.next(CanCrossEditingBoundary).isNull(); | 1423 return p.isNotNull() && p.next(CanCrossEditingBoundary).isNull(); |
1424 } | 1424 } |
1425 | 1425 |
1426 // --------- | 1426 // --------- |
1427 | 1427 |
1428 VisiblePosition startOfEditableContent(const VisiblePosition& visiblePosition) | 1428 VisiblePosition startOfEditableContent(const VisiblePosition& visiblePosition) |
1429 { | 1429 { |
1430 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); | 1430 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); |
1431 if (!highestRoot) | 1431 if (!highestRoot) |
1432 return VisiblePosition(); | 1432 return VisiblePosition(); |
1433 | 1433 |
1434 return VisiblePosition(firstPositionInNode(highestRoot)); | 1434 return VisiblePosition(firstPositionInNode(highestRoot)); |
1435 } | 1435 } |
1436 | 1436 |
1437 VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition) | 1437 VisiblePosition endOfEditableContent(const VisiblePosition& visiblePosition) |
1438 { | 1438 { |
1439 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); | 1439 ContainerNode* highestRoot = highestEditableRoot(visiblePosition.deepEquival
ent()); |
1440 if (!highestRoot) | 1440 if (!highestRoot) |
1441 return VisiblePosition(); | 1441 return VisiblePosition(); |
1442 | 1442 |
1443 return VisiblePosition(lastPositionInNode(highestRoot)); | 1443 return VisiblePosition(lastPositionInNode(highestRoot)); |
1444 } | 1444 } |
1445 | 1445 |
1446 bool isEndOfEditableOrNonEditableContent(const VisiblePosition &p) | 1446 bool isEndOfEditableOrNonEditableContent(const VisiblePosition& p) |
1447 { | 1447 { |
1448 return p.isNotNull() && p.next().isNull(); | 1448 return p.isNotNull() && p.next().isNull(); |
1449 } | 1449 } |
1450 | 1450 |
1451 VisiblePosition leftBoundaryOfLine(const VisiblePosition& c, TextDirection direc
tion) | 1451 VisiblePosition leftBoundaryOfLine(const VisiblePosition& c, TextDirection direc
tion) |
1452 { | 1452 { |
1453 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); | 1453 return direction == LTR ? logicalStartOfLine(c) : logicalEndOfLine(c); |
1454 } | 1454 } |
1455 | 1455 |
1456 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) | 1456 VisiblePosition rightBoundaryOfLine(const VisiblePosition& c, TextDirection dire
ction) |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 { | 2331 { |
2332 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); | 2332 return isVisuallyEquivalentCandidateAlgorithm<EditingStrategy>(position); |
2333 } | 2333 } |
2334 | 2334 |
2335 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) | 2335 bool isVisuallyEquivalentCandidate(const PositionInComposedTree& position) |
2336 { | 2336 { |
2337 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); | 2337 return isVisuallyEquivalentCandidateAlgorithm<EditingInComposedTreeStrategy>
(position); |
2338 } | 2338 } |
2339 | 2339 |
2340 } // namespace blink | 2340 } // namespace blink |
OLD | NEW |