From 88b795b46f0236976a6699f7af7dc1da1605b291 Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Wed, 22 Apr 2009 23:53:25 +0000 Subject: Don't send resize messages until the renderer has been initialized. [Retry of 14260 with fixed unit test.] 1) Moves renderer_initialized_ from RenderWidgetView into RenderWidgetHost (its parent). Should be identical semantics to before. 2) Test renderer_initialized_ in RWH::WasResized(). This also reverts r13725, which was another attempt at fixing this problem. BUG=9830,10659 TEST=From the Linux start page, click a link then click back -- should not get a gray page. From Google reader, click a link (which spawns a new tab within the same process) -- should not get a gray page. Review URL: http://codereview.chromium.org/93038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14273 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/renderer_host/render_view_host.cc | 12 +----------- chrome/browser/renderer_host/render_view_host.h | 6 ------ chrome/browser/renderer_host/render_widget_host.cc | 13 +++++++++++-- chrome/browser/renderer_host/render_widget_host.h | 8 +++++++- chrome/browser/renderer_host/render_widget_host_unittest.cc | 1 + chrome/browser/tab_contents/tab_contents_view.h | 4 ---- chrome/browser/tab_contents/tab_contents_view_gtk.cc | 7 +------ chrome/browser/tab_contents/tab_contents_view_gtk.h | 2 -- chrome/browser/tab_contents/tab_contents_view_mac.h | 1 - chrome/browser/tab_contents/tab_contents_view_mac.mm | 4 ---- chrome/browser/tab_contents/tab_contents_view_win.cc | 4 ---- chrome/browser/tab_contents/tab_contents_view_win.h | 1 - chrome/browser/tab_contents/web_contents.cc | 2 +- 13 files changed, 22 insertions(+), 43 deletions(-) diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index aa1b78c..76b8d5a 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -92,7 +92,6 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, : RenderWidgetHost(instance->GetProcess(), routing_id), instance_(instance), delegate_(delegate), - renderer_initialized_(false), waiting_for_drag_context_response_(false), debugger_attached_(false), enabled_bindings_(0), @@ -200,11 +199,6 @@ bool RenderViewHost::IsRenderViewLive() const { return process()->channel() && renderer_initialized_; } -void RenderViewHost::Init() { - RenderWidgetHost::Init(); - renderer_initialized_ = true; -} - void RenderViewHost::NavigateToEntry(const NavigationEntry& entry, bool is_reload) { ViewMsg_Navigate_Params params; @@ -866,13 +860,9 @@ void RenderViewHost::OnMsgRenderViewReady() { } void RenderViewHost::OnMsgRenderViewGone() { - // Our base class RenderWidgetHouse needs to reset some stuff. + // Our base class RenderWidgetHost needs to reset some stuff. RendererExited(); - // Clearing this flag causes us to re-create the renderer when recovering - // from a crashed renderer. - renderer_initialized_ = false; - delegate_->RenderViewGone(this); OnDebugDisconnect(); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index e6e7ad11..976a434 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -424,7 +424,6 @@ class RenderViewHost : public RenderWidgetHost { void WindowMoveOrResizeStarted(); // RenderWidgetHost public overrides. - virtual void Init(); virtual void Shutdown(); virtual bool IsRenderView() { return true; } virtual void OnMessageReceived(const IPC::Message& msg); @@ -592,11 +591,6 @@ class RenderViewHost : public RenderWidgetHost { HostPersonalization personalization_; #endif - // true if a renderer has once been valid. We use this flag to display a sad - // tab only when we lose our renderer and not if a paint occurs during - // initialization. - bool renderer_initialized_; - // true if we are currently waiting for a response for drag context // information. bool waiting_for_drag_context_response_; diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index dd14812..64fb609 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -47,7 +47,8 @@ static const int kHungRendererDelayMs = 20000; RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, int routing_id) - : view_(NULL), + : renderer_initialized_(false), + view_(NULL), process_(process), routing_id_(routing_id), is_loading_(false), @@ -81,6 +82,8 @@ RenderWidgetHost::~RenderWidgetHost() { void RenderWidgetHost::Init() { DCHECK(process_->channel()); + renderer_initialized_ = true; + // Send the ack along with the information on placement. gfx::NativeView plugin_view = view_->GetPluginNativeView(); Send(new ViewMsg_CreatingNew_ACK(routing_id_, @@ -159,8 +162,10 @@ void RenderWidgetHost::WasRestored() { } void RenderWidgetHost::WasResized() { - if (resize_ack_pending_ || !process_->channel() || !view_) + if (resize_ack_pending_ || !process_->channel() || !view_ || + !renderer_initialized_) { return; + } gfx::Rect view_bounds = view_->GetViewBounds(); gfx::Size new_size(view_bounds.width(), view_bounds.height()); @@ -347,6 +352,10 @@ void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, } void RenderWidgetHost::RendererExited() { + // Clearing this flag causes us to re-create the renderer when recovering + // from a crashed renderer. + renderer_initialized_ = false; + // Must reset these to ensure that mouse move events work with a new renderer. mouse_move_pending_ = false; next_mouse_move_.reset(); diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index b6fd4d0..ad81ad8 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -142,7 +142,7 @@ class RenderWidgetHost : public IPC::Channel::Listener { // Called when a renderer object already been created for this host, and we // just need to be attached to it. Used for window.open,