summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 17:53:48 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 17:53:48 +0000
commitb1b5a304d200fa38157eb003576f8e79f2be459d (patch)
tree784f448ca2d91669eb438a0d6eaa3afba75323d1 /chrome
parent24e51679046641c78881fadc3651ff7bf5458f03 (diff)
downloadchromium_src-b1b5a304d200fa38157eb003576f8e79f2be459d.zip
chromium_src-b1b5a304d200fa38157eb003576f8e79f2be459d.tar.gz
chromium_src-b1b5a304d200fa38157eb003576f8e79f2be459d.tar.bz2
A fix for Issue 3156 in chromium: "OmniBox: NavSuggest doesn't work fine when you select NavSuggest suggested item before finalizing IME."To investigate this issue today, a rich-edit control of Windows XP does not finish an ongoing composition before changing its text with a SetWindowText() call. (Thanks pkasting for colleting my corrupted comments.)To solve this issue, this change manually finishes an ongoing composition before calling the function.
Review URL: http://codereview.chromium.org/8669 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index f04c9f6..5974b81 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -305,6 +305,10 @@ void AutocompleteEditModel::SendOpenNotification(size_t selected_line,
void AutocompleteEditModel::AcceptKeyword() {
view_->OnBeforePossibleChange();
+ // NOTE: We don't need the IME composition hack in SetWindowTextAndCaretPos()
+ // here, because any active IME composition will eat <tab> characters,
+ // preventing the user from using tab-to-search until the composition is
+ // ended.
view_->SetWindowText(L"");
is_keyword_hint_ = false;
keyword_ui_state_ = KEYWORD;
@@ -897,6 +901,19 @@ void AutocompleteEditView::SetUserText(const std::wstring& text,
void AutocompleteEditView::SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos) {
+ HIMC imm_context = ImmGetContext(m_hWnd);
+ if (imm_context) {
+ // In Windows Vista, SetWindowText() automatically completes 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 complete any outstanding
+ // compositions here. This is harmless in Vista and in cases where the IME
+ // isn't composing.
+ ImmNotifyIME(imm_context, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
+ ImmReleaseContext(m_hWnd, imm_context);
+ }
+
SetWindowText(text.c_str());
PlaceCaretAt(caret_pos);
}
@@ -1044,6 +1061,9 @@ bool AutocompleteEditView::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.