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 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 size_t cursor = std::min(position, text().length()); | 1201 size_t cursor = std::min(position, text().length()); |
1202 if (IsValidCursorIndex(cursor)) | 1202 if (IsValidCursorIndex(cursor)) |
1203 SetSelectionModel(SelectionModel( | 1203 SetSelectionModel(SelectionModel( |
1204 Range(select ? selection().start() : cursor, cursor), | 1204 Range(select ? selection().start() : cursor, cursor), |
1205 (cursor == 0) ? CURSOR_FORWARD : CURSOR_BACKWARD)); | 1205 (cursor == 0) ? CURSOR_FORWARD : CURSOR_BACKWARD)); |
1206 } | 1206 } |
1207 | 1207 |
1208 void RenderText::OnTextAttributeChanged() { | 1208 void RenderText::OnTextAttributeChanged() { |
1209 layout_text_.clear(); | 1209 layout_text_.clear(); |
1210 display_text_.clear(); | 1210 display_text_.clear(); |
| 1211 text_elided_ = false; |
1211 line_breaks_.SetMax(0); | 1212 line_breaks_.SetMax(0); |
1212 | 1213 |
1213 if (obscured_) { | 1214 if (obscured_) { |
1214 size_t obscured_text_length = | 1215 size_t obscured_text_length = |
1215 static_cast<size_t>(UTF16IndexToOffset(text_, 0, text_.length())); | 1216 static_cast<size_t>(UTF16IndexToOffset(text_, 0, text_.length())); |
1216 layout_text_.assign(obscured_text_length, kPasswordReplacementChar); | 1217 layout_text_.assign(obscured_text_length, kPasswordReplacementChar); |
1217 | 1218 |
1218 if (obscured_reveal_index_ >= 0 && | 1219 if (obscured_reveal_index_ >= 0 && |
1219 obscured_reveal_index_ < static_cast<int>(text_.length())) { | 1220 obscured_reveal_index_ < static_cast<int>(text_.length())) { |
1220 // Gets the index range in |text_| to be revealed. | 1221 // Gets the index range in |text_| to be revealed. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 | 1454 |
1454 SetDisplayOffset(display_offset_.x() + delta_x); | 1455 SetDisplayOffset(display_offset_.x() + delta_x); |
1455 } | 1456 } |
1456 | 1457 |
1457 void RenderText::DrawSelection(Canvas* canvas) { | 1458 void RenderText::DrawSelection(Canvas* canvas) { |
1458 for (const Rect& s : GetSubstringBounds(selection())) | 1459 for (const Rect& s : GetSubstringBounds(selection())) |
1459 canvas->FillRect(s, selection_background_focused_color_); | 1460 canvas->FillRect(s, selection_background_focused_color_); |
1460 } | 1461 } |
1461 | 1462 |
1462 } // namespace gfx | 1463 } // namespace gfx |
OLD | NEW |