Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/renderer/spellchecker/spellcheck_worditerator.cc

Issue 1272683002: Creates BreakIterator::GetWordBreakStatus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« base/i18n/break_iterator.h ('K') | « base/i18n/break_iterator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Implements a custom word iterator used for our spellchecker. 5 // Implements a custom word iterator used for our spellchecker.
6 6
7 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h" 7 #include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 // Find a word that can be checked for spelling. Our rule sets filter out 375 // Find a word that can be checked for spelling. Our rule sets filter out
376 // invalid words (e.g. numbers and characters not supported by the 376 // invalid words (e.g. numbers and characters not supported by the
377 // spellchecker language) so this ubrk_getRuleStatus() call returns 377 // spellchecker language) so this ubrk_getRuleStatus() call returns
378 // UBRK_WORD_NONE when this iterator finds an invalid word. So, we skip such 378 // UBRK_WORD_NONE when this iterator finds an invalid word. So, we skip such
379 // words until we can find a valid word or reach the end of the input string. 379 // words until we can find a valid word or reach the end of the input string.
380 while (iterator_->Advance()) { 380 while (iterator_->Advance()) {
381 const size_t start = iterator_->prev(); 381 const size_t start = iterator_->prev();
382 const size_t length = iterator_->pos() - start; 382 const size_t length = iterator_->pos() - start;
383 if (iterator_->IsWord()) { 383 if (iterator_->IsWordBreak() == base::i18n::BreakIterator::IS_WORD_BREAK) {
384 if (Normalize(start, length, word_string)) { 384 if (Normalize(start, length, word_string)) {
385 *word_start = start; 385 *word_start = start;
386 *word_length = length; 386 *word_length = length;
387 return true; 387 return true;
388 } 388 }
389 } 389 }
390 } 390 }
391 391
392 // There aren't any more words in the given text. 392 // There aren't any more words in the given text.
393 return false; 393 return false;
(...skipping 20 matching lines...) Expand all
414 if (status != U_ZERO_ERROR && status != U_STRING_NOT_TERMINATED_WARNING) 414 if (status != U_ZERO_ERROR && status != U_STRING_NOT_TERMINATED_WARNING)
415 return false; 415 return false;
416 416
417 // Copy the normalized text to the output. 417 // Copy the normalized text to the output.
418 icu::StringCharacterIterator it(output); 418 icu::StringCharacterIterator it(output);
419 for (UChar c = it.first(); c != icu::CharacterIterator::DONE; c = it.next()) 419 for (UChar c = it.first(); c != icu::CharacterIterator::DONE; c = it.next())
420 attribute_->OutputChar(c, output_string); 420 attribute_->OutputChar(c, output_string);
421 421
422 return !output_string->empty(); 422 return !output_string->empty();
423 } 423 }
OLDNEW
« base/i18n/break_iterator.h ('K') | « base/i18n/break_iterator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698