Chromium Code Reviews| Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm |
| diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
| index 234af6bd046ef7bb0558444cb50a30726484b95c..6a81b143fe08a370a5bc59c1d007fbd081616954 100644 |
| --- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
| +++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
| @@ -983,6 +983,34 @@ willPositionSheet:(NSWindow*)sheet |
| return [bookmarkBarController_ toolbarDividerOpacity]; |
| } |
| +- (void)reAddViewToSuperview:(NSView*)view { |
| + // Hold a reference to the view so that it doesn't accidentally get |
| + // dealloc'ed. |
| + base::scoped_nsobject<NSView> reference([view retain]); |
| + |
| + // Get the current position of the view |
| + NSView* superview = [view superview]; |
|
Andre
2014/09/11 03:07:57
Can we skip this and do an early return if [superv
erikchen
2014/09/11 17:29:59
Sure.
|
| + NSArray* subviews = [superview subviews]; |
| + NSInteger index = [subviews indexOfObject:view]; |
| + NSView* siblingBelow = nil; |
| + if (index > 0) |
| + siblingBelow = [subviews objectAtIndex:index - 1]; |
| + |
| + // Remove the view. |
| + [view removeFromSuperview]; |
| + |
| + // Add it to the same position. |
| + if (siblingBelow) { |
| + [superview addSubview:view |
| + positioned:NSWindowAbove |
| + relativeTo:siblingBelow]; |
| + } else { |
| + [superview addSubview:view |
| + positioned:NSWindowBelow |
| + relativeTo:nil]; |
| + } |
| +} |
| + |
| // TODO(erikchen): The implementation of this method is quite fragile. The |
| // method cr_ensureSubview:... does not check that the subview is /directly/ |
| // above/below the given view. e.g. There are 3 subviews: A, B, C, in that |
| @@ -1075,27 +1103,8 @@ willPositionSheet:(NSWindow*)sheet |
| [CATransaction begin]; |
| [CATransaction setDisableActions:YES]; |
| - // Get the current position of the tabStripView. |
| - NSView* superview = [[self tabStripView] superview]; |
| - NSArray* subviews = [superview subviews]; |
| - NSInteger index = [subviews indexOfObject:[self tabStripView]]; |
| - NSView* siblingBelow = nil; |
| - if (index > 0) |
| - siblingBelow = [subviews objectAtIndex:index - 1]; |
| - |
| - // Remove the tabStripView. |
| - [[self tabStripView] removeFromSuperview]; |
| - |
| - // Add it to the same position. |
| - if (siblingBelow) { |
| - [superview addSubview:[self tabStripView] |
| - positioned:NSWindowAbove |
| - relativeTo:siblingBelow]; |
| - } else { |
| - [superview addSubview:[self tabStripView] |
| - positioned:NSWindowBelow |
| - relativeTo:nil]; |
| - } |
| + [self reAddViewToSuperview:[self tabStripView]]; |
| + [self reAddViewToSuperview:[avatarButtonController_ view]]; |
| [CATransaction commit]; |
| hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |