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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/render_text.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 599 }
600 600
601 VisualCursorDirection RenderText::GetVisualDirectionOfLogicalEnd() { 601 VisualCursorDirection RenderText::GetVisualDirectionOfLogicalEnd() {
602 return GetTextDirection() == base::i18n::LEFT_TO_RIGHT ? 602 return GetTextDirection() == base::i18n::LEFT_TO_RIGHT ?
603 CURSOR_RIGHT : CURSOR_LEFT; 603 CURSOR_RIGHT : CURSOR_LEFT;
604 } 604 }
605 605
606 void RenderText::Draw(Canvas* canvas) { 606 void RenderText::Draw(Canvas* canvas) {
607 EnsureLayout(); 607 EnsureLayout();
608 608
609 gfx::Rect clip_rect(display_rect()); 609 if (clip_to_display_rect()) {
610 clip_rect.Inset(ShadowValue::GetMargin(text_shadows_)); 610 gfx::Rect clip_rect(display_rect());
611 clip_rect.Inset(ShadowValue::GetMargin(text_shadows_));
611 612
612 canvas->Save(); 613 canvas->Save();
613 canvas->ClipRect(clip_rect); 614 canvas->ClipRect(clip_rect);
615 }
614 616
615 if (!text().empty()) 617 if (!text().empty())
616 DrawSelection(canvas); 618 DrawSelection(canvas);
617 619
618 DrawCursor(canvas); 620 DrawCursor(canvas);
619 621
620 if (!text().empty()) 622 if (!text().empty())
621 DrawVisualText(canvas); 623 DrawVisualText(canvas);
622 canvas->Restore(); 624
625 if (clip_to_display_rect())
626 canvas->Restore();
623 } 627 }
624 628
625 Rect RenderText::GetCursorBounds(const SelectionModel& caret, 629 Rect RenderText::GetCursorBounds(const SelectionModel& caret,
626 bool insert_mode) { 630 bool insert_mode) {
627 EnsureLayout(); 631 EnsureLayout();
628 632
629 size_t caret_pos = caret.caret_pos(); 633 size_t caret_pos = caret.caret_pos();
630 // In overtype mode, ignore the affinity and always indicate that we will 634 // In overtype mode, ignore the affinity and always indicate that we will
631 // overtype the next character. 635 // overtype the next character.
632 LogicalCursorDirection caret_affinity = 636 LogicalCursorDirection caret_affinity =
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 cursor_color_(kDefaultCursorColor), 709 cursor_color_(kDefaultCursorColor),
706 selection_color_(kDefaultSelectionColor), 710 selection_color_(kDefaultSelectionColor),
707 selection_background_focused_color_(kDefaultSelectionBackgroundColor), 711 selection_background_focused_color_(kDefaultSelectionBackgroundColor),
708 selection_background_unfocused_color_(kDefaultSelectionBackgroundColor), 712 selection_background_unfocused_color_(kDefaultSelectionBackgroundColor),
709 focused_(false), 713 focused_(false),
710 composition_range_(ui::Range::InvalidRange()), 714 composition_range_(ui::Range::InvalidRange()),
711 obscured_(false), 715 obscured_(false),
712 fade_head_(false), 716 fade_head_(false),
713 fade_tail_(false), 717 fade_tail_(false),
714 background_is_transparent_(false), 718 background_is_transparent_(false),
719 clip_to_display_rect_(true),
715 cached_bounds_and_offset_valid_(false) { 720 cached_bounds_and_offset_valid_(false) {
716 } 721 }
717 722
718 const Point& RenderText::GetUpdatedDisplayOffset() { 723 const Point& RenderText::GetUpdatedDisplayOffset() {
719 UpdateCachedBoundsAndOffset(); 724 UpdateCachedBoundsAndOffset();
720 return display_offset_; 725 return display_offset_;
721 } 726 }
722 727
723 SelectionModel RenderText::GetAdjacentSelectionModel( 728 SelectionModel RenderText::GetAdjacentSelectionModel(
724 const SelectionModel& current, 729 const SelectionModel& current,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 if (cursor_enabled() && cursor_visible() && focused()) { 966 if (cursor_enabled() && cursor_visible() && focused()) {
962 const Rect& bounds = GetUpdatedCursorBounds(); 967 const Rect& bounds = GetUpdatedCursorBounds();
963 if (bounds.width() != 0) 968 if (bounds.width() != 0)
964 canvas->FillRect(bounds, cursor_color_); 969 canvas->FillRect(bounds, cursor_color_);
965 else 970 else
966 canvas->DrawRect(bounds, cursor_color_); 971 canvas->DrawRect(bounds, cursor_color_);
967 } 972 }
968 } 973 }
969 974
970 } // namespace gfx 975 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698