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)toggleLayerOrdering:(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 // If the superview has a layer, then this hack isn't required. | |
| 992 NSView* superview = [view superview]; | |
| 993 if ([superview layer]) | |
| 994 return; | |
| 995 | |
| 996 // 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.
| |
| 997 NSArray* subviews = [superview subviews]; | |
| 998 NSInteger index = [subviews indexOfObject:view]; | |
| 999 NSView* siblingBelow = nil; | |
| 1000 if (index > 0) | |
| 1001 siblingBelow = [subviews objectAtIndex:index - 1]; | |
| 1002 | |
| 1003 // Remove the view. | |
| 1004 [view removeFromSuperview]; | |
| 1005 | |
| 1006 // Add it to the same position. | |
| 1007 if (siblingBelow) { | |
| 1008 [superview addSubview:view | |
| 1009 positioned:NSWindowAbove | |
| 1010 relativeTo:siblingBelow]; | |
| 1011 } else { | |
| 1012 [superview addSubview:view | |
| 1013 positioned:NSWindowBelow | |
| 1014 relativeTo:nil]; | |
| 1015 } | |
| 1016 } | |
| 1017 | |
| 986 // TODO(erikchen): The implementation of this method is quite fragile. The | 1018 // TODO(erikchen): The implementation of this method is quite fragile. The |
| 987 // method cr_ensureSubview:... does not check that the subview is /directly/ | 1019 // 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 | 1020 // 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 | 1021 // order. The method cr_ensureSubview:A isPositioned:NSWindowBelow |
| 990 // relativeTo:C will have no effect, even though the desired result may have | 1022 // relativeTo:C will have no effect, even though the desired result may have |
| 991 // been: B, A, C. Consider changing it? | 1023 // been: B, A, C. Consider changing it? |
| 992 - (void)updateSubviewZOrder:(BOOL)inAnyFullscreen { | 1024 - (void)updateSubviewZOrder:(BOOL)inAnyFullscreen { |
| 993 NSView* contentView = [[self window] contentView]; | 1025 NSView* contentView = [[self window] contentView]; |
| 994 NSView* toolbarView = [toolbarController_ view]; | 1026 NSView* toolbarView = [toolbarController_ view]; |
| 995 | 1027 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 // Repeatedly adding/removing the tabstrip from its superview during the | 1100 // Repeatedly adding/removing the tabstrip from its superview during the |
| 1069 // AppKit Fullscreen transition causes graphical glitches on 10.10. The | 1101 // AppKit Fullscreen transition causes graphical glitches on 10.10. The |
| 1070 // correct solution is to use the AppKit fullscreen transition APIs added | 1102 // correct solution is to use the AppKit fullscreen transition APIs added |
| 1071 // in 10.7+. | 1103 // in 10.7+. |
| 1072 // http://crbug.com/408791 | 1104 // http://crbug.com/408791 |
| 1073 if (!hasAdjustedTabStripWhileEnteringAppKitFullscreen_) { | 1105 if (!hasAdjustedTabStripWhileEnteringAppKitFullscreen_) { |
| 1074 // Disable implicit animations. | 1106 // Disable implicit animations. |
| 1075 [CATransaction begin]; | 1107 [CATransaction begin]; |
| 1076 [CATransaction setDisableActions:YES]; | 1108 [CATransaction setDisableActions:YES]; |
| 1077 | 1109 |
| 1078 // Get the current position of the tabStripView. | 1110 [self toggleLayerOrdering:[self tabStripView]]; |
| 1079 NSView* superview = [[self tabStripView] superview]; | 1111 [self toggleLayerOrdering:[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 | 1112 |
| 1100 [CATransaction commit]; | 1113 [CATransaction commit]; |
| 1101 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; | 1114 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |
| 1102 } | 1115 } |
| 1103 } else { | 1116 } else { |
| 1104 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; | 1117 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; |
| 1105 } | 1118 } |
| 1106 } | 1119 } |
| 1107 | 1120 |
| 1108 - (void)updateInfoBarTipVisibility { | 1121 - (void)updateInfoBarTipVisibility { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1138 | 1151 |
| 1139 - (void)exitAppKitFullscreen { | 1152 - (void)exitAppKitFullscreen { |
| 1140 DCHECK(base::mac::IsOSLionOrLater()); | 1153 DCHECK(base::mac::IsOSLionOrLater()); |
| 1141 if (FramedBrowserWindow* framedBrowserWindow = | 1154 if (FramedBrowserWindow* framedBrowserWindow = |
| 1142 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { | 1155 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { |
| 1143 [framedBrowserWindow toggleSystemFullScreen]; | 1156 [framedBrowserWindow toggleSystemFullScreen]; |
| 1144 } | 1157 } |
| 1145 } | 1158 } |
| 1146 | 1159 |
| 1147 @end // @implementation BrowserWindowController(Private) | 1160 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |