diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 16:24:45 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 16:24:45 +0000 |
commit | 76fcc3e9dc467366b9d1938834d7faff595ab873 (patch) | |
tree | dcfc78d6c356be77a902a3fe5e59a6590fe7521e /views | |
parent | 3a742fcae0c094dd1ea11354fb3dcfe9ccc07a73 (diff) | |
download | chromium_src-76fcc3e9dc467366b9d1938834d7faff595ab873.zip chromium_src-76fcc3e9dc467366b9d1938834d7faff595ab873.tar.gz chromium_src-76fcc3e9dc467366b9d1938834d7faff595ab873.tar.bz2 |
Revert 71169 - Revert 71167 - Remove wstring from gfx.
BUG=68882
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6121004
TBR=avi@chromium.org
Review URL: http://codereview.chromium.org/6134010
TBR=joi@chromium.org
Review URL: http://codereview.chromium.org/6130008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/text_button.cc | 6 | ||||
-rw-r--r-- | views/controls/label.cc | 2 | ||||
-rw-r--r-- | views/controls/label_unittest.cc | 18 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_gtk.cc | 2 | ||||
-rw-r--r-- | views/controls/textfield/gtk_views_entry.cc | 2 | ||||
-rw-r--r-- | views/controls/textfield/gtk_views_textview.cc | 2 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_views.cc | 10 | ||||
-rw-r--r-- | views/drag_utils.cc | 2 | ||||
-rw-r--r-- | views/view_text_utils.cc | 14 | ||||
-rw-r--r-- | views/window/custom_frame_view.cc | 7 |
11 files changed, 33 insertions, 34 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index 63eeb0e..470d97c 100644 --- a/views/controls/button/text_button.cc +++ b/views/controls/button/text_button.cc @@ -360,7 +360,7 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { text_bounds.y(), text_bounds.width(), text_bounds.height(), draw_string_flags); #else - canvas->DrawStringInt(UTF16ToWideHack(text_), + canvas->DrawStringInt(text_, font_, text_color, text_bounds.x(), @@ -371,11 +371,11 @@ void TextButton::Paint(gfx::Canvas* canvas, bool for_drag) { #endif } else if (has_text_halo_) { canvas->AsCanvasSkia()->DrawStringWithHalo( - UTF16ToWideHack(text_), font_, text_color, text_halo_color_, + text_, font_, text_color, text_halo_color_, text_bounds.x(), text_bounds.y(), text_bounds.width(), text_bounds.height(), draw_string_flags); } else { - canvas->DrawStringInt(UTF16ToWideHack(text_), + canvas->DrawStringInt(text_, font_, text_color, text_bounds.x(), diff --git a/views/controls/label.cc b/views/controls/label.cc index d4bf9f7..8692622 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -271,7 +271,7 @@ void Label::PaintText(gfx::Canvas* canvas, 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); diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc index 267d260..504861e 100644 --- a/views/controls/label_unittest.cc +++ b/views/controls/label_unittest.cc @@ -15,22 +15,22 @@ namespace views { // All text sizing measurements (width and height) should be greater than this. const int kMinTextDimension = 4; -#if defined(WIN_OS) +#if defined(OS_WIN) // Courier is failing on linux because it's non scalable. TEST(LabelTest, FontPropertyCourier) { Label label; - std::wstring font_name(L"courier"); - gfx::Font font = gfx::Font::CreateFont(font_name, 30); + string16 font_name(ASCIIToUTF16("courier")); + gfx::Font font(font_name, 30); label.SetFont(font); gfx::Font font_used = label.font(); - EXPECT_EQ(font_name, font_used.FontName()); - EXPECT_EQ(30, font_used.FontSize()); + EXPECT_EQ(font_name, font_used.GetFontName()); + EXPECT_EQ(30, font_used.GetFontSize()); } #endif TEST(LabelTest, FontPropertyArial) { Label label; - std::wstring font_name(L"arial"); + string16 font_name(ASCIIToUTF16("arial")); gfx::Font font(font_name, 30); label.SetFont(font); gfx::Font font_used = label.font(); @@ -214,7 +214,7 @@ TEST(LabelTest, MultiLineSizing) { // SizeToFit with limited width. label.SizeToFit(required_width - 1); int constrained_width = label.GetLocalBounds(true).width(); -#if defined(WIN_OS) +#if defined(OS_WIN) // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) // has to be fixed to return the size that fits to given width/height. EXPECT_LT(constrained_width, required_width); @@ -229,7 +229,7 @@ TEST(LabelTest, MultiLineSizing) { int required_height = label.GetHeightForWidth(required_width); EXPECT_GT(required_height, kMinTextDimension); int height_for_constrained_width = label.GetHeightForWidth(constrained_width); -#if defined(WIN_OS) +#if defined(OS_WIN) // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) // has to be fixed to return the size that fits to given width/height. EXPECT_GT(height_for_constrained_width, required_height); @@ -261,7 +261,7 @@ TEST(LabelTest, MultiLineSizing) { // calculation. If it is, then the height will grow when width // is shrunk. int height1 = label.GetHeightForWidth(required_width_with_border - 1); -#if defined(WIN_OS) +#if defined(OS_WIN) // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) // has to be fixed to return the size that fits to given width/height. EXPECT_GT(height1, required_height_with_border); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index e2359d7..8d2b84d 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -613,7 +613,7 @@ void MenuItemView::PaintAccelerator(gfx::Canvas* canvas) { else flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; canvas->DrawStringInt( - UTF16ToWideHack(accel_text), font, TextButton::kDisabledColor, + accel_text, font, TextButton::kDisabledColor, accel_bounds.x(), accel_bounds.y(), accel_bounds.width(), accel_bounds.height(), flags); } diff --git a/views/controls/menu/menu_item_view_gtk.cc b/views/controls/menu/menu_item_view_gtk.cc index ab4c5315..8c1d1ee 100644 --- a/views/controls/menu/menu_item_view_gtk.cc +++ b/views/controls/menu/menu_item_view_gtk.cc @@ -91,7 +91,7 @@ void MenuItemView::Paint(gfx::Canvas* canvas, bool for_drag) { (available_height - font.GetHeight()) / 2, width, font.GetHeight()); text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); - canvas->DrawStringInt(GetTitle(), font, fg_color, + canvas->DrawStringInt(WideToUTF16Hack(GetTitle()), font, fg_color, text_bounds.x(), text_bounds.y(), text_bounds.width(), text_bounds.height(), GetRootMenuItem()->GetDrawStringFlags()); diff --git a/views/controls/textfield/gtk_views_entry.cc b/views/controls/textfield/gtk_views_entry.cc index c8e03ce..9a2628b 100644 --- a/views/controls/textfield/gtk_views_entry.cc +++ b/views/controls/textfield/gtk_views_entry.cc @@ -45,7 +45,7 @@ static gint gtk_views_entry_expose_event(GtkWidget *widget, gfx::Font font = host->textfield()->font(); const string16 text = host->textfield()->text_to_display_when_empty(); canvas.DrawStringInt( - UTF16ToWide(text), font, + text, font, gfx::GdkColorToSkColor(widget->style->text[GTK_STATE_INSENSITIVE]), insets.left(), insets.top(), widget->allocation.width - insets.width(), font.GetHeight()); diff --git a/views/controls/textfield/gtk_views_textview.cc b/views/controls/textfield/gtk_views_textview.cc index b7ec107..a2cc19f 100644 --- a/views/controls/textfield/gtk_views_textview.cc +++ b/views/controls/textfield/gtk_views_textview.cc @@ -50,7 +50,7 @@ static gint gtk_views_textview_expose_event(GtkWidget *widget, gfx::Font font = host->textfield()->font(); const string16 text = host->textfield()->text_to_display_when_empty(); canvas.DrawStringInt( - UTF16ToWide(text), font, + text, font, gfx::GdkColorToSkColor(widget->style->text[GTK_STATE_INSENSITIVE]), insets.left(), insets.top(), widget->allocation.width - insets.width(), font.GetHeight()); diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc index 923de0c..ceb5325 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -404,13 +404,11 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { if ((*iter).selected) { canvas->FillRectInt(selection_color, x_offset, y, width, text_height); - canvas->DrawStringInt( - UTF16ToWide(text), GetFont(), kSelectedTextColor, - x_offset, y, width, text_height); + canvas->DrawStringInt(text, GetFont(), kSelectedTextColor, + x_offset, y, width, text_height); } else { - canvas->DrawStringInt( - UTF16ToWide(text), GetFont(), text_color, - x_offset, y, width, text_height); + canvas->DrawStringInt(text, GetFont(), text_color, + x_offset, y, width, text_height); } x_offset += width; } diff --git a/views/drag_utils.cc b/views/drag_utils.cc index 8c00edf..d249196 100644 --- a/views/drag_utils.cc +++ b/views/drag_utils.cc @@ -80,7 +80,7 @@ void CreateDragImageForFile(const FilePath& file_name, width - 2, font.GetHeight(), gfx::Canvas::TEXT_ALIGN_CENTER); #else - canvas.DrawStringInt(name, font, kFileDragImageTextColor, + canvas.DrawStringInt(WideToUTF16Hack(name), font, kFileDragImageTextColor, 0, icon->height() + kLinkDragImageVPadding, width, font.GetHeight(), gfx::Canvas::TEXT_ALIGN_CENTER); #endif diff --git a/views/view_text_utils.cc b/views/view_text_utils.cc index 8f13617..70cb8b9 100644 --- a/views/view_text_utils.cc +++ b/views/view_text_utils.cc @@ -110,14 +110,14 @@ void DrawTextStartingFrom(gfx::Canvas* canvas, // iterate to the next line breaking opportunity. while (iter.Advance()) { // Get the word and figure out the dimensions. - std::wstring word; + string16 word; if (!ltr_within_rtl) - word = UTF16ToWide(iter.GetString()); // Get the next word. + word = iter.GetString(); // Get the next word. else - word = text; // Draw the whole text at once. + word = text16; // Draw the whole text at once. - int w = font.GetStringWidth(WideToUTF16Hack(word)), h = font.GetHeight(); - gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(word), font, &w, &h, flags); + int w = font.GetStringWidth(word), h = font.GetHeight(); + gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags); // If we exceed the boundaries, we need to wrap. WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds); @@ -129,7 +129,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas, // When drawing LTR strings inside RTL text we need to make sure we // draw the trailing space (if one exists after the LTR text) to the // left of the LTR string. - if (ltr_within_rtl && word[word.size() - 1] == L' ') { + if (ltr_within_rtl && word[word.size() - 1] == ' ') { int space_w = font.GetStringWidth(ASCIIToUTF16(" ")); int space_h = font.GetHeight(); gfx::CanvasSkia::SizeStringInt(ASCIIToUTF16(" "), font, &space_w, @@ -143,7 +143,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas, canvas->DrawStringInt(word, font, text_color, x, y, w, font.GetHeight(), flags); - if (word.size() > 0 && word[word.size() - 1] == L'\x0a') { + if (word.size() > 0 && word[word.size() - 1] == '\x0a') { // When we come across '\n', we move to the beginning of the next line. position->set_width(0); position->Enlarge(0, font.GetHeight()); diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index b43b678..c2d8599 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -413,9 +413,10 @@ void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { if (!d) return; - canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE, - MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), - title_bounds_.width(), title_bounds_.height()); + canvas->DrawStringInt(WideToUTF16Hack(d->GetWindowTitle()), *title_font_, + SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_), + title_bounds_.y(), title_bounds_.width(), + title_bounds_.height()); } void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |