diff options
author | yoichio@chromium.org <yoichio@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 01:23:30 +0000 |
---|---|---|
committer | yoichio@chromium.org <yoichio@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 01:23:30 +0000 |
commit | a68d6cdc039db12fc579784f41955a4afc38ccd4 (patch) | |
tree | 0ab24fafa5e8df33fc3450c7e7559aa0f2c9f381 | |
parent | c1079b53697b430bea10047b7fcc6f7ae727c35c (diff) | |
download | chromium_src-a68d6cdc039db12fc579784f41955a4afc38ccd4.zip chromium_src-a68d6cdc039db12fc579784f41955a4afc38ccd4.tar.gz chromium_src-a68d6cdc039db12fc579784f41955a4afc38ccd4.tar.bz2 |
Refactoring. Move ui/base/win/ime_input.* to ui/base/ime/win/
renaming ImeInput to IMM32Manager.
That is IMM32 API wrapper.
BUG=246534
Review URL: https://chromiumcodereview.appspot.com/19504004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212199 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_win.cc | 54 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_win.h | 4 | ||||
-rw-r--r-- | ui/base/ime/ime.gypi | 8 | ||||
-rw-r--r-- | ui/base/ime/input_method_imm32.cc | 32 | ||||
-rw-r--r-- | ui/base/ime/input_method_win.cc | 11 | ||||
-rw-r--r-- | ui/base/ime/input_method_win.h | 6 | ||||
-rw-r--r-- | ui/base/ime/win/imm32_manager.cc (renamed from ui/base/win/ime_input.cc) | 65 | ||||
-rw-r--r-- | ui/base/ime/win/imm32_manager.h (renamed from ui/base/win/ime_input.h) | 48 | ||||
-rw-r--r-- | ui/ui.gyp | 2 | ||||
-rw-r--r-- | ui/views/ime/input_method_win.cc | 46 | ||||
-rw-r--r-- | ui/views/ime/input_method_win.h | 6 |
11 files changed, 143 insertions, 139 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 1c895ce..8a32194 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -723,7 +723,7 @@ void RenderWidgetHostViewWin::SelectionBoundsChanged( // Only update caret position if the input method is enabled. if (is_enabled) { caret_rect_ = gfx::UnionRects(params.anchor_rect, params.focus_rect); - ime_input_.UpdateCaretRect(m_hWnd, caret_rect_); + imm32_manager_.UpdateCaretRect(m_hWnd, caret_rect_); } } @@ -731,7 +731,7 @@ void RenderWidgetHostViewWin::ScrollOffsetChanged() { } void RenderWidgetHostViewWin::ImeCancelComposition() { - ime_input_.CancelIME(m_hWnd); + imm32_manager_.CancelIME(m_hWnd); } void RenderWidgetHostViewWin::ImeCompositionRangeChanged( @@ -1548,7 +1548,7 @@ void RenderWidgetHostViewWin::OnCancelMode() { void RenderWidgetHostViewWin::OnInputLangChange(DWORD character_set, HKL input_language_id) { TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnInputLangChange"); - // Send the given Locale ID to the ImeInput object and retrieves whether + // Send the given Locale ID to the IMM32Manager object and retrieves whether // or not the current input context has IMEs. // If the current input context has IMEs, a browser process has to send a // request to a renderer process that it needs status messages about @@ -1577,7 +1577,7 @@ void RenderWidgetHostViewWin::OnInputLangChange(DWORD character_set, // 1 Sending a request only if ime_status_ != ime_notification_, and; // 2 Copying ime_status to ime_notification_ if it sends the request // successfully (because Action 1 shows ime_status = !ime_notification_.) - bool ime_status = ime_input_.SetInputLanguage(); + bool ime_status = imm32_manager_.SetInputLanguage(); if (ime_status != ime_notification_) { if (render_widget_host_) { render_widget_host_->SetInputMethodActive(ime_status); @@ -1649,10 +1649,10 @@ LRESULT RenderWidgetHostViewWin::OnImeSetContext( } if (ime_notification_) - ime_input_.CreateImeWindow(m_hWnd); + imm32_manager_.CreateImeWindow(m_hWnd); - ime_input_.CleanupComposition(m_hWnd); - return ime_input_.SetImeWindowStyle( + imm32_manager_.CleanupComposition(m_hWnd); + return imm32_manager_.SetImeWindowStyle( m_hWnd, message, wparam, lparam, &handled); } @@ -1663,8 +1663,8 @@ LRESULT RenderWidgetHostViewWin::OnImeStartComposition( return 0; // Reset the composition status and create IME windows. - ime_input_.CreateImeWindow(m_hWnd); - ime_input_.ResetComposition(m_hWnd); + imm32_manager_.CreateImeWindow(m_hWnd); + imm32_manager_.ResetComposition(m_hWnd); // When the focus is on an element that does not draw composition by itself // (i.e., PPAPI plugin not handling IME), let IME to draw the text. Otherwise // we have to prevent WTL from calling ::DefWindowProc() because the function @@ -1681,7 +1681,7 @@ LRESULT RenderWidgetHostViewWin::OnImeComposition( return 0; // At first, update the position of the IME window. - ime_input_.UpdateImeWindow(m_hWnd); + imm32_manager_.UpdateImeWindow(m_hWnd); // ui::CompositionUnderline should be identical to // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. @@ -1692,10 +1692,10 @@ LRESULT RenderWidgetHostViewWin::OnImeComposition( // Retrieve the result string and its attributes of the ongoing composition // and send it to a renderer process. ui::CompositionText composition; - if (ime_input_.GetResult(m_hWnd, lparam, &composition.text)) { + if (imm32_manager_.GetResult(m_hWnd, lparam, &composition.text)) { render_widget_host_->ImeConfirmComposition( composition.text, ui::Range::InvalidRange(), false); - ime_input_.ResetComposition(m_hWnd); + imm32_manager_.ResetComposition(m_hWnd); // Fall though and try reading the composition string. // Japanese IMEs send a message containing both GCS_RESULTSTR and // GCS_COMPSTR, which means an ongoing composition has been finished @@ -1703,7 +1703,7 @@ LRESULT RenderWidgetHostViewWin::OnImeComposition( } // Retrieve the composition string and its attributes of the ongoing // composition and send it to a renderer process. - if (ime_input_.GetComposition(m_hWnd, lparam, &composition)) { + if (imm32_manager_.GetComposition(m_hWnd, lparam, &composition)) { // TODO(suzhe): due to a bug of webkit, we can't use selection range with // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 composition.selection = ui::Range(composition.selection.end()); @@ -1737,15 +1737,15 @@ LRESULT RenderWidgetHostViewWin::OnImeEndComposition( if (!render_widget_host_) return 0; - if (ime_input_.is_composing()) { + if (imm32_manager_.is_composing()) { // A composition has been ended while there is an ongoing composition, // i.e. the ongoing composition has been canceled. - // We need to reset the composition status both of the ImeInput object and - // of the renderer process. + // We need to reset the composition status both of the IMM32Manager object + // and of the renderer process. render_widget_host_->ImeCancelComposition(); - ime_input_.ResetComposition(m_hWnd); + imm32_manager_.ResetComposition(m_hWnd); } - ime_input_.DestroyImeWindow(m_hWnd); + imm32_manager_.DestroyImeWindow(m_hWnd); // Let WTL call ::DefWindowProc() and release its resources. handled = FALSE; return 0; @@ -1864,7 +1864,7 @@ LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam, if (base::win::IsTSFAwareRequired()) { ui::TSFBridge::GetInstance()->CancelComposition(); } else { - ime_input_.CleanupComposition(m_hWnd); + imm32_manager_.CleanupComposition(m_hWnd); } // Fall through. case WM_MOUSEMOVE: @@ -1941,11 +1941,11 @@ LRESULT RenderWidgetHostViewWin::OnKeyEvent(UINT message, WPARAM wparam, // Bug 9718: http://crbug.com/9718 To investigate IE and notepad, this // shortcut is enabled only on a PC having RTL keyboard layouts installed. // We should emulate them. - if (ui::ImeInput::IsRTLKeyboardLayoutInstalled()) { + if (ui::IMM32Manager::IsRTLKeyboardLayoutInstalled()) { if (message == WM_KEYDOWN) { if (wparam == VK_SHIFT) { base::i18n::TextDirection dir; - if (ui::ImeInput::IsCtrlShiftPressed(&dir)) { + if (ui::IMM32Manager::IsCtrlShiftPressed(&dir)) { render_widget_host_->UpdateTextDirection( dir == base::i18n::RIGHT_TO_LEFT ? WebKit::WebTextDirectionRightToLeft : @@ -2251,7 +2251,7 @@ LRESULT RenderWidgetHostViewWin::OnTouchEvent(UINT message, WPARAM wparam, if (base::win::IsTSFAwareRequired()) { ui::TSFBridge::GetInstance()->CancelComposition(); } else { - ime_input_.CleanupComposition(m_hWnd); + imm32_manager_.CleanupComposition(m_hWnd); } // TODO(jschuh): Add support for an arbitrary number of touchpoints. @@ -3114,7 +3114,7 @@ LRESULT RenderWidgetHostViewWin::OnDocumentFeed(RECONVERTSTRING* reconv) { LRESULT RenderWidgetHostViewWin::OnReconvertString(RECONVERTSTRING* reconv) { // If there is a composition string already, we don't allow reconversion. - if (ime_input_.is_composing()) + if (imm32_manager_.is_composing()) return 0; if (selection_range_.is_empty()) @@ -3164,7 +3164,7 @@ LRESULT RenderWidgetHostViewWin::OnQueryCharPosition( return 0; RECT target_rect = {}; - if (ime_input_.is_composing() && !composition_range_.is_empty() && + if (imm32_manager_.is_composing() && !composition_range_.is_empty() && position->dwCharPos < composition_character_bounds_.size()) { target_rect = composition_character_bounds_[position->dwCharPos].ToRECT(); @@ -3196,10 +3196,10 @@ void RenderWidgetHostViewWin::UpdateIMEState() { } if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD) { - ime_input_.EnableIME(m_hWnd); - ime_input_.SetUseCompositionWindow(!can_compose_inline_); + imm32_manager_.EnableIME(m_hWnd); + imm32_manager_.SetUseCompositionWindow(!can_compose_inline_); } else { - ime_input_.DisableIME(m_hWnd); + imm32_manager_.DisableIME(m_hWnd); } } diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index 956164a..325a4f4 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -25,9 +25,9 @@ #include "ui/base/gestures/gesture_recognizer.h" #include "ui/base/gestures/gesture_types.h" #include "ui/base/ime/text_input_client.h" +#include "ui/base/ime/win/imm32_manager.h" #include "ui/base/ime/win/tsf_bridge.h" #include "ui/base/win/extra_sdk_defines.h" -#include "ui/base/win/ime_input.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/point.h" #include "ui/surface/accelerated_surface_win.h" @@ -475,7 +475,7 @@ class RenderWidgetHostViewWin // Wrapper class for IME input. // (See "ui/base/win/ime_input.h" for its details.) - ui::ImeInput ime_input_; + ui::IMM32Manager imm32_manager_; // Represents whether or not this browser process is receiving status // messages about the focused edit control from a renderer process. diff --git a/ui/base/ime/ime.gypi b/ui/base/ime/ime.gypi index e25bb8a..b8a1896 100644 --- a/ui/base/ime/ime.gypi +++ b/ui/base/ime/ime.gypi @@ -34,7 +34,9 @@ 'text_input_client.h', 'text_input_type.h', ], - 'tsf_files': [ + 'win_ime_files': [ + 'win/imm32_manager.cc', + 'win/imm32_manager.h', 'win/tsf_bridge.cc', 'win/tsf_bridge.h', 'win/tsf_event_router.cc', @@ -47,7 +49,7 @@ }, 'sources': [ '<@(ime_files)', - '<@(tsf_files)', + '<@(win_ime_files)', ], 'conditions': [ ['use_aura==0 and OS!="win"', { @@ -78,7 +80,7 @@ }], ['OS!="win"', { 'sources!': [ - '<@(tsf_files)', + '<@(win_ime_files)', 'input_method_imm32.cc', 'input_method_imm32.h', 'input_method_tsf.cc', diff --git a/ui/base/ime/input_method_imm32.cc b/ui/base/ime/input_method_imm32.cc index 625f41b..922894f 100644 --- a/ui/base/ime/input_method_imm32.cc +++ b/ui/base/ime/input_method_imm32.cc @@ -86,7 +86,7 @@ bool InputMethodIMM32::OnUntranslatedIMEMessage( void InputMethodIMM32::OnTextInputTypeChanged(const TextInputClient* client) { if (IsTextInputClientFocused(client) && IsWindowFocused(client)) { - ime_input_.CancelIME(GetAttachedWindowHandle(client)); + imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); UpdateIMEState(); } InputMethodWin::OnTextInputTypeChanged(client); @@ -109,7 +109,7 @@ void InputMethodIMM32::OnCaretBoundsChanged(const TextInputClient* client) { GetClientRect(attached_window, &r); POINT window_point = { screen_bounds.x(), screen_bounds.y() }; ScreenToClient(attached_window, &window_point); - ime_input_.UpdateCaretRect( + imm32_manager_.UpdateCaretRect( attached_window, gfx::Rect(gfx::Point(window_point.x, window_point.y), screen_bounds.size())); @@ -117,7 +117,7 @@ void InputMethodIMM32::OnCaretBoundsChanged(const TextInputClient* client) { void InputMethodIMM32::CancelComposition(const TextInputClient* client) { if (enabled_ && IsTextInputClientFocused(client)) - ime_input_.CancelIME(GetAttachedWindowHandle(client)); + imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); } void InputMethodIMM32::SetFocusedTextInputClient(TextInputClient* client) { @@ -160,10 +160,10 @@ LRESULT InputMethodIMM32::OnImeSetContext(HWND window_handle, BOOL* handled) { active_ = (wparam == TRUE); if (active_) - ime_input_.CreateImeWindow(window_handle); + imm32_manager_.CreateImeWindow(window_handle); OnInputMethodChanged(); - return ime_input_.SetImeWindowStyle( + return imm32_manager_.SetImeWindowStyle( window_handle, message, wparam, lparam, handled); } @@ -179,8 +179,8 @@ LRESULT InputMethodIMM32::OnImeStartComposition(HWND window_handle, // Reset the composition status and create IME windows. composing_window_handle_ = window_handle; - ime_input_.CreateImeWindow(window_handle); - ime_input_.ResetComposition(window_handle); + imm32_manager_.CreateImeWindow(window_handle); + imm32_manager_.ResetComposition(window_handle); return 0; } @@ -194,15 +194,15 @@ LRESULT InputMethodIMM32::OnImeComposition(HWND window_handle, *handled = TRUE; // At first, update the position of the IME window. - ime_input_.UpdateImeWindow(window_handle); + imm32_manager_.UpdateImeWindow(window_handle); // Retrieve the result string and its attributes of the ongoing composition // and send it to a renderer process. ui::CompositionText composition; - if (ime_input_.GetResult(window_handle, lparam, &composition.text)) { + if (imm32_manager_.GetResult(window_handle, lparam, &composition.text)) { if (!IsTextInputTypeNone()) GetTextInputClient()->InsertText(composition.text); - ime_input_.ResetComposition(window_handle); + imm32_manager_.ResetComposition(window_handle); // Fall though and try reading the composition string. // Japanese IMEs send a message containing both GCS_RESULTSTR and // GCS_COMPSTR, which means an ongoing composition has been finished @@ -210,7 +210,7 @@ LRESULT InputMethodIMM32::OnImeComposition(HWND window_handle, } // Retrieve the composition string and its attributes of the ongoing // composition and send it to a renderer process. - if (ime_input_.GetComposition(window_handle, lparam, &composition) && + if (imm32_manager_.GetComposition(window_handle, lparam, &composition) && !IsTextInputTypeNone()) GetTextInputClient()->SetCompositionText(composition); @@ -230,8 +230,8 @@ LRESULT InputMethodIMM32::OnImeEndComposition(HWND window_handle, if (!IsTextInputTypeNone() && GetTextInputClient()->HasCompositionText()) GetTextInputClient()->ClearCompositionText(); - ime_input_.ResetComposition(window_handle); - ime_input_.DestroyImeWindow(window_handle); + imm32_manager_.ResetComposition(window_handle); + imm32_manager_.DestroyImeWindow(window_handle); return 0; } @@ -256,7 +256,7 @@ LRESULT InputMethodIMM32::OnImeNotify(UINT message, void InputMethodIMM32::ConfirmCompositionText() { if (composing_window_handle_) - ime_input_.CleanupComposition(composing_window_handle_); + imm32_manager_.CleanupComposition(composing_window_handle_); if (!IsTextInputTypeNone()) { // Though above line should confirm the client's composition text by sending @@ -273,11 +273,11 @@ void InputMethodIMM32::UpdateIMEState() { switch (GetTextInputType()) { case ui::TEXT_INPUT_TYPE_NONE: case ui::TEXT_INPUT_TYPE_PASSWORD: - ime_input_.DisableIME(GetAttachedWindowHandle(GetTextInputClient())); + imm32_manager_.DisableIME(GetAttachedWindowHandle(GetTextInputClient())); enabled_ = false; break; default: - ime_input_.EnableIME(GetAttachedWindowHandle(GetTextInputClient())); + imm32_manager_.EnableIME(GetAttachedWindowHandle(GetTextInputClient())); enabled_ = true; break; } diff --git a/ui/base/ime/input_method_win.cc b/ui/base/ime/input_method_win.cc index c469ec3..30c6cc1 100644 --- a/ui/base/ime/input_method_win.cc +++ b/ui/base/ime/input_method_win.cc @@ -46,7 +46,8 @@ bool InputMethodWin::DispatchKeyEvent( return !!handled; // Don't send WM_CHAR for post event processing. } // Handles ctrl-shift key to change text direction and layout alignment. - if (ui::ImeInput::IsRTLKeyboardLayoutInstalled() && !IsTextInputTypeNone()) { + if (ui::IMM32Manager::IsRTLKeyboardLayoutInstalled() && + !IsTextInputTypeNone()) { // TODO: shouldn't need to generate a KeyEvent here. const ui::KeyEvent key(native_key_event, native_key_event.message == WM_CHAR); @@ -54,7 +55,7 @@ bool InputMethodWin::DispatchKeyEvent( if (key.type() == ui::ET_KEY_PRESSED) { if (code == ui::VKEY_SHIFT) { base::i18n::TextDirection dir; - if (ui::ImeInput::IsCtrlShiftPressed(&dir)) + if (ui::IMM32Manager::IsCtrlShiftPressed(&dir)) pending_requested_direction_ = dir; } else if (code != ui::VKEY_CONTROL) { pending_requested_direction_ = base::i18n::UNKNOWN_DIRECTION; @@ -89,9 +90,9 @@ bool InputMethodWin::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) { } void InputMethodWin::OnInputLocaleChanged() { - active_ = ime_input_.SetInputLanguage(); - locale_ = ime_input_.GetInputLanguageName(); - direction_ = ime_input_.GetTextDirection(); + active_ = imm32_manager_.SetInputLanguage(); + locale_ = imm32_manager_.GetInputLanguageName(); + direction_ = imm32_manager_.GetTextDirection(); OnInputMethodChanged(); } diff --git a/ui/base/ime/input_method_win.h b/ui/base/ime/input_method_win.h index 9b4b58e..1a62799 100644 --- a/ui/base/ime/input_method_win.h +++ b/ui/base/ime/input_method_win.h @@ -12,7 +12,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "ui/base/ime/input_method_base.h" -#include "ui/base/win/ime_input.h" +#include "ui/base/ime/win/imm32_manager.h" namespace ui { @@ -57,8 +57,8 @@ class UI_EXPORT InputMethodWin : public InputMethodBase { bool active_; // Windows IMM32 wrapper. - // (See "ui/base/win/ime_input.h" for its details.) - ui::ImeInput ime_input_; + // (See "ui/base/ime/win/ime_input.h" for its details.) + ui::IMM32Manager imm32_manager_; private: // The toplevel window handle. diff --git a/ui/base/win/ime_input.cc b/ui/base/ime/win/imm32_manager.cc index 8b9aa5b..ef2a129 100644 --- a/ui/base/win/ime_input.cc +++ b/ui/base/ime/win/imm32_manager.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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. -#include "ui/base/win/ime_input.h" +#include "ui/base/ime/win/imm32_manager.h" #include <atlbase.h> #include <atlcom.h> @@ -27,7 +27,7 @@ COMPILE_ASSERT(sizeof(wchar_t) == sizeof(char16), wchar_t__char16_diff); /////////////////////////////////////////////////////////////////////////////// -// ImeInput +// IMM32Manager namespace { @@ -38,8 +38,8 @@ bool IsTargetAttribute(char attribute) { attribute == ATTR_TARGET_NOTCONVERTED); } -// Helper function for ImeInput::GetCompositionInfo() method, to get the target -// range that's selected by the user in the current composition string. +// Helper function for IMM32Manager::GetCompositionInfo() method, to get the +// target range that's selected by the user in the current composition string. void GetCompositionTargetRange(HIMC imm_context, int* target_start, int* target_end) { int attribute_size = ::ImmGetCompositionString(imm_context, GCS_COMPATTR, @@ -65,8 +65,8 @@ void GetCompositionTargetRange(HIMC imm_context, int* target_start, } } -// Helper function for ImeInput::GetCompositionInfo() method, to get underlines -// information of the current composition string. +// Helper function for IMM32Manager::GetCompositionInfo() method, to get +// underlines information of the current composition string. void GetCompositionUnderlines(HIMC imm_context, int target_start, int target_end, @@ -116,7 +116,7 @@ bool IsRTLPrimaryLangID(LANGID lang) { namespace ui { -ImeInput::ImeInput() +IMM32Manager::IMM32Manager() : ime_status_(false), input_language_id_(LANG_USER_DEFAULT), is_composing_(false), @@ -125,10 +125,10 @@ ImeInput::ImeInput() use_composition_window_(false) { } -ImeInput::~ImeInput() { +IMM32Manager::~IMM32Manager() { } -bool ImeInput::SetInputLanguage() { +bool IMM32Manager::SetInputLanguage() { // Retrieve the current keyboard layout from Windows and determine whether // or not the current input context has IMEs. // Also save its input language for language-specific operations required @@ -155,7 +155,7 @@ bool ImeInput::SetInputLanguage() { return ime_status_; } -void ImeInput::CreateImeWindow(HWND window_handle) { +void IMM32Manager::CreateImeWindow(HWND window_handle) { // When a user disables TSF (Text Service Framework) and CUAS (Cicero // Unaware Application Support), Chinese IMEs somehow ignore function calls // to ::ImmSetCandidateWindow(), i.e. they do not move their candidate @@ -178,7 +178,7 @@ void ImeInput::CreateImeWindow(HWND window_handle) { UpdateImeWindow(window_handle); } -LRESULT ImeInput::SetImeWindowStyle(HWND window_handle, UINT message, +LRESULT IMM32Manager::SetImeWindowStyle(HWND window_handle, UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { // To prevent the IMM (Input Method Manager) from displaying the IME @@ -194,7 +194,7 @@ LRESULT ImeInput::SetImeWindowStyle(HWND window_handle, UINT message, return ::DefWindowProc(window_handle, message, wparam, lparam); } -void ImeInput::DestroyImeWindow(HWND window_handle) { +void IMM32Manager::DestroyImeWindow(HWND window_handle) { // Destroy the system caret if we have created for this IME input context. if (system_caret_) { ::DestroyCaret(); @@ -202,7 +202,7 @@ void ImeInput::DestroyImeWindow(HWND window_handle) { } } -void ImeInput::MoveImeWindow(HWND window_handle, HIMC imm_context) { +void IMM32Manager::MoveImeWindow(HWND window_handle, HIMC imm_context) { // Does nothing when the target window has no input focus. This is important // because the renderer may issue SelectionBoundsChanged event even when it // has no input focus. (e.g. the page update caused by incremental search.) @@ -217,7 +217,7 @@ void ImeInput::MoveImeWindow(HWND window_handle, HIMC imm_context) { const int kCaretMargin = 1; if (!use_composition_window_ && PRIMARYLANGID(input_language_id_) == LANG_CHINESE) { - // As written in a comment in ImeInput::CreateImeWindow(), + // As written in a comment in IMM32Manager::CreateImeWindow(), // Chinese IMEs ignore function calls to ::ImmSetCandidateWindow() // when a user disables TSF (Text Service Framework) and CUAS (Cicero // Unaware Application Support). @@ -265,7 +265,7 @@ void ImeInput::MoveImeWindow(HWND window_handle, HIMC imm_context) { ::ImmSetCandidateWindow(imm_context, &exclude_rectangle); } -void ImeInput::UpdateImeWindow(HWND window_handle) { +void IMM32Manager::UpdateImeWindow(HWND window_handle) { // Just move the IME window attached to the given window. if (caret_rect_.x() >= 0 && caret_rect_.y() >= 0) { HIMC imm_context = ::ImmGetContext(window_handle); @@ -276,7 +276,7 @@ void ImeInput::UpdateImeWindow(HWND window_handle) { } } -void ImeInput::CleanupComposition(HWND window_handle) { +void IMM32Manager::CleanupComposition(HWND window_handle) { // Notify the IMM attached to the given window to complete the ongoing // composition, (this case happens when the given window is de-activated // while composing a text and re-activated), and reset the omposition status. @@ -290,12 +290,12 @@ void ImeInput::CleanupComposition(HWND window_handle) { } } -void ImeInput::ResetComposition(HWND window_handle) { +void IMM32Manager::ResetComposition(HWND window_handle) { // Currently, just reset the composition status. is_composing_ = false; } -void ImeInput::CompleteComposition(HWND window_handle, HIMC imm_context) { +void IMM32Manager::CompleteComposition(HWND window_handle, HIMC imm_context) { // We have to confirm there is an ongoing composition before completing it. // This is for preventing some IMEs from getting confused while completing an // ongoing composition even if they do not have any ongoing compositions.) @@ -305,7 +305,7 @@ void ImeInput::CompleteComposition(HWND window_handle, HIMC imm_context) { } } -void ImeInput::GetCompositionInfo(HIMC imm_context, LPARAM lparam, +void IMM32Manager::GetCompositionInfo(HIMC imm_context, LPARAM lparam, CompositionText* composition) { // We only care about GCS_COMPATTR, GCS_COMPCLAUSE and GCS_CURSORPOS, and // convert them into underlines and selection range respectively. @@ -365,7 +365,7 @@ void ImeInput::GetCompositionInfo(HIMC imm_context, LPARAM lparam, } } -bool ImeInput::GetString(HIMC imm_context, +bool IMM32Manager::GetString(HIMC imm_context, WPARAM lparam, int type, string16* result) { @@ -380,7 +380,8 @@ bool ImeInput::GetString(HIMC imm_context, return true; } -bool ImeInput::GetResult(HWND window_handle, LPARAM lparam, string16* result) { +bool IMM32Manager::GetResult( + HWND window_handle, LPARAM lparam, string16* result) { bool ret = false; HIMC imm_context = ::ImmGetContext(window_handle); if (imm_context) { @@ -390,7 +391,7 @@ bool ImeInput::GetResult(HWND window_handle, LPARAM lparam, string16* result) { return ret; } -bool ImeInput::GetComposition(HWND window_handle, LPARAM lparam, +bool IMM32Manager::GetComposition(HWND window_handle, LPARAM lparam, CompositionText* composition) { bool ret = false; HIMC imm_context = ::ImmGetContext(window_handle); @@ -425,7 +426,7 @@ bool ImeInput::GetComposition(HWND window_handle, LPARAM lparam, return ret; } -void ImeInput::DisableIME(HWND window_handle) { +void IMM32Manager::DisableIME(HWND window_handle) { // A renderer process have moved its input focus to a password input // when there is an ongoing composition, e.g. a user has clicked a // mouse button and selected a password input while composing a text. @@ -435,7 +436,7 @@ void ImeInput::DisableIME(HWND window_handle) { ::ImmAssociateContextEx(window_handle, NULL, 0); } -void ImeInput::CancelIME(HWND window_handle) { +void IMM32Manager::CancelIME(HWND window_handle) { if (is_composing_) { HIMC imm_context = ::ImmGetContext(window_handle); if (imm_context) { @@ -446,7 +447,7 @@ void ImeInput::CancelIME(HWND window_handle) { } } -void ImeInput::EnableIME(HWND window_handle) { +void IMM32Manager::EnableIME(HWND window_handle) { // Load the default IME context. // NOTE(hbono) // IMM ignores this call if the IME context is loaded. Therefore, we do @@ -454,7 +455,7 @@ void ImeInput::EnableIME(HWND window_handle) { ::ImmAssociateContextEx(window_handle, NULL, IACE_DEFAULT); } -void ImeInput::UpdateCaretRect(HWND window_handle, +void IMM32Manager::UpdateCaretRect(HWND window_handle, const gfx::Rect& caret_rect) { // Save the caret position, and Update the position of the IME window. // This update is used for moving an IME window when a renderer process @@ -470,11 +471,11 @@ void ImeInput::UpdateCaretRect(HWND window_handle, } } -void ImeInput::SetUseCompositionWindow(bool use_composition_window) { +void IMM32Manager::SetUseCompositionWindow(bool use_composition_window) { use_composition_window_ = use_composition_window; } -std::string ImeInput::GetInputLanguageName() const { +std::string IMM32Manager::GetInputLanguageName() const { const LCID locale_id = MAKELCID(input_language_id_, SORT_DEFAULT); // max size for LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME is 9. wchar_t buffer[9]; @@ -501,13 +502,13 @@ std::string ImeInput::GetInputLanguageName() const { return language.append(1, '-').append(region); } -base::i18n::TextDirection ImeInput::GetTextDirection() const { +base::i18n::TextDirection IMM32Manager::GetTextDirection() const { return IsRTLPrimaryLangID(PRIMARYLANGID(input_language_id_)) ? base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT; } // static -bool ImeInput::IsRTLKeyboardLayoutInstalled() { +bool IMM32Manager::IsRTLKeyboardLayoutInstalled() { static enum { RTL_KEYBOARD_LAYOUT_NOT_INITIALIZED, RTL_KEYBOARD_LAYOUT_INSTALLED, @@ -541,7 +542,7 @@ bool ImeInput::IsRTLKeyboardLayoutInstalled() { return false; } -bool ImeInput::IsCtrlShiftPressed(base::i18n::TextDirection* direction) { +bool IMM32Manager::IsCtrlShiftPressed(base::i18n::TextDirection* direction) { uint8_t keystate[256]; if (!::GetKeyboardState(&keystate[0])) return false; diff --git a/ui/base/win/ime_input.h b/ui/base/ime/win/imm32_manager.h index 47f6c1d..d519802 100644 --- a/ui/base/win/ime_input.h +++ b/ui/base/ime/win/imm32_manager.h @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright 2013 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. -#ifndef UI_BASE_WIN_IME_INPUT_H_ -#define UI_BASE_WIN_IME_INPUT_H_ +#ifndef UI_BASE_IME_WIN_IMM32_MANAGER_H +#define UI_BASE_IME_WIN_IMM32_MANAGER_H #include <windows.h> @@ -27,36 +27,36 @@ struct CompositionText; // The following items enumerates the simplest steps for an (window) // application to control its IMEs with the struct and the class defined // this file. -// 1. Add an instance of the ImeInput class to its window class. -// (The ImeInput class needs a window handle.) +// 1. Add an instance of the IMM32Manager class to its window class. +// (The IMM32Manager class needs a window handle.) // 2. Add messages handlers listed in the following subsections, follow the -// instructions written in each subsection, and use the ImeInput class. +// instructions written in each subsection, and use the IMM32Manager class. // 2.1. WM_IME_SETCONTEXT (0x0281) // Call the functions listed below: -// - ImeInput::CreateImeWindow(); -// - ImeInput::CleanupComposition(), and; -// - ImeInput::SetImeWindowStyle(). +// - IMM32Manager::CreateImeWindow(); +// - IMM32Manager::CleanupComposition(), and; +// - IMM32Manager::SetImeWindowStyle(). // An application MUST prevent from calling ::DefWindowProc(). // 2.2. WM_IME_STARTCOMPOSITION (0x010D) // Call the functions listed below: -// - ImeInput::CreateImeWindow(), and; -// - ImeInput::ResetComposition(). +// - IMM32Manager::CreateImeWindow(), and; +// - IMM32Manager::ResetComposition(). // An application MUST prevent from calling ::DefWindowProc(). // 2.3. WM_IME_COMPOSITION (0x010F) // Call the functions listed below: -// - ImeInput::UpdateImeWindow(); -// - ImeInput::GetResult(); -// - ImeInput::GetComposition(), and; -// - ImeInput::ResetComposition() (optional). +// - IMM32Manager::UpdateImeWindow(); +// - IMM32Manager::GetResult(); +// - IMM32Manager::GetComposition(), and; +// - IMM32Manager::ResetComposition() (optional). // An application MUST prevent from calling ::DefWindowProc(). // 2.4. WM_IME_ENDCOMPOSITION (0x010E) // Call the functions listed below: -// - ImeInput::ResetComposition(), and; -// - ImeInput::DestroyImeWindow(). +// - IMM32Manager::ResetComposition(), and; +// - IMM32Manager::DestroyImeWindow(). // An application CAN call ::DefWindowProc(). // 2.5. WM_INPUTLANGCHANGE (0x0051) // Call the functions listed below: -// - ImeInput::SetInputLanguage(). +// - IMM32Manager::SetInputLanguage(). // An application CAN call ::DefWindowProc(). // This class controls the IMM (Input Method Manager) through IMM32 APIs and @@ -73,10 +73,10 @@ struct CompositionText; // hand, we can NEVER disable either TSF or CUAS in Windows Vista, i.e. // THIS CLASS IS NOT ONLY USED ON THE INPUT CONTEXTS OF EAST-ASIAN // LANGUAGES BUT ALSO USED ON THE INPUT CONTEXTS OF ALL LANGUAGES. -class UI_EXPORT ImeInput { +class UI_EXPORT IMM32Manager { public: - ImeInput(); - ~ImeInput(); + IMM32Manager(); + ~IMM32Manager(); // Retrieves whether or not there is an ongoing composition. bool is_composing() const { return is_composing_; } @@ -129,7 +129,7 @@ class UI_EXPORT ImeInput { // Represents the window handle of the caller. void UpdateImeWindow(HWND window_handle); - // Cleans up the all resources attached to the given ImeInput object, and + // Cleans up the all resources attached to the given IMM32Manager object, and // reset its composition status. // Parameters // * window_handle [in] (HWND) @@ -311,9 +311,9 @@ class UI_EXPORT ImeInput { // Indicates whether or not we want IME to render composition text. bool use_composition_window_; - DISALLOW_COPY_AND_ASSIGN(ImeInput); + DISALLOW_COPY_AND_ASSIGN(IMM32Manager); }; } // namespace ui -#endif // UI_BASE_WIN_IME_INPUT_H_ +#endif // UI_BASE_IME_WIN_IMM32_MANAGER_H @@ -359,8 +359,6 @@ 'base/win/hwnd_subclass.h', 'base/win/hwnd_util.cc', 'base/win/hwnd_util.h', - 'base/win/ime_input.cc', - 'base/win/ime_input.h', 'base/win/message_box_win.cc', 'base/win/message_box_win.h', 'base/win/mouse_wheel_util.cc', diff --git a/ui/views/ime/input_method_win.cc b/ui/views/ime/input_method_win.cc index 1cd18d8..5ec7c72 100644 --- a/ui/views/ime/input_method_win.cc +++ b/ui/views/ime/input_method_win.cc @@ -36,7 +36,7 @@ InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, InputMethodWin::~InputMethodWin() { if (widget()) - ime_input_.DisableIME(hwnd_); + imm32_manager_.DisableIME(hwnd_); } void InputMethodWin::Init(Widget* widget) { @@ -104,12 +104,13 @@ bool InputMethodWin::OnUntranslatedIMEMessage(const base::NativeEvent& event, void InputMethodWin::DispatchKeyEvent(const ui::KeyEvent& key) { // Handles ctrl-shift key to change text direction and layout alignment. - if (ui::ImeInput::IsRTLKeyboardLayoutInstalled() && !IsTextInputTypeNone()) { + if (ui::IMM32Manager::IsRTLKeyboardLayoutInstalled() && + !IsTextInputTypeNone()) { ui::KeyboardCode code = key.key_code(); if (key.type() == ui::ET_KEY_PRESSED) { if (code == ui::VKEY_SHIFT) { base::i18n::TextDirection dir; - if (ui::ImeInput::IsCtrlShiftPressed(&dir)) + if (ui::IMM32Manager::IsCtrlShiftPressed(&dir)) pending_requested_direction_ = dir; } else if (code != ui::VKEY_CONTROL) { pending_requested_direction_ = base::i18n::UNKNOWN_DIRECTION; @@ -128,7 +129,7 @@ void InputMethodWin::DispatchKeyEvent(const ui::KeyEvent& key) { void InputMethodWin::OnTextInputTypeChanged(View* view) { if (IsViewFocused(view)) { - ime_input_.CancelIME(hwnd_); + imm32_manager_.CancelIME(hwnd_); UpdateIMEState(); } InputMethodBase::OnTextInputTypeChanged(view); @@ -138,18 +139,18 @@ void InputMethodWin::OnCaretBoundsChanged(View* view) { gfx::Rect rect; if (!IsViewFocused(view) || !GetCaretBoundsInWidget(&rect)) return; - ime_input_.UpdateCaretRect(hwnd_, rect); + imm32_manager_.UpdateCaretRect(hwnd_, rect); } void InputMethodWin::CancelComposition(View* view) { if (IsViewFocused(view)) - ime_input_.CancelIME(hwnd_); + imm32_manager_.CancelIME(hwnd_); } void InputMethodWin::OnInputLocaleChanged() { - active_ = ime_input_.SetInputLanguage(); - locale_ = ime_input_.GetInputLanguageName(); - direction_ = ime_input_.GetTextDirection(); + active_ = imm32_manager_.SetInputLanguage(); + locale_ = imm32_manager_.GetInputLanguageName(); + direction_ = imm32_manager_.GetTextDirection(); OnInputMethodChanged(); } @@ -188,10 +189,11 @@ LRESULT InputMethodWin::OnImeSetContext( UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { active_ = (wparam == TRUE); if (active_) - ime_input_.CreateImeWindow(hwnd_); + imm32_manager_.CreateImeWindow(hwnd_); OnInputMethodChanged(); - return ime_input_.SetImeWindowStyle(hwnd_, message, wparam, lparam, handled); + return imm32_manager_.SetImeWindowStyle(hwnd_, message, wparam, lparam, + handled); } LRESULT InputMethodWin::OnImeStartComposition( @@ -205,8 +207,8 @@ LRESULT InputMethodWin::OnImeStartComposition( return 0; // Reset the composition status and create IME windows. - ime_input_.CreateImeWindow(hwnd_); - ime_input_.ResetComposition(hwnd_); + imm32_manager_.CreateImeWindow(hwnd_); + imm32_manager_.ResetComposition(hwnd_); return 0; } @@ -220,14 +222,14 @@ LRESULT InputMethodWin::OnImeComposition( return 0; // At first, update the position of the IME window. - ime_input_.UpdateImeWindow(hwnd_); + imm32_manager_.UpdateImeWindow(hwnd_); // Retrieve the result string and its attributes of the ongoing composition // and send it to a renderer process. ui::CompositionText composition; - if (ime_input_.GetResult(hwnd_, lparam, &composition.text)) { + if (imm32_manager_.GetResult(hwnd_, lparam, &composition.text)) { GetTextInputClient()->InsertText(composition.text); - ime_input_.ResetComposition(hwnd_); + imm32_manager_.ResetComposition(hwnd_); // Fall though and try reading the composition string. // Japanese IMEs send a message containing both GCS_RESULTSTR and // GCS_COMPSTR, which means an ongoing composition has been finished @@ -235,7 +237,7 @@ LRESULT InputMethodWin::OnImeComposition( } // Retrieve the composition string and its attributes of the ongoing // composition and send it to a renderer process. - if (ime_input_.GetComposition(hwnd_, lparam, &composition)) + if (imm32_manager_.GetComposition(hwnd_, lparam, &composition)) GetTextInputClient()->SetCompositionText(composition); return 0; @@ -252,8 +254,8 @@ LRESULT InputMethodWin::OnImeEndComposition( if (GetTextInputClient()->HasCompositionText()) GetTextInputClient()->ClearCompositionText(); - ime_input_.ResetComposition(hwnd_); - ime_input_.DestroyImeWindow(hwnd_); + imm32_manager_.ResetComposition(hwnd_); + imm32_manager_.DestroyImeWindow(hwnd_); return 0; } @@ -481,7 +483,7 @@ LRESULT InputMethodWin::OnQueryCharPosition(IMECHARPOSITION *char_positon) { void InputMethodWin::ConfirmCompositionText() { if (!IsTextInputTypeNone()) { - ime_input_.CleanupComposition(hwnd_); + imm32_manager_.CleanupComposition(hwnd_); // Though above line should confirm the client's composition text by sending // a result text to us, in case the input method and the client are in // inconsistent states, we check the client's composition state again. @@ -496,10 +498,10 @@ void InputMethodWin::UpdateIMEState() { switch (GetTextInputType()) { case ui::TEXT_INPUT_TYPE_NONE: case ui::TEXT_INPUT_TYPE_PASSWORD: - ime_input_.DisableIME(hwnd_); + imm32_manager_.DisableIME(hwnd_); break; default: - ime_input_.EnableIME(hwnd_); + imm32_manager_.EnableIME(hwnd_); break; } } diff --git a/ui/views/ime/input_method_win.h b/ui/views/ime/input_method_win.h index 84c804e..5668e8f3 100644 --- a/ui/views/ime/input_method_win.h +++ b/ui/views/ime/input_method_win.h @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "ui/base/win/ime_input.h" +#include "ui/base/ime/win/imm32_manager.h" #include "ui/views/ime/input_method_base.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" @@ -104,8 +104,8 @@ class InputMethodWin : public InputMethodBase { base::i18n::TextDirection pending_requested_direction_; // Windows IMM32 wrapper. - // (See "ui/base/win/ime_input.h" for its details.) - ui::ImeInput ime_input_; + // (See "ui/base/ime/win/ime_input.h" for its details.) + ui::IMM32Manager imm32_manager_; ui::InputMethod* const host_; |