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 "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void RenderWidgetHostViewViews::InitAsPopup( | 115 void RenderWidgetHostViewViews::InitAsPopup( |
116 RenderWidgetHostView* parent_host_view, | 116 RenderWidgetHostView* parent_host_view, |
117 const gfx::Rect& pos) { | 117 const gfx::Rect& pos) { |
118 RenderWidgetHostViewViews* parent = | 118 RenderWidgetHostViewViews* parent = |
119 static_cast<RenderWidgetHostViewViews*>(parent_host_view); | 119 static_cast<RenderWidgetHostViewViews*>(parent_host_view); |
120 parent->AddChildView(this); | 120 parent->AddChildView(this); |
121 // If the parent loses focus then the popup will close. So we need | 121 // If the parent loses focus then the popup will close. So we need |
122 // to tell the parent it's showing a popup so that it doesn't respond to | 122 // to tell the parent it's showing a popup so that it doesn't respond to |
123 // blurs. | 123 // blurs. |
124 parent->is_showing_context_menu_ = true; | 124 parent->is_showing_context_menu_ = true; |
125 views::View::SetBoundsRect(pos); | 125 |
| 126 // pos is in screen coordinates but a view is positioned relative |
| 127 // to its parent. Here we convert screen coordinates to relative |
| 128 // coordinates. |
| 129 gfx::Point p(pos.x() - parent_host_view->GetViewBounds().x(), |
| 130 pos.y() - parent_host_view->GetViewBounds().y()); |
| 131 views::View::SetBounds(p.x(), p.y(), pos.width(), pos.height()); |
126 Show(); | 132 Show(); |
127 | 133 |
128 if (NeedsInputGrab()) { | 134 if (NeedsInputGrab()) { |
129 set_focusable(true); | 135 set_focusable(true); |
130 RequestFocus(); | 136 RequestFocus(); |
131 } | 137 } |
132 } | 138 } |
133 | 139 |
134 void RenderWidgetHostViewViews::InitAsFullscreen( | 140 void RenderWidgetHostViewViews::InitAsFullscreen( |
135 RenderWidgetHostView* /*reference_host_view*/) { | 141 RenderWidgetHostView* /*reference_host_view*/) { |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 | 809 |
804 void RenderWidgetHostViewViews::FinishImeCompositionSession() { | 810 void RenderWidgetHostViewViews::FinishImeCompositionSession() { |
805 if (!has_composition_text_) | 811 if (!has_composition_text_) |
806 return; | 812 return; |
807 if (host_) | 813 if (host_) |
808 host_->ImeConfirmComposition(); | 814 host_->ImeConfirmComposition(); |
809 DCHECK(GetInputMethod()); | 815 DCHECK(GetInputMethod()); |
810 GetInputMethod()->CancelComposition(this); | 816 GetInputMethod()->CancelComposition(this); |
811 has_composition_text_ = false; | 817 has_composition_text_ = false; |
812 } | 818 } |
OLD | NEW |