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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1334 delta_x = display_rect_.right() - cursor_bounds_.right(); | 1334 delta_x = display_rect_.right() - cursor_bounds_.right(); |
1335 } else if (cursor_bounds_.x() < display_rect_.x()) { | 1335 } else if (cursor_bounds_.x() < display_rect_.x()) { |
1336 // TODO(xji): have similar problem as above when overflow character is a | 1336 // TODO(xji): have similar problem as above when overflow character is a |
1337 // LTR character. | 1337 // LTR character. |
1338 // | 1338 // |
1339 // Pan to show the cursor when it overflows to the left. | 1339 // Pan to show the cursor when it overflows to the left. |
1340 delta_x = display_rect_.x() - cursor_bounds_.x(); | 1340 delta_x = display_rect_.x() - cursor_bounds_.x(); |
1341 } else if (display_offset_.x() != 0) { | 1341 } else if (display_offset_.x() != 0) { |
1342 // Reduce the pan offset to show additional overflow text when the display | 1342 // Reduce the pan offset to show additional overflow text when the display |
1343 // width increases. | 1343 // width increases. |
1344 const int negate_rtl = horizontal_alignment_ == ALIGN_RIGHT ? -1 : 1; | 1344 const int negate_rtl = horizontal_alignment_ == ALIGN_RIGHT ? -1 : 1; |
msw
2014/07/11 22:33:04
nit: consider combining the two scale factors.
| |
1345 const int offset = negate_rtl * display_offset_.x(); | 1345 const int double_center = horizontal_alignment_ == ALIGN_CENTER ? 2 : 1; |
msw
2014/07/11 22:33:04
nit: consider |scale_center|
| |
1346 const int offset = negate_rtl * double_center * display_offset_.x(); | |
1346 if (display_width > (content_width + offset)) { | 1347 if (display_width > (content_width + offset)) { |
msw
2014/07/11 22:33:04
I don't think this condition will capture all the
mohsen
2014/07/14 20:57:01
In your example, no extra empty space will be show
msw
2014/07/16 01:41:43
I think this is wrong, the alignment offset
| |
1347 delta_x = negate_rtl * (display_width - (content_width + offset)); | 1348 delta_x = negate_rtl * (display_width - (content_width + offset)) / |
1349 double_center; | |
1348 } | 1350 } |
1349 } | 1351 } |
1350 | 1352 |
1351 Vector2d delta_offset(delta_x, 0); | 1353 Vector2d delta_offset(delta_x, 0); |
1352 display_offset_ += delta_offset; | 1354 display_offset_ += delta_offset; |
1353 cursor_bounds_ += delta_offset; | 1355 cursor_bounds_ += delta_offset; |
1354 } | 1356 } |
1355 | 1357 |
1356 void RenderText::DrawSelection(Canvas* canvas) { | 1358 void RenderText::DrawSelection(Canvas* canvas) { |
1357 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1359 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1358 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1360 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1359 canvas->FillRect(*i, selection_background_focused_color_); | 1361 canvas->FillRect(*i, selection_background_focused_color_); |
1360 } | 1362 } |
1361 | 1363 |
1362 } // namespace gfx | 1364 } // namespace gfx |
OLD | NEW |