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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 int max_offset = 0; | 885 int max_offset = 0; |
886 if (extra_content > 0) { | 886 if (extra_content > 0) { |
887 switch (horizontal_alignment_) { | 887 switch (horizontal_alignment_) { |
888 case ALIGN_LEFT: | 888 case ALIGN_LEFT: |
889 min_offset = -extra_content; | 889 min_offset = -extra_content; |
890 break; | 890 break; |
891 case ALIGN_RIGHT: | 891 case ALIGN_RIGHT: |
892 max_offset = extra_content; | 892 max_offset = extra_content; |
893 break; | 893 break; |
894 case ALIGN_CENTER: | 894 case ALIGN_CENTER: |
895 min_offset = -extra_content / 2; | 895 min_offset = -(extra_content + 1) / 2; |
sky
2014/07/21 22:37:43
Why do you need to do this change?
mohsen
2014/07/21 23:07:56
This is an off-by-one pixel bug I had in my previo
| |
896 max_offset = extra_content / 2; | 896 max_offset = extra_content / 2; |
897 break; | 897 break; |
898 default: | 898 default: |
899 break; | 899 break; |
900 } | 900 } |
901 } | 901 } |
902 if (horizontal_offset < min_offset) | 902 if (horizontal_offset < min_offset) |
903 horizontal_offset = min_offset; | 903 horizontal_offset = min_offset; |
904 else if (horizontal_offset > max_offset) | 904 else if (horizontal_offset > max_offset) |
905 horizontal_offset = max_offset; | 905 horizontal_offset = max_offset; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1353 cursor_bounds_ += delta_offset; | 1353 cursor_bounds_ += delta_offset; |
1354 } | 1354 } |
1355 | 1355 |
1356 void RenderText::DrawSelection(Canvas* canvas) { | 1356 void RenderText::DrawSelection(Canvas* canvas) { |
1357 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1357 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1358 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1358 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1359 canvas->FillRect(*i, selection_background_focused_color_); | 1359 canvas->FillRect(*i, selection_background_focused_color_); |
1360 } | 1360 } |
1361 | 1361 |
1362 } // namespace gfx | 1362 } // namespace gfx |
OLD | NEW |