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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/framed_browser_window.mm
diff --git a/chrome/browser/ui/cocoa/framed_browser_window.mm b/chrome/browser/ui/cocoa/framed_browser_window.mm
index c79a99675ba7adbf7b8043ad6e516163c50a7cfe..9daf43125cdeca54da06f1ff72b58a9c421afa44 100644
--- a/chrome/browser/ui/cocoa/framed_browser_window.mm
+++ b/chrome/browser/ui/cocoa/framed_browser_window.mm
@@ -33,6 +33,16 @@
// - close/min in the background don't bring the window forward
// - rollover effects work correctly
+// The NSLayoutConstraint class hierarchy only exists in the 10.11 SDK. When
+// targeting something lower, constraintEqualToAnchor:constant: needs to be
+// invoked using duck typing.
+#if !defined(MAC_OS_X_VERSION_10_11) || \
+ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
+@interface NSObject (NSLayoutConstraint)
+- (NSLayoutConstraint*)constraintEqualToAnchor:(id)anchor constant:(CGFloat)c;
+@end
+#endif
+
namespace {
// Size of the gradient. Empirically determined so that the gradient looks
@@ -265,8 +275,16 @@ const CGFloat kWindowGradientHeight = 24.0;
leadingTargetAnchor = [[button superview] rightAnchor];
leadingOffset = -leadingOffset;
}
- [[leadingSourceAnchor constraintEqualToAnchor:leadingTargetAnchor
- constant:leadingOffset] setActive:YES];
+
+#if !defined(MAC_OS_X_VERSION_10_11) || \
+ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
+ id leadingSourceAnchorDuck = leadingSourceAnchor;
+#else
+ NSLayoutXAxisAnchor* leadingSourceAnchorDuck = leadingSourceAnchor;
+#endif
+ [[leadingSourceAnchorDuck constraintEqualToAnchor:leadingTargetAnchor
+ constant:leadingOffset]
+ setActive:YES];
}
- (void)adjustCloseButton:(NSNotification*)notification {
« 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