diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 10:03:08 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 10:03:08 +0000 |
commit | 6278441fe3cad3a15a61da31ca502fc3768b8b43 (patch) | |
tree | d17d3ab850a2baf86bf7660911b74141d21425f2 /views/controls/label.cc | |
parent | e79ed67a728c71d84a707af179a51a5818f5d9c9 (diff) | |
download | chromium_src-6278441fe3cad3a15a61da31ca502fc3768b8b43.zip chromium_src-6278441fe3cad3a15a61da31ca502fc3768b8b43.tar.gz chromium_src-6278441fe3cad3a15a61da31ca502fc3768b8b43.tar.bz2 |
Revert 104076 - Change std::wstring to string16 for views::Link
Change wst::string to string16 for view::Label and views::Link
BUG=68267
TEST=no user visible changes
Review URL: http://codereview.chromium.org/8113031
TBR=yosin@chromium.org
Review URL: http://codereview.chromium.org/8142026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/label.cc')
-rw-r--r-- | views/controls/label.cc | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/views/controls/label.cc b/views/controls/label.cc index 867b24f..e61c6e1 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -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 char Label::kViewClassName[] = "views/Label"; 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 @@ void Label::SetFont(const gfx::Font& font) { 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::GetAccessibleState(ui::AccessibleViewState* state) { } 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::OnBoundsChanged(const gfx::Rect& previous_bounds) { 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 @@ gfx::Font Label::GetDefaultFont() { 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 @@ gfx::Rect Label::GetAvailableRect() const { 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 @@ void Label::CalculateDrawStringParams(string16* paint_text, 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 @@ void Label::CalculateDrawStringParams(string16* paint_text, // 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(); |