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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 566473002: mac: Make the avatar button layer backed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from avi. Created 6 years, 3 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
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;

Powered by Google App Engine
This is Rietveld 408576698