| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/ime/input_method_base.h" |
| 6 |
| 7 #include "ui/base/event.h" |
| 5 #include "ui/base/ime/text_input_client.h" | 8 #include "ui/base/ime/text_input_client.h" |
| 6 #include "ui/views/ime/input_method_base.h" | |
| 7 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
| 8 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| 9 | 11 |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 | 13 |
| 12 namespace views { | 14 namespace views { |
| 13 | 15 |
| 14 InputMethodBase::InputMethodBase() | 16 InputMethodBase::InputMethodBase() |
| 15 : delegate_(NULL), | 17 : delegate_(NULL), |
| 16 widget_(NULL), | 18 widget_(NULL), |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 bool InputMethodBase::IsTextInputTypeNone() const { | 91 bool InputMethodBase::IsTextInputTypeNone() const { |
| 90 return GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE; | 92 return GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE; |
| 91 } | 93 } |
| 92 | 94 |
| 93 void InputMethodBase::OnInputMethodChanged() const { | 95 void InputMethodBase::OnInputMethodChanged() const { |
| 94 ui::TextInputClient* client = GetTextInputClient(); | 96 ui::TextInputClient* client = GetTextInputClient(); |
| 95 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) | 97 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) |
| 96 client->OnInputMethodChanged(); | 98 client->OnInputMethodChanged(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void InputMethodBase::DispatchKeyEventPostIME(const KeyEvent& key) const { | 101 void InputMethodBase::DispatchKeyEventPostIME(const ui::KeyEvent& key) const { |
| 100 if (delegate_) | 102 if (delegate_) |
| 101 delegate_->DispatchKeyEventPostIME(key); | 103 delegate_->DispatchKeyEventPostIME(key); |
| 102 } | 104 } |
| 103 | 105 |
| 104 bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { | 106 bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { |
| 105 DCHECK(rect); | 107 DCHECK(rect); |
| 106 ui::TextInputClient* client = GetTextInputClient(); | 108 ui::TextInputClient* client = GetTextInputClient(); |
| 107 if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) | 109 if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) |
| 108 return false; | 110 return false; |
| 109 | 111 |
| 110 *rect = GetFocusedView()->ConvertRectToWidget(client->GetCaretBounds()); | 112 *rect = GetFocusedView()->ConvertRectToWidget(client->GetCaretBounds()); |
| 111 | 113 |
| 112 // We need to do coordinate conversion if the focused view is inside a child | 114 // We need to do coordinate conversion if the focused view is inside a child |
| 113 // Widget. | 115 // Widget. |
| 114 if (GetFocusedView()->GetWidget() != widget_) | 116 if (GetFocusedView()->GetWidget() != widget_) |
| 115 return Widget::ConvertRect(GetFocusedView()->GetWidget(), widget_, rect); | 117 return Widget::ConvertRect(GetFocusedView()->GetWidget(), widget_, rect); |
| 116 return true; | 118 return true; |
| 117 } | 119 } |
| 118 | 120 |
| 119 } // namespace views | 121 } // namespace views |
| OLD | NEW |