summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:09:06 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:09:06 +0000
commit6e9d11ebd13b9e3582697f7480c3d920331dc087 (patch)
tree6545c2f5ecbdb66c3785a2abdae158464ea63503 /chrome/browser/cocoa
parente8dec209df749eac3a3e566d96d0fdde3dadbe1e (diff)
downloadchromium_src-6e9d11ebd13b9e3582697f7480c3d920331dc087.zip
chromium_src-6e9d11ebd13b9e3582697f7480c3d920331dc087.tar.gz
chromium_src-6e9d11ebd13b9e3582697f7480c3d920331dc087.tar.bz2
Don't install the RWHVMac into the view hierarchy until everything has been properly sized. This avoids sending spurrious resize message with incorrect sizes to the renderer.
BUG=15717 TEST=pages should always be the correct size when loaded in bg or foreground. No more flashing a small size then redrawing. Review URL: http://codereview.chromium.org/155099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.h10
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.mm4
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm7
3 files changed, 18 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h
index f79b9ea..e262db1 100644
--- a/chrome/browser/cocoa/tab_contents_controller.h
+++ b/chrome/browser/cocoa/tab_contents_controller.h
@@ -12,7 +12,11 @@ class TabContentsCommandObserver;
class TabStripModel;
// A class that controls the web contents of a tab. It manages displaying the
-// native view for a given TabContents in |contentsBox_|.
+// native view for a given TabContents in |contentsBox_|. Note that just
+// creating the class does not display the view in |contentsBox_|. We defer
+// inserting it until the box is the correct size to avoid multiple resize
+// messages to the renderer. You must call |-ensureContentsVisible| to display
+// the render widget host view.
@interface TabContentsController : NSViewController {
@private
@@ -32,6 +36,10 @@ class TabStripModel;
// enabled.
- (void)willBecomeSelectedTab;
+// Call when the tab view is properly sized and the render widget host view
+// should be put into the view hierarchy.
+- (void)ensureContentsVisible;
+
// Called when the tab contents is updated in some non-descript way (the
// notification from the model isn't specific). |updatedContents| could reflect
// an entirely new tab contents object.
diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm
index b2ac634..9f676d3 100644
--- a/chrome/browser/cocoa/tab_contents_controller.mm
+++ b/chrome/browser/cocoa/tab_contents_controller.mm
@@ -26,7 +26,9 @@
[super dealloc];
}
-- (void)awakeFromNib {
+// Call when the tab view is properly sized and the render widget host view
+// should be put into the view hierarchy.
+- (void)ensureContentsVisible {
[contentsBox_ setContentView:contents_->GetNativeView()];
}
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 0bf6a59..4227253 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -78,10 +78,15 @@ NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
- (void)swapInTabAtIndex:(NSInteger)index {
TabContentsController* controller = [tabContentsArray_ objectAtIndex:index];
- // Resize the new view to fit the window
+ // Resize the new view to fit the window. Calling |view| may lazily
+ // instantiate the TabContentsController from the nib. Until we call
+ // |-ensureContentsVisible|, the controller doesn't install the RWHVMac into
+ // the view hierarchy. This is in order to avoid sending the renderer a
+ // spurious default size loaded from the nib during the call to |-view|.
NSView* newView = [controller view];
NSRect frame = [switchView_ bounds];
[newView setFrame:frame];
+ [controller ensureContentsVisible];
// Remove the old view from the view hierarchy. We know there's only one
// child of |switchView_| because we're the one who put it there. There