| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/base/cocoa/nscolor_additions.h" | 5 #import "ui/base/cocoa/nscolor_additions.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #import "base/mac/sdk_forward_declarations.h" | 8 #import "base/mac/sdk_forward_declarations.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 | 10 |
| 11 @implementation NSColor (ChromeAdditions) | 11 @implementation NSColor (ChromeAdditions) |
| 12 | 12 |
| 13 - (CGColorRef)cr_CGColor { | 13 - (CGColorRef)cr_CGColor { |
| 14 // Redirect to -[NSColor CGColor] if available because it caches. | 14 // Redirect to -[NSColor CGColor] if available because it caches. |
| 15 static BOOL redirect = | 15 static BOOL redirect = |
| 16 [NSColor instancesRespondToSelector:@selector(CGColor)]; | 16 [NSColor instancesRespondToSelector:@selector(CGColor)]; |
| 17 if (redirect) | 17 if (redirect) |
| 18 return [self CGColor]; | 18 return [self CGColor]; |
| 19 | 19 |
| 20 const NSInteger numberOfComponents = [self numberOfComponents]; | 20 const NSInteger numberOfComponents = [self numberOfComponents]; |
| 21 std::vector<CGFloat> components(numberOfComponents, 0.0); | 21 std::vector<CGFloat> components(numberOfComponents, 0.0); |
| 22 [self getComponents:components.data()]; | 22 [self getComponents:components.data()]; |
| 23 auto color = CGColorCreate([[self colorSpace] CGColorSpace], | 23 auto* color = |
| 24 components.data()); | 24 CGColorCreate([[self colorSpace] CGColorSpace], components.data()); |
| 25 base::mac::CFTypeRefToNSObjectAutorelease(color); | 25 base::mac::CFTypeRefToNSObjectAutorelease(color); |
| 26 return color; | 26 return color; |
| 27 } | 27 } |
| 28 | 28 |
| 29 @end | 29 @end |
| OLD | NEW |