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

Side by Side Diff: content/browser/web_contents/web_contents_view_guest.cc

Issue 490293003: Fix <webview> context menu positioning on mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« 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 "content/browser/web_contents/web_contents_view_guest.h" 5 #include "content/browser/web_contents/web_contents_view_guest.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 8 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" 9 #include "content/browser/browser_plugin/browser_plugin_guest.h"
10 #include "content/browser/frame_host/interstitial_page_impl.h" 10 #include "content/browser/frame_host/interstitial_page_impl.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // not have the native view associated with this WebContentsViewGuest in the 66 // not have the native view associated with this WebContentsViewGuest in the
67 // view hierarchy. We add this view as embedder's child here. 67 // view hierarchy. We add this view as embedder's child here.
68 // This would go in WebContentsViewGuest::CreateView, but that is too early to 68 // This would go in WebContentsViewGuest::CreateView, but that is too early to
69 // access embedder_web_contents(). Therefore, we do it here. 69 // access embedder_web_contents(). Therefore, we do it here.
70 parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView()); 70 parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView());
71 #endif // defined(USE_AURA) 71 #endif // defined(USE_AURA)
72 } 72 }
73 73
74 ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams( 74 ContextMenuParams WebContentsViewGuest::ConvertContextMenuParams(
75 const ContextMenuParams& params) const { 75 const ContextMenuParams& params) const {
76 #if defined(USE_AURA) 76 // We need to add |offset| of the guest from the embedder to position the
77 // Context menu uses ScreenPositionClient::ConvertPointToScreen() in aura 77 // menu properly.
78 // to calculate popup position. Guest's native view
79 // (platform_view_->GetNativeView()) is part of the embedder's view hierarchy,
80 // but is placed at (0, 0) w.r.t. the embedder's position. Therefore, |offset|
81 // is added to |params|.
82 gfx::Rect embedder_bounds; 78 gfx::Rect embedder_bounds;
83 guest_->embedder_web_contents()->GetView()->GetContainerBounds( 79 guest_->embedder_web_contents()->GetView()->GetContainerBounds(
84 &embedder_bounds); 80 &embedder_bounds);
85 gfx::Rect guest_bounds; 81 gfx::Rect guest_bounds;
86 GetContainerBounds(&guest_bounds); 82 GetContainerBounds(&guest_bounds);
87 83
88 gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin(); 84 gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin();
89 ContextMenuParams params_in_embedder = params; 85 ContextMenuParams params_in_embedder = params;
90 params_in_embedder.x += offset.x(); 86 params_in_embedder.x += offset.x();
91 params_in_embedder.y += offset.y(); 87 params_in_embedder.y += offset.y();
92 return params_in_embedder; 88 return params_in_embedder;
93 #else
94 return params;
95 #endif
96 } 89 }
97 90
98 void WebContentsViewGuest::GetContainerBounds(gfx::Rect* out) const { 91 void WebContentsViewGuest::GetContainerBounds(gfx::Rect* out) const {
99 // We need embedder container's bounds to calculate our bounds. 92 // We need embedder container's bounds to calculate our bounds.
100 guest_->embedder_web_contents()->GetView()->GetContainerBounds(out); 93 guest_->embedder_web_contents()->GetView()->GetContainerBounds(out);
101 gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point()); 94 gfx::Point guest_coordinates = guest_->GetScreenCoordinates(gfx::Point());
102 out->Offset(guest_coordinates.x(), guest_coordinates.y()); 95 out->Offset(guest_coordinates.x(), guest_coordinates.y());
103 out->set_size(size_); 96 out->set_size(size_);
104 } 97 }
105 98
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 embedder_render_view_host->GetDelegate()->GetDelegateView(); 240 embedder_render_view_host->GetDelegate()->GetDelegateView();
248 if (view) { 241 if (view) {
249 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag")); 242 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.StartDrag"));
250 view->StartDragging(drop_data, ops, image, image_offset, event_info); 243 view->StartDragging(drop_data, ops, image, image_offset, event_info);
251 } else { 244 } else {
252 embedder_web_contents->SystemDragEnded(); 245 embedder_web_contents->SystemDragEnded();
253 } 246 }
254 } 247 }
255 248
256 } // namespace content 249 } // namespace content
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