Commit ade83471 authored by miu@chromium.org's avatar miu@chromium.org

Fix Flash fullscreen context menu target and position.

This resolves two problems regarding the right-click context menu for Flash fullscreen widgets.  First, the WebContentsViewDelegate implementations (for Views and Cocoa) were assuming the event target for the context menu click is always the widget provided by WebContentsView.  Flash fullscreen is actually a separate widget.  Second, the renderer was trying to be "too smart" by computing the screen coordinates of the context menu itself.  This is fixed by removing the offset calculation, which allows the coordinates to be cleanly translated by the windowing toolkit, browser-side.

BUG=348965
TEST=Repro steps in bug 348965 result in expected behavior.

Review URL: https://codereview.chromium.org/183973027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255321 0039d316-1c4b-4281-b951-d872f2087c98
parent 1286c0b0
...@@ -15,6 +15,7 @@ class RenderViewContextMenuMac; ...@@ -15,6 +15,7 @@ class RenderViewContextMenuMac;
class WebDragBookmarkHandlerMac; class WebDragBookmarkHandlerMac;
namespace content { namespace content {
class RenderWidgetHostView;
class WebContents; class WebContents;
} }
...@@ -36,6 +37,8 @@ class ChromeWebContentsViewDelegateMac ...@@ -36,6 +37,8 @@ class ChromeWebContentsViewDelegateMac
const content::ContextMenuParams& params) OVERRIDE; const content::ContextMenuParams& params) OVERRIDE;
private: private:
content::RenderWidgetHostView* GetActiveRenderWidgetHostView();
// The context menu. Callbacks are asynchronous so we need to keep it around. // The context menu. Callbacks are asynchronous so we need to keep it around.
scoped_ptr<RenderViewContextMenuMac> context_menu_; scoped_ptr<RenderViewContextMenuMac> context_menu_;
......
...@@ -43,18 +43,22 @@ void ChromeWebContentsViewDelegateMac::ShowContextMenu( ...@@ -43,18 +43,22 @@ void ChromeWebContentsViewDelegateMac::ShowContextMenu(
// the second mouse event arrives. In this case, |ShowContextMenu()| will // the second mouse event arrives. In this case, |ShowContextMenu()| will
// get called multiple times - if so, don't create another context menu. // get called multiple times - if so, don't create another context menu.
// TODO(asvitkine): Fix the renderer so that it doesn't do this. // TODO(asvitkine): Fix the renderer so that it doesn't do this.
content::RenderWidgetHostView* widget_view = content::RenderWidgetHostView* widget_view = GetActiveRenderWidgetHostView();
web_contents_->GetRenderWidgetHostView();
if (widget_view && widget_view->IsShowingContextMenu()) if (widget_view && widget_view->IsShowingContextMenu())
return; return;
context_menu_.reset(new RenderViewContextMenuMac( context_menu_.reset(new RenderViewContextMenuMac(
render_frame_host, render_frame_host, params, widget_view->GetNativeView()));
params,
web_contents_->GetView()->GetContentNativeView()));
context_menu_->Init(); context_menu_->Init();
} }
content::RenderWidgetHostView*
ChromeWebContentsViewDelegateMac::GetActiveRenderWidgetHostView() {
return web_contents_->GetFullscreenRenderWidgetHostView() ?
web_contents_->GetFullscreenRenderWidgetHostView() :
web_contents_->GetRenderWidgetHostView();
}
namespace chrome { namespace chrome {
content::WebContentsViewDelegate* CreateWebContentsViewDelegate( content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
......
...@@ -137,14 +137,13 @@ void ChromeWebContentsViewDelegateViews::ShowContextMenu( ...@@ -137,14 +137,13 @@ void ChromeWebContentsViewDelegateViews::ShowContextMenu(
gfx::Point screen_point(params.x, params.y); gfx::Point screen_point(params.x, params.y);
// Convert from content coordinates to window coordinates. // Convert from target window coordinates to root window coordinates.
aura::Window* web_contents_window = aura::Window* target_window = GetActiveNativeView();
web_contents_->GetView()->GetNativeView(); aura::Window* root_window = target_window->GetRootWindow();
aura::Window* root_window = web_contents_window->GetRootWindow();
aura::client::ScreenPositionClient* screen_position_client = aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window); aura::client::GetScreenPositionClient(root_window);
if (screen_position_client) { if (screen_position_client) {
screen_position_client->ConvertPointToScreen(web_contents_window, screen_position_client->ConvertPointToScreen(target_window,
&screen_point); &screen_point);
} }
// Enable recursive tasks on the message loop so we can get updates while // Enable recursive tasks on the message loop so we can get updates while
...@@ -163,9 +162,14 @@ void ChromeWebContentsViewDelegateViews::SizeChanged(const gfx::Size& size) { ...@@ -163,9 +162,14 @@ void ChromeWebContentsViewDelegateViews::SizeChanged(const gfx::Size& size) {
sad_tab->GetWidget()->SetBounds(gfx::Rect(size)); sad_tab->GetWidget()->SetBounds(gfx::Rect(size));
} }
aura::Window* ChromeWebContentsViewDelegateViews::GetActiveNativeView() {
return web_contents_->GetFullscreenRenderWidgetHostView() ?
web_contents_->GetFullscreenRenderWidgetHostView()->GetNativeView() :
web_contents_->GetView()->GetNativeView();
}
views::Widget* ChromeWebContentsViewDelegateViews::GetTopLevelWidget() { views::Widget* ChromeWebContentsViewDelegateViews::GetTopLevelWidget() {
return views::Widget::GetTopLevelWidgetForNativeView( return views::Widget::GetTopLevelWidgetForNativeView(GetActiveNativeView());
web_contents_->GetView()->GetNativeView());
} }
views::FocusManager* views::FocusManager*
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
class RenderViewContextMenuViews; class RenderViewContextMenuViews;
namespace aura {
class Window;
}
namespace content { namespace content {
class WebContents; class WebContents;
class WebDragDestDelegate; class WebDragDestDelegate;
...@@ -43,6 +47,7 @@ class ChromeWebContentsViewDelegateViews ...@@ -43,6 +47,7 @@ class ChromeWebContentsViewDelegateViews
virtual void SizeChanged(const gfx::Size& size) OVERRIDE; virtual void SizeChanged(const gfx::Size& size) OVERRIDE;
private: private:
aura::Window* GetActiveNativeView();
views::Widget* GetTopLevelWidget(); views::Widget* GetTopLevelWidget();
views::FocusManager* GetFocusManager(); views::FocusManager* GetFocusManager();
void SetInitialFocus(); void SetInitialFocus();
......
...@@ -203,18 +203,10 @@ gfx::Point RendererPpapiHostImpl::PluginPointToRenderFrame( ...@@ -203,18 +203,10 @@ gfx::Point RendererPpapiHostImpl::PluginPointToRenderFrame(
PP_Instance instance, PP_Instance instance,
const gfx::Point& pt) const { const gfx::Point& pt) const {
PepperPluginInstanceImpl* plugin_instance = GetAndValidateInstance(instance); PepperPluginInstanceImpl* plugin_instance = GetAndValidateInstance(instance);
if (!plugin_instance) if (!plugin_instance || plugin_instance->flash_fullscreen()) {
// Flash fullscreen is special in that it renders into its own separate,
// dedicated window. So, do not offset the point.
return pt; return pt;
RenderFrameImpl* render_frame = static_cast<RenderFrameImpl*>(
GetRenderFrameForInstance(instance));
if (plugin_instance->view_data().is_fullscreen ||
plugin_instance->flash_fullscreen()) {
blink::WebRect window_rect = render_frame->GetRenderWidget()->windowRect();
blink::WebRect screen_rect =
render_frame->GetRenderWidget()->screenInfo().rect;
return gfx::Point(pt.x() - window_rect.x + screen_rect.x,
pt.y() - window_rect.y + screen_rect.y);
} }
return gfx::Point(pt.x() + plugin_instance->view_data().rect.point.x, return gfx::Point(pt.x() + plugin_instance->view_data().rect.point.x,
pt.y() + plugin_instance->view_data().rect.point.y); pt.y() + plugin_instance->view_data().rect.point.y);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment