summaryrefslogtreecommitdiffstats
path: root/app/gfx/text_elider.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 00:42:03 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 00:42:03 +0000
commita6ed3e143ed88f495e5c00a79ad9ea68f8253533 (patch)
tree3400ccbbfa9a26da9b4144d7f09c058dcd1dfc15 /app/gfx/text_elider.cc
parent3c31dc9ee55519e7e34016d4edd2f250640410b0 (diff)
downloadchromium_src-a6ed3e143ed88f495e5c00a79ad9ea68f8253533.zip
chromium_src-a6ed3e143ed88f495e5c00a79ad9ea68f8253533.tar.gz
chromium_src-a6ed3e143ed88f495e5c00a79ad9ea68f8253533.tar.bz2
Re-enable TextEliderTest.ElideTextLongStrings.
Pango returns 0 for absurdly long strings. Cut the text in half and try again if this occurs. BUG=15435 Review URL: http://codereview.chromium.org/414013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/text_elider.cc')
-rw-r--r--app/gfx/text_elider.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/gfx/text_elider.cc b/app/gfx/text_elider.cc
index dc9b199..3d94813 100644
--- a/app/gfx/text_elider.cc
+++ b/app/gfx/text_elider.cc
@@ -301,6 +301,14 @@ std::wstring ElideText(const std::wstring& text,
return text;
int current_text_pixel_width = font.GetStringWidth(text);
+
+ // Pango will return 0 width for absurdly long strings. Cut the string in
+ // half and try again.
+ if (current_text_pixel_width <= 0 && !text.empty()) {
+ return ElideText(text.substr(0, text.length() / 2), font,
+ available_pixel_width);
+ }
+
if (current_text_pixel_width <= available_pixel_width)
return text;