diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 09:00:12 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 09:00:12 +0000 |
commit | 4ea470c9f1d92d4e4ad1f20caf4d6cd02ca44e20 (patch) | |
tree | e9b307f56eb340ee8d511d02bfa5d36c0b26313c /chrome | |
parent | ed54318708245efdfcf7454d3aaebfd419f4448c (diff) | |
download | chromium_src-4ea470c9f1d92d4e4ad1f20caf4d6cd02ca44e20.zip chromium_src-4ea470c9f1d92d4e4ad1f20caf4d6cd02ca44e20.tar.gz chromium_src-4ea470c9f1d92d4e4ad1f20caf4d6cd02ca44e20.tar.bz2 |
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 auto-complete when an omnibox starts with whitespace characters.
BUG=3798
TEST=Type "google.com" on Omnibox, type "Tab" to start tab-to-search, type 'nihao' on Microsoft New Phonetic IME, and see we can see Chinese characters in the omnibox.
Review URL: http://codereview.chromium.org/391070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 27 |
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 |