OLD | NEW |
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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // this iterator. | 332 // this iterator. |
333 attribute_ = attribute; | 333 attribute_ = attribute; |
334 return true; | 334 return true; |
335 } | 335 } |
336 | 336 |
337 bool SpellcheckWordIterator::IsInitialized() const { | 337 bool SpellcheckWordIterator::IsInitialized() const { |
338 // Return true if we have an ICU custom iterator. | 338 // Return true if we have an ICU custom iterator. |
339 return !!iterator_; | 339 return !!iterator_; |
340 } | 340 } |
341 | 341 |
342 bool SpellcheckWordIterator::SetText(const char16* text, size_t length) { | 342 bool SpellcheckWordIterator::SetText(const base::char16* text, size_t length) { |
343 DCHECK(!!iterator_); | 343 DCHECK(!!iterator_); |
344 | 344 |
345 // Set the text to be split by this iterator. | 345 // Set the text to be split by this iterator. |
346 UErrorCode status = U_ZERO_ERROR; | 346 UErrorCode status = U_ZERO_ERROR; |
347 ubrk_setText(iterator_, text, length, &status); | 347 ubrk_setText(iterator_, text, length, &status); |
348 if (U_FAILURE(status)) | 348 if (U_FAILURE(status)) |
349 return false; | 349 return false; |
350 | 350 |
351 // Retrieve the position to the first word in this text. We return false if | 351 // Retrieve the position to the first word in this text. We return false if |
352 // this text does not have any words. (For example, The input text consists | 352 // this text does not have any words. (For example, The input text consists |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (status != U_ZERO_ERROR && status != U_STRING_NOT_TERMINATED_WARNING) | 422 if (status != U_ZERO_ERROR && status != U_STRING_NOT_TERMINATED_WARNING) |
423 return false; | 423 return false; |
424 | 424 |
425 // Copy the normalized text to the output. | 425 // Copy the normalized text to the output. |
426 icu::StringCharacterIterator it(output); | 426 icu::StringCharacterIterator it(output); |
427 for (UChar c = it.first(); c != icu::CharacterIterator::DONE; c = it.next()) | 427 for (UChar c = it.first(); c != icu::CharacterIterator::DONE; c = it.next()) |
428 attribute_->OutputChar(c, output_string); | 428 attribute_->OutputChar(c, output_string); |
429 | 429 |
430 return !output_string->empty(); | 430 return !output_string->empty(); |
431 } | 431 } |
OLD | NEW |