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

Side by Side Diff: ui/gfx/render_text.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 2 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') | ui/gfx/render_text_mac.h » ('j') | 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 } 637 }
638 638
639 return text_direction_; 639 return text_direction_;
640 } 640 }
641 641
642 VisualCursorDirection RenderText::GetVisualDirectionOfLogicalEnd() { 642 VisualCursorDirection RenderText::GetVisualDirectionOfLogicalEnd() {
643 return GetTextDirection() == base::i18n::LEFT_TO_RIGHT ? 643 return GetTextDirection() == base::i18n::LEFT_TO_RIGHT ?
644 CURSOR_RIGHT : CURSOR_LEFT; 644 CURSOR_RIGHT : CURSOR_LEFT;
645 } 645 }
646 646
647 SizeF RenderText::GetStringSizeF() {
648 const Size size = GetStringSize();
649 return SizeF(size.width(), size.height());
650 }
651
647 int RenderText::GetContentWidth() { 652 int RenderText::GetContentWidth() {
648 return GetStringSize().width() + (cursor_enabled_ ? 1 : 0); 653 return GetStringSize().width() + (cursor_enabled_ ? 1 : 0);
649 } 654 }
650 655
651 void RenderText::Draw(Canvas* canvas) { 656 void RenderText::Draw(Canvas* canvas) {
652 EnsureLayout(); 657 EnsureLayout();
653 658
654 if (clip_to_display_rect()) { 659 if (clip_to_display_rect()) {
655 Rect clip_rect(display_rect()); 660 Rect clip_rect(display_rect());
656 clip_rect.Inset(ShadowValue::GetMargin(text_shadows_)); 661 clip_rect.Inset(ShadowValue::GetMargin(text_shadows_));
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 cursor_bounds_ += delta_offset; 1132 cursor_bounds_ += delta_offset;
1128 } 1133 }
1129 1134
1130 void RenderText::DrawSelection(Canvas* canvas) { 1135 void RenderText::DrawSelection(Canvas* canvas) {
1131 const std::vector<Rect> sel = GetSubstringBounds(selection()); 1136 const std::vector<Rect> sel = GetSubstringBounds(selection());
1132 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) 1137 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i)
1133 canvas->FillRect(*i, selection_background_focused_color_); 1138 canvas->FillRect(*i, selection_background_focused_color_);
1134 } 1139 }
1135 1140
1136 } // namespace gfx 1141 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/render_text_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698