diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 15:16:04 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 15:16:04 +0000 |
commit | b22558a183cefa554a1730188a51994504100351 (patch) | |
tree | 1761e4f23e2e9060ff7bfa5a9026a4937d73e312 /views | |
parent | 3f891cf79f72f4768a15bfae051e08b9211ed8c3 (diff) | |
download | chromium_src-b22558a183cefa554a1730188a51994504100351.zip chromium_src-b22558a183cefa554a1730188a51994504100351.tar.gz chromium_src-b22558a183cefa554a1730188a51994504100351.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71169 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, 34 insertions, 33 deletions
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc index 470d97c..63eeb0e 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(text_, + canvas->DrawStringInt(UTF16ToWideHack(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( - text_, font_, text_color, text_halo_color_, + UTF16ToWideHack(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(text_, + canvas->DrawStringInt(UTF16ToWideHack(text_), font_, text_color, text_bounds.x(), diff --git a/views/controls/label.cc b/views/controls/label.cc index 8692622..d4bf9f7 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(WideToUTF16Hack(text), font_, color_, + canvas->DrawStringInt(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 504861e..267d260 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(OS_WIN) +#if defined(WIN_OS) // Courier is failing on linux because it's non scalable. TEST(LabelTest, FontPropertyCourier) { Label label; - string16 font_name(ASCIIToUTF16("courier")); - gfx::Font font(font_name, 30); + std::wstring font_name(L"courier"); + gfx::Font font = gfx::Font::CreateFont(font_name, 30); label.SetFont(font); gfx::Font font_used = label.font(); - EXPECT_EQ(font_name, font_used.GetFontName()); - EXPECT_EQ(30, font_used.GetFontSize()); + EXPECT_EQ(font_name, font_used.FontName()); + EXPECT_EQ(30, font_used.FontSize()); } #endif TEST(LabelTest, FontPropertyArial) { Label label; - string16 font_name(ASCIIToUTF16("arial")); + std::wstring font_name(L"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(OS_WIN) +#if defined(WIN_OS) // 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(OS_WIN) +#if defined(WIN_OS) // 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(OS_WIN) +#if defined(WIN_OS) // 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 8d2b84d..e2359d7 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( - accel_text, font, TextButton::kDisabledColor, + UTF16ToWideHack(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 8c1d1ee..ab4c5315 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(WideToUTF16Hack(GetTitle()), font, fg_color, + canvas->DrawStringInt(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 9a2628b..c8e03ce 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( - text, font, + UTF16ToWide(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 a2cc19f..b7ec107 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( - text, font, + UTF16ToWide(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 ceb5325..923de0c 100644 --- a/views/controls/textfield/native_textfield_views.cc +++ b/views/controls/textfield/native_textfield_views.cc @@ -404,11 +404,13 @@ void NativeTextfieldViews::PaintTextAndCursor(gfx::Canvas* canvas) { if ((*iter).selected) { canvas->FillRectInt(selection_color, x_offset, y, width, text_height); - canvas->DrawStringInt(text, GetFont(), kSelectedTextColor, - x_offset, y, width, text_height); + canvas->DrawStringInt( + UTF16ToWide(text), GetFont(), kSelectedTextColor, + x_offset, y, width, text_height); } else { - canvas->DrawStringInt(text, GetFont(), text_color, - x_offset, y, width, text_height); + canvas->DrawStringInt( + UTF16ToWide(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 d249196..8c00edf 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(WideToUTF16Hack(name), font, kFileDragImageTextColor, + canvas.DrawStringInt(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 70cb8b9..8f13617 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. - string16 word; + std::wstring word; if (!ltr_within_rtl) - word = iter.GetString(); // Get the next word. + word = UTF16ToWide(iter.GetString()); // Get the next word. else - word = text16; // Draw the whole text at once. + word = text; // Draw the whole text at once. - int w = font.GetStringWidth(word), h = font.GetHeight(); - gfx::CanvasSkia::SizeStringInt(word, font, &w, &h, flags); + int w = font.GetStringWidth(WideToUTF16Hack(word)), h = font.GetHeight(); + gfx::CanvasSkia::SizeStringInt(WideToUTF16Hack(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] == ' ') { + if (ltr_within_rtl && word[word.size() - 1] == L' ') { 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] == '\x0a') { + if (word.size() > 0 && word[word.size() - 1] == L'\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 c2d8599..b43b678 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -413,10 +413,9 @@ void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { if (!d) return; - canvas->DrawStringInt(WideToUTF16Hack(d->GetWindowTitle()), *title_font_, - SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_), - title_bounds_.y(), title_bounds_.width(), - title_bounds_.height()); + canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE, + MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), + title_bounds_.width(), title_bounds_.height()); } void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |