From 34ac70504d7090a9689c78fbcadd1a1224fc9cdd Mon Sep 17 00:00:00 2001 From: "tony@chromium.org" Date: Fri, 25 Sep 2009 17:07:23 +0000 Subject: Allow the initial size of TabContentViews to be based on the size of another TabContents by having an optional TabContents* passed into the TabContents ctor. This fixes a race condition where it's possible for a web page to load before getting the sizing information from the browser. The new flow passes the size information to the renderer process before passing the URL to load. BUG=20159 Review URL: http://codereview.chromium.org/201130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27199 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/dom_view.cc | 2 +- chrome/browser/views/tab_contents/tab_contents_view_gtk.cc | 5 +++-- chrome/browser/views/tab_contents/tab_contents_view_gtk.h | 2 +- chrome/browser/views/tab_contents/tab_contents_view_win.cc | 2 +- chrome/browser/views/tab_contents/tab_contents_view_win.h | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'chrome/browser/views') diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc index 322281e..c8cebf7 100644 --- a/chrome/browser/views/dom_view.cc +++ b/chrome/browser/views/dom_view.cc @@ -22,7 +22,7 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) { initialized_ = true; tab_contents_.reset(new TabContents(profile, instance, - MSG_ROUTING_NONE, NULL)); + MSG_ROUTING_NONE, NULL, NULL)); views::NativeViewHost::Attach(tab_contents_->GetNativeView()); return true; } diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc index e39bfde..6a4f76c 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc @@ -117,9 +117,10 @@ TabContentsViewGtk::~TabContentsViewGtk() { CloseNow(); } -void TabContentsViewGtk::CreateView() { +void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) { set_delete_on_destroy(false); - WidgetGtk::Init(NULL, gfx::Rect()); + WidgetGtk::Init(NULL, gfx::Rect(0, 0, initial_size.width(), + initial_size.height())); } RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget( diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h index 8788468..1b03885 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h @@ -31,7 +31,7 @@ class TabContentsViewGtk : public TabContentsView, // TabContentsView implementation -------------------------------------------- - virtual void CreateView(); + virtual void CreateView(const gfx::Size& initial_size); virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host); virtual gfx::NativeView GetNativeView() const; diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc index 9d22dbf..22a1552 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc @@ -86,7 +86,7 @@ void TabContentsViewWin::Unparent() { ::SetParent(GetNativeView(), NULL); } -void TabContentsViewWin::CreateView() { +void TabContentsViewWin::CreateView(const gfx::Size& initial_size) { set_delete_on_destroy(false); // Since we create these windows parented to the desktop window initially, we // don't want to create them initially visible. diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.h b/chrome/browser/views/tab_contents/tab_contents_view_win.h index 479f3c4..cf52294 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.h +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.h @@ -34,7 +34,7 @@ class TabContentsViewWin : public TabContentsView, // TabContentsView implementation -------------------------------------------- - virtual void CreateView(); + virtual void CreateView(const gfx::Size& initial_size); virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host); virtual gfx::NativeView GetNativeView() const; -- cgit v1.1