| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 width:(CGFloat)width | 184 width:(CGFloat)width |
| 185 fullscreen:(BOOL)fullscreen { | 185 fullscreen:(BOOL)fullscreen { |
| 186 // Nothing to do if no tab strip. | 186 // Nothing to do if no tab strip. |
| 187 if (![self hasTabStrip]) | 187 if (![self hasTabStrip]) |
| 188 return maxY; | 188 return maxY; |
| 189 | 189 |
| 190 NSView* tabStripView = [self tabStripView]; | 190 NSView* tabStripView = [self tabStripView]; |
| 191 CGFloat tabStripHeight = NSHeight([tabStripView frame]); | 191 CGFloat tabStripHeight = NSHeight([tabStripView frame]); |
| 192 maxY -= tabStripHeight; | 192 maxY -= tabStripHeight; |
| 193 NSRect tabStripFrame = NSMakeRect(0, maxY, width, tabStripHeight); | 193 NSRect tabStripFrame = NSMakeRect(0, maxY, width, tabStripHeight); |
| 194 BOOL requiresRelayout = !NSEqualRects(tabStripFrame, [tabStripView frame]); |
| 194 | 195 |
| 195 // In Yosemite fullscreen, manually add the fullscreen controls to the tab | 196 // In Yosemite fullscreen, manually add the fullscreen controls to the tab |
| 196 // strip. | 197 // strip. |
| 197 BOOL addControlsInFullscreen = | 198 BOOL addControlsInFullscreen = |
| 198 [self isInAppKitFullscreen] && base::mac::IsOSYosemiteOrLater(); | 199 [self isInAppKitFullscreen] && base::mac::IsOSYosemiteOrLater(); |
| 199 | 200 |
| 200 // Set left indentation based on fullscreen mode status. | 201 // Set left indentation based on fullscreen mode status. |
| 201 CGFloat leftIndent = 0; | 202 CGFloat leftIndent = 0; |
| 202 if (!fullscreen || addControlsInFullscreen) | 203 if (!fullscreen || addControlsInFullscreen) |
| 203 leftIndent = [[tabStripController_ class] defaultLeftIndentForControls]; | 204 leftIndent = [[tabStripController_ class] defaultLeftIndentForControls]; |
| 204 [tabStripController_ setLeftIndentForControls:leftIndent]; | 205 if (leftIndent != [tabStripController_ leftIndentForControls]) { |
| 206 [tabStripController_ setLeftIndentForControls:leftIndent]; |
| 207 requiresRelayout = YES; |
| 208 } |
| 205 | 209 |
| 206 if (addControlsInFullscreen) | 210 if (addControlsInFullscreen) |
| 207 [tabStripController_ addWindowControls]; | 211 [tabStripController_ addWindowControls]; |
| 208 else | 212 else |
| 209 [tabStripController_ removeWindowControls]; | 213 [tabStripController_ removeWindowControls]; |
| 210 | 214 |
| 211 // fullScreenButton is non-nil when isInAnyFullscreenMode is NO, and OS | 215 // fullScreenButton is non-nil when isInAnyFullscreenMode is NO, and OS |
| 212 // version is in the range 10.7 <= version <= 10.9. Starting with 10.10, the | 216 // version is in the range 10.7 <= version <= 10.9. Starting with 10.10, the |
| 213 // zoom/maximize button acts as the fullscreen button. | 217 // zoom/maximize button acts as the fullscreen button. |
| 214 NSButton* fullScreenButton = | 218 NSButton* fullScreenButton = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 rightIndent = width - NSMinX([fullScreenButton frame]); | 255 rightIndent = width - NSMinX([fullScreenButton frame]); |
| 252 | 256 |
| 253 if ([self shouldUseNewAvatarButton]) { | 257 if ([self shouldUseNewAvatarButton]) { |
| 254 // The new avatar button is to the left of the fullscreen button. | 258 // The new avatar button is to the left of the fullscreen button. |
| 255 // (The old avatar button is to the right). | 259 // (The old avatar button is to the right). |
| 256 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset; | 260 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset; |
| 257 } | 261 } |
| 258 } else if ([self shouldShowAvatar]) { | 262 } else if ([self shouldShowAvatar]) { |
| 259 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset; | 263 rightIndent += NSWidth([avatarButton frame]) + kAvatarRightOffset; |
| 260 } | 264 } |
| 261 [tabStripController_ setRightIndentForControls:rightIndent]; | 265 |
| 266 if (rightIndent != [tabStripController_ rightIndentForControls]) { |
| 267 [tabStripController_ setRightIndentForControls:rightIndent]; |
| 268 requiresRelayout = YES; |
| 269 } |
| 262 | 270 |
| 263 // It is undesirable to force tabs relayout when the tap strip's frame did | 271 // It is undesirable to force tabs relayout when the tap strip's frame did |
| 264 // not change, because it will interrupt tab animations in progress. | 272 // not change, because it will interrupt tab animations in progress. |
| 265 // In addition, there appears to be an AppKit bug on <10.9 where interrupting | 273 // In addition, there appears to be an AppKit bug on <10.9 where interrupting |
| 266 // a tab animation resulted in the tab frame being the animator's target | 274 // a tab animation resulted in the tab frame being the animator's target |
| 267 // frame instead of the interrupting setFrame. (See http://crbug.com/415093) | 275 // frame instead of the interrupting setFrame. (See http://crbug.com/415093) |
| 268 if (!NSEqualRects(tabStripFrame, [tabStripView frame])){ | 276 if (requiresRelayout) { |
| 269 [tabStripView setFrame:tabStripFrame]; | 277 [tabStripView setFrame:tabStripFrame]; |
| 270 [tabStripController_ layoutTabsWithoutAnimation]; | 278 [tabStripController_ layoutTabsWithoutAnimation]; |
| 271 } | 279 } |
| 272 | 280 |
| 273 return maxY; | 281 return maxY; |
| 274 } | 282 } |
| 275 | 283 |
| 276 - (BOOL)placeBookmarkBarBelowInfoBar { | 284 - (BOOL)placeBookmarkBarBelowInfoBar { |
| 277 // If we are currently displaying the NTP detached bookmark bar or animating | 285 // If we are currently displaying the NTP detached bookmark bar or animating |
| 278 // to/from it (from/to anything else), we display the bookmark bar below the | 286 // to/from it (from/to anything else), we display the bookmark bar below the |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1033 |
| 1026 [CATransaction commit]; | 1034 [CATransaction commit]; |
| 1027 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; | 1035 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES; |
| 1028 } | 1036 } |
| 1029 } else { | 1037 } else { |
| 1030 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; | 1038 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO; |
| 1031 } | 1039 } |
| 1032 } | 1040 } |
| 1033 | 1041 |
| 1034 @end // @implementation BrowserWindowController(Private) | 1042 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |