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..a95a65c65cff1f0af0715258f32a9e26f37e4e74 100644 |
| --- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
| +++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
| @@ -983,6 +983,38 @@ willPositionSheet:(NSWindow*)sheet |
| return [bookmarkBarController_ toolbarDividerOpacity]; |
| } |
| +- (void)toggleLayerOrdering:(NSView*)view { |
| + // Hold a reference to the view so that it doesn't accidentally get |
| + // dealloc'ed. |
| + base::scoped_nsobject<NSView> reference([view retain]); |
| + |
| + // If the superview has a layer, then this hack isn't required. |
| + NSView* superview = [view superview]; |
| + if ([superview layer]) |
| + return; |
| + |
| + // Get the current position of the view |
|
Avi (use Gerrit)
2014/09/12 05:58:17
end the comment with a . as complete sentences are
erikchen
2014/09/12 17:29:55
Done.
|
| + 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 +1107,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 toggleLayerOrdering:[self tabStripView]]; |
| + [self toggleLayerOrdering:[avatarButtonController_ view]]; |
| [CATransaction commit]; |
| hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |