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

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

Issue 23769011: Move a bunch of windows stuff from ui/base/win to ui/gfx/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar bustage. Created 7 years, 3 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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "ui/base/clipboard/clipboard.h" 13 #include "ui/base/clipboard/clipboard.h"
14 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
15 #include "ui/base/text/utf16_indexing.h"
16 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
18 #include "ui/gfx/range/range.h" 17 #include "ui/gfx/range/range.h"
19 #include "ui/gfx/render_text.h" 18 #include "ui/gfx/render_text.h"
20 #include "ui/gfx/text_constants.h" 19 #include "ui/gfx/text_constants.h"
20 #include "ui/gfx/utf16_indexing.h"
21 #include "ui/views/controls/textfield/textfield.h" 21 #include "ui/views/controls/textfield/textfield.h"
22 22
23 namespace views { 23 namespace views {
24 24
25 namespace internal { 25 namespace internal {
26 26
27 // An edit object holds enough information/state to undo/redo the 27 // An edit object holds enough information/state to undo/redo the
28 // change. Two edits are merged when possible, for example, when 28 // change. Two edits are merged when possible, for example, when
29 // you type new characters in sequence. |Commit()| can be used to 29 // you type new characters in sequence. |Commit()| can be used to
30 // mark an edit as an independent edit and it shouldn't be merged. 30 // mark an edit as an independent edit and it shouldn't be merged.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 return true; 377 return true;
378 } 378 }
379 if (HasSelection()) { 379 if (HasSelection()) {
380 DeleteSelection(); 380 DeleteSelection();
381 return true; 381 return true;
382 } 382 }
383 size_t cursor_position = GetCursorPosition(); 383 size_t cursor_position = GetCursorPosition();
384 if (cursor_position > 0) { 384 if (cursor_position > 0) {
385 // Delete one code point, which may be two UTF-16 words. 385 // Delete one code point, which may be two UTF-16 words.
386 size_t previous_char = 386 size_t previous_char =
387 ui::UTF16OffsetToIndex(GetText(), cursor_position, -1); 387 gfx::UTF16OffsetToIndex(GetText(), cursor_position, -1);
388 ExecuteAndRecordDelete(gfx::Range(cursor_position, previous_char), true); 388 ExecuteAndRecordDelete(gfx::Range(cursor_position, previous_char), true);
389 return true; 389 return true;
390 } 390 }
391 return false; 391 return false;
392 } 392 }
393 393
394 size_t TextfieldViewsModel::GetCursorPosition() const { 394 size_t TextfieldViewsModel::GetCursorPosition() const {
395 return render_text_->cursor_position(); 395 return render_text_->cursor_position();
396 } 396 }
397 397
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 if (delete_from != delete_to) 790 if (delete_from != delete_to)
791 render_text_->SetText(text.erase(delete_from, delete_to - delete_from)); 791 render_text_->SetText(text.erase(delete_from, delete_to - delete_from));
792 if (!new_text.empty()) 792 if (!new_text.empty())
793 render_text_->SetText(text.insert(new_text_insert_at, new_text)); 793 render_text_->SetText(text.insert(new_text_insert_at, new_text));
794 render_text_->SetCursorPosition(new_cursor_pos); 794 render_text_->SetCursorPosition(new_cursor_pos);
795 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't). 795 // TODO(oshima): mac selects the text that is just undone (but gtk doesn't).
796 // This looks fine feature and we may want to do the same. 796 // This looks fine feature and we may want to do the same.
797 } 797 }
798 798
799 } // namespace views 799 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_win.cc ('k') | ui/views/widget/aero_tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698