summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 08:00:45 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 08:00:45 +0000
commited245db0360efc2d545244ed83f55e337368b0b5 (patch)
treec571e2bc6ee78faec7dd7326390298610bd1c870 /content
parent2a58eb1b70534eb673c569f92731694d6e0dafd7 (diff)
downloadchromium_src-ed245db0360efc2d545244ed83f55e337368b0b5.zip
chromium_src-ed245db0360efc2d545244ed83f55e337368b0b5.tar.gz
chromium_src-ed245db0360efc2d545244ed83f55e337368b0b5.tar.bz2
Instead of passing a base WebContents with WebContents::CreateParams to determine the initial size, specify the size explictely.
This elimiates a short window where the WebView has a (0, 0) windowRect if no base WebContents is given BUG=111316 R=jam@chromium.org Review URL: https://codereview.chromium.org/11593018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/web_contents/web_contents_impl.cc13
-rw-r--r--content/public/browser/web_contents.cc2
-rw-r--r--content/public/browser/web_contents.h6
-rw-r--r--content/shell/shell.cc8
4 files changed, 15 insertions, 14 deletions
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 05cba39..6c52386 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1086,10 +1086,10 @@ void WebContentsImpl::Stop() {
WebContents* WebContentsImpl::Clone() {
// We use our current SiteInstance since the cloned entry will use it anyway.
- // We pass |this| for the |base_web_contents| to size the view correctly, and
- // our own opener so that the cloned page can access it if it was before.
+ // We pass our own opener so that the cloned page can access it if it was
+ // before.
CreateParams create_params(GetBrowserContext(), GetSiteInstance());
- create_params.base_web_contents = this;
+ create_params.initial_size = view_->GetContainerSize();
WebContentsImpl* tc = CreateWithOpener(create_params, opener_);
tc->GetController().CopyStateFrom(controller_);
FOR_EACH_OBSERVER(WebContentsObserver,
@@ -1164,10 +1164,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
}
CHECK(view_.get());
- // We have the initial size of the view be based on the size of the view of
- // the passed in WebContents.
- gfx::Size initial_size = params.base_web_contents ?
- params.base_web_contents->GetView()->GetContainerSize() : gfx::Size();
+ gfx::Size initial_size = params.initial_size;
view_->CreateView(initial_size, params.context);
// Listen for whether our opener gets destroyed.
@@ -1336,7 +1333,7 @@ void WebContentsImpl::CreateNewWindow(
session_storage_namespace);
CreateParams create_params(GetBrowserContext(), site_instance);
create_params.routing_id = route_id;
- create_params.base_web_contents = this;
+ create_params.initial_size = view_->GetContainerSize();
new_contents->Init(create_params);
new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState());
diff --git a/content/public/browser/web_contents.cc b/content/public/browser/web_contents.cc
index c6daee1..0c27483 100644
--- a/content/public/browser/web_contents.cc
+++ b/content/public/browser/web_contents.cc
@@ -12,7 +12,6 @@ WebContents::CreateParams::CreateParams(BrowserContext* context)
: browser_context(context),
site_instance(NULL),
routing_id(MSG_ROUTING_NONE),
- base_web_contents(NULL),
context(NULL) {}
WebContents::CreateParams::CreateParams(
@@ -20,7 +19,6 @@ WebContents::CreateParams::CreateParams(
: browser_context(context),
site_instance(site),
routing_id(MSG_ROUTING_NONE),
- base_web_contents(NULL),
context(NULL) {}
} // namespace content
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 226d36b..54fcc9d 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -18,6 +18,7 @@
#include "ipc/ipc_sender.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/size.h"
#include "webkit/glue/window_open_disposition.h"
namespace base {
@@ -77,9 +78,8 @@ class WebContents : public PageNavigator,
SiteInstance* site_instance;
int routing_id;
- // Used if we want to size the new WebContents's view based on the view of
- // an existing WebContents. This can be NULL if not needed.
- const WebContents* base_web_contents;
+ // Initial size of the new WebContent's view. Can be (0, 0) if not needed.
+ gfx::Size initial_size;
// Used to specify the location context which display the new view should
// belong. This can be NULL if not needed.
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index 45f9660..f21b6f9 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -20,6 +20,7 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
#include "content/shell/shell_browser_main_parts.h"
#include "content/shell/shell_content_browser_client.h"
#include "content/shell/shell_devtools_delegate.h"
@@ -117,7 +118,12 @@ Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
WebContents* base_web_contents) {
WebContents::CreateParams create_params(browser_context, site_instance);
create_params.routing_id = routing_id;
- create_params.base_web_contents = base_web_contents;
+ if (base_web_contents) {
+ create_params.initial_size =
+ base_web_contents->GetView()->GetContainerSize();
+ } else {
+ create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight);
+ }
WebContents* web_contents = WebContents::Create(create_params);
Shell* shell = CreateShell(web_contents);
if (!url.is_empty())