summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/username_view.cc3
-rw-r--r--chrome/browser/ui/views/sad_tab_view.cc5
-rw-r--r--gfx/canvas_skia.h3
-rw-r--r--gfx/canvas_skia_linux.cc9
-rw-r--r--gfx/canvas_skia_mac.mm4
-rw-r--r--gfx/platform_font_gtk.cc3
-rw-r--r--gfx/platform_font_mac.mm4
-rw-r--r--gfx/platform_font_win.cc4
-rw-r--r--views/controls/button/text_button.cc3
-rw-r--r--views/controls/label.cc6
-rw-r--r--views/view_text_utils.cc5
11 files changed, 31 insertions, 18 deletions
diff --git a/chrome/browser/chromeos/login/username_view.cc b/chrome/browser/chromeos/login/username_view.cc
index 750c788..efc1976 100644
--- a/chrome/browser/chromeos/login/username_view.cc
+++ b/chrome/browser/chromeos/login/username_view.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/login/username_view.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
#include "gfx/rect.h"
@@ -78,7 +79,7 @@ void UsernameView::PaintUsername(const gfx::Rect& bounds) {
gfx::Canvas::TEXT_VALIGN_MIDDLE |
gfx::Canvas::NO_ELLIPSIS;
int text_height;
- gfx::CanvasSkia::SizeStringInt(GetText(), font(),
+ gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(GetText()), font(),
&text_width_, &text_height,
flags);
text_width_ = std::min(text_width_, bounds.width() - margin_width_);
diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc
index f8a48a9..8849f4b 100644
--- a/chrome/browser/ui/views/sad_tab_view.cc
+++ b/chrome/browser/ui/views/sad_tab_view.cc
@@ -6,6 +6,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
@@ -95,8 +96,8 @@ void SadTabView::Layout() {
gfx::CanvasSkia cc(0, 0, true);
int message_width = static_cast<int>(width() * kMessageSize);
int message_height = 0;
- cc.SizeStringInt(message_, *message_font_, &message_width, &message_height,
- gfx::Canvas::MULTI_LINE);
+ cc.SizeStringInt(WideToUTF16Hack(message_), *message_font_, &message_width,
+ &message_height, gfx::Canvas::MULTI_LINE);
int message_x = (width() - message_width) / 2;
int message_y = title_bounds_.bottom() + kTitleMessageSpacing;
message_bounds_.SetRect(message_x, message_y, message_width, message_height);
diff --git a/gfx/canvas_skia.h b/gfx/canvas_skia.h
index d309784..153e812 100644
--- a/gfx/canvas_skia.h
+++ b/gfx/canvas_skia.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/basictypes.h"
+#include "base/string16.h"
#include "gfx/canvas.h"
#include "skia/ext/platform_canvas.h"
@@ -48,7 +49,7 @@ class CanvasSkia : public skia::PlatformCanvas,
// Attempts to fit the text with the provided width and height. Increases
// height and then width as needed to make the text fit. This method
// supports multiple lines.
- static void SizeStringInt(const std::wstring& text,
+ static void SizeStringInt(const string16& text,
const gfx::Font& font,
int* width, int* height,
int flags);
diff --git a/gfx/canvas_skia_linux.cc b/gfx/canvas_skia_linux.cc
index 02a2dfab..e07929b 100644
--- a/gfx/canvas_skia_linux.cc
+++ b/gfx/canvas_skia_linux.cc
@@ -90,7 +90,7 @@ static void UpdateCairoFontOptions() {
// Pass a width > 0 to force wrapping and elliding.
static void SetupPangoLayout(PangoLayout* layout,
- const std::wstring& text,
+ const string16& text,
const gfx::Font& font,
int width,
int flags) {
@@ -140,7 +140,7 @@ static void SetupPangoLayout(PangoLayout* layout,
pango_font_description_free(desc);
// Set text and accelerator character if needed.
- std::string utf8 = WideToUTF8(text);
+ std::string utf8 = UTF16ToUTF8(text);
if (flags & gfx::Canvas::SHOW_PREFIX) {
// Escape the text string to be used as markup.
gchar* escaped_text = g_markup_escape_text(utf8.c_str(), utf8.size());
@@ -211,7 +211,8 @@ DrawStringContext::DrawStringContext(gfx::CanvasSkia* canvas,
cr_ = canvas_->beginPlatformPaint();
layout_ = pango_cairo_create_layout(cr_);
- SetupPangoLayout(layout_, text, font, bounds_.width(), flags_);
+ SetupPangoLayout(layout_, WideToUTF16Hack(text), font, bounds_.width(),
+ flags_);
pango_layout_set_height(layout_, bounds_.height() * PANGO_SCALE);
@@ -309,7 +310,7 @@ CanvasSkia::~CanvasSkia() {
}
// static
-void CanvasSkia::SizeStringInt(const std::wstring& text,
+void CanvasSkia::SizeStringInt(const string16& text,
const gfx::Font& font,
int* width, int* height,
int flags) {
diff --git a/gfx/canvas_skia_mac.mm b/gfx/canvas_skia_mac.mm
index 547a5e4..1c3dcca 100644
--- a/gfx/canvas_skia_mac.mm
+++ b/gfx/canvas_skia_mac.mm
@@ -25,12 +25,12 @@ CanvasSkia::~CanvasSkia() {
}
// static
-void CanvasSkia::SizeStringInt(const std::wstring& text,
+void CanvasSkia::SizeStringInt(const string16& text,
const gfx::Font& font,
int* width, int* height,
int flags) {
NSFont* native_font = font.GetNativeFont();
- NSString* ns_string = base::SysWideToNSString(text);
+ NSString* ns_string = base::SysUTF16ToNSString(text);
NSDictionary* attributes =
[NSDictionary dictionaryWithObject:native_font
forKey:NSFontAttributeName];
diff --git a/gfx/platform_font_gtk.cc b/gfx/platform_font_gtk.cc
index 7633c10..bc4d05b 100644
--- a/gfx/platform_font_gtk.cc
+++ b/gfx/platform_font_gtk.cc
@@ -221,7 +221,8 @@ int PlatformFontGtk::GetAverageCharacterWidth() const {
int PlatformFontGtk::GetStringWidth(const std::wstring& text) const {
int width = 0, height = 0;
- CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontGtk*>(this)),
+ CanvasSkia::SizeStringInt(WideToUTF16Hack(text),
+ Font(const_cast<PlatformFontGtk*>(this)),
&width, &height, gfx::Canvas::NO_ELLIPSIS);
return width;
}
diff --git a/gfx/platform_font_mac.mm b/gfx/platform_font_mac.mm
index 1fb8316..80b9be4 100644
--- a/gfx/platform_font_mac.mm
+++ b/gfx/platform_font_mac.mm
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/scoped_nsobject.h"
#include "base/sys_string_conversions.h"
+#include "base/utf_string_conversions.h"
#include "gfx/canvas_skia.h"
#include "gfx/font.h"
@@ -57,7 +58,8 @@ int PlatformFontMac::GetAverageCharacterWidth() const {
int PlatformFontMac::GetStringWidth(const std::wstring& text) const {
int width = 0, height = 0;
- CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontMac*>(this)),
+ CanvasSkia::SizeStringInt(WideToUTF16Hack(text),
+ Font(const_cast<PlatformFontMac*>(this)),
&width, &height, gfx::Canvas::NO_ELLIPSIS);
return width;
}
diff --git a/gfx/platform_font_win.cc b/gfx/platform_font_win.cc
index 41cadde..05db587 100644
--- a/gfx/platform_font_win.cc
+++ b/gfx/platform_font_win.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "base/win_util.h"
#include "gfx/canvas_skia.h"
#include "gfx/font.h"
@@ -103,7 +104,8 @@ int PlatformFontWin::GetAverageCharacterWidth() const {
int PlatformFontWin::GetStringWidth(const std::wstring& text) const {
int width = 0, height = 0;
- CanvasSkia::SizeStringInt(text, Font(const_cast<PlatformFontWin*>(this)),
+ CanvasSkia::SizeStringInt(WideToUTF16Hack(text),
+ Font(const_cast<PlatformFontWin*>(this)),
&width, &height, gfx::Canvas::NO_ELLIPSIS);
return width;
}
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index 578be80..1df698a 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -9,6 +9,7 @@
#include "app/throb_animation.h"
#include "app/resource_bundle.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "gfx/canvas_skia.h"
#include "views/controls/button/button.h"
#include "views/event.h"
@@ -402,7 +403,7 @@ void TextButton::UpdateColor() {
void TextButton::UpdateTextSize() {
int width = 0, height = 0;
gfx::CanvasSkia::SizeStringInt(
- text_, font_, &width, &height,
+ WideToUTF16Hack(text_), font_, &width, &height,
gfx::Canvas::NO_ELLIPSIS | PrefixTypeToCanvasType(prefix_type_));
// Add 2 extra pixels to width and height when text halo is used.
diff --git a/views/controls/label.cc b/views/controls/label.cc
index 32df88a..b228c78b 100644
--- a/views/controls/label.cc
+++ b/views/controls/label.cc
@@ -68,7 +68,8 @@ int Label::GetHeightForWidth(int w) {
w = std::max(0, w - GetInsets().width());
int h = font_.GetHeight();
- gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h, ComputeMultiLineFlags());
+ gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(text_), font_, &w, &h,
+ ComputeMultiLineFlags());
return h + GetInsets().height();
}
@@ -294,7 +295,8 @@ gfx::Size Label::GetTextSize() const {
int flags = ComputeMultiLineFlags();
if (!is_multi_line_)
flags |= gfx::Canvas::NO_ELLIPSIS;
- gfx::CanvasSkia::SizeStringInt(text_, font_, &w, &h, flags);
+ gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(text_), font_, &w, &h,
+ flags);
text_size_.SetSize(w, h);
text_size_valid_ = true;
}
diff --git a/views/view_text_utils.cc b/views/view_text_utils.cc
index 9b4442d..73bef45 100644
--- a/views/view_text_utils.cc
+++ b/views/view_text_utils.cc
@@ -117,7 +117,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas,
word = text; // Draw the whole text at once.
int w = font.GetStringWidth(word), h = font.GetHeight();
- gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags);
+ gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(word), font, &w, &h, flags);
// If we exceed the boundaries, we need to wrap.
WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds);
@@ -131,7 +131,8 @@ void DrawTextStartingFrom(gfx::Canvas* canvas,
// left of the LTR string.
if (ltr_within_rtl && word[word.size() - 1] == L' ') {
int space_w = font.GetStringWidth(L" "), space_h = font.GetHeight();
- gfx::CanvasSkia::SizeStringInt(L" ", font, &space_w, &space_h, flags);
+ gfx::CanvasSkia::SizeStringInt(UTF8ToUTF16(" "), font, &space_w,
+ &space_h, flags);
x += space_w;
}
}