summaryrefslogtreecommitdiffstats
path: root/app/gfx
diff options
context:
space:
mode:
authormmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-01 21:09:42 +0000
committermmoss@google.com <mmoss@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-01 21:09:42 +0000
commit949870e0eba9f1774ad1435e3d12e92bbf7309f0 (patch)
tree306b54f714eee1911e812a6110374ccbaa776234 /app/gfx
parentdedd33e7ad19964bab22f4d35c4f66872c463c3d (diff)
downloadchromium_src-949870e0eba9f1774ad1435e3d12e92bbf7309f0.zip
chromium_src-949870e0eba9f1774ad1435e3d12e92bbf7309f0.tar.gz
chromium_src-949870e0eba9f1774ad1435e3d12e92bbf7309f0.tar.bz2
Workaround for Pango integer overflow on really long strings.
This fixes TextEliderTest.ElideTextLongStrings breakage on "Linux Tests (dbg-shlib)(1)" (Karmic). http://chrome-buildbot.corp.google.com:8016/builders/Linux%20Tests%20(dbg-shlib)(1)/builds/1367/steps/app_unittests/logs/stdio Review URL: http://codereview.chromium.org/661244 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx')
-rw-r--r--app/gfx/text_elider.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/gfx/text_elider.cc b/app/gfx/text_elider.cc
index 3d94813..a925664a 100644
--- a/app/gfx/text_elider.cc
+++ b/app/gfx/text_elider.cc
@@ -304,6 +304,12 @@ std::wstring ElideText(const std::wstring& text,
// Pango will return 0 width for absurdly long strings. Cut the string in
// half and try again.
+ // This is caused by an int overflow in Pango (specifically, in
+ // pango_glyph_string_extents_range). It's actually more subtle than just
+ // returning 0, since on super absurdly long strings, the int can wrap and
+ // return positive numbers again. Detecting that is probably not worth it
+ // (eliding way too much from a ridiculous string is probably still
+ // ridiculous), but we should check other widths for bogus values as well.
if (current_text_pixel_width <= 0 && !text.empty()) {
return ElideText(text.substr(0, text.length() / 2), font,
available_pixel_width);
@@ -324,6 +330,12 @@ std::wstring ElideText(const std::wstring& text,
// handle kerning/ligatures/etc. correctly.
std::wstring guess_str = text.substr(0, guess) + kEllipsis;
int guess_length = font.GetStringWidth(guess_str);
+ // Check again that we didn't hit a Pango width overflow. If so, cut the
+ // current string in half and start over.
+ if (guess_length <= 0) {
+ return ElideText(guess_str.substr(0, guess_str.length() / 2), font,
+ available_pixel_width);
+ }
if (guess_length > available_pixel_width) {
if (hi == guess)
break;