Skip to content

Commit

Permalink
Revert 71167 - Remove wstring from gfx.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joi@chromium.org committed Jan 12, 2011
1 parent 3f891cf commit b22558a
Show file tree
Hide file tree
Showing 55 changed files with 185 additions and 184 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ - (NSInteger)highlightedRow;
// The popup's font is a slightly smaller version of the field's.
NSFont* fieldFont = AutocompleteEditViewMac::GetFieldFont();
const CGFloat resultFontSize = [fieldFont pointSize] + kEditFontAdjust;
gfx::Font resultFont(base::SysNSStringToUTF16([fieldFont fontName]),
gfx::Font resultFont(base::SysNSStringToWide([fieldFont fontName]),
static_cast<int>(resultFontSize));

AutocompleteMatrix* matrix = GetAutocompleteMatrix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ virtual void SetUp() {
color_ = [NSColor blackColor];
dimColor_ = [NSColor darkGrayColor];
font_ = gfx::Font(
base::SysNSStringToUTF16([[NSFont userFontOfSize:12] fontName]), 12);
base::SysNSStringToWide([[NSFont userFontOfSize:12] fontName]), 12);
}

// Returns the length of the run starting at |location| for which
Expand Down
26 changes: 13 additions & 13 deletions chrome/browser/chromeos/dom_ui/menu_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,30 @@ namespace {
const int kNoExtraResource = -1;

// A utility function that generates css font property from gfx::Font.
// NOTE: Returns UTF-8.
std::string GetFontShorthand(const gfx::Font* font) {
std::string out;
std::wstring GetFontShorthand(const gfx::Font* font) {
std::wstring out;
if (font == NULL) {
font = &(views::MenuConfig::instance().font);
}
if (font->GetStyle() & gfx::Font::BOLD) {
out.append("bold ");
out.append(L"bold ");
}
if (font->GetStyle() & gfx::Font::ITALIC) {
out.append("italic ");
out.append(L"italic ");
}
if (font->GetStyle() & gfx::Font::UNDERLINED) {
out.append("underline ");
out.append(L"underline ");
}

// TODO(oshima): The font size from gfx::Font is too small when
// used in webkit. Figure out the reason.
out.append(base::IntToString(font->GetFontSize() + 4));
out.append("px/");
out.append(base::IntToString(std::max(kFavIconSize, font->GetHeight())));
out.append("px \"");
out.append(UTF16ToUTF8(font->GetFontName()));
out.append("\",sans-serif");
out.append(ASCIIToWide(base::IntToString(font->GetFontSize() + 4)));
out.append(L"px/");
out.append(ASCIIToWide(base::IntToString(
std::max(kFavIconSize, font->GetHeight()))));
out.append(L"px \"");
out.append(font->GetFontName());
out.append(L"\",sans-serif");
return out;
}

Expand Down Expand Up @@ -619,7 +619,7 @@ DictionaryValue* MenuUI::CreateMenuItem(const menus::MenuModel* model,
item->SetBoolean("checked", model->IsItemCheckedAt(index));
item->SetInteger("command_id", model->GetCommandIdAt(index));
item->SetString(
"font", GetFontShorthand(model->GetLabelFontAt(index)));
"font", WideToUTF16(GetFontShorthand(model->GetLabelFontAt(index))));
SkBitmap icon;
if (model->GetIconAt(index, &icon) && !icon.isNull() && !icon.empty()) {
item->SetString("icon", dom_ui_util::GetImageDataUrl(icon));
Expand Down
9 changes: 4 additions & 5 deletions chrome/browser/chromeos/drop_shadow_label.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "chrome/browser/chromeos/drop_shadow_label.h"

#include "base/utf_string_conversions.h"
#include "gfx/canvas.h"
#include "gfx/color_utils.h"

Expand Down Expand Up @@ -45,19 +44,19 @@ void DropShadowLabel::PaintText(gfx::Canvas* canvas,
SkColorGetG(kDefaultColor),
SkColorGetB(kDefaultColor));
for (int i = 0; i < drop_shadow_size_; i++) {
canvas->DrawStringInt(WideToUTF16Hack(text), font(), color,
canvas->DrawStringInt(text, font(), color,
text_bounds.x() + i, text_bounds.y(),
text_bounds.width(), text_bounds.height(), flags);
canvas->DrawStringInt(WideToUTF16Hack(text), font(), color,
canvas->DrawStringInt(text, font(), color,
text_bounds.x() + i, text_bounds.y() + i,
text_bounds.width(), text_bounds.height(), flags);
canvas->DrawStringInt(WideToUTF16Hack(text), font(), color,
canvas->DrawStringInt(text, font(), color,
text_bounds.x(), text_bounds.y() + i,
text_bounds.width(), text_bounds.height(), flags);
}
}

canvas->DrawStringInt(WideToUTF16Hack(text), font(), GetColor(),
canvas->DrawStringInt(text, font(), GetColor(),
text_bounds.x(), text_bounds.y(),
text_bounds.width(), text_bounds.height(), flags);

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chromeos/login/oobe_progress_bar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void OobeProgressBar::Paint(gfx::Canvas* canvas) {
next_x - ix, line_->height());
}

string16 str = l10n_util::GetStringUTF16(steps_[i]);
std::wstring str = UTF16ToWide(l10n_util::GetStringUTF16(steps_[i]));
canvas->DrawStringInt(str, font_, color,
x + kTextPadding, y + dot->height() + kTextPadding,
(next_x - x - 2 * kTextPadding),
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/chromeos/login/username_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ void UsernameView::PaintUsername(const gfx::Rect& bounds) {
// Note, direct call of the DrawStringInt method produces the green dots
// along the text perimeter (when the label is place on the white background).
SkColor kInvisibleHaloColor = 0x00000000;
canvas.DrawStringWithHalo(WideToUTF16Hack(GetText()), font(), GetColor(),
kInvisibleHaloColor, bounds.x() + margin_width_,
bounds.y(), bounds.width() - 2 * margin_width_,
bounds.height(), flags);
canvas.DrawStringWithHalo(GetText(), font(), GetColor(), kInvisibleHaloColor,
bounds.x() + margin_width_, bounds.y(),
bounds.width() - 2 * margin_width_, bounds.height(),
flags);

text_image_.reset(new SkBitmap(canvas.ExtractBitmap()));

Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/chromeos/panels/panel_scroller_header.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.

#include "chrome/browser/chromeos/panels/panel_scroller_header.h"

Expand Down Expand Up @@ -45,6 +45,6 @@ void PanelScrollerHeader::Paint(gfx::Canvas* canvas) {
gfx::Font font =
rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
int font_top = 1;
canvas->DrawStringInt(title_, font, 0xFF000000, 3, font_top,
canvas->DrawStringInt(UTF16ToWideHack(title_), font, 0xFF000000, 3, font_top,
size().width(), size().height() - font_top);
}
3 changes: 2 additions & 1 deletion chrome/browser/gtk/bookmark_utils_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ gboolean OnDragIconExpose(GtkWidget* sender,
int text_width = sender->allocation.width - text_x;
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
canvas.DrawStringInt(data->text, base_font, data->text_color,
canvas.DrawStringInt(UTF16ToWide(data->text),
base_font, data->text_color,
text_x, 0, text_width, sender->allocation.height);

return TRUE;
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/gtk/options/fonts_page_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ std::string MakeFontName(std::string family_name, int pixel_size) {
// The given font might not be available (the default fonts we use are not
// installed by default on some distros). So figure out which font we are
// actually falling back to and display that. (See crbug.com/31381.)
string16 actual_family_name = gfx::Font(
UTF8ToUTF16(family_name), pixel_size).GetFontName();
std::wstring actual_family_name = gfx::Font(
UTF8ToWide(family_name), pixel_size).GetFontName();
std::string fontname;
// TODO(mattm): We can pass in the size in pixels (px), and the font button
// actually honors it, but when you open the selector it interprets it as
// points. See crbug.com/17857
base::SStringPrintf(&fontname, "%s, %dpx",
UTF16ToUTF8(actual_family_name).c_str(), pixel_size);
WideToUTF8(actual_family_name).c_str(), pixel_size);
return fontname;
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/gtk/tabs/tab_renderer_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ void TabRendererGtk::PaintTitle(gfx::Canvas* canvas) {

SkColor title_color = IsSelected() ? selected_title_color_
: unselected_title_color_;
canvas->DrawStringInt(title, *title_font_, title_color,
canvas->DrawStringInt(UTF16ToWideHack(title), *title_font_, title_color,
title_bounds_.x(), title_bounds_.y(),
title_bounds_.width(), title_bounds_.height());
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void CloudPrintSetupFlow::GetDOMMessageHandlers(
void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));

if (setup_done_) {
Expand Down Expand Up @@ -282,7 +282,7 @@ void CloudPrintSetupFlow::ShowSetupDone() {
if (dom_ui_) {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));
gfx::Size done_size = gfx::GetLocalizedContentsSizeForFont(
IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS,
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/remoting/setup_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void SetupFlow::GetDOMMessageHandlers(
void SetupFlow::GetDialogSize(gfx::Size* size) const {
PrefService* prefs = profile_->GetPrefs();
gfx::Font approximate_web_font(
UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));

// TODO(pranavk) Replace the following SYNC resources with REMOTING Resources.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/sync/sync_setup_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ SyncSetupFlow::~SyncSetupFlow() {
void SyncSetupFlow::GetDialogSize(gfx::Size* size) const {
PrefService* prefs = service_->profile()->GetPrefs();
gfx::Font approximate_web_font = gfx::Font(
UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));

*size = gfx::GetLocalizedContentsSizeForFont(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ @implementation BookmarkMenuCocoaController

+ (NSString*)menuTitleForNode:(const BookmarkNode*)node {
NSFont* nsfont = [NSFont menuBarFontOfSize:0]; // 0 means "default"
gfx::Font font(base::SysNSStringToUTF16([nsfont fontName]),
gfx::Font font(base::SysNSStringToWide([nsfont fontName]),
static_cast<int>([nsfont pointSize]));
string16 title = gfx::ElideText(node->GetTitle(),
font,
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/cocoa/download/download_item_cell.mm
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ - (NSBezierPath*)rightRoundedPath:(CGFloat)radius inRect:(NSRect)rect {

- (NSString*)elideTitle:(int)availableWidth {
NSFont* font = [self font];
gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
gfx::Font font_chr(base::SysNSStringToWide([font fontName]),
[font pointSize]);

return base::SysUTF16ToNSString(
Expand All @@ -403,7 +403,7 @@ - (NSString*)elideTitle:(int)availableWidth {

- (NSString*)elideStatus:(int)availableWidth {
NSFont* font = [self secondaryFont];
gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
gfx::Font font_chr(base::SysNSStringToWide([font fontName]),
[font pointSize]);

return base::SysUTF16ToNSString(ElideText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

// Middle-elide the label to fit |width_left|. This leaves the
// prefix and the trailing country code in place.
gfx::Font font(base::SysNSStringToUTF16([font_ fontName]),
gfx::Font font(base::SysNSStringToWide([font_ fontName]),
[font_ pointSize]);
NSString* elided_label = base::SysUTF16ToNSString(
ElideText(base::SysNSStringToUTF16(full_label_), font, width_left, true));
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/cocoa/status_bubble_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished {
scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
text_width = static_cast<int>(scaled_width.width);
NSFont* font = [[window_ contentView] font];
gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
gfx::Font font_chr(base::SysNSStringToWide([font fontName]),
[font pointSize]);

string16 original_url_text = net::FormatUrl(url, UTF16ToUTF8(languages));
Expand Down Expand Up @@ -606,7 +606,7 @@ - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished {

// Generate the URL string that fits in the expanded bubble.
NSFont* font = [[window_ contentView] font];
gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
gfx::Font font_chr(base::SysNSStringToWide([font fontName]),
[font pointSize]);
string16 expanded_url = gfx::ElideUrl(url_, font_chr,
max_bubble_width, UTF16ToWideHack(languages_));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ int AutocompleteResultView::DrawString(
for (Classifications::const_iterator j(i->classifications.begin());
j != i->classifications.end(); ++j) {
int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width);
canvas->DrawStringInt(WideToUTF16Hack(j->text), *j->font, j->color, left,
y, j->pixel_width, j->font->GetHeight(), flags);
canvas->DrawStringInt(j->text, *j->font, j->color, left, y,
j->pixel_width, j->font->GetHeight(), flags);
x += j->pixel_width;
}
}
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/ui/views/download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,8 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
SkColorGetG(file_name_color)),
static_cast<int>(kDownloadItemLuminanceMod *
SkColorGetB(file_name_color)));
canvas->DrawStringInt(WideToUTF16Hack(status_text_), font_,
file_name_color, mirrored_x, y, kTextWidth,
font_.GetHeight());
canvas->DrawStringInt(status_text_, font_, file_name_color,
mirrored_x, y, kTextWidth, font_.GetHeight());
}
}

Expand Down Expand Up @@ -634,7 +633,7 @@ void DownloadItemView::Paint(gfx::Canvas* canvas) {
(box_height_ - font_.GetHeight()) / 2);

// Draw the file's name.
canvas->DrawStringInt(filename, font_,
canvas->DrawStringInt(UTF16ToWide(filename), font_,
IsEnabled() ? file_name_color :
kFileNameDisabledColor,
mirrored_x, y, kTextWidth, font_.GetHeight());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
return;
}
if (delegate->ShouldShowWindowTitle()) {
canvas->DrawStringInt(WideToUTF16Hack(delegate->GetWindowTitle()),
canvas->DrawStringInt(delegate->GetWindowTitle(),
BrowserFrame::GetTitleFont(),
SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_),
title_bounds_.y(), title_bounds_.width(), title_bounds_.height());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void ContentSettingImageView::Paint(gfx::Canvas* canvas) {
if (animation_in_progress_) {
// Paint text to the right of the icon.
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
canvas->DrawStringInt(animated_text_,
canvas->DrawStringInt(UTF16ToWideHack(animated_text_),
rb.GetFont(ResourceBundle::MediumFont), SK_ColorBLACK,
GetImageBounds().right() + kTextMarginPixels, y(),
width() - GetImageBounds().width(), height(),
Expand Down
10 changes: 5 additions & 5 deletions chrome/browser/ui/views/sad_tab_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ void SadTabView::Paint(gfx::Canvas* canvas) {

canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y());

canvas->DrawStringInt(WideToUTF16Hack(title_), *title_font_, kTitleColor,
title_bounds_.x(), title_bounds_.y(),
title_bounds_.width(), title_bounds_.height(),
canvas->DrawStringInt(title_, *title_font_, kTitleColor, title_bounds_.x(),
title_bounds_.y(), title_bounds_.width(),
title_bounds_.height(),
gfx::Canvas::TEXT_ALIGN_CENTER);

canvas->DrawStringInt(WideToUTF16Hack(message_), *message_font_,
kMessageColor, message_bounds_.x(), message_bounds_.y(),
canvas->DrawStringInt(message_, *message_font_, kMessageColor,
message_bounds_.x(), message_bounds_.y(),
message_bounds_.width(), message_bounds_.height(),
gfx::Canvas::MULTI_LINE);

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/status_bubble_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) {
(SkColorGetR(text_color) + SkColorGetR(toolbar_color)) / 2,
(SkColorGetG(text_color) + SkColorGetR(toolbar_color)) / 2,
(SkColorGetB(text_color) + SkColorGetR(toolbar_color)) / 2);
canvas->DrawStringInt(text_,
canvas->DrawStringInt(UTF16ToWide(text_),
views::Label::font(),
text_color,
body_bounds.x(),
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/tabs/base_tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void BaseTab::PaintTitle(gfx::Canvas* canvas, SkColor title_color) {
Browser::FormatTitleForDisplay(&title);
}

canvas->DrawStringInt(title, *font_, title_color,
canvas->DrawStringInt(UTF16ToWideHack(title), *font_, title_color,
title_bounds().x(), title_bounds().y(),
title_bounds().width(), title_bounds().height());
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/theme_install_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void ThemeInstallBubbleView::Paint(gfx::Canvas* canvas) {
body_bounds.set_x(MirroredLeftPointForRect(body_bounds));

SkColor text_color = SK_ColorWHITE;
canvas->DrawStringInt(text_,
canvas->DrawStringInt(UTF16ToWideHack(text_),
views::Label::font(),
text_color,
body_bounds.x(),
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/badge_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SkPaint* GetBadgeTextPaintSingleton() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
typeface = SkTypeface::CreateFromName(
UTF16ToUTF8(base_font.GetFontName()).c_str(), SkTypeface::kNormal);
WideToUTF8(base_font.GetFontName()).c_str(), SkTypeface::kNormal);
}

text_paint->setTypeface(typeface);
Expand Down
Loading

0 comments on commit b22558a

Please sign in to comment.