diff options
author | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 09:35:49 +0000 |
---|---|---|
committer | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 09:35:49 +0000 |
commit | eaa4f14e5187ba2f1be85a0cdd4e044a8abc5c3c (patch) | |
tree | b66c020cb7cca8a66c5c5b20feef6ecd88ed701c | |
parent | 46860da6ddd4e6855923a93990317964dba0ecbf (diff) | |
download | chromium_src-eaa4f14e5187ba2f1be85a0cdd4e044a8abc5c3c.zip chromium_src-eaa4f14e5187ba2f1be85a0cdd4e044a8abc5c3c.tar.gz chromium_src-eaa4f14e5187ba2f1be85a0cdd4e044a8abc5c3c.tar.bz2 |
Clean-up: Removes gfx::FontList::GetStringWidth(text).
gfx::GetStringWidth(text, font_list) in ui/gfx/text_utils.h is recommended and gfx::FontList::GetStringWidth(text) is obsolete. Remove the method.
TEST=none
Review URL: https://codereview.chromium.org/144183005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246548 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/cocoa/status_bubble_mac.mm | 3 | ||||
-rw-r--r-- | chrome/browser/ui/views/download/download_item_view.cc | 3 | ||||
-rw-r--r-- | ui/gfx/font_list.cc | 13 | ||||
-rw-r--r-- | ui/gfx/font_list.h | 3 | ||||
-rw-r--r-- | ui/views/controls/label.cc | 3 |
5 files changed, 6 insertions, 19 deletions
diff --git a/chrome/browser/ui/cocoa/status_bubble_mac.mm b/chrome/browser/ui/cocoa/status_bubble_mac.mm index a1b40f9..06ea023 100644 --- a/chrome/browser/ui/cocoa/status_bubble_mac.mm +++ b/chrome/browser/ui/cocoa/status_bubble_mac.mm @@ -22,6 +22,7 @@ #include "ui/gfx/font_list.h" #include "ui/gfx/point.h" #include "ui/gfx/text_elider.h" +#include "ui/gfx/text_utils.h" namespace { @@ -629,7 +630,7 @@ void StatusBubbleMac::ExpandBubble() { // Scale width from gfx::Font in view coordinates to window coordinates. int required_width_for_string = - font_list_chr.GetStringWidth(expanded_url) + + gfx::GetStringWidth(expanded_url, font_list_chr) + kTextPadding * 2 + kBubbleViewTextPositionX; NSSize scaled_width = NSMakeSize(required_width_for_string, 0); scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil]; diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index ffc4865..65f6495 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -42,6 +42,7 @@ #include "ui/gfx/color_utils.h" #include "ui/gfx/image/image.h" #include "ui/gfx/text_elider.h" +#include "ui/gfx/text_utils.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/label.h" #include "ui/views/mouse_constants.h" @@ -771,7 +772,7 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) { base::string16 status_string = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, base::string16()); - int status_string_width = font_list_.GetStringWidth(status_string); + int status_string_width = gfx::GetStringWidth(status_string, font_list_); // Then, elide the file name. base::string16 filename_string = gfx::ElideFilename(download()->GetFileNameToReportUser(), font_list_, diff --git a/ui/gfx/font_list.cc b/ui/gfx/font_list.cc index c2a9927..bb4c954 100644 --- a/ui/gfx/font_list.cc +++ b/ui/gfx/font_list.cc @@ -225,19 +225,6 @@ int FontList::GetCapHeight() const { return GetPrimaryFont().GetCapHeight(); } -int FontList::GetStringWidth(const base::string16& text) const { - // Rely on the primary font metrics for the time being. - // TODO(yukishiino): Not only the first font, all the fonts in the list should - // be taken into account to compute the pixels needed to display |text|. - // Also this method, including one in Font class, should be deprecated and - // client code should call Canvas::GetStringWidth(text, font_list) directly. - // Our plan is as follows: - // 1. Introduce the FontList version of Canvas::GetStringWidth(). - // 2. Make client code call Canvas::GetStringWidth(). - // 3. Retire {Font,FontList}::GetStringWidth(). - return GetPrimaryFont().GetStringWidth(text); -} - int FontList::GetExpectedTextWidth(int length) const { // Rely on the primary font metrics for the time being. return GetPrimaryFont().GetExpectedTextWidth(length); diff --git a/ui/gfx/font_list.h b/ui/gfx/font_list.h index 244da88..c70c37f 100644 --- a/ui/gfx/font_list.h +++ b/ui/gfx/font_list.h @@ -96,9 +96,6 @@ class GFX_EXPORT FontList { // Currently returns the cap height of the primary font. int GetCapHeight() const; - // Returns the number of horizontal pixels needed to display |text|. - int GetStringWidth(const base::string16& text) const; - // Returns the expected number of horizontal pixels needed to display the // specified length of characters. Call GetStringWidth() to retrieve the // actual number. diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc index 0a7362d..11409b4 100644 --- a/ui/views/controls/label.cc +++ b/ui/views/controls/label.cc @@ -216,7 +216,8 @@ gfx::Size Label::GetMinimumSize() { if ((!visible() && collapse_when_hidden_) || text_size.IsEmpty()) return gfx::Size(); - gfx::Size size(font_list_.GetStringWidth(base::string16(gfx::kEllipsisUTF16)), + gfx::Size size(gfx::GetStringWidth(base::string16(gfx::kEllipsisUTF16), + font_list_), font_list_.GetHeight()); size.SetToMin(text_size); // The actual text may be shorter than an ellipsis. gfx::Insets insets = GetInsets(); |