summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/base/clipboard/clipboard_win.cc3
-rw-r--r--ui/base/l10n/l10n_util.cc4
-rw-r--r--ui/base/win/ime_input.cc27
-rw-r--r--ui/views/controls/textfield/native_textfield_win.cc16
4 files changed, 21 insertions, 29 deletions
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index 492dd31..a543fe6 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -604,7 +604,8 @@ void Clipboard::ReadFiles(std::vector<FilePath>* files) const {
if (count) {
for (int i = 0; i < count; ++i) {
- int size = ::DragQueryFile(drop, i, NULL, 0) + 1;
+ UINT size = ::DragQueryFile(drop, i, NULL, 0) + 1;
+ DCHECK_GT(size, 1u);
std::wstring file;
::DragQueryFile(drop, i, WriteInto(&file, size), size);
files->push_back(FilePath(file));
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 1c2aca0..28dbc43 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -478,12 +478,12 @@ string16 GetDisplayNameForLocale(const std::string& locale,
locale_code = "zh-Hant";
UErrorCode error = U_ZERO_ERROR;
- const int buffer_size = 1024;
+ const int kBufferSize = 1024;
string16 display_name;
int actual_size = uloc_getDisplayName(locale_code.c_str(),
display_locale.c_str(),
- WriteInto(&display_name, buffer_size + 1), buffer_size, &error);
+ WriteInto(&display_name, kBufferSize), kBufferSize - 1, &error);
DCHECK(U_SUCCESS(error));
display_name.resize(actual_size);
// Add an RTL mark so parentheses are properly placed.
diff --git a/ui/base/win/ime_input.cc b/ui/base/win/ime_input.cc
index 50bf3ea..049ab02 100644
--- a/ui/base/win/ime_input.cc
+++ b/ui/base/win/ime_input.cc
@@ -339,22 +339,19 @@ void ImeInput::GetCompositionInfo(HIMC imm_context, LPARAM lparam,
}
}
-bool ImeInput::GetString(HIMC imm_context, WPARAM lparam, int type,
+bool ImeInput::GetString(HIMC imm_context,
+ WPARAM lparam,
+ int type,
string16* result) {
- bool ret = false;
- if (lparam & type) {
- int string_size = ::ImmGetCompositionString(imm_context, type, NULL, 0);
- if (string_size > 0) {
- int string_length = string_size / sizeof(wchar_t);
- wchar_t *string_data = WriteInto(result, string_length + 1);
- if (string_data) {
- // Fill the given result object.
- ::ImmGetCompositionString(imm_context, type, string_data, string_size);
- ret = true;
- }
- }
- }
- return ret;
+ if (!(lparam & type))
+ return false;
+ LONG string_size = ::ImmGetCompositionString(imm_context, type, NULL, 0);
+ if (string_size <= 0)
+ return false;
+ DCHECK_EQ(0u, string_size % sizeof(wchar_t));
+ ::ImmGetCompositionString(imm_context, type,
+ WriteInto(result, (string_size / sizeof(wchar_t)) + 1), string_size);
+ return true;
}
bool ImeInput::GetResult(HWND window_handle, LPARAM lparam, string16* result) {
diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc
index 20cae12..3b598e1 100644
--- a/ui/views/controls/textfield/native_textfield_win.cc
+++ b/ui/views/controls/textfield/native_textfield_win.cc
@@ -173,18 +173,16 @@ void NativeTextfieldWin::AttachHack() {
string16 NativeTextfieldWin::GetText() const {
int len = GetTextLength() + 1;
- if (len <= 1)
- return string16();
-
string16 str;
- GetWindowText(WriteInto(&str, len), len);
+ if (len > 1)
+ GetWindowText(WriteInto(&str, len), len);
// The text get from GetWindowText() might be wrapped with explicit bidi
// control characters. Refer to UpdateText() for detail. Without such
// wrapping, in RTL chrome, a pure LTR string ending with parenthesis will
// not be displayed correctly in a textfield. For example, "Yahoo!" will be
// displayed as "!Yahoo", and "Google (by default)" will be displayed as
// "(Google (by default".
- return base::i18n::StripWrappingBidiControlCharacters(WideToUTF16(str));
+ return base::i18n::StripWrappingBidiControlCharacters(str);
}
void NativeTextfieldWin::UpdateText() {
@@ -206,15 +204,11 @@ void NativeTextfieldWin::AppendText(const string16& text) {
}
string16 NativeTextfieldWin::GetSelectedText() const {
- // Figure out the length of the selection.
CHARRANGE sel;
GetSel(sel);
- if (sel.cpMin == sel.cpMax) // GetSelText() crashes on NULL input.
- return string16();
-
- // Grab the selected text.
string16 str;
- GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1));
+ if (sel.cpMin != sel.cpMax)
+ GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1));
return str;
}