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

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

Issue 2348143003: MacViews: Implement Force Touch/Mac dictionary lookup for Textfields. (Closed)
Patch Set: Address nits. Created 4 years, 2 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
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_model.h" 5 #include "ui/views/controls/textfield/textfield_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (HasCompositionText()) 617 if (HasCompositionText())
618 CancelCompositionText(); 618 CancelCompositionText();
619 ExecuteAndRecordReplace(DO_NOT_MERGE, 619 ExecuteAndRecordReplace(DO_NOT_MERGE,
620 GetCursorPosition(), 620 GetCursorPosition(),
621 position + new_text.length(), 621 position + new_text.length(),
622 new_text, 622 new_text,
623 position); 623 position);
624 } 624 }
625 625
626 base::string16 TextfieldModel::GetTextFromRange(const gfx::Range& range) const { 626 base::string16 TextfieldModel::GetTextFromRange(const gfx::Range& range) const {
627 if (range.IsValid() && range.GetMin() < text().length()) 627 return render_text_->GetTextFromRange(range);
628 return text().substr(range.GetMin(), range.length());
629 return base::string16();
630 } 628 }
631 629
632 void TextfieldModel::GetTextRange(gfx::Range* range) const { 630 void TextfieldModel::GetTextRange(gfx::Range* range) const {
633 *range = gfx::Range(0, text().length()); 631 *range = gfx::Range(0, text().length());
634 } 632 }
635 633
636 void TextfieldModel::SetCompositionText( 634 void TextfieldModel::SetCompositionText(
637 const ui::CompositionText& composition) { 635 const ui::CompositionText& composition) {
638 if (HasCompositionText()) 636 if (HasCompositionText())
639 CancelCompositionText(); 637 CancelCompositionText();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 render_text_->SetCursorPosition(new_cursor_pos); 851 render_text_->SetCursorPosition(new_cursor_pos);
854 // TODO(oshima): Select text that was just undone, like Mac (but not GTK). 852 // TODO(oshima): Select text that was just undone, like Mac (but not GTK).
855 } 853 }
856 854
857 // static 855 // static
858 void TextfieldModel::ClearKillBuffer() { 856 void TextfieldModel::ClearKillBuffer() {
859 SetKillBuffer(base::string16()); 857 SetKillBuffer(base::string16());
860 } 858 }
861 859
862 } // namespace views 860 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698