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

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

Issue 915383003: Fix alignment format in multiline mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable test on mac Created 5 years, 10 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
« no previous file with comments | « no previous file | ui/gfx/render_text_harfbuzz.h » ('j') | ui/gfx/render_text_unittest.cc » ('J')
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 #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
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
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
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text_harfbuzz.h » ('j') | ui/gfx/render_text_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698