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

Side by Side Diff: ui/views/controls/textfield/textfield_views_model.cc

Issue 10412009: Enable disabled omnibox tests on aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | Annotate | Revision Log
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/views/controls/textfield/textfield_views_model.h" 5 #include "ui/views/controls/textfield/textfield_views_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 bool TextfieldViewsModel::SetText(const string16& text) { 308 bool TextfieldViewsModel::SetText(const string16& text) {
309 bool changed = false; 309 bool changed = false;
310 if (HasCompositionText()) { 310 if (HasCompositionText()) {
311 ConfirmCompositionText(); 311 ConfirmCompositionText();
312 changed = true; 312 changed = true;
313 } 313 }
314 if (GetText() != text) { 314 if (GetText() != text) {
315 if (changed) // No need to remember composition. 315 if (changed) // No need to remember composition.
316 Undo(); 316 Undo();
317 size_t old_cursor = GetCursorPosition(); 317 size_t old_cursor = GetCursorPosition();
318 size_t new_cursor = old_cursor > text.length() ? text.length() : old_cursor; 318 // SetText moves the cursor to the end.
319 size_t new_cursor = text.length();
sky 2012/05/18 20:28:30 Does this force scrolling when the omnibox does a
319 SelectAll(); 320 SelectAll();
320 // If there is a composition text, don't merge with previous edit. 321 // If there is a composition text, don't merge with previous edit.
321 // Otherwise, force merge the edits. 322 // Otherwise, force merge the edits.
322 ExecuteAndRecordReplace( 323 ExecuteAndRecordReplace(
323 changed ? DO_NOT_MERGE : MERGE_WITH_PREVIOUS, 324 changed ? DO_NOT_MERGE : MERGE_WITH_PREVIOUS,
324 old_cursor, 325 old_cursor,
325 new_cursor, 326 new_cursor,
326 text, 327 text,
327 0U); 328 0U);
328 render_text_->SetCursorPosition(new_cursor); 329 render_text_->SetCursorPosition(new_cursor);
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 if (delete_from != delete_to) 780 if (delete_from != delete_to)
780 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); 781 render_text_->SetText(text.erase(delete_from, delete_to - delete_from));
781 if (!new_text.empty()) 782 if (!new_text.empty())
782 render_text_->SetText(text.insert(new_text_insert_at, new_text)); 783 render_text_->SetText(text.insert(new_text_insert_at, new_text));
783 render_text_->SetCursorPosition(new_cursor_pos); 784 render_text_->SetCursorPosition(new_cursor_pos);
784 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). 785 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't).
785 // This looks fine feature and we may want to do the same. 786 // This looks fine feature and we may want to do the same.
786 } 787 }
787 788
788 } // namespace views 789 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698