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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1079 } | 1079 } |
1080 | 1080 |
1081 HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() { | 1081 HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() { |
1082 if (horizontal_alignment_ != ALIGN_TO_HEAD) | 1082 if (horizontal_alignment_ != ALIGN_TO_HEAD) |
1083 return horizontal_alignment_; | 1083 return horizontal_alignment_; |
1084 return GetTextDirection() == base::i18n::RIGHT_TO_LEFT ? ALIGN_RIGHT | 1084 return GetTextDirection() == base::i18n::RIGHT_TO_LEFT ? ALIGN_RIGHT |
1085 : ALIGN_LEFT; | 1085 : ALIGN_LEFT; |
1086 } | 1086 } |
1087 | 1087 |
1088 Vector2d RenderText::GetAlignmentOffset(size_t line_number) { | 1088 Vector2d RenderText::GetAlignmentOffset(size_t line_number) { |
1089 // TODO(ckocagil): Enable |lines_| usage in other platforms. | 1089 // TODO(ckocagil): Enable |lines_| usage on mac. |
1090 #if defined(OS_WIN) | 1090 #if defined(OS_WIN) || defined(OS_CHROMEOS) |
msw
2015/02/19 01:13:50
This should actually check if the current instance
oshima
2015/02/19 04:40:14
That means this is already broken and should be fi
oshima
2015/02/23 18:50:53
Used !defined(OS_MACOSX) in this CL. I uploaded th
| |
1091 DCHECK_LT(line_number, lines_.size()); | 1091 DCHECK_LT(line_number, lines_.size()); |
1092 #endif | 1092 #endif |
1093 Vector2d offset; | 1093 Vector2d offset; |
1094 HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); | 1094 HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); |
1095 if (horizontal_alignment != ALIGN_LEFT) { | 1095 if (horizontal_alignment != ALIGN_LEFT) { |
1096 #if defined(OS_WIN) | 1096 #if !defined(OS_WIN) || defined(OS_CHROMEOS) |
msw
2015/02/19 01:13:50
This is *definitely* wrong with the "!" added for
oshima
2015/02/23 18:50:53
Sorry, this was from my experiment. (I was playing
| |
1097 const int width = std::ceil(lines_[line_number].size.width()) + | 1097 const int width = std::ceil(lines_[line_number].size.width()) + |
1098 (cursor_enabled_ ? 1 : 0); | 1098 (cursor_enabled_ ? 1 : 0); |
1099 #else | 1099 #else |
1100 const int width = GetContentWidth(); | 1100 const int width = GetContentWidth(); |
1101 #endif | 1101 #endif |
1102 offset.set_x(display_rect().width() - width); | 1102 offset.set_x(display_rect().width() - width); |
1103 // Put any extra margin pixel on the left to match legacy behavior. | 1103 // Put any extra margin pixel on the left to match legacy behavior. |
1104 if (horizontal_alignment == ALIGN_CENTER) | 1104 if (horizontal_alignment == ALIGN_CENTER) |
1105 offset.set_x((offset.x() + 1) / 2); | 1105 offset.set_x((offset.x() + 1) / 2); |
1106 } | 1106 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1425 SetDisplayOffset(display_offset_.x() + delta_x); | 1425 SetDisplayOffset(display_offset_.x() + delta_x); |
1426 } | 1426 } |
1427 | 1427 |
1428 void RenderText::DrawSelection(Canvas* canvas) { | 1428 void RenderText::DrawSelection(Canvas* canvas) { |
1429 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1429 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1430 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1430 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1431 canvas->FillRect(*i, selection_background_focused_color_); | 1431 canvas->FillRect(*i, selection_background_focused_color_); |
1432 } | 1432 } |
1433 | 1433 |
1434 } // namespace gfx | 1434 } // namespace gfx |
OLD | NEW |