| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_layout.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 // In Yosemite, there is no longer an exit fullscreen button in the top-right | 204 // In Yosemite, there is no longer an exit fullscreen button in the top-right |
| 205 // corner of the OSX Menu Bar. Instead, a Cocoa application's toolbar is | 205 // corner of the OSX Menu Bar. Instead, a Cocoa application's toolbar is |
| 206 // expected to have traffic lights. Chrome doesn't use an NSToolbar, so it | 206 // expected to have traffic lights. Chrome doesn't use an NSToolbar, so it |
| 207 // needs to manually add the traffic lights to the tab strip. | 207 // needs to manually add the traffic lights to the tab strip. |
| 208 layout.addCustomWindowControls = | 208 layout.addCustomWindowControls = |
| 209 parameters_.inAnyFullscreen && parameters_.isOSYosemiteOrLater; | 209 parameters_.inAnyFullscreen && parameters_.isOSYosemiteOrLater; |
| 210 | 210 |
| 211 // Set left indentation based on fullscreen mode status. | 211 // Set left indentation based on fullscreen mode status. |
| 212 if (!parameters_.inAnyFullscreen || layout.addCustomWindowControls) | 212 if (!parameters_.inAnyFullscreen || layout.addCustomWindowControls) |
| 213 layout.leftIndent = [TabStripController defaultLeftIndentForControls]; | 213 layout.leadingIndent = [TabStripController defaultLeadingIndentForControls]; |
| 214 | 214 |
| 215 // Lay out the icognito/avatar badge because calculating the indentation on | 215 // Lay out the icognito/avatar badge because calculating the indentation on |
| 216 // the right depends on it. | 216 // the right depends on it. |
| 217 if (parameters_.shouldShowAvatar) { | 217 if (parameters_.shouldShowAvatar) { |
| 218 CGFloat badgeXOffset = -kAvatarRightOffset; | 218 CGFloat badgeXOffset = -kAvatarRightOffset; |
| 219 CGFloat badgeYOffset = 0; | 219 CGFloat badgeYOffset = 0; |
| 220 CGFloat buttonHeight = parameters_.avatarSize.height; | 220 CGFloat buttonHeight = parameters_.avatarSize.height; |
| 221 | 221 |
| 222 if (parameters_.shouldUseNewAvatar) { | 222 if (parameters_.shouldUseNewAvatar) { |
| 223 // The fullscreen icon (if present) is displayed to the right of the | 223 // The fullscreen icon (if present) is displayed to the right of the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 250 // fullscreen button (old style), or to its left (new style). | 250 // fullscreen button (old style), or to its left (new style). |
| 251 // The right indentation is calculated to prevent the tab strip from | 251 // The right indentation is calculated to prevent the tab strip from |
| 252 // overlapping these buttons. | 252 // overlapping these buttons. |
| 253 CGFloat maxX = width; | 253 CGFloat maxX = width; |
| 254 if (!NSIsEmptyRect(parameters_.fullscreenButtonFrame)) { | 254 if (!NSIsEmptyRect(parameters_.fullscreenButtonFrame)) { |
| 255 maxX = NSMinX(parameters_.fullscreenButtonFrame); | 255 maxX = NSMinX(parameters_.fullscreenButtonFrame); |
| 256 } | 256 } |
| 257 if (parameters_.shouldShowAvatar) { | 257 if (parameters_.shouldShowAvatar) { |
| 258 maxX = std::min(maxX, NSMinX(layout.avatarFrame)); | 258 maxX = std::min(maxX, NSMinX(layout.avatarFrame)); |
| 259 } | 259 } |
| 260 layout.rightIndent = width - maxX; | 260 layout.trailingIndent = width - maxX; |
| 261 | 261 |
| 262 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { | 262 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { |
| 263 std::swap(layout.leftIndent, layout.rightIndent); | |
| 264 layout.avatarFrame.origin.x = | 263 layout.avatarFrame.origin.x = |
| 265 width - parameters_.avatarSize.width - layout.avatarFrame.origin.x; | 264 width - parameters_.avatarSize.width - layout.avatarFrame.origin.x; |
| 266 } | 265 } |
| 267 | 266 |
| 268 output_.tabStripLayout = layout; | 267 output_.tabStripLayout = layout; |
| 269 } | 268 } |
| 270 | 269 |
| 271 - (void)computeContentViewLayout { | 270 - (void)computeContentViewLayout { |
| 272 chrome::LayoutParameters parameters = parameters_; | 271 chrome::LayoutParameters parameters = parameters_; |
| 273 CGFloat maxY = maxY_; | 272 CGFloat maxY = maxY_; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 401 |
| 403 @end | 402 @end |
| 404 | 403 |
| 405 @implementation BrowserWindowLayout (ExposedForTesting) | 404 @implementation BrowserWindowLayout (ExposedForTesting) |
| 406 | 405 |
| 407 - (void)setOSYosemiteOrLater:(BOOL)osYosemiteOrLater { | 406 - (void)setOSYosemiteOrLater:(BOOL)osYosemiteOrLater { |
| 408 parameters_.isOSYosemiteOrLater = osYosemiteOrLater; | 407 parameters_.isOSYosemiteOrLater = osYosemiteOrLater; |
| 409 } | 408 } |
| 410 | 409 |
| 411 @end | 410 @end |
| OLD | NEW |