Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: ui/views/ime/input_method_base.cc

Issue 14731011: Return caret bounds in local coordinates from GetCaretBoundsInWidget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698