summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 21:50:31 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 21:50:31 +0000
commit69e95edf406054fe899b489068b3925419a3c2e2 (patch)
tree0540101d8922f0b1149e8ac5929128c9614f2656 /views
parent23ae0592bb8cd3559ae8c6a2abfa1bddc24e9066 (diff)
downloadchromium_src-69e95edf406054fe899b489068b3925419a3c2e2.zip
chromium_src-69e95edf406054fe899b489068b3925419a3c2e2.tar.gz
chromium_src-69e95edf406054fe899b489068b3925419a3c2e2.tar.bz2
Update native_textfield_win.cc to parallel previous changes to omnibox_view_win.cc.
BUG=101938 TEST=none Review URL: http://codereview.chromium.org/8343036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/textfield/native_textfield_win.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index c49f76d..025fc40 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -173,6 +173,9 @@ void NativeTextfieldWin::AttachHack() {
string16 NativeTextfieldWin::GetText() const {
int len = GetTextLength() + 1;
+ if (len <= 1)
+ return string16();
+
string16 str;
GetWindowText(WriteInto(&str, len), len);
// The text get from GetWindowText() might be wrapped with explicit bidi
@@ -204,16 +207,14 @@ void NativeTextfieldWin::AppendText(const string16& text) {
string16 NativeTextfieldWin::GetSelectedText() const {
// Figure out the length of the selection.
- long start;
- long end;
- GetSel(start, end);
+ CHARRANGE sel;
+ GetSel(sel);
+ if (sel.cpMin == sel.cpMax) // GetSelText() crashes on NULL input.
+ return string16();
// Grab the selected text.
string16 str;
- long length = end - start;
- if (length > 0)
- GetSelText(WriteInto(&str, length + 1));
-
+ GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1));
return str;
}