diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 23:53:25 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 23:53:25 +0000 |
commit | 88b795b46f0236976a6699f7af7dc1da1605b291 (patch) | |
tree | 6775521c0e71e4570a090b3c7b7e68d4f22b42ef | |
parent | e5d8b05f5f57390eab6bea89a35c5dc011df113a (diff) | |
download | chromium_src-88b795b46f0236976a6699f7af7dc1da1605b291.zip chromium_src-88b795b46f0236976a6699f7af7dc1da1605b291.tar.gz chromium_src-88b795b46f0236976a6699f7af7dc1da1605b291.tar.bz2 |
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
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, <select> dropdown // menus, and other times when the renderer initiates creating an object. - virtual void Init(); + void Init(); // Tells the renderer to die and then calls Destroy(). virtual void Shutdown(); @@ -282,6 +282,12 @@ class RenderWidgetHost : public IPC::Channel::Listener { virtual void NotifyRendererUnresponsive() {} virtual void NotifyRendererResponsive() {} + protected: + // 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_; + private: FRIEND_TEST(RenderWidgetHostTest, Resize); FRIEND_TEST(RenderWidgetHostTest, HiddenPaint); diff --git a/chrome/browser/renderer_host/render_widget_host_unittest.cc b/chrome/browser/renderer_host/render_widget_host_unittest.cc index 7ebb8e8..0711e3d 100644 --- a/chrome/browser/renderer_host/render_widget_host_unittest.cc +++ b/chrome/browser/renderer_host/render_widget_host_unittest.cc @@ -161,6 +161,7 @@ class RenderWidgetHostTest : public testing::Test { host_.reset(new MockRenderWidgetHost(process_, 1)); view_.reset(new TestView); host_->set_view(view_.get()); + host_->Init(); } void TearDown() { view_.reset(); diff --git a/chrome/browser/tab_contents/tab_contents_view.h b/chrome/browser/tab_contents/tab_contents_view.h index 2a17dff..7095bf8 100644 --- a/chrome/browser/tab_contents/tab_contents_view.h +++ b/chrome/browser/tab_contents/tab_contents_view.h @@ -124,10 +124,6 @@ class TabContentsView : public RenderViewHostDelegate::View { // invoked, SetInitialFocus is invoked. virtual void RestoreFocus() = 0; - // Sets children's size. May involve packing them in order to get the - // toolkit to send them resize events. - virtual void SetChildSize(RenderWidgetHostView* rwh_view) = 0; - protected: TabContentsView() {} // Abstract interface. diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index 7262d19..6c6bc30 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -101,6 +101,7 @@ RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget( g_signal_connect(view->native_view(), "button-press-event", G_CALLBACK(OnMouseDown), this); gfx::RemoveAllChildren(vbox_.get()); + gtk_box_pack_start(GTK_BOX(vbox_.get()), content_view_, TRUE, TRUE, 0); return view; } @@ -186,12 +187,6 @@ void TabContentsViewGtk::RestoreFocus() { NOTIMPLEMENTED() << " -- need to restore the focus position on this page."; } -void TabContentsViewGtk::SetChildSize(RenderWidgetHostView* rwh_view) { - // Packing the gtk widget in a container will cause a configure-event to be - // sent to the widget. - gtk_box_pack_start(GTK_BOX(vbox_.get()), content_view_, TRUE, TRUE, 0); -} - void TabContentsViewGtk::UpdateDragCursor(bool is_drop_target) { NOTIMPLEMENTED(); } diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.h b/chrome/browser/tab_contents/tab_contents_view_gtk.h index 94c60c4..08c4388 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.h @@ -43,7 +43,6 @@ class TabContentsViewGtk : public TabContentsView { virtual void SetInitialFocus(); virtual void StoreFocus(); virtual void RestoreFocus(); - virtual void SetChildSize(RenderWidgetHostView* rwh_view); // Backend implementation of RenderViewHostDelegate::View. virtual void ShowContextMenu(const ContextMenuParams& params); @@ -56,7 +55,6 @@ class TabContentsViewGtk : public TabContentsView { const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update); - private: // We keep track of the timestamp of the latest mousedown event. static gboolean OnMouseDown(GtkWidget* widget, diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.h b/chrome/browser/tab_contents/tab_contents_view_mac.h index 920fd76..ae40894 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.h +++ b/chrome/browser/tab_contents/tab_contents_view_mac.h @@ -58,7 +58,6 @@ class TabContentsViewMac : public TabContentsView, virtual void SetInitialFocus(); virtual void StoreFocus(); virtual void RestoreFocus(); - virtual void SetChildSize(RenderWidgetHostView* rwh_view); // Backend implementation of RenderViewHostDelegate::View. virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id, diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 291c73c..d7e4398 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -160,10 +160,6 @@ void TabContentsViewMac::RestoreFocus() { // TODO(port) } -void TabContentsViewMac::SetChildSize(RenderWidgetHostView* rwh_view) { - rwh_view->SetSize(GetContainerSize()); -} - void TabContentsViewMac::UpdateDragCursor(bool is_drop_target) { NOTIMPLEMENTED(); } diff --git a/chrome/browser/tab_contents/tab_contents_view_win.cc b/chrome/browser/tab_contents/tab_contents_view_win.cc index 3278c60..f5f3d96 100644 --- a/chrome/browser/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/tab_contents/tab_contents_view_win.cc @@ -310,10 +310,6 @@ void TabContentsViewWin::RestoreFocus() { } } -void TabContentsViewWin::SetChildSize(RenderWidgetHostView* rwh_view) { - rwh_view->SetSize(GetContainerSize()); -} - void TabContentsViewWin::UpdateDragCursor(bool is_drop_target) { drop_target_->set_is_drop_target(is_drop_target); } diff --git a/chrome/browser/tab_contents/tab_contents_view_win.h b/chrome/browser/tab_contents/tab_contents_view_win.h index 227dfa5..8ef2765 100644 --- a/chrome/browser/tab_contents/tab_contents_view_win.h +++ b/chrome/browser/tab_contents/tab_contents_view_win.h @@ -43,7 +43,6 @@ class TabContentsViewWin : public TabContentsView, virtual void SetInitialFocus(); virtual void StoreFocus(); virtual void RestoreFocus(); - virtual void SetChildSize(RenderWidgetHostView* rwh_view); // Backend implementation of RenderViewHostDelegate::View. virtual void ShowContextMenu(const ContextMenuParams& params); diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index 6236f6a..dcd566c 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -1559,7 +1559,7 @@ bool WebContents::CreateRenderViewForRenderManager( return false; // Now that the RenderView has been created, we need to tell it its size. - view_->SetChildSize(rwh_view); + rwh_view->SetSize(view_->GetContainerSize()); UpdateMaxPageIDIfNecessary(render_view_host->site_instance(), render_view_host); |