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

Side by Side Diff: ui/base/win/ime_input.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | views/controls/textfield/native_textfield_win.cc » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/win/ime_input.h" 5 #include "ui/base/win/ime_input.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 if (target_end < length) { 333 if (target_end < length) {
334 underline.start_offset = target_end; 334 underline.start_offset = target_end;
335 underline.end_offset = length; 335 underline.end_offset = length;
336 underline.thick = false; 336 underline.thick = false;
337 composition->underlines.push_back(underline); 337 composition->underlines.push_back(underline);
338 } 338 }
339 } 339 }
340 } 340 }
341 341
342 bool ImeInput::GetString(HIMC imm_context, WPARAM lparam, int type, 342 bool ImeInput::GetString(HIMC imm_context,
343 WPARAM lparam,
344 int type,
343 string16* result) { 345 string16* result) {
344 bool ret = false; 346 if (!(lparam & type))
345 if (lparam & type) { 347 return false;
346 int string_size = ::ImmGetCompositionString(imm_context, type, NULL, 0); 348 LONG string_size = ::ImmGetCompositionString(imm_context, type, NULL, 0);
347 if (string_size > 0) { 349 if (string_size <= 0)
348 int string_length = string_size / sizeof(wchar_t); 350 return false;
349 wchar_t *string_data = WriteInto(result, string_length + 1); 351 DCHECK_EQ(0u, string_size % sizeof(wchar_t));
350 if (string_data) { 352 ::ImmGetCompositionString(imm_context, type,
351 // Fill the given result object. 353 WriteInto(result, (string_size / sizeof(wchar_t)) + 1), string_size);
352 ::ImmGetCompositionString(imm_context, type, string_data, string_size); 354 return true;
353 ret = true;
354 }
355 }
356 }
357 return ret;
358 } 355 }
359 356
360 bool ImeInput::GetResult(HWND window_handle, LPARAM lparam, string16* result) { 357 bool ImeInput::GetResult(HWND window_handle, LPARAM lparam, string16* result) {
361 bool ret = false; 358 bool ret = false;
362 HIMC imm_context = ::ImmGetContext(window_handle); 359 HIMC imm_context = ::ImmGetContext(window_handle);
363 if (imm_context) { 360 if (imm_context) {
364 ret = GetString(imm_context, lparam, GCS_RESULTSTR, result); 361 ret = GetString(imm_context, lparam, GCS_RESULTSTR, result);
365 ::ImmReleaseContext(window_handle, imm_context); 362 ::ImmReleaseContext(window_handle, imm_context);
366 } 363 }
367 return ret; 364 return ret;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 keystate[VK_RCONTROL] = 0; 549 keystate[VK_RCONTROL] = 0;
553 keystate[VK_LCONTROL] = 0; 550 keystate[VK_LCONTROL] = 0;
554 for (int i = 0; i <= VK_PACKET; ++i) { 551 for (int i = 0; i <= VK_PACKET; ++i) {
555 if (keystate[i] & kKeyDownMask) 552 if (keystate[i] & kKeyDownMask)
556 return false; 553 return false;
557 } 554 }
558 return true; 555 return true;
559 } 556 }
560 557
561 } // namespace ui 558 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | views/controls/textfield/native_textfield_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698