summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 06:29:33 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 06:29:33 +0000
commitb49eb8716bbae4181c840c4a010665e3cc5aea8f (patch)
tree4403a0e756accca746a1d0f1468df60ea9fb7eb4 /chrome/browser
parentf649c5eda1375c0499ba93f2b10f3c573df8c3f8 (diff)
downloadchromium_src-b49eb8716bbae4181c840c4a010665e3cc5aea8f.zip
chromium_src-b49eb8716bbae4181c840c4a010665e3cc5aea8f.tar.gz
chromium_src-b49eb8716bbae4181c840c4a010665e3cc5aea8f.tar.bz2
Cancels an ongoing IME composition when receiving an IME_CANCEL_COMPOSITION event on Windows.
This change just adds ImeInput::CancelIME() and use it when receiving an IME_CANCEL_COMPOSITION event. (I'm not sure it works well with all IMEs, though.) BUG=9883 TEST=none Review URL: http://codereview.chromium.org/2099012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/ime_input.cc13
-rw-r--r--chrome/browser/ime_input.h10
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc2
3 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/ime_input.cc b/chrome/browser/ime_input.cc
index 21b5229..3f60670 100644
--- a/chrome/browser/ime_input.cc
+++ b/chrome/browser/ime_input.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -304,6 +304,17 @@ void ImeInput::DisableIME(HWND window_handle) {
::ImmAssociateContextEx(window_handle, NULL, 0);
}
+void ImeInput::CancelIME(HWND window_handle) {
+ if (is_composing_) {
+ HIMC imm_context = ::ImmGetContext(window_handle);
+ if (imm_context) {
+ ::ImmNotifyIME(imm_context, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
+ ::ImmReleaseContext(window_handle, imm_context);
+ }
+ ResetComposition(window_handle);
+ }
+}
+
void ImeInput::EnableIME(HWND window_handle,
const gfx::Rect& caret_rect,
bool complete) {
diff --git a/chrome/browser/ime_input.h b/chrome/browser/ime_input.h
index b1ebf4a..45fe21f 100644
--- a/chrome/browser/ime_input.h
+++ b/chrome/browser/ime_input.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -235,6 +235,12 @@ class ImeInput {
// Represents the window handle of the caller.
void DisableIME(HWND window_handle);
+ // Cancels an ongoing composition of the IME attached to the given window.
+ // Parameters
+ // * window_handle [in] (HWND)
+ // Represents the window handle of the caller.
+ void CancelIME(HWND window_handle);
+
protected:
// Determines whether or not the given attribute represents a target
// (a.k.a. a selection).
@@ -300,7 +306,7 @@ class ImeInput {
// The rectangle of the input caret retrieved from a renderer process.
gfx::Rect caret_rect_;
- DISALLOW_EVIL_CONSTRUCTORS(ImeInput);
+ DISALLOW_COPY_AND_ASSIGN(ImeInput);
};
#endif // CHROME_BROWSER_IME_INPUT_H_
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index b482b87..e195317 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -614,6 +614,8 @@ void RenderWidgetHostViewWin::IMEUpdateStatus(int control,
const gfx::Rect& caret_rect) {
if (control == IME_DISABLE) {
ime_input_.DisableIME(m_hWnd);
+ } else if (control == IME_CANCEL_COMPOSITION) {
+ ime_input_.CancelIME(m_hWnd);
} else {
ime_input_.EnableIME(m_hWnd, caret_rect,
control == IME_COMPLETE_COMPOSITION);