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

Unified Diff: ui/gfx/render_text_pango.cc

Issue 543073002: Don't paint text outside display area (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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 07cbfb93cdf5c0e71d09261b618bd009028ba17c..1df03bb2cc410429bfa214ee2d5bd7415eea5f48 100644
--- a/ui/gfx/render_text_pango.cc
+++ b/ui/gfx/render_text_pango.cc
@@ -410,9 +410,12 @@ void RenderTextPango::DrawVisualText(Canvas* canvas) {
internal::StyleIterator style(colors(), styles());
for (GSList* it = current_line_->runs; it; it = it->next) {
+ // Don't do anything if we're outside the display area
msw 2014/09/08 19:10:30 nit: "Skip painting runs outside the display area.
+ if (SkScalarTruncToInt(x) >= display_rect().right())
+ break;
+
PangoLayoutRun* run = reinterpret_cast<PangoLayoutRun*>(it->data);
int glyph_count = run->glyphs->num_glyphs;
- // TODO(msw): Skip painting runs outside the display rect area, like Win.
if (glyph_count == 0)
continue;
@@ -446,8 +449,11 @@ void RenderTextPango::DrawVisualText(Canvas* canvas) {
x += pango_units_to_double(glyph.geometry.width);
++glyph_index;
- const size_t glyph_text_index = (glyph_index == glyph_count) ?
- style_range.end() : GetGlyphTextIndex(run, glyph_index);
+ const size_t glyph_text_index =
+ (glyph_index == glyph_count ||
+ SkScalarTruncToInt(x) >= display_rect().right())
msw 2014/09/05 20:15:32 Truncation doesn't seem correct here; why do we ne
Arjan van Leeuwen 2014/09/08 09:20:11 This is what actually stops it from rendering glyp
msw 2014/09/08 19:10:30 Ah, your change below to the while loop on [new] l
Arjan van Leeuwen 2014/09/09 07:03:59 Right. Added some comments now.
+ ? style_range.end()
+ : GetGlyphTextIndex(run, glyph_index);
if (!IndexInRange(style_range, glyph_text_index)) {
// TODO(asvitkine): For cases like "fi", where "fi" is a single glyph
// but can span multiple styles, Pango splits the
@@ -470,7 +476,8 @@ void RenderTextPango::DrawVisualText(Canvas* canvas) {
style_start_glyph_index = glyph_index;
style_start_x = x;
}
- } while (glyph_index < glyph_count);
+ } while (glyph_index < glyph_count &&
+ SkScalarTruncToInt(x) < display_rect().right());
}
renderer.EndDiagonalStrike();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698