summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-18 03:09:30 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-18 03:09:30 +0000
commit7b60ddadf4d55987b9cbffdad16c776b276f44cc (patch)
treed7ed3c050e5ecf7a6e36d409d29e69c1f631da45
parentd59b36bab5ee52cde0233dc4240a187e8bfa4ebe (diff)
downloadchromium_src-7b60ddadf4d55987b9cbffdad16c776b276f44cc.zip
chromium_src-7b60ddadf4d55987b9cbffdad16c776b276f44cc.tar.gz
chromium_src-7b60ddadf4d55987b9cbffdad16c776b276f44cc.tar.bz2
Merge 32166 - A quick fix for Issue 3798.
Some Chinese IMEs insert whitespace characters (U+3000) instead of input characters while they are composing text. So, trimming these whitespace characters (at the beginning of an omnibox) prevents from inputting text on these IMEs. As a quick fix, this change prevent our AutocompleteEditViewWin::OnImeComposition() from starting autocomplete when an omnibox starts with whitespace characters. BUG=3798 TEST=Type "google.com" on Omnibox, type "Tab" to start tabtosearch, type 'nihao' on Microsoft New Phonetic IME, and see we can see Chinese characters in the omnibox. Review URL: http://codereview.chromium.org/391070 TBR=hbono@chromium.org Review URL: http://codereview.chromium.org/399058 git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@32268 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 134cbea4..00cd12c 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -1252,6 +1252,33 @@ LRESULT AutocompleteEditViewWin::OnImeComposition(UINT message,
ScopedFreeze freeze(this, GetTextObjectModel());
OnBeforePossibleChange();
LRESULT result = DefWindowProc(message, wparam, lparam);
+
+ // Some IMEs insert whitespace characters instead of input characters while
+ // they are composing text, and trimming these whitespace characters at the
+ // beginning of this control (in OnAfterPossibleChange()) prevents users from
+ // inputting text on these IMEs.
+ // To prevent this problem, we should not start auto-complete if the
+ // composition string starts with whitespace characters.
+ // (When we type a space key to insert a whitespace character, IMEs don't
+ // insert the whitespace character to their composition string but their
+ // result string. So, this code doesn't prevent us from updating autocomplete
+ // when we insert a whitespace character.)
+ if (lparam & GCS_COMPSTR) {
+ std::wstring text;
+ HIMC context = ImmGetContext(m_hWnd);
+ if (context) {
+ int size = ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0);
+ if (size > 0) {
+ wchar_t* text_data = WriteInto(&text, size / sizeof(wchar_t) + 1);
+ if (text_data)
+ ImmGetCompositionString(context, GCS_COMPSTR, text_data, size);
+ }
+ ImmReleaseContext(m_hWnd, context);
+ }
+ if (!text.empty() && IsWhitespace(text[0]))
+ return result;
+ }
+
if (!OnAfterPossibleChange() && (lparam & GCS_RESULTSTR)) {
// The result string changed, but the text in the popup didn't actually
// change. This means the user finalized the composition. Rerun