From 2533ce1803f3324e69134e93f59acbb44afb1aa2 Mon Sep 17 00:00:00 2001 From: "mbelshe@google.com" Date: Sat, 9 May 2009 00:02:24 +0000 Subject: Defer window.close(), resizeTo() and moveTo() actions by posting a task back to the message loop before notifying the RenderWidgetHost to perform these operations. Otherwise the JS code races with the browser to use the modified window. BUG=http://crbug.com/6377 BUG=http://crbug.com/6192 Cache a pending_window_rect on the render_view (moved from prior CL where I had it on the chrome_client_impl). This is a short lived cache, and not a complete solution. It fixes this case, where a JS script makes multiple operations and expects the GetWindowSize() to be correct immedately after having called SetWindowSize(). BUG=http://crbug.com/835 Review URL: http://codereview.chromium.org/115030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15698 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/renderer_host/render_view_host.cc | 6 +++++- chrome/browser/renderer_host/render_widget_host.cc | 4 +++- chrome/browser/renderer_host/resource_message_filter.cc | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 843a110..395167c 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -849,14 +849,17 @@ void RenderViewHost::OnMsgShowView(int route_id, if (view) { view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture, creator_url); + Send(new ViewMsg_Move_ACK(route_id)); } } void RenderViewHost::OnMsgShowWidget(int route_id, const gfx::Rect& initial_pos) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); - if (view) + if (view) { view->ShowCreatedWidget(route_id, initial_pos); + Send(new ViewMsg_Move_ACK(route_id)); + } } void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { @@ -967,6 +970,7 @@ void RenderViewHost::OnMsgClose() { void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { delegate_->RequestMove(pos); + Send(new ViewMsg_Move_ACK(routing_id())); } void RenderViewHost::OnMsgDidRedirectProvisionalLoad(int32 page_id, diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 7519e3d..62e09d7 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -461,8 +461,10 @@ void RenderWidgetHost::OnMsgClose() { void RenderWidgetHost::OnMsgRequestMove(const gfx::Rect& pos) { // Note that we ignore the position. - if (view_) + if (view_) { view_->SetSize(pos.size()); + Send(new ViewMsg_Move_ACK(routing_id_)); + } } void RenderWidgetHost::OnMsgPaintRect( diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 6a51ee7..5f3051c 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -225,9 +225,9 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { // we cannot make X calls from the IO thread. On other platforms, we can // handle these calls directly. IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetScreenInfo, - OnGetScreenInfo); + OnGetScreenInfo) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetWindowRect, - OnGetWindowRect); + OnGetWindowRect) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRootWindowRect, OnGetRootWindowRect) -- cgit v1.1