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

Unified Diff: ui/gfx/render_text.cc

Issue 10638015: RenderText: Only clip if necessary to workaround a Skia bug in the PDF path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
« 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.cc
===================================================================
--- ui/gfx/render_text.cc (revision 143591)
+++ ui/gfx/render_text.cc (working copy)
@@ -606,11 +606,23 @@
void RenderText::Draw(Canvas* canvas) {
EnsureLayout();
- gfx::Rect clip_rect(display_rect());
- clip_rect.Inset(ShadowValue::GetMargin(text_shadows_));
+ // Normally, always clipping is harmless. However, there is a Skia bug with
+ // the PDF path (http://crbug.com/133548) that results in incorrect clipping
+ // when drawing to the document margins. Workaround the issue by only clipping
+ // when necessary, since the PDF print path does not require clipping.
+ //
+ // TODO(asvitkine): Remove this logic once http://crbug.com/133548 is fixed
+ // on the Skia side.
+ const Size size = GetStringSize();
+ const bool need_to_clip = display_rect().width() < size.width() ||
msw 2012/06/22 19:30:13 This doesn't account for display_offset_ or other
+ display_rect().height() < size.height();
+ if (need_to_clip) {
+ gfx::Rect clip_rect(display_rect());
+ clip_rect.Inset(ShadowValue::GetMargin(text_shadows_));
- canvas->Save();
- canvas->ClipRect(clip_rect);
+ canvas->Save();
+ canvas->ClipRect(clip_rect);
+ }
if (!text().empty())
DrawSelection(canvas);
@@ -619,7 +631,9 @@
if (!text().empty())
DrawVisualText(canvas);
- canvas->Restore();
+
+ if (need_to_clip)
+ canvas->Restore();
}
Rect RenderText::GetCursorBounds(const SelectionModel& caret,
« 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