| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |