diff options
Diffstat (limited to 'chrome/browser/cocoa/tab_cell.mm')
-rw-r--r-- | chrome/browser/cocoa/tab_cell.mm | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/tab_cell.mm b/chrome/browser/cocoa/tab_cell.mm index 088f848..fcb398b 100644 --- a/chrome/browser/cocoa/tab_cell.mm +++ b/chrome/browser/cocoa/tab_cell.mm @@ -10,6 +10,38 @@ #define CP1_MULTIPLIER 1.0/3.0 #define CP2_MULTIPLIER 3.0/8.0 +namespace { + NSGradient *getGradientForStyle(bool selected, bool active) { + // Workaround for + // rdar://6857649 - NSGradient fails when using LAB Colorspace + // Once that's fixed we can remove this function and just call through + // to -[GTMTheme gradientForStyle:active:] directly with + // GTMThemeStyleTabBarSelected/GTMThemeStyleTabBarDeselected + NSUInteger startHighlight, endHighlight; + if (selected) { + startHighlight = GTMColorationLightHighlight; + endHighlight = GTMColorationLightMidtone; + } else { + startHighlight = GTMColorationBaseShadow; + endHighlight = GTMColorationBaseShadow; + } + + NSColor *backgroundColor = [[GTMTheme defaultTheme] backgroundColor]; + NSColor *startColor = [backgroundColor gtm_colorAdjustedFor:startHighlight + faded:!active]; + NSColor *endColor = [backgroundColor gtm_colorAdjustedFor:endHighlight + faded:!active]; + NSColorSpace *genericRGB = [NSColorSpace genericRGBColorSpace]; + startColor = [startColor colorUsingColorSpace:genericRGB]; + endColor = [endColor colorUsingColorSpace:genericRGB]; + + return [[[NSGradient alloc] initWithStartingColor:startColor + endingColor:endColor] + autorelease]; + + } +} // namespace + @implementation TabCell - (id)initTextCell:(NSString *)aString { @@ -75,12 +107,10 @@ [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y)]; [path lineToPoint:NSMakePoint(bottomRight.x + 1, bottomRight.y + 1)]; - GTMTheme *theme = [GTMTheme defaultTheme]; NSGradient *gradient = nil; if (selected) { - gradient = [theme gradientForStyle:GTMThemeStyleTabBarSelected - active:active]; + gradient = getGradientForStyle(true, active); // Stroke with a translucent black [[NSColor colorWithCalibratedWhite:0.0 alpha:active ? 0.5 : 0.3] set]; [[NSGraphicsContext currentContext] saveGraphicsState]; @@ -90,8 +120,7 @@ [path fill]; [[NSGraphicsContext currentContext] restoreGraphicsState]; } else { - gradient = [theme gradientForStyle:GTMThemeStyleTabBarDeselected - active:active]; + gradient = getGradientForStyle(false, active); // Stroke with a translucent black [[NSColor colorWithCalibratedWhite:0.0 alpha:active ? 0.3 : 0.1] set]; } |