Changeset 162184 in webkit
- Timestamp:
- Jan 16, 2014 10:22:46 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r162180 r162184 1 2014-01-15 Sam Weinig <sam@webkit.org> 2 3 TextBreakIterator's should support Latin-1 for all iterator types (Part 3) 4 https://bugs.webkit.org/show_bug.cgi?id=126856 5 6 Reviewed by Ryosuke Niwa. 7 8 Change all the TextBreakIterator creation functions to take StringViews. Remove a few 9 now unnecessary up-conversions to UTF-16 in the process. 10 11 * dom/CharacterData.cpp: 12 * editing/TextCheckingHelper.cpp: 13 * editing/VisibleUnits.cpp: 14 * platform/graphics/StringTruncator.cpp: 15 * platform/graphics/mac/ComplexTextController.cpp: 16 * platform/text/TextBoundaries.cpp: 17 * platform/text/TextBreakIterator.cpp: 18 * platform/text/TextBreakIterator.h: 19 * rendering/RenderText.cpp: 20 1 21 2014-01-16 Anders Carlsson <andersca@apple.com> 2 22 -
trunk/Source/WebCore/dom/CharacterData.cpp
r161851 r162184 75 75 // We need at least two characters look-ahead to account for UTF-16 surrogates. 76 76 if (characterLengthLimit < characterLength) { 77 NonSharedCharacterBreakIterator it( string.deprecatedCharacters() + offset, (characterLengthLimit + 2 > characterLength) ? characterLength : characterLengthLimit + 2);77 NonSharedCharacterBreakIterator it(StringView(string).substring(offset, (characterLengthLimit + 2 > characterLength) ? characterLength : characterLengthLimit + 2)); 78 78 if (!isTextBreak(it, characterLengthLimit)) 79 79 characterLengthLimit = textBreakPreceding(it, characterLengthLimit); -
trunk/Source/WebCore/editing/TextCheckingHelper.cpp
r161851 r162184 71 71 #endif 72 72 73 static void findMisspellings(TextCheckerClient* client, const UChar* text, int start, intlength, Vector<TextCheckingResult>& results)74 { 75 TextBreakIterator* iterator = wordBreakIterator( text + start, length);73 static void findMisspellings(TextCheckerClient* client, const UChar* text, int length, Vector<TextCheckingResult>& results) 74 { 75 TextBreakIterator* iterator = wordBreakIterator(StringView(text, length)); 76 76 if (!iterator) 77 77 return; … … 84 84 int misspellingLocation = -1; 85 85 int misspellingLength = 0; 86 client->checkSpellingOfString(text + start +wordStart, wordLength, &misspellingLocation, &misspellingLength);86 client->checkSpellingOfString(text + wordStart, wordLength, &misspellingLocation, &misspellingLength); 87 87 if (0 < misspellingLength) { 88 88 ASSERT(0 <= misspellingLocation && misspellingLocation <= wordLength); … … 90 90 TextCheckingResult misspelling; 91 91 misspelling.type = TextCheckingTypeSpelling; 92 misspelling.location = start +wordStart + misspellingLocation;92 misspelling.location = wordStart + misspellingLocation; 93 93 misspelling.length = misspellingLength; 94 94 misspelling.replacement = client->getAutoCorrectSuggestionForMisspelledWord(String(text + misspelling.location, misspelling.length)); … … 649 649 Vector<TextCheckingResult> spellingResult; 650 650 if (checkingTypes & TextCheckingTypeSpelling) 651 findMisspellings(client, text, 0,length, spellingResult);651 findMisspellings(client, text, length, spellingResult); 652 652 653 653 #if USE(GRAMMAR_CHECKING) -
trunk/Source/WebCore/editing/VisibleUnits.cpp
r161861 r162184 302 302 len += textBox->len(); 303 303 304 return wordBreakIterator( string.data(), len);305 } 304 return wordBreakIterator(StringView(string.data(), len)); 305 } 306 306 307 307 static TextBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePosition& visiblePosition, const InlineTextBox* textBox, … … 323 323 } 324 324 325 return wordBreakIterator( string.data(), len);326 } 325 return wordBreakIterator(StringView(string.data(), len)); 326 } 327 327 328 328 static bool isLogicalStartOfWord(TextBreakIterator* iter, int position, bool hardLineBreak) … … 386 386 iter = wordBreakIteratorForMaxOffsetBoundary(visiblePosition, textBox, nextBoxInDifferentBlock, string, leafBoxes); 387 387 else if (movingIntoNewBox) { 388 iter = wordBreakIterator( textBox->renderer().text()->deprecatedCharacters() + textBox->start(), textBox->len());388 iter = wordBreakIterator(StringView(textBox->renderer().text()).substring(textBox->start(), textBox->len())); 389 389 previouslyVisitedBox = box; 390 390 } … … 1047 1047 static unsigned startSentenceBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&) 1048 1048 { 1049 TextBreakIterator* iterator = sentenceBreakIterator( characters, length);1049 TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length)); 1050 1050 // FIXME: The following function can return -1; we don't handle that. 1051 1051 return textBreakPreceding(iterator, length); … … 1059 1059 static unsigned endSentenceBoundary(const UChar* characters, unsigned length, unsigned, BoundarySearchContextAvailability, bool&) 1060 1060 { 1061 TextBreakIterator* iterator = sentenceBreakIterator( characters, length);1061 TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length)); 1062 1062 return textBreakNext(iterator); 1063 1063 } … … 1072 1072 { 1073 1073 // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's not right. 1074 TextBreakIterator* iterator = sentenceBreakIterator( characters, length);1074 TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length)); 1075 1075 // FIXME: The following function can return -1; we don't handle that. 1076 1076 return textBreakPreceding(iterator, length); … … 1087 1087 // FIXME: This is identical to endSentenceBoundary. This isn't right, it needs to 1088 1088 // move to the equivlant position in the following sentence. 1089 TextBreakIterator* iterator = sentenceBreakIterator( characters, length);1089 TextBreakIterator* iterator = sentenceBreakIterator(StringView(characters, length)); 1090 1090 return textBreakFollowing(iterator, 0); 1091 1091 } -
trunk/Source/WebCore/platform/graphics/StringTruncator.cpp
r161851 r162184 64 64 65 65 unsigned omitStart = (keepCount + 1) / 2; 66 NonSharedCharacterBreakIterator it( string.deprecatedCharacters(), length);66 NonSharedCharacterBreakIterator it(StringView(string).substring(0, length)); 67 67 unsigned omitEnd = boundedTextBreakFollowing(it, omitStart + (length - keepCount) - 1, length); 68 68 omitStart = textBreakAtOrPreceding(it, omitStart); … … 116 116 #endif 117 117 118 NonSharedCharacterBreakIterator it( string.deprecatedCharacters(), length);118 NonSharedCharacterBreakIterator it(StringView(string).substring(0, length)); 119 119 unsigned keepLength = textBreakAtOrPreceding(it, keepCount); 120 120 unsigned truncatedLength = shouldInsertEllipsis ? keepLength + 1 : keepLength; … … 132 132 ASSERT(keepCount < STRING_BUFFER_SIZE); 133 133 134 NonSharedCharacterBreakIterator it( string.deprecatedCharacters(), length);134 NonSharedCharacterBreakIterator it(StringView(string).substring(0, length)); 135 135 unsigned keepLength = textBreakAtOrPreceding(it, keepCount); 136 136 memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength); … … 144 144 ASSERT(keepCount < STRING_BUFFER_SIZE); 145 145 146 TextBreakIterator* it = wordBreakIterator( string.deprecatedCharacters(), length);146 TextBreakIterator* it = wordBreakIterator(StringView(string).substring(0, length)); 147 147 unsigned keepLength = textBreakAtOrPreceding(it, keepCount); 148 148 memcpy(buffer, string.deprecatedCharacters(), sizeof(UChar) * keepLength); … … 164 164 unsigned startIndex = length - keepCount; 165 165 166 NonSharedCharacterBreakIterator it(string .deprecatedCharacters(), length);166 NonSharedCharacterBreakIterator it(string); 167 167 unsigned adjustedStartIndex = startIndex; 168 168 startIndex = boundedTextBreakFollowing(it, startIndex, length - startIndex); -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
r161589 r162184 210 210 CFIndex hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance); 211 211 int stringLength = complexTextRun.stringLength(); 212 TextBreakIterator* cursorPositionIterator = cursorMovementIterator( complexTextRun.characters(), stringLength);212 TextBreakIterator* cursorPositionIterator = cursorMovementIterator(StringView(complexTextRun.characters(), stringLength)); 213 213 int clusterStart; 214 214 if (isTextBreak(cursorPositionIterator, hitIndex)) -
trunk/Source/WebCore/platform/text/TextBoundaries.cpp
r160526 r162184 62 62 int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward) 63 63 { 64 TextBreakIterator* it = wordBreakIterator( chars, len);64 TextBreakIterator* it = wordBreakIterator(StringView(chars, len)); 65 65 66 66 if (forward) { … … 91 91 void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end) 92 92 { 93 TextBreakIterator* it = wordBreakIterator( chars, len);93 TextBreakIterator* it = wordBreakIterator(StringView(chars, len)); 94 94 *end = textBreakFollowing(it, position); 95 95 if (*end < 0) … … 100 100 void findEndWordBoundary(const UChar* chars, int len, int position, int* end) 101 101 { 102 TextBreakIterator* it = wordBreakIterator( chars, len);102 TextBreakIterator* it = wordBreakIterator(StringView(chars, len)); 103 103 *end = textBreakFollowing(it, position); 104 104 if (*end < 0) -
trunk/Source/WebCore/platform/text/TextBreakIterator.cpp
r162109 r162184 139 139 // Static iterators 140 140 141 TextBreakIterator* wordBreakIterator( const UChar* buffer, int length)141 TextBreakIterator* wordBreakIterator(StringView string) 142 142 { 143 143 static TextBreakIterator* staticWordBreakIterator = initializeIterator(UBRK_WORD); … … 145 145 return nullptr; 146 146 147 return setTextForIterator(*staticWordBreakIterator, StringView(buffer, length));148 } 149 150 TextBreakIterator* sentenceBreakIterator( const UChar* buffer, int length)147 return setTextForIterator(*staticWordBreakIterator, string); 148 } 149 150 TextBreakIterator* sentenceBreakIterator(StringView string) 151 151 { 152 152 static TextBreakIterator* staticSentenceBreakIterator = initializeIterator(UBRK_SENTENCE); … … 154 154 return nullptr; 155 155 156 return setTextForIterator(*staticSentenceBreakIterator, StringView(buffer, length));157 } 158 159 TextBreakIterator* cursorMovementIterator( const UChar* buffer, int length)156 return setTextForIterator(*staticSentenceBreakIterator, string); 157 } 158 159 TextBreakIterator* cursorMovementIterator(StringView string) 160 160 { 161 161 #if !PLATFORM(IOS) … … 251 251 return nullptr; 252 252 253 return setTextForIterator(*staticCursorMovementIterator, StringView(buffer, length));253 return setTextForIterator(*staticCursorMovementIterator, string); 254 254 } 255 255 … … 286 286 } 287 287 288 NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator( const UChar* buffer, int length)288 NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(StringView string) 289 289 { 290 290 m_iterator = nonSharedCharacterBreakIterator; … … 296 296 return; 297 297 298 m_iterator = setTextForIterator(*m_iterator, StringView(buffer, length));298 m_iterator = setTextForIterator(*m_iterator, string); 299 299 } 300 300 … … 365 365 return stringLength; 366 366 367 NonSharedCharacterBreakIterator it(s .deprecatedCharacters(), stringLength);367 NonSharedCharacterBreakIterator it(s); 368 368 if (!it) 369 369 return stringLength; … … 386 386 return std::min(stringLength, numGraphemeClusters); 387 387 388 NonSharedCharacterBreakIterator it(s .deprecatedCharacters(), stringLength);388 NonSharedCharacterBreakIterator it(s); 389 389 if (!it) 390 390 return std::min(stringLength, numGraphemeClusters); -
trunk/Source/WebCore/platform/text/TextBreakIterator.h
r161844 r162184 37 37 // from character break iterator is Thai prepend characters, see bug 24342. 38 38 // Use this for insertion point and selection manipulations. 39 TextBreakIterator* cursorMovementIterator( const UChar*, int length);39 TextBreakIterator* cursorMovementIterator(StringView); 40 40 41 TextBreakIterator* wordBreakIterator( const UChar*, int length);42 TextBreakIterator* sentenceBreakIterator( const UChar*, int length);41 TextBreakIterator* wordBreakIterator(StringView); 42 TextBreakIterator* sentenceBreakIterator(StringView); 43 43 44 44 TextBreakIterator* acquireLineBreakIterator(StringView, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength); … … 170 170 WTF_MAKE_NONCOPYABLE(NonSharedCharacterBreakIterator); 171 171 public: 172 NonSharedCharacterBreakIterator( const UChar*, int length);172 NonSharedCharacterBreakIterator(StringView); 173 173 ~NonSharedCharacterBreakIterator(); 174 174 -
trunk/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp
r151316 r162184 92 92 return; 93 93 94 TextBreakIterator* iter = wordBreakIterator(string .characters(), string.length());94 TextBreakIterator* iter = wordBreakIterator(string); 95 95 if (!iter) 96 96 return; -
trunk/Source/WebCore/rendering/RenderText.cpp
r161851 r162184 135 135 } 136 136 137 TextBreakIterator* boundary = wordBreakIterator( stringWithPrevious.characters(), length + 1);137 TextBreakIterator* boundary = wordBreakIterator(StringView(stringWithPrevious.characters(), length + 1)); 138 138 if (!boundary) 139 139 return; … … 1341 1341 1342 1342 StringImpl* textImpl = m_text.impl(); 1343 TextBreakIterator* iterator = cursorMovementIterator( textImpl->characters16(), textImpl->length());1343 TextBreakIterator* iterator = cursorMovementIterator(StringView(textImpl->characters16(), textImpl->length())); 1344 1344 if (!iterator) 1345 1345 return current - 1; … … 1494 1494 1495 1495 StringImpl* textImpl = m_text.impl(); 1496 TextBreakIterator* iterator = cursorMovementIterator( textImpl->characters16(), textImpl->length());1496 TextBreakIterator* iterator = cursorMovementIterator(StringView(textImpl->characters16(), textImpl->length())); 1497 1497 if (!iterator) 1498 1498 return current + 1; -
trunk/Source/WebKit/ios/ChangeLog
r162158 r162184 1 2014-01-15 Sam Weinig <sam@webkit.org> 2 3 TextBreakIterator's should support Latin-1 for all iterator types (Part 3) 4 https://bugs.webkit.org/show_bug.cgi?id=126856 5 6 Reviewed by Ryosuke Niwa. 7 8 Change all the TextBreakIterator creation functions to take StringViews. Remove a few 9 now unnecessary up-conversions to UTF-16 in the process. 10 11 * Misc/WebNSStringDrawing.mm: 12 1 13 2014-01-16 Anders Carlsson <andersca@apple.com> 2 14 -
trunk/Source/WebKit/ios/Misc/WebNSStringDrawing.mm
r160106 r162184 457 457 // We can break on characters. We should do something smarter, like split the length of the entire line 458 458 // Don't, however, break in the middle of a character. 459 NonSharedCharacterBreakIterator it( pos, lengthRemaining);459 NonSharedCharacterBreakIterator it(StringView(pos, lengthRemaining)); 460 460 breakPos = boundedTextBreakFollowing(it, 0, lengthRemaining); 461 461 } … … 538 538 // Fit it on a line one character at a time and break when no more characters fit 539 539 // Force at least one character to avoid the edge case where a single glyph doesn't fit within width 540 NonSharedCharacterBreakIterator it( pos, lengthRemaining);540 NonSharedCharacterBreakIterator it(StringView(pos, lengthRemaining)); 541 541 int offset = 0; 542 542 int nextCharBreak = boundedTextBreakFollowing(it, offset, lengthRemaining); -
trunk/Source/WebKit2/ChangeLog
r162182 r162184 1 2014-01-15 Sam Weinig <sam@webkit.org> 2 3 TextBreakIterator's should support Latin-1 for all iterator types (Part 3) 4 https://bugs.webkit.org/show_bug.cgi?id=126856 5 6 Reviewed by Ryosuke Niwa. 7 8 Change all the TextBreakIterator creation functions to take StringViews. Remove a few 9 now unnecessary up-conversions to UTF-16 in the process. 10 11 * UIProcess/efl/TextCheckerEfl.cpp: 12 (WebKit::nextWordOffset): 13 (WebKit::TextChecker::checkTextOfParagraph): 14 1 15 2014-01-16 Eunmi Lee <eunmi15.lee@samsung.com> 2 16 -
trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp
r151314 r162184 128 128 // For many word separators, the method doesn't properly determine the boundaries 129 129 // without resetting the iterator. 130 TextBreakIterator* textIterator = wordBreakIterator( text, length);130 TextBreakIterator* textIterator = wordBreakIterator(StringView(text, length)); 131 131 if (!textIterator) 132 132 return currentOffset; … … 154 154 #if ENABLE(SPELLCHECK) 155 155 if (checkingTypes & TextCheckingTypeSpelling) { 156 TextBreakIterator* textIterator = wordBreakIterator( text, length);156 TextBreakIterator* textIterator = wordBreakIterator(StringView(text, length)); 157 157 if (!textIterator) 158 158 return paragraphCheckingResult;
Note: See TracChangeset
for help on using the changeset viewer.