diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 07:14:45 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 07:14:45 +0000 |
commit | 04df4f1ea242136c0829b8d922c3aefdbb4ebd85 (patch) | |
tree | b8b73d5e2d2418bd3a15e0ffdc488080cc21d27d /chrome | |
parent | 7b8a6e4b33e39ce54e9e99553eba5e25cc071fa7 (diff) | |
download | chromium_src-04df4f1ea242136c0829b8d922c3aefdbb4ebd85.zip chromium_src-04df4f1ea242136c0829b8d922c3aefdbb4ebd85.tar.gz chromium_src-04df4f1ea242136c0829b8d922c3aefdbb4ebd85.tar.bz2 |
Reverts my r4300 and re-fixes Issue 3156 and 13500.
My r4300, which is a fix Issue 3156, has been causing regressions (Issue 9596, Issue 13500, Issue 29290, etc.)
Every time when this change caused regressions, we added more code to Chromium and made Chromium code more complicated.
So, I think it is better to revert this change once and find another solution for Issue 3156 rather than to add another workaround for Issue 29290.
To look into Issue 3156 more deeply, it is caused by a recursive message-handler call.
When SetWindowText() is called while an IME is composing text, the IME calls SendMessage() to send a WM_IME_COMPOSITION message.
When we receive this WM_IME_COMPOSITION message, it updates the omnibox and calls SetWindowText()...
This recursive call caused not only Issue 3156 but also caused some other IME issues, such as Issue 13500.
BUG=3156,13500,29290
TEST=On XP, open a new tab, set the IME to Hiragana, type 'c', and then click an entry in the popup. The browser should navigate and show the popup URL without a crash.
TEST=Open Gmail, compose a new e-mail (without using a tear-off window), set the IME to Hiragana, type 'c' in its message body, and wait for the draft auto-saving. The browser should show the 'c' character.
Review URL: http://codereview.chromium.org/467015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 37 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.h | 2 |
2 files changed, 16 insertions, 23 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index f0396de..6e570ea 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -617,26 +617,6 @@ void AutocompleteEditViewWin::SetUserText(const std::wstring& text, void AutocompleteEditViewWin::SetWindowTextAndCaretPos(const std::wstring& text, size_t caret_pos) { - HIMC imm_context = ImmGetContext(m_hWnd); - if (imm_context) { - // In Windows Vista, SetWindowText() automatically cancels any ongoing - // IME composition, and updates the text of the underlying edit control. - // In Windows XP, however, SetWindowText() gets applied to the IME - // composition string if it exists, and doesn't update the underlying edit - // control. To avoid this, we force the IME to cancel any outstanding - // compositions here. This is harmless in Vista and in cases where the IME - // isn't composing. - - // NOTE: We MUST ignore messages like WM_IME_COMPOSITION that may be sent as - // a result of doing this. Until the SetWindowText() call below, the - // underlying edit (on XP) has out-of-date text in it; for problems this can - // cause, see OnImeComposition(). - ignore_ime_messages_ = true; - ImmNotifyIME(imm_context, NI_COMPOSITIONSTR, CPS_CANCEL, 0); - ImmReleaseContext(m_hWnd, imm_context); - ignore_ime_messages_ = false; - } - SetWindowText(text.c_str()); PlaceCaretAt(caret_pos); } @@ -803,9 +783,6 @@ bool AutocompleteEditViewWin::OnInlineAutocompleteTextMaybeChanged( return false; ScopedFreeze freeze(this, GetTextObjectModel()); - // NOTE: We don't need the IME composition hack in SetWindowTextAndCaretPos() - // here, because UpdatePopup() disables inline autocomplete when a - // composition is in progress, thus preventing us from reaching this code. SetWindowText(display_text.c_str()); // Set a reversed selection to keep the caret in the same position, which // avoids scrolling the user's text. @@ -1718,6 +1695,20 @@ void AutocompleteEditViewWin::OnSetFocus(HWND focus_wnd) { SetMsgHandled(false); } +LRESULT AutocompleteEditViewWin::OnSetText(const wchar_t* text) { + // Ignore all IME messages while we process this WM_SETTEXT message. + // When SetWindowText() is called while an IME is composing text, the IME + // calls SendMessage() to send a WM_IME_COMPOSITION message. When we receive + // this WM_IME_COMPOSITION message, we update the omnibox and may call + // SetWindowText() again. To stop this recursive message-handler call, we + // stop updating the omnibox while we process a WM_SETTEXT message. + // We wouldn't need to do this update anyway, because either we're in the + // middle of updating the omnibox already or the caller of SetWindowText() + // is going to update the omnibox next. + AutoReset auto_reset_ignore_ime_messages(&ignore_ime_messages_, true); + return DefWindowProc(WM_SETTEXT, 0, reinterpret_cast<LPARAM>(text)); +} + void AutocompleteEditViewWin::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) { diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h index 03a1d89..8da5ad1 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h @@ -177,6 +177,7 @@ class AutocompleteEditViewWin MSG_WM_RBUTTONDOWN(OnNonLButtonDown) MSG_WM_RBUTTONUP(OnNonLButtonUp) MSG_WM_SETFOCUS(OnSetFocus) + MSG_WM_SETTEXT(OnSetText) MSG_WM_SYSCHAR(OnSysChar) // WM_SYSxxx == WM_xxx with ALT down MSG_WM_SYSKEYDOWN(OnKeyDown) MSG_WM_SYSKEYUP(OnKeyUp) @@ -260,6 +261,7 @@ class AutocompleteEditViewWin void OnPaint(HDC bogus_hdc); void OnPaste(); void OnSetFocus(HWND focus_wnd); + LRESULT OnSetText(const wchar_t* text); void OnSysChar(TCHAR ch, UINT repeat_count, UINT flags); void OnWindowPosChanging(WINDOWPOS* window_pos); |