| Index: trunk/src/ui/views/ime/input_method_win.cc
|
| ===================================================================
|
| --- trunk/src/ui/views/ime/input_method_win.cc (revision 202706)
|
| +++ trunk/src/ui/views/ime/input_method_win.cc (working copy)
|
| @@ -7,17 +7,14 @@
|
| #include "base/basictypes.h"
|
| #include "base/logging.h"
|
| #include "base/string_util.h"
|
| -#include "base/win/metro.h"
|
| #include "ui/base/events/event.h"
|
| #include "ui/base/events/event_constants.h"
|
| #include "ui/base/events/event_utils.h"
|
| #include "ui/base/ime/composition_text.h"
|
| #include "ui/base/ime/input_method.h"
|
| #include "ui/base/ime/text_input_client.h"
|
| -#include "ui/base/ime/win/tsf_bridge.h"
|
| #include "ui/base/keycodes/keyboard_codes.h"
|
| #include "ui/base/win/hwnd_util.h"
|
| -#include "ui/views/win/hwnd_util.h"
|
|
|
| // Extra number of chars before and after selection (or composition) range which
|
| // is returned to IME for improving conversion accuracy.
|
| @@ -49,32 +46,11 @@
|
| }
|
|
|
| void InputMethodWin::OnFocus() {
|
| - if (base::win::IsTSFAwareRequired()) {
|
| - if (GetTextInputClient()) {
|
| - ui::TSFBridge* tsf_bridge = ui::TSFBridge::GetInstance();
|
| - tsf_bridge->SetFocusedClient(hwnd_, GetTextInputClient());
|
| - }
|
| - } else {
|
| - // Use switch here in case we are going to add more text input types.
|
| - // We disable input method in password field.
|
| - switch (GetTextInputType()) {
|
| - case ui::TEXT_INPUT_TYPE_NONE:
|
| - case ui::TEXT_INPUT_TYPE_PASSWORD:
|
| - ime_input_.DisableIME(hwnd_);
|
| - break;
|
| - default:
|
| - ime_input_.EnableIME(hwnd_);
|
| - break;
|
| - }
|
| - OnTextInputTypeChanged(GetFocusedView());
|
| - OnCaretBoundsChanged(GetFocusedView());
|
| - }
|
| + UpdateIMEState();
|
| }
|
|
|
| void InputMethodWin::OnBlur() {
|
| ConfirmCompositionText();
|
| - if (base::win::IsTSFAwareRequired() && GetTextInputClient())
|
| - ui::TSFBridge::GetInstance()->RemoveFocusedClient(GetTextInputClient());
|
| }
|
|
|
| void InputMethodWin::DispatchKeyEvent(const ui::KeyEvent& key) {
|
| @@ -103,49 +79,22 @@
|
|
|
| void InputMethodWin::OnTextInputTypeChanged(View* view) {
|
| if (IsViewFocused(view)) {
|
| - if (base::win::IsTSFAwareRequired()) {
|
| - if (GetTextInputClient()) {
|
| - ui::TSFBridge::GetInstance()->OnTextInputTypeChanged(
|
| - GetTextInputClient());
|
| - }
|
| - } else {
|
| - ime_input_.CancelIME(hwnd_);
|
| - // Use switch here in case we are going to add more text input types.
|
| - // We disable input method in password field.
|
| - switch (GetTextInputType()) {
|
| - case ui::TEXT_INPUT_TYPE_NONE:
|
| - case ui::TEXT_INPUT_TYPE_PASSWORD:
|
| - ime_input_.DisableIME(hwnd_);
|
| - break;
|
| - default:
|
| - ime_input_.EnableIME(hwnd_);
|
| - break;
|
| - }
|
| - OnCaretBoundsChanged(GetFocusedView());
|
| - }
|
| + ime_input_.CancelIME(hwnd_);
|
| + UpdateIMEState();
|
| }
|
| InputMethodBase::OnTextInputTypeChanged(view);
|
| }
|
|
|
| void InputMethodWin::OnCaretBoundsChanged(View* view) {
|
| - if (base::win::IsTSFAwareRequired()) {
|
| - ui::TSFBridge::GetInstance()->OnTextLayoutChanged();
|
| - } else {
|
| - gfx::Rect rect;
|
| - if (!IsViewFocused(view) || !GetCaretBoundsInWidget(&rect))
|
| - return;
|
| - ime_input_.UpdateCaretRect(hwnd_, rect);
|
| - }
|
| + gfx::Rect rect;
|
| + if (!IsViewFocused(view) || !GetCaretBoundsInWidget(&rect))
|
| + return;
|
| + ime_input_.UpdateCaretRect(hwnd_, rect);
|
| }
|
|
|
| void InputMethodWin::CancelComposition(View* view) {
|
| - if (IsViewFocused(view)) {
|
| - if (base::win::IsTSFAwareRequired()) {
|
| - ui::TSFBridge::GetInstance()->CancelComposition();
|
| - } else {
|
| - ime_input_.CancelIME(hwnd_);
|
| - }
|
| - }
|
| + if (IsViewFocused(view))
|
| + ime_input_.CancelIME(hwnd_);
|
| }
|
|
|
| std::string InputMethodWin::GetInputLocale() {
|
| @@ -207,26 +156,7 @@
|
| }
|
|
|
| void InputMethodWin::OnDidChangeFocus(View* focused_before, View* focused) {
|
| - if (base::win::IsTSFAwareRequired()) {
|
| - if (GetTextInputClient()) {
|
| - ui::TSFBridge::GetInstance()->SetFocusedClient(HWNDForView(focused),
|
| - GetTextInputClient());
|
| - }
|
| - } else {
|
| - // Use switch here in case we are going to add more text input types.
|
| - // We disable input method in password field.
|
| - switch (GetTextInputType()) {
|
| - case ui::TEXT_INPUT_TYPE_NONE:
|
| - case ui::TEXT_INPUT_TYPE_PASSWORD:
|
| - ime_input_.DisableIME(hwnd_);
|
| - break;
|
| - default:
|
| - ime_input_.EnableIME(hwnd_);
|
| - break;
|
| - }
|
| - OnTextInputTypeChanged(GetFocusedView());
|
| - OnCaretBoundsChanged(GetFocusedView());
|
| - }
|
| + UpdateIMEState();
|
| }
|
|
|
| void InputMethodWin::OnInputLangChange(DWORD character_set,
|
| @@ -349,7 +279,7 @@
|
|
|
| // Explicitly show the system menu at a good location on [Alt]+[Space].
|
| // Note: Setting |handled| to FALSE for DefWindowProc triggering of the system
|
| - // menu causes undesirable titlebar artifacts in the classic theme.
|
| + // menu causes unsdesirable titlebar artifacts in the classic theme.
|
| if (message == WM_SYSCHAR && wparam == VK_SPACE)
|
| ui::ShowSystemMenu(hwnd_);
|
|
|
| @@ -434,7 +364,7 @@
|
| memcpy((char*)reconv + sizeof(RECONVERTSTRING),
|
| text.c_str(), len * sizeof(WCHAR));
|
|
|
| - // According to Microsoft API document, IMR_RECONVERTSTRING and
|
| + // According to Microsft API document, IMR_RECONVERTSTRING and
|
| // IMR_DOCUMENTFEED should return reconv, but some applications return
|
| // need_size.
|
| return reinterpret_cast<LRESULT>(reconv);
|
| @@ -517,21 +447,27 @@
|
|
|
| void InputMethodWin::ConfirmCompositionText() {
|
| if (!IsTextInputTypeNone()) {
|
| - if (base::win::IsTSFAwareRequired()) {
|
| - // TSFBridge has not implemented ConfirmComposition yet. So here cancel
|
| - // the composition instead as a workaround.
|
| - // TODO(ime): Implement ConfirmComposition for TSF.
|
| - ui::TSFBridge::GetInstance()->CancelComposition();
|
| - } else {
|
| - ime_input_.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.
|
| - if (GetTextInputClient()->HasCompositionText())
|
| - GetTextInputClient()->ConfirmCompositionText();
|
| - }
|
| + ime_input_.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.
|
| + if (GetTextInputClient()->HasCompositionText())
|
| + GetTextInputClient()->ConfirmCompositionText();
|
| }
|
| }
|
|
|
| +void InputMethodWin::UpdateIMEState() {
|
| + // Use switch here in case we are going to add more text input types.
|
| + // We disable input method in password field.
|
| + switch (GetTextInputType()) {
|
| + case ui::TEXT_INPUT_TYPE_NONE:
|
| + case ui::TEXT_INPUT_TYPE_PASSWORD:
|
| + ime_input_.DisableIME(hwnd_);
|
| + break;
|
| + default:
|
| + ime_input_.EnableIME(hwnd_);
|
| + break;
|
| + }
|
| +}
|
| +
|
| } // namespace views
|
|
|