| 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 #include <climits> | 8 #include <climits> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() { | 1087 HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() { |
| 1088 if (horizontal_alignment_ != ALIGN_TO_HEAD) | 1088 if (horizontal_alignment_ != ALIGN_TO_HEAD) |
| 1089 return horizontal_alignment_; | 1089 return horizontal_alignment_; |
| 1090 return GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT ? | 1090 return GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT ? |
| 1091 ALIGN_RIGHT : ALIGN_LEFT; | 1091 ALIGN_RIGHT : ALIGN_LEFT; |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 Vector2d RenderText::GetAlignmentOffset(size_t line_number) { | 1094 Vector2d RenderText::GetAlignmentOffset(size_t line_number) { |
| 1095 // TODO(ckocagil): Enable |lines_| usage in other platforms. | 1095 // TODO(ckocagil): Enable |lines_| usage on RenderTextMac. |
| 1096 #if defined(OS_WIN) | 1096 #if !defined(OS_MACOSX) |
| 1097 DCHECK_LT(line_number, lines_.size()); | 1097 DCHECK_LT(line_number, lines_.size()); |
| 1098 #endif | 1098 #endif |
| 1099 Vector2d offset; | 1099 Vector2d offset; |
| 1100 HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); | 1100 HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); |
| 1101 if (horizontal_alignment != ALIGN_LEFT) { | 1101 if (horizontal_alignment != ALIGN_LEFT) { |
| 1102 #if defined(OS_WIN) | 1102 #if !defined(OS_MACOSX) |
| 1103 const int width = std::ceil(lines_[line_number].size.width()) + | 1103 const int width = std::ceil(lines_[line_number].size.width()) + |
| 1104 (cursor_enabled_ ? 1 : 0); | 1104 (cursor_enabled_ ? 1 : 0); |
| 1105 #else | 1105 #else |
| 1106 const int width = GetContentWidth(); | 1106 const int width = GetContentWidth(); |
| 1107 #endif | 1107 #endif |
| 1108 offset.set_x(display_rect().width() - width); | 1108 offset.set_x(display_rect().width() - width); |
| 1109 // Put any extra margin pixel on the left to match legacy behavior. | 1109 // Put any extra margin pixel on the left to match legacy behavior. |
| 1110 if (horizontal_alignment == ALIGN_CENTER) | 1110 if (horizontal_alignment == ALIGN_CENTER) |
| 1111 offset.set_x((offset.x() + 1) / 2); | 1111 offset.set_x((offset.x() + 1) / 2); |
| 1112 } | 1112 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 | 1456 |
| 1457 SetDisplayOffset(display_offset_.x() + delta_x); | 1457 SetDisplayOffset(display_offset_.x() + delta_x); |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 void RenderText::DrawSelection(Canvas* canvas) { | 1460 void RenderText::DrawSelection(Canvas* canvas) { |
| 1461 for (const Rect& s : GetSubstringBounds(selection())) | 1461 for (const Rect& s : GetSubstringBounds(selection())) |
| 1462 canvas->FillRect(s, selection_background_focused_color_); | 1462 canvas->FillRect(s, selection_background_focused_color_); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 } // namespace gfx | 1465 } // namespace gfx |
| OLD | NEW |