OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/ime/input_method_base.h" | 5 #include "views/ime/input_method_base.h" |
6 #include "views/view.h" | 6 #include "views/view.h" |
7 #include "views/widget/widget.h" | 7 #include "views/widget/widget.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 delegate_->DispatchKeyEventPostIME(key); | 89 delegate_->DispatchKeyEventPostIME(key); |
90 } | 90 } |
91 | 91 |
92 bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { | 92 bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { |
93 DCHECK(rect); | 93 DCHECK(rect); |
94 TextInputClient* client = GetTextInputClient(); | 94 TextInputClient* client = GetTextInputClient(); |
95 if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) | 95 if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) |
96 return false; | 96 return false; |
97 | 97 |
98 *rect = client->GetCaretBounds(); | 98 *rect = client->GetCaretBounds(); |
99 gfx::Point origin = rect->origin(); | 99 View::ConvertRectToWidget(focused_view_, rect); |
100 gfx::Point end = gfx::Point(rect->right(), rect->bottom()); | |
101 | |
102 View::ConvertPointToWidget(focused_view_, &origin); | |
103 View::ConvertPointToWidget(focused_view_, &end); | |
104 rect->SetRect(origin.x(), origin.y(), | |
105 end.x() - origin.x(), end.y() - origin.y()); | |
106 | 100 |
107 // We need to do coordinate conversion if the focused view is inside a child | 101 // We need to do coordinate conversion if the focused view is inside a child |
108 // Widget. | 102 // Widget. |
109 if (focused_view_->GetWidget() != widget_) | 103 if (focused_view_->GetWidget() != widget_) |
110 return Widget::ConvertRect(focused_view_->GetWidget(), widget_, rect); | 104 return Widget::ConvertRect(focused_view_->GetWidget(), widget_, rect); |
111 return true; | 105 return true; |
112 } | 106 } |
113 | 107 |
114 void InputMethodBase::FocusedViewWillChange() { | 108 void InputMethodBase::FocusedViewWillChange() { |
115 } | 109 } |
116 | 110 |
117 void InputMethodBase::FocusedViewDidChange() { | 111 void InputMethodBase::FocusedViewDidChange() { |
118 } | 112 } |
119 | 113 |
120 } // namespace views | 114 } // namespace views |
OLD | NEW |