Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: chrome/browser/ui/cocoa/framed_browser_window.mm

Issue 2416513002: Mac: Fix SDK 10.11 build error from r424609. (Closed)
Patch Set: Duck typing Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698