Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / cocoa / nscolor_additions.mm
blob3e1a94b5e5614d3427f7c508a23150a627659e18
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
3 // found in the LICENSE file.
5 #import "ui/base/cocoa/nscolor_additions.h"
7 #include "base/mac/foundation_util.h"
8 #import "base/mac/sdk_forward_declarations.h"
9 #include "base/macros.h"
11 @implementation NSColor (ChromeAdditions)
13 - (CGColorRef)cr_CGColor {
14   // Redirect to -[NSColor CGColor] if available because it caches.
15   static BOOL redirect =
16       [NSColor instancesRespondToSelector:@selector(CGColor)];
17   if (redirect)
18     return [self CGColor];
20   const NSInteger numberOfComponents = [self numberOfComponents];
21   std::vector<CGFloat> components(numberOfComponents, 0.0);
22   [self getComponents:components.data()];
23   auto color = CGColorCreate([[self colorSpace] CGColorSpace],
24                              components.data());
25   base::mac::CFTypeRefToNSObjectAutorelease(color);
26   return color;
29 @end