Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 2138213003: Mac: Do layout before adding the WebContents to the view hierarchy when switching tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ensureContentsVisibleInSuperview Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index 44d1d9808a484e1df8a12a9caa4b2dfdab503528..3a19757dd342ae08eb8e99b1ce750a0081d98faf 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -580,43 +580,22 @@ private:
// positions.
ScopedCAActionDisabler ca_disabler;
- // 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];
-
- // Turns content autoresizing off, so removing and inserting views won't
- // trigger unnecessary content relayout.
- [controller ensureContentsSizeDoesNotChange];
-
- // 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
- // may not be any children in the case of a tab that's been closed, in
- // which case there's no swapping going on.
- NSArray* subviews = [switchView_ subviews];
- if ([subviews count]) {
- NSView* oldView = [subviews objectAtIndex:0];
- // Set newView frame to the oldVew frame to prevent NSSplitView hosting
- // sidebar and tab content from resizing sidebar's content view.
- // ensureContentsVisible (see below) sets content size and autoresizing
- // properties.
- [newView setFrame:[oldView frame]];
- // Remove the old view first, to ensure ConstrainedWindowSheets keyed to the
- // old WebContents are removed before adding new ones.
- [oldView removeFromSuperview];
- [switchView_ addSubview:newView];
- } else {
- [newView setFrame:[switchView_ bounds]];
- [switchView_ addSubview:newView];
- }
+ // Ensure the nib is loaded. Sizing won't occur until it's added to the view
+ // hierarchy with -ensureContentsVisibleInSuperview:.
+ [controller view];
+
+ // Remove the old view from the view hierarchy to suppress resizes. We know
+ // there's only one child of |switchView_| because we're the one who put it
+ // there. There may not be any children in the case of a tab that's been
+ // closed, in which case there's nothing removed.
+ [[[switchView_ subviews] firstObject] removeFromSuperview];
- // New content is in place, delegate should adjust itself accordingly.
+ // Prepare the container with any infobars or docked devtools it wants.
[delegate_ onActivateTabWithContents:[controller webContents]];
- // It also restores content autoresizing properties.
- [controller ensureContentsVisible];
+ // Sizes the WebContents to match the possibly updated size of |switchView_|,
+ // then adds it and starts auto-resizing again.
+ [controller ensureContentsVisibleInSuperview:switchView_];
}
// Create a new tab view and set its cell correctly so it draws the way we want
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698