Don't install the RWHVMac into the view hierarchy until everything has been...

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
parent e8dec209
...@@ -12,7 +12,11 @@ class TabContentsCommandObserver; ...@@ -12,7 +12,11 @@ class TabContentsCommandObserver;
class TabStripModel; class TabStripModel;
// A class that controls the web contents of a tab. It manages displaying the // 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 { @interface TabContentsController : NSViewController {
@private @private
...@@ -32,6 +36,10 @@ class TabStripModel; ...@@ -32,6 +36,10 @@ class TabStripModel;
// enabled. // enabled.
- (void)willBecomeSelectedTab; - (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 // Called when the tab contents is updated in some non-descript way (the
// notification from the model isn't specific). |updatedContents| could reflect // notification from the model isn't specific). |updatedContents| could reflect
// an entirely new tab contents object. // an entirely new tab contents object.
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
[super dealloc]; [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()]; [contentsBox_ setContentView:contents_->GetNativeView()];
} }
......
...@@ -78,10 +78,15 @@ NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged"; ...@@ -78,10 +78,15 @@ NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
- (void)swapInTabAtIndex:(NSInteger)index { - (void)swapInTabAtIndex:(NSInteger)index {
TabContentsController* controller = [tabContentsArray_ objectAtIndex: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]; NSView* newView = [controller view];
NSRect frame = [switchView_ bounds]; NSRect frame = [switchView_ bounds];
[newView setFrame:frame]; [newView setFrame:frame];
[controller ensureContentsVisible];
// Remove the old view from the view hierarchy. We know there's only one // 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 // child of |switchView_| because we're the one who put it there. There
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment