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

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

Issue 8343036: Update native_textfield_win.cc to parallel previous changes to omnibox_view_win.cc. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/native_textfield_win.cc
===================================================================
--- views/controls/textfield/native_textfield_win.cc (revision 107404)
+++ views/controls/textfield/native_textfield_win.cc (working copy)
@@ -173,6 +173,9 @@
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 @@
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698