summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-29 23:00:43 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-29 23:00:43 +0000
commitc69acd33d46f165a3838811dd7989452c85d77e5 (patch)
treeb65fcbbab14ca354d677a5d83fead74f571cce5f
parenta2f7c2624565a8bcbc5e53e249b6d7ab7814db48 (diff)
downloadchromium_src-c69acd33d46f165a3838811dd7989452c85d77e5.zip
chromium_src-c69acd33d46f165a3838811dd7989452c85d77e5.tar.gz
chromium_src-c69acd33d46f165a3838811dd7989452c85d77e5.tar.bz2
Clean up the Windows-ness in the sizing of new views. Write a bunch of comments
about issues I discovered in this process. Review URL: http://codereview.chromium.org/19677 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8923 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h25
-rw-r--r--chrome/browser/tab_contents/web_contents.cc25
-rw-r--r--chrome/browser/tab_contents/web_contents_view.h8
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.cc2
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.h2
5 files changed, 28 insertions, 34 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 2238773..76316b4 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -21,24 +21,23 @@ class RenderProcessHost;
class RenderWidgetHost;
class WebCursor;
-///////////////////////////////////////////////////////////////////////////////
-//
-// RenderWidgetHostView
-//
-// RenderWidgetHostView is an interface implemented by an object that acts as
-// the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its
-// associated RenderProcessHost own the "Model" in this case which is the
-// child renderer process. The View is responsible for receiving events from
-// the surrounding environment and passing them to the RenderWidgetHost, and
-// for actually displaying the content of the RenderWidgetHost when it
-// changes.
-//
-///////////////////////////////////////////////////////////////////////////////
+// RenderWidgetHostView is an interface implemented by an object that acts as
+// the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its
+// associated RenderProcessHost own the "Model" in this case which is the
+// child renderer process. The View is responsible for receiving events from
+// the surrounding environment and passing them to the RenderWidgetHost, and
+// for actually displaying the content of the RenderWidgetHost when it
+// changes.
class RenderWidgetHostView {
public:
// Platform-specific creator. Use this to construct new RenderWidgetHostViews
// rather than using RenderWidgetHostViewWin & friends.
//
+ // This function must NOT size it, because the RenderView in the renderer
+ // wounldn't have been created yet. The widget would set its "waiting for
+ // resize ack" flag, and the ack would never come becasue no RenderView
+ // received it.
+ //
// The RenderWidgetHost must already be created (because we can't know if it's
// going to be a regular RenderWidgetHost or a RenderViewHost (a subclass).
static RenderWidgetHostView* CreateViewForWidget(RenderWidgetHost* widget);
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index 8cc690f..4f4af00 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -29,7 +29,7 @@
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/renderer_host/render_widget_host_view_win.h" // TODO(brettw) delete me.
+#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
@@ -1376,19 +1376,16 @@ void WebContents::UpdateRenderViewSizeForRenderManager() {
bool WebContents::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host) {
- RenderWidgetHostView* rvh_view = view_->CreateViewForWidget(render_view_host);
-
- bool ok = render_view_host->CreateRenderView();
- if (ok) {
- // TODO(brettw) hack alert. Do this in some cross platform way, or move
- // to the view?
- RenderWidgetHostViewWin* rvh_view_win =
- static_cast<RenderWidgetHostViewWin*>(rvh_view);
- rvh_view->SetSize(view_->GetContainerSize());
- UpdateMaxPageIDIfNecessary(render_view_host->site_instance(),
- render_view_host);
- }
- return ok;
+ RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host);
+ if (!render_view_host->CreateRenderView())
+ return false;
+
+ // Now that the RenderView has been created, we need to tell it its size.
+ rwh_view->SetSize(view_->GetContainerSize());
+
+ UpdateMaxPageIDIfNecessary(render_view_host->site_instance(),
+ render_view_host);
+ return true;
}
void WebContents::Observe(NotificationType type,
diff --git a/chrome/browser/tab_contents/web_contents_view.h b/chrome/browser/tab_contents/web_contents_view.h
index 1db1a52..309a33d 100644
--- a/chrome/browser/tab_contents/web_contents_view.h
+++ b/chrome/browser/tab_contents/web_contents_view.h
@@ -18,7 +18,6 @@ class Browser;
class RenderViewHost;
class RenderWidgetHost;
class RenderWidgetHostView;
-class RenderWidgetHostViewWin; // TODO(brettw) this should not be necessary.
class WebContents;
struct WebDropData;
class WebKeyboardEvent;
@@ -43,10 +42,9 @@ class WebContentsView : public RenderViewHostDelegate::View {
virtual void CreateView() = 0;
// Sets up the View that holds the rendered web page, receives messages for
- // it and contains page plugins.
- // TODO(brettw) make this so we don't need to return the Win version (see the
- // caller in WebContents).
- virtual RenderWidgetHostViewWin* CreateViewForWidget(
+ // it and contains page plugins. The host view should be sized to the current
+ // size of the WebContents.
+ virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host) = 0;
// Returns the native widget that contains the contents of the tab.
diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc
index f294d6a..e93916e 100644
--- a/chrome/browser/tab_contents/web_contents_view_win.cc
+++ b/chrome/browser/tab_contents/web_contents_view_win.cc
@@ -64,7 +64,7 @@ void WebContentsViewWin::CreateView() {
drop_target_ = new WebDropTarget(GetHWND(), web_contents_);
}
-RenderWidgetHostViewWin* WebContentsViewWin::CreateViewForWidget(
+RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget(
RenderWidgetHost* render_widget_host) {
DCHECK(!render_widget_host->view());
RenderWidgetHostViewWin* view =
diff --git a/chrome/browser/tab_contents/web_contents_view_win.h b/chrome/browser/tab_contents/web_contents_view_win.h
index d891614..543efb4 100644
--- a/chrome/browser/tab_contents/web_contents_view_win.h
+++ b/chrome/browser/tab_contents/web_contents_view_win.h
@@ -30,7 +30,7 @@ class WebContentsViewWin : public WebContentsView,
virtual WebContents* GetWebContents();
virtual void CreateView();
- virtual RenderWidgetHostViewWin* CreateViewForWidget(
+ virtual RenderWidgetHostView* CreateViewForWidget(
RenderWidgetHost* render_widget_host);
virtual gfx::NativeView GetNativeView() const;
virtual gfx::NativeView GetContentNativeView() const;