Commit 2682f5f0 authored by erikchen's avatar erikchen Committed by Commit bot

mac: Make the avatar button layer backed.

Since it's added to the NSThemeFrame directly as a subview, it also needs to be
removed/added during the fullscreen transition animation.

BUG=411770

Review URL: https://codereview.chromium.org/566473002

Cr-Commit-Position: refs/heads/master@{#294726}
parent fec4238c
...@@ -134,6 +134,14 @@ ...@@ -134,6 +134,14 @@
// The opacity for the toolbar divider; 0 means that it shouldn't be shown. // The opacity for the toolbar divider; 0 means that it shouldn't be shown.
- (CGFloat)toolbarDividerOpacity; - (CGFloat)toolbarDividerOpacity;
// When a view does not have a layer, but it has multiple subviews with layers,
// the ordering of the layers is not well defined. Removing a subview and
// re-adding it to the same position has the side effect of updating the layer
// ordering to better reflect the subview ordering.
// This is a hack needed because NSThemeFrame is not layer backed, but it has
// multiple direct subviews which are. http://crbug.com/413009
- (void)updateLayerOrdering:(NSView*)view;
// Ensures the z-order of subviews is correct. // Ensures the z-order of subviews is correct.
- (void)updateSubviewZOrder:(BOOL)inPresentationMode; - (void)updateSubviewZOrder:(BOOL)inPresentationMode;
......
...@@ -977,6 +977,38 @@ willPositionSheet:(NSWindow*)sheet ...@@ -977,6 +977,38 @@ willPositionSheet:(NSWindow*)sheet
return [bookmarkBarController_ toolbarDividerOpacity]; return [bookmarkBarController_ toolbarDividerOpacity];
} }
- (void)updateLayerOrdering:(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.
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 // TODO(erikchen): The implementation of this method is quite fragile. The
// method cr_ensureSubview:... does not check that the subview is /directly/ // 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 // above/below the given view. e.g. There are 3 subviews: A, B, C, in that
...@@ -1069,27 +1101,8 @@ willPositionSheet:(NSWindow*)sheet ...@@ -1069,27 +1101,8 @@ willPositionSheet:(NSWindow*)sheet
[CATransaction begin]; [CATransaction begin];
[CATransaction setDisableActions:YES]; [CATransaction setDisableActions:YES];
// Get the current position of the tabStripView. [self updateLayerOrdering:[self tabStripView]];
NSView* superview = [[self tabStripView] superview]; [self updateLayerOrdering:[avatarButtonController_ view]];
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];
}
[CATransaction commit]; [CATransaction commit];
hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES;
......
...@@ -186,6 +186,7 @@ NSImage* GetImageFromResourceID(int resourceId) { ...@@ -186,6 +186,7 @@ NSImage* GetImageFromResourceID(int resourceId) {
if (errorController) if (errorController)
[cell setHasError:errorController->HasError() withTitle:[button_ title]]; [cell setHasError:errorController->HasError() withTitle:[button_ title]];
[button_ setWantsLayer:YES];
[self setView:button_]; [self setView:button_];
[button_ setBezelStyle:NSShadowlessSquareBezelStyle]; [button_ setBezelStyle:NSShadowlessSquareBezelStyle];
......
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