diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 18:15:25 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 18:15:25 +0000 |
commit | 36f1e277205d0bc6621866b1242ea7ee00166d4a (patch) | |
tree | 9d9fa8d67e2c2a4d5be66a99a04aa45d6fa9b58a /gfx | |
parent | 27a64faaaa8a1d23826794a5763d34cac5fbf9fe (diff) | |
download | chromium_src-36f1e277205d0bc6621866b1242ea7ee00166d4a.zip chromium_src-36f1e277205d0bc6621866b1242ea7ee00166d4a.tar.gz chromium_src-36f1e277205d0bc6621866b1242ea7ee00166d4a.tar.bz2 |
Convert SizeStringInt from taking a wstring to a string16.
BUG=23581
Review URL: http://codereview.chromium.org/5158006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/canvas_skia.h | 3 | ||||
-rw-r--r-- | gfx/canvas_skia_linux.cc | 9 | ||||
-rw-r--r-- | gfx/canvas_skia_mac.mm | 4 | ||||
-rw-r--r-- | gfx/platform_font_gtk.cc | 3 | ||||
-rw-r--r-- | gfx/platform_font_mac.mm | 4 | ||||
-rw-r--r-- | gfx/platform_font_win.cc | 4 |
6 files changed, 17 insertions, 10 deletions
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; } |