Index: ui/native_theme/native_theme_mac.mm |
diff --git a/ui/native_theme/native_theme_mac.mm b/ui/native_theme/native_theme_mac.mm |
index 60c049cb27d95d5822bf4310969dfb0381a46c61..f4339e0cfaf1e5e496ad9f669cff8657d0117640 100644 |
--- a/ui/native_theme/native_theme_mac.mm |
+++ b/ui/native_theme/native_theme_mac.mm |
@@ -97,15 +97,17 @@ SkColor NSSystemColorToSkColor(NSColor* color) { |
// windowBackgroundColor; need to first convert colorspace." Hence the |
// conversion first to CGColor. |
CGColorRef cg_color = [color CGColor]; |
- if (CGColorGetNumberOfComponents(cg_color) == 4) |
+ const size_t component_count = CGColorGetNumberOfComponents(cg_color); |
+ if (component_count == 4) |
return gfx::CGColorRefToSkColor(cg_color); |
- CHECK_EQ(2u, CGColorGetNumberOfComponents(cg_color)); |
+ CHECK(component_count == 1 || component_count == 2); |
// Two components means a grayscale channel and an alpha channel, which |
// CGColorRefToSkColor will not like. But RGB is additive, so the conversion |
// is easy (RGB to grayscale is less easy). |
Avi (use Gerrit)
2014/10/16 15:13:40
Update comment?
tapted
2014/10/17 04:18:51
Done.
|
const CGFloat* components = CGColorGetComponents(cg_color); |
- return SkColorSetARGB(SkScalarRoundToInt(255.0 * components[1]), |
+ CGFloat alpha = component_count == 2 ? components[1] : 1.0; |
+ return SkColorSetARGB(SkScalarRoundToInt(255.0 * alpha), |
SkScalarRoundToInt(255.0 * components[0]), |
SkScalarRoundToInt(255.0 * components[0]), |
SkScalarRoundToInt(255.0 * components[0])); |