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

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: sync and rebase. Created 6 years, 5 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
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_pango.cc
diff --git a/ui/gfx/render_text_pango.cc b/ui/gfx/render_text_pango.cc
index 9db3995fcee95a34c2b9b6a6b132c7c9ad8b3df7..b3a84fa523236468f32d02abbb9e4974757e32eb 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.
+ 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
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698