diff options
author | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-13 00:31:44 +0000 |
---|---|---|
committer | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-13 00:31:44 +0000 |
commit | 6ed842ed0df8fcdeaeacb0e57da7eef0132196e2 (patch) | |
tree | 654e8fc3d5753dc7ba7e2fb16771a19a102fc5fe | |
parent | 0dd7769fc76a86619a4ebdd092851ccce923c4b8 (diff) | |
download | chromium_src-6ed842ed0df8fcdeaeacb0e57da7eef0132196e2.zip chromium_src-6ed842ed0df8fcdeaeacb0e57da7eef0132196e2.tar.gz chromium_src-6ed842ed0df8fcdeaeacb0e57da7eef0132196e2.tar.bz2 |
Remove ampersands from menu item titles. See http://crosbug.com/1273
BUG=None
TEST=Right click bookmark bar. See no & in Cut,Copy,Paste and Bookmark
Manager.
Review URL: http://codereview.chromium.org/593074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38987 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | app/gfx/canvas_linux.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/app/gfx/canvas_linux.cc b/app/gfx/canvas_linux.cc index a0f7e0d..0179577 100755 --- a/app/gfx/canvas_linux.cc +++ b/app/gfx/canvas_linux.cc @@ -16,6 +16,8 @@ namespace { +const gunichar kAcceleratorChar = '&'; + // Font settings that we initialize once and then use when drawing text in // DrawStringInt(). static cairo_font_options_t* cairo_font_options = NULL; @@ -114,6 +116,7 @@ Canvas::~Canvas() { // Pass a width > 0 to force wrapping and elliding. static void SetupPangoLayout(PangoLayout* layout, + const std::wstring& text, const gfx::Font& font, int width, int flags) { @@ -161,6 +164,20 @@ static void SetupPangoLayout(PangoLayout* layout, PangoFontDescription* desc = gfx::Font::PangoFontFromGfxFont(font); pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); + + // Set text and accelerator character if needed. + std::string utf8 = WideToUTF8(text); + if (flags & gfx::Canvas::HIDE_PREFIX) { + // Escape the text string to be used as markup. + gchar* escaped_text = g_markup_escape_text(utf8.c_str(), utf8.size()); + pango_layout_set_markup_with_accel(layout, + escaped_text, + strlen(escaped_text), + kAcceleratorChar, NULL); + g_free(escaped_text); + } else { + pango_layout_set_text(layout, utf8.data(), utf8.size()); + } } // static @@ -173,10 +190,7 @@ void Canvas::SizeStringInt(const std::wstring& text, cairo_t* cr = cairo_create(surface); PangoLayout* layout = pango_cairo_create_layout(cr); - SetupPangoLayout(layout, font, *width, flags); - - std::string utf8 = WideToUTF8(text); - pango_layout_set_text(layout, utf8.data(), utf8.size()); + SetupPangoLayout(layout, text, font, *width, flags); pango_layout_get_pixel_size(layout, width, height); @@ -212,7 +226,7 @@ void Canvas::DrawStringInt(const std::wstring& text, cairo_t* cr = beginPlatformPaint(); PangoLayout* layout = pango_cairo_create_layout(cr); - SetupPangoLayout(layout, font, w, flags); + SetupPangoLayout(layout, text, font, w, flags); pango_layout_set_height(layout, h * PANGO_SCALE); @@ -222,9 +236,6 @@ void Canvas::DrawStringInt(const std::wstring& text, SkColorGetG(color) / 255.0, SkColorGetB(color) / 255.0); - std::string utf8 = WideToUTF8(text); - pango_layout_set_text(layout, utf8.data(), utf8.size()); - int width, height; pango_layout_get_pixel_size(layout, &width, &height); |