| 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/framed_browser_window.h" | 5 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <objc/runtime.h> | 8 #include <objc/runtime.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #import "ui/base/cocoa/nsview_additions.h" | 26 #import "ui/base/cocoa/nsview_additions.h" |
| 27 #include "ui/base/material_design/material_design_controller.h" | 27 #include "ui/base/material_design/material_design_controller.h" |
| 28 | 28 |
| 29 // Implementer's note: Moving the window controls is tricky. When altering the | 29 // Implementer's note: Moving the window controls is tricky. When altering the |
| 30 // code, ensure that: | 30 // code, ensure that: |
| 31 // - accessibility hit testing works | 31 // - accessibility hit testing works |
| 32 // - the accessibility hierarchy is correct | 32 // - the accessibility hierarchy is correct |
| 33 // - close/min in the background don't bring the window forward | 33 // - close/min in the background don't bring the window forward |
| 34 // - rollover effects work correctly | 34 // - rollover effects work correctly |
| 35 | 35 |
| 36 // The NSLayoutConstraint class hierarchy only exists in the 10.11 SDK. When |
| 37 // targeting something lower, constraintEqualToAnchor:constant: needs to be |
| 38 // invoked using duck typing. |
| 39 #if !defined(MAC_OS_X_VERSION_10_11) || \ |
| 40 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 |
| 41 @interface NSObject (NSLayoutConstraint) |
| 42 - (NSLayoutConstraint*)constraintEqualToAnchor:(id)anchor constant:(CGFloat)c; |
| 43 @end |
| 44 #endif |
| 45 |
| 36 namespace { | 46 namespace { |
| 37 | 47 |
| 38 // Size of the gradient. Empirically determined so that the gradient looks | 48 // Size of the gradient. Empirically determined so that the gradient looks |
| 39 // like what the heuristic does when there are just a few tabs. | 49 // like what the heuristic does when there are just a few tabs. |
| 40 const CGFloat kWindowGradientHeight = 24.0; | 50 const CGFloat kWindowGradientHeight = 24.0; |
| 41 | 51 |
| 42 } | 52 } |
| 43 | 53 |
| 44 @interface FramedBrowserWindow (Private) | 54 @interface FramedBrowserWindow (Private) |
| 45 | 55 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 268 |
| 259 // Do not use leadingAnchor because |ShouldDoExperimentalRTLLayout| | 269 // Do not use leadingAnchor because |ShouldDoExperimentalRTLLayout| |
| 260 // should determine if current locale is RTL. | 270 // should determine if current locale is RTL. |
| 261 NSLayoutXAxisAnchor* leadingSourceAnchor = [button leftAnchor]; | 271 NSLayoutXAxisAnchor* leadingSourceAnchor = [button leftAnchor]; |
| 262 NSLayoutXAxisAnchor* leadingTargetAnchor = [[button superview] leftAnchor]; | 272 NSLayoutXAxisAnchor* leadingTargetAnchor = [[button superview] leftAnchor]; |
| 263 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { | 273 if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) { |
| 264 leadingSourceAnchor = [button rightAnchor]; | 274 leadingSourceAnchor = [button rightAnchor]; |
| 265 leadingTargetAnchor = [[button superview] rightAnchor]; | 275 leadingTargetAnchor = [[button superview] rightAnchor]; |
| 266 leadingOffset = -leadingOffset; | 276 leadingOffset = -leadingOffset; |
| 267 } | 277 } |
| 268 [[leadingSourceAnchor constraintEqualToAnchor:leadingTargetAnchor | 278 |
| 269 constant:leadingOffset] setActive:YES]; | 279 #if !defined(MAC_OS_X_VERSION_10_11) || \ |
| 280 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 |
| 281 id leadingSourceAnchorDuck = leadingSourceAnchor; |
| 282 #else |
| 283 NSLayoutXAxisAnchor* leadingSourceAnchorDuck = leadingSourceAnchor; |
| 284 #endif |
| 285 [[leadingSourceAnchorDuck constraintEqualToAnchor:leadingTargetAnchor |
| 286 constant:leadingOffset] |
| 287 setActive:YES]; |
| 270 } | 288 } |
| 271 | 289 |
| 272 - (void)adjustCloseButton:(NSNotification*)notification { | 290 - (void)adjustCloseButton:(NSNotification*)notification { |
| 273 [self adjustButton:[notification object] | 291 [self adjustButton:[notification object] |
| 274 ofKind:NSWindowCloseButton]; | 292 ofKind:NSWindowCloseButton]; |
| 275 } | 293 } |
| 276 | 294 |
| 277 - (void)adjustMiniaturizeButton:(NSNotification*)notification { | 295 - (void)adjustMiniaturizeButton:(NSNotification*)notification { |
| 278 [self adjustButton:[notification object] | 296 [self adjustButton:[notification object] |
| 279 ofKind:NSWindowMiniaturizeButton]; | 297 ofKind:NSWindowMiniaturizeButton]; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 [self childWindowsDidChange]; | 516 [self childWindowsDidChange]; |
| 499 } | 517 } |
| 500 | 518 |
| 501 - (void)childWindowsDidChange { | 519 - (void)childWindowsDidChange { |
| 502 id delegate = [self delegate]; | 520 id delegate = [self delegate]; |
| 503 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) | 521 if ([delegate respondsToSelector:@selector(childWindowsDidChange)]) |
| 504 [delegate childWindowsDidChange]; | 522 [delegate childWindowsDidChange]; |
| 505 } | 523 } |
| 506 | 524 |
| 507 @end | 525 @end |
| OLD | NEW |