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

Unified Diff: views/controls/label.cc

Issue 8142026: Revert 104076 - Change std::wstring to string16 for views::Link (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/label.h ('k') | views/controls/label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/label.cc
===================================================================
--- views/controls/label.cc (revision 104083)
+++ views/controls/label.cc (working copy)
@@ -4,10 +4,8 @@
#include "views/controls/label.h"
-#include <algorithm>
#include <cmath>
#include <limits>
-#include <vector>
#include "base/i18n/rtl.h"
#include "base/logging.h"
@@ -35,14 +33,14 @@
const int Label::kFocusBorderPadding = 1;
Label::Label() {
- Init(string16(), GetDefaultFont());
+ Init(std::wstring(), GetDefaultFont());
}
-Label::Label(const string16& text) {
+Label::Label(const std::wstring& text) {
Init(text, GetDefaultFont());
}
-Label::Label(const string16& text, const gfx::Font& font) {
+Label::Label(const std::wstring& text, const gfx::Font& font) {
Init(text, font);
}
@@ -56,16 +54,16 @@
SchedulePaint();
}
-void Label::SetText(const string16& text) {
- text_ = text;
+void Label::SetText(const std::wstring& text) {
+ text_ = WideToUTF16Hack(text);
url_set_ = false;
text_size_valid_ = false;
PreferredSizeChanged();
SchedulePaint();
}
-const string16 Label::GetText() const {
- return url_set_ ? UTF8ToUTF16(url_.spec()) : text_;
+const std::wstring Label::GetText() const {
+ return url_set_ ? UTF8ToWide(url_.spec()) : UTF16ToWideHack(text_);
}
void Label::SetURL(const GURL& url) {
@@ -261,10 +259,10 @@
}
void Label::PaintText(gfx::Canvas* canvas,
- const string16& text,
+ const std::wstring& text,
const gfx::Rect& text_bounds,
int flags) {
- canvas->DrawStringInt(text, font_, color_,
+ canvas->DrawStringInt(WideToUTF16Hack(text), font_, color_,
text_bounds.x(), text_bounds.y(),
text_bounds.width(), text_bounds.height(), flags);
@@ -305,7 +303,7 @@
void Label::OnPaint(gfx::Canvas* canvas) {
OnPaintBackground(canvas);
- string16 paint_text;
+ std::wstring paint_text;
gfx::Rect text_bounds;
int flags = 0;
CalculateDrawStringParams(&paint_text, &text_bounds, &flags);
@@ -325,7 +323,7 @@
return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
}
-void Label::Init(const string16& text, const gfx::Font& font) {
+void Label::Init(const std::wstring& text, const gfx::Font& font) {
static bool initialized = false;
if (!initialized) {
#if defined(OS_WIN)
@@ -434,7 +432,7 @@
return bounds;
}
-void Label::CalculateDrawStringParams(string16* paint_text,
+void Label::CalculateDrawStringParams(std::wstring* paint_text,
gfx::Rect* text_bounds,
int* flags) const {
DCHECK(paint_text && text_bounds && flags);
@@ -442,8 +440,8 @@
if (url_set_) {
// TODO(jungshik) : Figure out how to get 'intl.accept_languages'
// preference and use it when calling ElideUrl.
- *paint_text = ui::ElideUrl(url_, font_, GetAvailableRect().width(),
- std::string());
+ *paint_text = UTF16ToWideHack(
+ ui::ElideUrl(url_, font_, GetAvailableRect().width(), std::string()));
// An URLs is always treated as an LTR text and therefore we should
// explicitly mark it as such if the locale is RTL so that URLs containing
@@ -454,13 +452,13 @@
// characters. We use the locale settings because an URL is always treated
// as an LTR string, even if its containing view does not use an RTL UI
// layout.
- *paint_text = base::i18n::GetDisplayStringInLTRDirectionality(
- *paint_text);
+ *paint_text = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality(
+ WideToUTF16(*paint_text)));
} else if (elide_in_middle_) {
- *paint_text = ui::ElideText(text_, font_, GetAvailableRect().width(),
- true);
+ *paint_text = UTF16ToWideHack(ui::ElideText(text_,
+ font_, GetAvailableRect().width(), true));
} else {
- *paint_text = text_;
+ *paint_text = UTF16ToWideHack(text_);
}
*text_bounds = GetTextBounds();
« no previous file with comments | « views/controls/label.h ('k') | views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698