OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
96 static EphemeralRange expandEndToSentenceBoundary(const EphemeralRange& range) | 96 static EphemeralRange expandEndToSentenceBoundary(const EphemeralRange& range) |
97 { | 97 { |
98 DCHECK(range.isNotNull()); | 98 DCHECK(range.isNotNull()); |
99 const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition(
)); | 99 const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition(
)); |
100 DCHECK(visibleEnd.isNotNull()); | 100 DCHECK(visibleEnd.isNotNull()); |
101 const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent(); | 101 const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent(); |
102 // TODO(xiaochengh): |sentenceEnd < range.startPosition()| seems possible, | 102 // TODO(xiaochengh): |sentenceEnd < range.endPosition()| is possible, |
103 // which would trigger a DCHECK in EphemeralRange's constructor. Need more | 103 // which would trigger a DCHECK in EphemeralRange's constructor if we return |
104 // investigation, and if that is really the case, fix it. | 104 // it directly. However, this shouldn't happen and needs to be fixed. |
105 return EphemeralRange(range.startPosition(), sentenceEnd.isNotNull() ? sente
nceEnd : range.endPosition()); | 105 return EphemeralRange(range.startPosition(), sentenceEnd.isNotNull() && sent
enceEnd > range.endPosition() ? sentenceEnd : range.endPosition()); |
106 } | 106 } |
107 | 107 |
108 static EphemeralRange expandRangeToSentenceBoundary(const EphemeralRange& range) | 108 static EphemeralRange expandRangeToSentenceBoundary(const EphemeralRange& range) |
109 { | 109 { |
110 DCHECK(range.isNotNull()); | 110 DCHECK(range.isNotNull()); |
111 const VisiblePosition& visibleStart = createVisiblePosition(range.startPosit
ion()); | 111 const VisiblePosition& visibleStart = createVisiblePosition(range.startPosit
ion()); |
112 DCHECK(visibleStart.isNotNull()); | 112 DCHECK(visibleStart.isNotNull()); |
113 const Position& sentenceStart = startOfSentence(visibleStart).deepEquivalent
(); | 113 const Position& sentenceStart = startOfSentence(visibleStart).deepEquivalent
(); |
114 const VisiblePosition& visibleEnd = createVisiblePosition(range.endPosition(
)); | 114 // TODO(xiaochengh): |sentenceStart > range.startPosition()| is possible, |
115 DCHECK(visibleStart.isNotNull()); | 115 // which would trigger a DCHECK in EphemeralRange's constructor if we return |
116 const Position& sentenceEnd = endOfSentence(visibleEnd).deepEquivalent(); | 116 // it directly. However, this shouldn't happen and needs to be fixed. |
117 return EphemeralRange(sentenceStart.isNull() ? range.startPosition() : sente
nceStart, sentenceEnd.isNull() ? range.endPosition() : sentenceEnd); | 117 return expandEndToSentenceBoundary(EphemeralRange(sentenceStart.isNotNull()
&& sentenceStart < range.startPosition() ? sentenceStart : range.startPosition()
, range.endPosition())); |
118 } | 118 } |
119 | 119 |
120 } // namespace | 120 } // namespace |
121 | 121 |
122 SpellChecker* SpellChecker::create(LocalFrame& frame) | 122 SpellChecker* SpellChecker::create(LocalFrame& frame) |
123 { | 123 { |
124 return new SpellChecker(frame); | 124 return new SpellChecker(frame); |
125 } | 125 } |
126 | 126 |
127 static SpellCheckerClient& emptySpellCheckerClient() | 127 static SpellCheckerClient& emptySpellCheckerClient() |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 VisiblePosition newParagraphStart = startOfNextParagraph(createVisiblePo
sition(paragraphEnd)); | 940 VisiblePosition newParagraphStart = startOfNextParagraph(createVisiblePo
sition(paragraphEnd)); |
941 paragraphStart = newParagraphStart.toParentAnchoredPosition(); | 941 paragraphStart = newParagraphStart.toParentAnchoredPosition(); |
942 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPositio
n(); | 942 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPositio
n(); |
943 firstIteration = false; | 943 firstIteration = false; |
944 totalLengthProcessed += currentLength; | 944 totalLengthProcessed += currentLength; |
945 } | 945 } |
946 return std::make_pair(firstFoundItem, firstFoundOffset); | 946 return std::make_pair(firstFoundItem, firstFoundOffset); |
947 } | 947 } |
948 | 948 |
949 } // namespace blink | 949 } // namespace blink |
OLD | NEW |