| Index: chrome/browser/ui/cocoa/tabs/tab_view.mm
|
| diff --git a/chrome/browser/ui/cocoa/tabs/tab_view.mm b/chrome/browser/ui/cocoa/tabs/tab_view.mm
|
| index 3804cfa6e64268254a1c1f0da9010bfc88d5640b..6263deaac59aa2e18f53e08d48567e9ddcf30c44 100644
|
| --- a/chrome/browser/ui/cocoa/tabs/tab_view.mm
|
| +++ b/chrome/browser/ui/cocoa/tabs/tab_view.mm
|
| @@ -80,6 +80,10 @@ @interface TabHeavyImageMaker : TabImageMaker
|
| + (void)setTabEdgeStrokeColor;
|
| @end
|
|
|
| +@interface TabHeavyInvertedImageMaker : TabImageMaker
|
| ++ (void)setTabEdgeStrokeColor;
|
| +@end
|
| +
|
| @interface TabController(Private)
|
| // The TabView's close button.
|
| - (HoverCloseButton*)closeButton;
|
| @@ -92,8 +96,20 @@ - (HoverCloseButton*)closeButton;
|
| enum StrokeType {
|
| STROKE_NORMAL,
|
| STROKE_HEAVY,
|
| + STROKE_HEAVY_INVERTED,
|
| };
|
|
|
| +Class drawingClassForStrokeType(StrokeType stroke_type) {
|
| + switch (stroke_type) {
|
| + case STROKE_NORMAL:
|
| + return [TabImageMaker class];
|
| + case STROKE_HEAVY:
|
| + return [TabHeavyImageMaker class];
|
| + case STROKE_HEAVY_INVERTED:
|
| + return [TabHeavyInvertedImageMaker class];
|
| + }
|
| +}
|
| +
|
| NSImage* imageForResourceID(int resource_id, StrokeType stroke_type) {
|
| CGFloat imageWidth = resource_id == IDR_TAB_ACTIVE_CENTER ? 1 : 18;
|
| SEL theSelector = 0;
|
| @@ -120,8 +136,7 @@ - (HoverCloseButton*)closeButton;
|
| }
|
| DCHECK(theSelector);
|
|
|
| - Class makerClass = stroke_type == STROKE_HEAVY ? [TabHeavyImageMaker class]
|
| - : [TabImageMaker class];
|
| + Class makerClass = drawingClassForStrokeType(stroke_type);
|
| base::scoped_nsobject<NSCustomImageRep> imageRep([[NSCustomImageRep alloc]
|
| initWithDrawSelector:theSelector
|
| delegate:makerClass]);
|
| @@ -154,8 +169,20 @@ - (HoverCloseButton*)closeButton;
|
| (imageForResourceID(IDR_TAB_ACTIVE_LEFT, STROKE_HEAVY),
|
| imageForResourceID(IDR_TAB_ACTIVE_CENTER, STROKE_HEAVY),
|
| imageForResourceID(IDR_TAB_ACTIVE_RIGHT, STROKE_HEAVY)));
|
| -
|
| - return stroke_type == STROKE_HEAVY ? heavyStroke : stroke;
|
| + CR_DEFINE_STATIC_LOCAL(
|
| + ui::ThreePartImage, heavyInvertedStroke,
|
| + (imageForResourceID(IDR_TAB_ACTIVE_LEFT, STROKE_HEAVY_INVERTED),
|
| + imageForResourceID(IDR_TAB_ACTIVE_CENTER, STROKE_HEAVY_INVERTED),
|
| + imageForResourceID(IDR_TAB_ACTIVE_RIGHT, STROKE_HEAVY_INVERTED)));
|
| +
|
| + switch (stroke_type) {
|
| + case STROKE_NORMAL:
|
| + return stroke;
|
| + case STROKE_HEAVY:
|
| + return heavyStroke;
|
| + case STROKE_HEAVY_INVERTED:
|
| + return heavyInvertedStroke;
|
| + }
|
| }
|
|
|
| CGFloat LineWidthFromContext(CGContextRef context) {
|
| @@ -521,10 +548,12 @@ - (void)drawStroke:(NSRect)dirtyRect {
|
| clipRect.origin.y += [self cr_lineWidth];
|
| NSRectClip(clipRect);
|
| const ui::ThemeProvider* provider = [[self window] themeProvider];
|
| - GetStrokeImage(state_ == NSOnState,
|
| - provider && provider->ShouldIncreaseContrast()
|
| - ? STROKE_HEAVY
|
| - : STROKE_NORMAL)
|
| + StrokeType stroke_type = STROKE_NORMAL;
|
| + if (provider && provider->ShouldIncreaseContrast()) {
|
| + stroke_type =
|
| + [[self window] hasDarkTheme] ? STROKE_HEAVY_INVERTED : STROKE_HEAVY;
|
| + }
|
| + GetStrokeImage(state_ == NSOnState, stroke_type)
|
| .DrawInRect(bounds, NSCompositeSourceOver, alpha);
|
| }
|
|
|
| @@ -1032,3 +1061,17 @@ + (void)setTabEdgeStrokeColor {
|
| }
|
|
|
| @end
|
| +
|
| +@implementation TabHeavyInvertedImageMaker
|
| +
|
| +// For "Increase Contrast" mode, when using a dark theme, the stroke should be
|
| +// drawn in flat white instead of flat black. There is normally no need to
|
| +// special-case this since the lower-contrast border is equally visible in light
|
| +// or dark themes.
|
| ++ (void)setTabEdgeStrokeColor {
|
| + static NSColor* heavyStrokeColor =
|
| + [skia::SkColorToSRGBNSColor(SK_ColorWHITE) retain];
|
| + [heavyStrokeColor set];
|
| +}
|
| +
|
| +@end
|
|
|