summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 23:50:38 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 23:50:38 +0000
commitdabd6f450e9594a8962ef6f79447a8bfdc1c9f05 (patch)
treeaa4c8d04049f0ce9022fc5d4f8229f8a4584428c
parenta414e5ee96a40adb231c5b9585db275c10c2c104 (diff)
downloadchromium_src-dabd6f450e9594a8962ef6f79447a8bfdc1c9f05.zip
chromium_src-dabd6f450e9594a8962ef6f79447a8bfdc1c9f05.tar.gz
chromium_src-dabd6f450e9594a8962ef6f79447a8bfdc1c9f05.tar.bz2
wstring: remove wstring version of SplitString
Retry of r84336. BUG=23581 Review URL: http://codereview.chromium.org/6930047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84355 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/string_split.cc10
-rw-r--r--base/string_split.h6
-rw-r--r--base/string_split_unittest.cc21
-rw-r--r--views/controls/label.cc9
4 files changed, 25 insertions, 21 deletions
diff --git a/base/string_split.cc b/base/string_split.cc
index 44b5d06..2b1a037 100644
--- a/base/string_split.cc
+++ b/base/string_split.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.
@@ -35,20 +35,12 @@ static void SplitStringT(const STR& str,
}
}
-void SplitString(const std::wstring& str,
- wchar_t c,
- std::vector<std::wstring>* r) {
- SplitStringT(str, c, true, r);
-}
-
-#if !defined(WCHAR_T_IS_UTF16)
void SplitString(const string16& str,
char16 c,
std::vector<string16>* r) {
DCHECK(CBU16_IS_SINGLE(c));
SplitStringT(str, c, true, r);
}
-#endif
void SplitString(const std::string& str,
char c,
diff --git a/base/string_split.h b/base/string_split.h
index f2e8c86..883b126 100644
--- a/base/string_split.h
+++ b/base/string_split.h
@@ -20,12 +20,6 @@ namespace base {
// |str| begins with or ends with |s|, then an empty string is inserted.
//
// Every substring is trimmed of any leading or trailing white space.
-// Where wchar_t is char16 (i.e. Windows), |c| must be in BMP
-// (Basic Multilingual Plane). Elsewhere (Linux/Mac), wchar_t
-// should be a valid Unicode code point (32-bit).
-BASE_API void SplitString(const std::wstring& str,
- wchar_t c,
- std::vector<std::wstring>* r);
// NOTE: |c| must be in BMP (Basic Multilingual Plane)
BASE_API void SplitString(const string16& str,
char16 c,
diff --git a/base/string_split_unittest.cc b/base/string_split_unittest.cc
index 749d566..ee5877b 100644
--- a/base/string_split_unittest.cc
+++ b/base/string_split_unittest.cc
@@ -1,8 +1,10 @@
-// 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.
#include "base/string_split.h"
+
+#include "base/utf_string_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -10,6 +12,23 @@ using ::testing::ElementsAre;
namespace base {
+namespace {
+
+#if !defined(WCHAR_T_IS_UTF16)
+// Overload SplitString with a wide-char version to make it easier to
+// test the string16 version with wide character literals.
+void SplitString(const std::wstring& str,
+ wchar_t c,
+ std::vector<std::wstring>* result) {
+ std::vector<string16> result16;
+ SplitString(WideToUTF16(str), c, &result16);
+ for (size_t i = 0; i < result16.size(); ++i)
+ result->push_back(UTF16ToWide(result16[i]));
+}
+#endif
+
+} // anonymous namespace
+
class SplitStringIntoKeyValuesTest : public testing::Test {
protected:
std::string key;
diff --git a/views/controls/label.cc b/views/controls/label.cc
index 80454c3..627dd98 100644
--- a/views/controls/label.cc
+++ b/views/controls/label.cc
@@ -141,14 +141,13 @@ const Background* Label::GetMouseOverBackground() const {
void Label::SizeToFit(int max_width) {
DCHECK(is_multi_line_);
- std::vector<std::wstring> lines;
- base::SplitString(UTF16ToWideHack(text_), L'\n', &lines);
+ std::vector<string16> lines;
+ base::SplitString(text_, '\n', &lines);
int label_width = 0;
- for (std::vector<std::wstring>::const_iterator iter = lines.begin();
+ for (std::vector<string16>::const_iterator iter = lines.begin();
iter != lines.end(); ++iter) {
- label_width = std::max(label_width,
- font_.GetStringWidth(WideToUTF16Hack(*iter)));
+ label_width = std::max(label_width, font_.GetStringWidth(*iter));
}
label_width += GetInsets().width();