Commit ec4125c8 authored by W. James MacLean's avatar W. James MacLean Committed by Commit Bot

Use outermost WebContents to get right view type.

Since we can have more than one nested WebContents, we should make
sure to get the outermost WebContents when initializing a popup
window.

Bug: 1002598
Change-Id: I568d31813e46af441760ef22afb9d3e4ae4c65ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1819559
Commit-Queue: James MacLean <wjmaclean@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700811}
parent 350b6c82
...@@ -397,6 +397,8 @@ void RenderWidgetHostViewAura::InitAsPopup( ...@@ -397,6 +397,8 @@ void RenderWidgetHostViewAura::InitAsPopup(
RenderWidgetHostView* parent_host_view, RenderWidgetHostView* parent_host_view,
const gfx::Rect& bounds_in_screen) { const gfx::Rect& bounds_in_screen) {
DCHECK_EQ(widget_type_, WidgetType::kPopup); DCHECK_EQ(widget_type_, WidgetType::kPopup);
DCHECK(!static_cast<RenderWidgetHostViewBase*>(parent_host_view)
->IsRenderWidgetHostViewChildFrame());
popup_parent_host_view_ = popup_parent_host_view_ =
static_cast<RenderWidgetHostViewAura*>(parent_host_view); static_cast<RenderWidgetHostViewAura*>(parent_host_view);
......
...@@ -3105,11 +3105,21 @@ void WebContentsImpl::ShowCreatedWidget(int process_id, ...@@ -3105,11 +3105,21 @@ void WebContentsImpl::ShowCreatedWidget(int process_id,
if (!widget_host_view) if (!widget_host_view)
return; return;
RenderWidgetHostView* view = nullptr; // GetOutermostWebContents() returns |this| if there are no outer WebContents.
if (GetOuterWebContents()) { RenderWidgetHostView* view =
view = GetOuterWebContents()->GetRenderWidgetHostView(); GetOutermostWebContents()->GetRenderWidgetHostView();
} else {
view = GetRenderWidgetHostView(); gfx::Rect transformed_rect(initial_rect);
RenderWidgetHostView* this_view = GetRenderWidgetHostView();
if (this_view != view) {
// We need to transform the coordinates of initial_rect.
gfx::Point origin =
this_view->TransformPointToRootCoordSpace(initial_rect.origin());
gfx::Point bottom_right =
this_view->TransformPointToRootCoordSpace(initial_rect.bottom_right());
transformed_rect =
gfx::Rect(origin.x(), origin.y(), bottom_right.x() - origin.x(),
bottom_right.y() - origin.y());
} }
// Fullscreen child widgets are frames, other child widgets are popups. // Fullscreen child widgets are frames, other child widgets are popups.
...@@ -3131,7 +3141,7 @@ void WebContentsImpl::ShowCreatedWidget(int process_id, ...@@ -3131,7 +3141,7 @@ void WebContentsImpl::ShowCreatedWidget(int process_id,
if (!widget_host_view->HasFocus()) if (!widget_host_view->HasFocus())
widget_host_view->Focus(); widget_host_view->Focus();
} else { } else {
widget_host_view->InitAsPopup(view, initial_rect); widget_host_view->InitAsPopup(view, transformed_rect);
} }
RenderWidgetHostImpl* render_widget_host_impl = widget_host_view->host(); RenderWidgetHostImpl* render_widget_host_impl = widget_host_view->host();
......
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