Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 if (!barVisibilityUpdatesEnabled_ || [barVisibilityLocks_ count]) | 976 if (!barVisibilityUpdatesEnabled_ || [barVisibilityLocks_ count]) |
| 977 return; | 977 return; |
| 978 [presentationModeController_ ensureOverlayHiddenWithAnimation:animation | 978 [presentationModeController_ ensureOverlayHiddenWithAnimation:animation |
| 979 delay:delay]; | 979 delay:delay]; |
| 980 } | 980 } |
| 981 | 981 |
| 982 - (CGFloat)toolbarDividerOpacity { | 982 - (CGFloat)toolbarDividerOpacity { |
| 983 return [bookmarkBarController_ toolbarDividerOpacity]; | 983 return [bookmarkBarController_ toolbarDividerOpacity]; |
| 984 } | 984 } |
| 985 | 985 |
| 986 - (void)reAddViewToSuperview:(NSView*)view { | |
| 987 // Hold a reference to the view so that it doesn't accidentally get | |
| 988 // dealloc'ed. | |
| 989 base::scoped_nsobject<NSView> reference([view retain]); | |
| 990 | |
| 991 // Get the current position of the view | |
| 992 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.
| |
| 993 NSArray* subviews = [superview subviews]; | |
| 994 NSInteger index = [subviews indexOfObject:view]; | |
| 995 NSView* siblingBelow = nil; | |
| 996 if (index > 0) | |
| 997 siblingBelow = [subviews objectAtIndex:index - 1]; | |
| 998 | |
| 999 // Remove the view. | |
| 1000 [view removeFromSuperview]; | |
| 1001 | |
| 1002 // Add it to the same position. | |
| 1003 if (siblingBelow) { | |
| 1004 [superview addSubview:view | |
| 1005 positioned:NSWindowAbove | |
| 1006 relativeTo:siblingBelow]; | |
| 1007 } else { | |
| 1008 [superview addSubview:view | |
| 1009 positioned:NSWindowBelow | |
| 1010 relativeTo:nil]; | |
| 1011 } | |
| 1012 } | |
| 1013 | |
| 986 // TODO(erikchen): The implementation of this method is quite fragile. The | 1014 // TODO(erikchen): The implementation of this method is quite fragile. The |
| 987 // method cr_ensureSubview:... does not check that the subview is /directly/ | 1015 // method cr_ensureSubview:... does not check that the subview is /directly/ |
| 988 // above/below the given view. e.g. There are 3 subviews: A, B, C, in that | 1016 // above/below the given view. e.g. There are 3 subviews: A, B, C, in that |
| 989 // order. The method cr_ensureSubview:A isPositioned:NSWindowBelow | 1017 // order. The method cr_ensureSubview:A isPositioned:NSWindowBelow |
| 990 // relativeTo:C will have no effect, even though the desired result may have | 1018 // relativeTo:C will have no effect, even though the desired result may have |
| 991 // been: B, A, C. Consider changing it? | 1019 // been: B, A, C. Consider changing it? |
| 992 - (void)updateSubviewZOrder:(BOOL)inAnyFullscreen { | 1020 - (void)updateSubviewZOrder:(BOOL)inAnyFullscreen { |
| 993 NSView* contentView = [[self window] contentView]; | 1021 NSView* contentView = [[self window] contentView]; |
| 994 NSView* toolbarView = [toolbarController_ view]; | 1022 NSView* toolbarView = [toolbarController_ view]; |
| 995 | 1023 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 // Repeatedly adding/removing the tabstrip from its superview during the | 1096 // Repeatedly adding/removing the tabstrip from its superview during the |
| 1069 // AppKit Fullscreen transition causes graphical glitches on 10.10. The | 1097 // AppKit Fullscreen transition causes graphical glitches on 10.10. The |
| 1070 // correct solution is to use the AppKit fullscreen transition APIs added | 1098 // correct solution is to use the AppKit fullscreen transition APIs added |
| 1071 // in 10.7+. | 1099 // in 10.7+. |
| 1072 // http://crbug.com/408791 | 1100 // http://crbug.com/408791 |
| 1073 if (!hasAdjustedTabStripWhileEnteringAppKitFullscreen_) { | 1101 if (!hasAdjustedTabStripWhileEnteringAppKitFullscreen_) { |
| 1074 // Disable implicit animations. | 1102 // Disable implicit animations. |
| 1075 [CATransaction begin]; | 1103 [CATransaction begin]; |
| 1076 [CATransaction setDisableActions:YES]; | 1104 [CATransaction setDisableActions:YES]; |
| 1077 | 1105 |
| 1078 // Get the current position of the tabStripView. | 1106 [self reAddViewToSuperview:[self tabStripView]]; |
| 1079 NSView* superview = [[self tabStripView] superview]; | 1107 [self reAddViewToSuperview:[avatarButtonController_ view]]; |
| 1080 NSArray* subviews = [superview subviews]; | |
| 1081 NSInteger index = [subviews indexOfObject:[self tabStripView]]; | |
| 1082 NSView* siblingBelow = nil; | |
| 1083 if (index > 0) | |
| 1084 siblingBelow = [subviews objectAtIndex:index - 1]; | |
| 1085 | |
| 1086 // Remove the tabStripView. | |
| 1087 [[self tabStripView] removeFromSuperview]; | |
| 1088 | |
| 1089 // Add it to the same position. | |
| 1090 if (siblingBelow) { | |
| 1091 [superview addSubview:[self tabStripView] | |
| 1092 positioned:NSWindowAbove | |
| 1093 relativeTo:siblingBelow]; | |
| 1094 } else { | |
| 1095 [superview addSubview:[self tabStripView] | |
| 1096 positioned:NSWindowBelow | |
| 1097 relativeTo:nil]; | |
| 1098 } | |
| 1099 | 1108 |
| 1100 [CATransaction commit]; | 1109 [CATransaction commit]; |
| 1101 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; | 1110 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |
| 1102 } | 1111 } |
| 1103 } else { | 1112 } else { |
| 1104 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; | 1113 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; |
| 1105 } | 1114 } |
| 1106 } | 1115 } |
| 1107 | 1116 |
| 1108 - (void)updateInfoBarTipVisibility { | 1117 - (void)updateInfoBarTipVisibility { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1138 | 1147 |
| 1139 - (void)exitAppKitFullscreen { | 1148 - (void)exitAppKitFullscreen { |
| 1140 DCHECK(base::mac::IsOSLionOrLater()); | 1149 DCHECK(base::mac::IsOSLionOrLater()); |
| 1141 if (FramedBrowserWindow* framedBrowserWindow = | 1150 if (FramedBrowserWindow* framedBrowserWindow = |
| 1142 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { | 1151 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { |
| 1143 [framedBrowserWindow toggleSystemFullScreen]; | 1152 [framedBrowserWindow toggleSystemFullScreen]; |
| 1144 } | 1153 } |
| 1145 } | 1154 } |
| 1146 | 1155 |
| 1147 @end // @implementation BrowserWindowController(Private) | 1156 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |