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" | 5 #include "ui/views/ime/input_method_base.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/events/event.h" | 8 #include "ui/base/events/event.h" |
9 #include "ui/base/ime/text_input_client.h" | 9 #include "ui/base/ime/text_input_client.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (delegate_) | 79 if (delegate_) |
80 delegate_->DispatchKeyEventPostIME(key); | 80 delegate_->DispatchKeyEventPostIME(key); |
81 } | 81 } |
82 | 82 |
83 bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { | 83 bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { |
84 DCHECK(rect); | 84 DCHECK(rect); |
85 ui::TextInputClient* client = GetTextInputClient(); | 85 ui::TextInputClient* client = GetTextInputClient(); |
86 if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) | 86 if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) |
87 return false; | 87 return false; |
88 | 88 |
89 *rect = GetFocusedView()->ConvertRectToWidget(client->GetCaretBounds()); | 89 gfx::Rect caret_bounds = client->GetCaretBounds(); |
| 90 gfx::Point caret_origin = caret_bounds.origin(); |
| 91 View::ConvertPointFromScreen(GetFocusedView(), &caret_origin); |
| 92 caret_bounds.set_origin(caret_origin); |
| 93 *rect = GetFocusedView()->ConvertRectToWidget(caret_bounds); |
90 | 94 |
91 // Convert coordinates if the focused view is inside a child Widget. | 95 // Convert coordinates if the focused view is inside a child Widget. |
92 if (GetFocusedView()->GetWidget() != widget_) | 96 if (GetFocusedView()->GetWidget() != widget_) |
93 return Widget::ConvertRect(GetFocusedView()->GetWidget(), widget_, rect); | 97 return Widget::ConvertRect(GetFocusedView()->GetWidget(), widget_, rect); |
94 return true; | 98 return true; |
95 } | 99 } |
96 | 100 |
97 } // namespace views | 101 } // namespace views |
OLD | NEW |