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/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "grit/ui_strings.h" | 10 #include "grit/ui_strings.h" |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 DCHECK(rect); | 1318 DCHECK(rect); |
1319 if (!HasCompositionText()) | 1319 if (!HasCompositionText()) |
1320 return false; | 1320 return false; |
1321 gfx::RenderText* render_text = GetRenderText(); | 1321 gfx::RenderText* render_text = GetRenderText(); |
1322 const gfx::Range& composition_range = render_text->GetCompositionRange(); | 1322 const gfx::Range& composition_range = render_text->GetCompositionRange(); |
1323 DCHECK(!composition_range.is_empty()); | 1323 DCHECK(!composition_range.is_empty()); |
1324 | 1324 |
1325 size_t text_index = composition_range.start() + index; | 1325 size_t text_index = composition_range.start() + index; |
1326 if (composition_range.end() <= text_index) | 1326 if (composition_range.end() <= text_index) |
1327 return false; | 1327 return false; |
1328 if (!render_text->IsCursorablePosition(text_index)) { | 1328 if (!render_text->IsValidCursorIndex(text_index)) { |
1329 text_index = render_text->IndexOfAdjacentGrapheme( | 1329 text_index = render_text->IndexOfAdjacentGrapheme( |
1330 text_index, gfx::CURSOR_BACKWARD); | 1330 text_index, gfx::CURSOR_BACKWARD); |
1331 } | 1331 } |
1332 if (text_index < composition_range.start()) | 1332 if (text_index < composition_range.start()) |
1333 return false; | 1333 return false; |
1334 const gfx::SelectionModel caret(text_index, gfx::CURSOR_BACKWARD); | 1334 const gfx::SelectionModel caret(text_index, gfx::CURSOR_BACKWARD); |
1335 *rect = render_text->GetCursorBounds(caret, false); | 1335 *rect = render_text->GetCursorBounds(caret, false); |
1336 ConvertRectToScreen(this, rect); | 1336 ConvertRectToScreen(this, rect); |
1337 return true; | 1337 return true; |
1338 } | 1338 } |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 const size_t length = selection_clipboard_text.length(); | 1680 const size_t length = selection_clipboard_text.length(); |
1681 range = gfx::Range(range.start() + length, range.end() + length); | 1681 range = gfx::Range(range.start() + length, range.end() + length); |
1682 } | 1682 } |
1683 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); | 1683 model_->MoveCursorTo(gfx::SelectionModel(range, affinity)); |
1684 UpdateAfterChange(true, true); | 1684 UpdateAfterChange(true, true); |
1685 OnAfterUserAction(); | 1685 OnAfterUserAction(); |
1686 } | 1686 } |
1687 } | 1687 } |
1688 | 1688 |
1689 } // namespace views | 1689 } // namespace views |
OLD | NEW |