diff options
-rw-r--r-- | app/text_elider.cc | 5 | ||||
-rw-r--r-- | base/i18n/char_iterator.cc | 10 | ||||
-rw-r--r-- | base/i18n/char_iterator.h | 8 | ||||
-rw-r--r-- | base/i18n/char_iterator_unittest.cc | 16 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/wizard_accessibility_handler.cc | 10 | ||||
-rw-r--r-- | webkit/plugins/ppapi/event_conversion.cc | 4 |
6 files changed, 34 insertions, 19 deletions
diff --git a/app/text_elider.cc b/app/text_elider.cc index c4052aa..77ad958 100644 --- a/app/text_elider.cc +++ b/app/text_elider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,6 @@ #include "net/base/net_util.h" #include "net/base/registry_controlled_domain.h" - namespace { const char* kEllipsis = "\xE2\x80\xA6"; @@ -616,7 +615,7 @@ void RectangleString::AddWord(const string16& word) { // Word is so big that it must be fragmented. int array_start = 0; int char_start = 0; - base::UTF16CharIterator chars(&word); + base::i18n::UTF16CharIterator chars(&word); while (!chars.end()) { // When boundary is hit, add as much as will fit on this line. if (current_col_ + (chars.char_pos() - char_start) >= max_cols_) { diff --git a/base/i18n/char_iterator.cc b/base/i18n/char_iterator.cc index a6cf944..ce4d513 100644 --- a/base/i18n/char_iterator.cc +++ b/base/i18n/char_iterator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "unicode/utf16.h" namespace base { +namespace i18n { UTF8CharIterator::UTF8CharIterator(const std::string* str) : str_(reinterpret_cast<const uint8_t*>(str->data())), @@ -20,6 +21,9 @@ UTF8CharIterator::UTF8CharIterator(const std::string* str) U8_NEXT(str_, next_pos_, len_, char_); } +UTF8CharIterator::~UTF8CharIterator() { +} + bool UTF8CharIterator::Advance() { if (array_pos_ >= len_) return false; @@ -54,6 +58,9 @@ UTF16CharIterator::UTF16CharIterator(const char16* str, size_t str_len) ReadChar(); } +UTF16CharIterator::~UTF16CharIterator() { +} + bool UTF16CharIterator::Advance() { if (array_pos_ >= len_) return false; @@ -71,4 +78,5 @@ void UTF16CharIterator::ReadChar() { U16_NEXT(str_, next_pos_, len_, char_); } +} // namespace i18n } // namespace base diff --git a/base/i18n/char_iterator.h b/base/i18n/char_iterator.h index f45b04b..bd7cc9f 100644 --- a/base/i18n/char_iterator.h +++ b/base/i18n/char_iterator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,12 +25,13 @@ typedef unsigned char uint8_t; #endif namespace base { +namespace i18n { class UTF8CharIterator { public: // Requires |str| to live as long as the UTF8CharIterator does. UTF8CharIterator(const std::string* str); - ~UTF8CharIterator() {} + ~UTF8CharIterator(); // Return the starting array index of the current character within the // string. @@ -77,7 +78,7 @@ class UTF16CharIterator { // Requires |str| to live as long as the UTF16CharIterator does. UTF16CharIterator(const string16* str); UTF16CharIterator(const char16* str, size_t str_len); - ~UTF16CharIterator() {} + ~UTF16CharIterator(); // Return the starting array index of the current character within the // string. @@ -123,6 +124,7 @@ class UTF16CharIterator { DISALLOW_COPY_AND_ASSIGN(UTF16CharIterator); }; +} // namespace i18n } // namespace base #endif // BASE_I18N_CHAR_ITERATOR_H_ diff --git a/base/i18n/char_iterator_unittest.cc b/base/i18n/char_iterator_unittest.cc index 4fe7ebb..6d1294e 100644 --- a/base/i18n/char_iterator_unittest.cc +++ b/base/i18n/char_iterator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,16 +7,19 @@ #include "base/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { +namespace i18n { + TEST(CharIteratorsTest, TestUTF8) { std::string empty(""); - base::UTF8CharIterator empty_iter(&empty); + UTF8CharIterator empty_iter(&empty); ASSERT_TRUE(empty_iter.end()); ASSERT_EQ(0, empty_iter.array_pos()); ASSERT_EQ(0, empty_iter.char_pos()); ASSERT_FALSE(empty_iter.Advance()); std::string str("s\303\273r"); // [u with circumflex] - base::UTF8CharIterator iter(&str); + UTF8CharIterator iter(&str); ASSERT_FALSE(iter.end()); ASSERT_EQ(0, iter.array_pos()); ASSERT_EQ(0, iter.char_pos()); @@ -47,7 +50,7 @@ TEST(CharIteratorsTest, TestUTF8) { TEST(CharIteratorsTest, TestUTF16) { string16 empty = UTF8ToUTF16(""); - base::UTF16CharIterator empty_iter(&empty); + UTF16CharIterator empty_iter(&empty); ASSERT_TRUE(empty_iter.end()); ASSERT_EQ(0, empty_iter.array_pos()); ASSERT_EQ(0, empty_iter.char_pos()); @@ -59,7 +62,7 @@ TEST(CharIteratorsTest, TestUTF16) { // math double-struck A - 4 bytes in UTF8, 2 codewords in UTF16 // z string16 str = UTF8ToUTF16("x\303\273\360\235\224\270z"); - base::UTF16CharIterator iter(&str); + UTF16CharIterator iter(&str); ASSERT_FALSE(iter.end()); ASSERT_EQ(0, iter.array_pos()); ASSERT_EQ(0, iter.char_pos()); @@ -93,3 +96,6 @@ TEST(CharIteratorsTest, TestUTF16) { ASSERT_FALSE(iter.Advance()); } + +} // namespace i18n +} // namespace base diff --git a/chrome/browser/chromeos/login/wizard_accessibility_handler.cc b/chrome/browser/chromeos/login/wizard_accessibility_handler.cc index ab24214..5a66e0f 100644 --- a/chrome/browser/chromeos/login/wizard_accessibility_handler.cc +++ b/chrome/browser/chromeos/login/wizard_accessibility_handler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,7 +27,7 @@ namespace keys = extension_accessibility_api_constants; namespace { static std::string SubstringUTF8(std::string str, int start, int len) { - base::UTF8CharIterator iter(&str); + base::i18n::UTF8CharIterator iter(&str); for (int i = 0; i < start; i++) { if (!iter.Advance()) return std::string(); @@ -300,7 +300,7 @@ std::string WizardAccessibilityHandler::GetTextBoxValue( const AccessibilityTextBoxInfo* textbox_info) { std::string value = textbox_info->value(); if (textbox_info->password()) { - base::UTF8CharIterator iter(&value); + base::i18n::UTF8CharIterator iter(&value); std::string obscured; while (!iter.end()) { obscured += "*"; @@ -377,7 +377,7 @@ void WizardAccessibilityHandler::DescribeTextContentsChanged( // character's UTF8-encoded representation. scoped_array<int32> old_chars(new int32[old_array_len]); scoped_array<int> old_indices(new int[old_array_len + 1]); - base::UTF8CharIterator old_iter(&old_value); + base::i18n::UTF8CharIterator old_iter(&old_value); while (!old_iter.end()) { old_chars[old_iter.char_pos()] = old_iter.get(); old_indices[old_iter.char_pos()] = old_iter.array_pos(); @@ -388,7 +388,7 @@ void WizardAccessibilityHandler::DescribeTextContentsChanged( scoped_array<int32> new_chars(new int32[new_array_len]); scoped_array<int> new_indices(new int[new_array_len + 1]); - base::UTF8CharIterator new_iter(&new_value); + base::i18n::UTF8CharIterator new_iter(&new_value); while (!new_iter.end()) { new_chars[new_iter.char_pos()] = new_iter.get(); new_indices[new_iter.char_pos()] = new_iter.array_pos(); diff --git a/webkit/plugins/ppapi/event_conversion.cc b/webkit/plugins/ppapi/event_conversion.cc index a598bdb..f7d9139 100644 --- a/webkit/plugins/ppapi/event_conversion.cc +++ b/webkit/plugins/ppapi/event_conversion.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -94,7 +94,7 @@ void AppendCharEvent(const WebInputEvent& event, utf16_char_count++; // Make a separate PP_InputEvent for each Unicode character in the input. - base::UTF16CharIterator iter(key_event.text, utf16_char_count); + base::i18n::UTF16CharIterator iter(key_event.text, utf16_char_count); while (!iter.end()) { PP_InputEvent result = GetPPEventWithCommonFieldsAndType(event); result.u.character.modifier = key_event.modifiers; |