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

Unified Diff: views/controls/textfield/textfield.cc

Issue 6318004: Add TextRange and related methods to Textfield Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | views/controls/textfield/textfield_views_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/textfield.cc
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 50e6b942fd423cddcf84bfe906df0ee03809b4d0..a228ed970e2480e3b1da0406c3231de7aef92fb9 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,6 +35,27 @@ namespace views {
const char Textfield::kViewClassName[] = "views/Textfield";
/////////////////////////////////////////////////////////////////////////////
+// TextRange
+
+TextRange::TextRange(size_t start, size_t end)
+ : start_(start),
+ end_(end) {
+}
+
+size_t TextRange::GetMin() const {
+ return std::min(start_, end_);
+}
+
+size_t TextRange::GetMax() const {
+ return std::max(start_, end_);
+}
+
+void TextRange::SetRange(size_t start, size_t end) {
+ start_ = start;
+ end_ = end;
+}
+
+/////////////////////////////////////////////////////////////////////////////
// Textfield
Textfield::Textfield()
@@ -242,6 +263,23 @@ bool Textfield::IsIMEComposing() const {
return native_wrapper_ && native_wrapper_->IsIMEComposing();
}
+void Textfield::GetSelectedRange(TextRange* range) const {
+ DCHECK(native_wrapper_);
+ if (native_wrapper_)
+ native_wrapper_->GetSelectedRange(range);
+}
+
+void Textfield::SelectRange(const TextRange& range) {
+ DCHECK(native_wrapper_);
+ if (native_wrapper_)
+ native_wrapper_->SelectRange(range);
+}
+
+size_t Textfield::GetCursorPosition() const {
+ DCHECK(native_wrapper_);
+ return native_wrapper_ ? native_wrapper_->GetCursorPosition() : 0;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Textfield, View overrides:
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | views/controls/textfield/textfield_views_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698