Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: ui/gfx/render_text_pango.cc

Issue 354963003: Move gfx::ElideText functionality to RenderText. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Exclude unreachable code by platform. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/render_text_pango.cc
diff --git a/ui/gfx/render_text_pango.cc b/ui/gfx/render_text_pango.cc
index a126926461720aa771db13c3457180a4dae3ec2a..d8ff7f615e9aa22b0ce6dd7db4ffa9066a71641e 100644
--- a/ui/gfx/render_text_pango.cc
+++ b/ui/gfx/render_text_pango.cc
@@ -82,6 +82,15 @@ Size RenderTextPango::GetStringSize() {
EnsureLayout();
int width = 0, height = 0;
pango_layout_get_pixel_size(layout_, &width, &height);
+
+ // Pango returns 0 widths for very long strings (of 0x40000 chars or more).
+ // This is caused by an int overflow in pango_glyph_string_extents_range.
+ // Absurdly long strings may even report non-zero garbage values for width;
+ // while detecting that isn't worthwhile, this handles the 0 width cases.
Alexei Svitkine (slow) 2014/07/03 20:12:33 Did we file a bug against pango for this? iirc Beh
msw 2014/07/08 19:07:36 I'm not sure and can't find any relevant open bugs
Evan Stade 2014/07/08 21:07:19 Unfortunately, my memory lasts exactly 5 years, so
+ const long kAbsurdLength = 100000;
+ if (width == 0 && g_utf8_strlen(layout_text_, -1) > kAbsurdLength)
+ width = font_list().GetExpectedTextWidth(g_utf8_strlen(layout_text_, -1));
+
// Keep a consistent height between this particular string's PangoLayout and
// potentially larger text supported by the FontList.
// For example, if a text field contains a Japanese character, which is

Powered by Google App Engine
This is Rietveld 408576698