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, |