| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "ui/base/ime/input_method_imm32.h" | 5 #include "ui/base/ime/input_method_imm32.h" | 
| 6 | 6 | 
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" | 
| 8 #include "ui/base/ime/composition_text.h" | 8 #include "ui/base/ime/composition_text.h" | 
| 9 #include "ui/base/ime/text_input_client.h" | 9 #include "ui/base/ime/text_input_client.h" | 
| 10 #include "ui/base/ime/win/tsf_input_scope.h" | 10 #include "ui/base/ime/win/tsf_input_scope.h" | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 87 | 87 | 
| 88 void InputMethodIMM32::OnTextInputTypeChanged(const TextInputClient* client) { | 88 void InputMethodIMM32::OnTextInputTypeChanged(const TextInputClient* client) { | 
| 89   if (IsTextInputClientFocused(client) && IsWindowFocused(client)) { | 89   if (IsTextInputClientFocused(client) && IsWindowFocused(client)) { | 
| 90     imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); | 90     imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); | 
| 91     UpdateIMEState(); | 91     UpdateIMEState(); | 
| 92   } | 92   } | 
| 93   InputMethodWin::OnTextInputTypeChanged(client); | 93   InputMethodWin::OnTextInputTypeChanged(client); | 
| 94 } | 94 } | 
| 95 | 95 | 
| 96 void InputMethodIMM32::OnCaretBoundsChanged(const TextInputClient* client) { | 96 void InputMethodIMM32::OnCaretBoundsChanged(const TextInputClient* client) { | 
| 97   if (enabled_ && IsTextInputClientFocused(client) && IsWindowFocused(client)) { | 97   if (!enabled_ || !IsTextInputClientFocused(client) || | 
| 98     // The current text input type should not be NONE if |client| is focused. | 98       !IsWindowFocused(client)) { | 
| 99     DCHECK(!IsTextInputTypeNone()); | 99     return; | 
| 100     gfx::Rect screen_bounds(GetTextInputClient()->GetCaretBounds()); | 100   } | 
|  | 101   // The current text input type should not be NONE if |client| is focused. | 
|  | 102   DCHECK(!IsTextInputTypeNone()); | 
|  | 103   gfx::Rect screen_bounds(GetTextInputClient()->GetCaretBounds()); | 
| 101 | 104 | 
| 102     HWND attached_window = GetAttachedWindowHandle(client); | 105   HWND attached_window = GetAttachedWindowHandle(client); | 
| 103     // TODO(ime): see comment in TextInputClient::GetCaretBounds(), this | 106   // TODO(ime): see comment in TextInputClient::GetCaretBounds(), this | 
| 104     // conversion shouldn't be necessary. | 107   // conversion shouldn't be necessary. | 
| 105     RECT r = {}; | 108   RECT r = {}; | 
| 106     GetClientRect(attached_window, &r); | 109   GetClientRect(attached_window, &r); | 
| 107     POINT window_point = { screen_bounds.x(), screen_bounds.y() }; | 110   POINT window_point = { screen_bounds.x(), screen_bounds.y() }; | 
| 108     ScreenToClient(attached_window, &window_point); | 111   ScreenToClient(attached_window, &window_point); | 
| 109     gfx::Rect caret_rect(gfx::Point(window_point.x, window_point.y), | 112   gfx::Rect caret_rect(gfx::Point(window_point.x, window_point.y), | 
| 110                          screen_bounds.size()); | 113                        screen_bounds.size()); | 
| 111     imm32_manager_.UpdateCaretRect(attached_window, caret_rect); | 114   imm32_manager_.UpdateCaretRect(attached_window, caret_rect); | 
| 112   } |  | 
| 113   InputMethodWin::OnCaretBoundsChanged(client); |  | 
| 114 } | 115 } | 
| 115 | 116 | 
| 116 void InputMethodIMM32::CancelComposition(const TextInputClient* client) { | 117 void InputMethodIMM32::CancelComposition(const TextInputClient* client) { | 
| 117   if (enabled_ && IsTextInputClientFocused(client)) | 118   if (enabled_ && IsTextInputClientFocused(client)) | 
| 118     imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); | 119     imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); | 
| 119 } | 120 } | 
| 120 | 121 | 
| 121 bool InputMethodIMM32::IsCandidatePopupOpen() const { | 122 bool InputMethodIMM32::IsCandidatePopupOpen() const { | 
| 122   return is_candidate_popup_open_; | 123   return is_candidate_popup_open_; | 
| 123 } | 124 } | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 277       enabled_ = true; | 278       enabled_ = true; | 
| 278       break; | 279       break; | 
| 279   } | 280   } | 
| 280 | 281 | 
| 281   imm32_manager_.SetTextInputMode(window_handle, text_input_mode); | 282   imm32_manager_.SetTextInputMode(window_handle, text_input_mode); | 
| 282   tsf_inputscope::SetInputScopeForTsfUnawareWindow( | 283   tsf_inputscope::SetInputScopeForTsfUnawareWindow( | 
| 283       window_handle, text_input_type, text_input_mode); | 284       window_handle, text_input_type, text_input_mode); | 
| 284 } | 285 } | 
| 285 | 286 | 
| 286 }  // namespace ui | 287 }  // namespace ui | 
| OLD | NEW | 
|---|