Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6560)

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_view.mm

Issue 18486007: Fix the misalignment on CrOS of the tab background images (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm ('k') | chrome/browser/ui/cocoa/themed_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e4271e259f3474d02f46c9478764ecfd08b7377b..d4abeb38ea361716baef34b35c4056ac74c05756 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_view.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_view.mm
@@ -302,6 +302,12 @@ const CGFloat kRapidCloseDist = 2.5;
// Draws the active tab background.
- (void)drawFillForActiveTab:(NSRect)dirtyRect {
+ gfx::ScopedNSGraphicsContextSaveGState scopedGState;
+ NSGraphicsContext* context = [NSGraphicsContext currentContext];
+ NSPoint position = [[self window]
+ themeImagePositionForAlignment:THEME_IMAGE_ALIGN_WITH_TAB_STRIP];
+ [context cr_setPatternPhase:position forView:self];
+
NSColor* backgroundImageColor = [self backgroundColorForSelected:YES];
[backgroundImageColor set];
@@ -323,9 +329,6 @@ const CGFloat kRapidCloseDist = 2.5;
ThemeService* themeProvider =
static_cast<ThemeService*>([[self window] themeProvider]);
- NSPoint position = [[self window]
- themeImagePositionForAlignment: THEME_IMAGE_ALIGN_WITH_TAB_STRIP];
- [context cr_setPatternPhase:position forView:self];
CGImageRef mask([self tabClippingMask]);
CGRect maskBounds = CGRectMake(0, 0, maskCacheWidth_, kMaskHeight);
@@ -342,7 +345,10 @@ const CGFloat kRapidCloseDist = 2.5;
if (dirtyRect.origin.y < 1)
dirtyRect.origin.y = 2 * [self cr_lineWidth];
- // Draw the tab background.
+ // Draw the tinted frame image.
+ NSPoint position = [[self window]
+ themeImagePositionForAlignment:THEME_IMAGE_ALIGN_WITH_FRAME];
+ [context cr_setPatternPhase:position forView:self];
NSColor* backgroundImageColor = [self backgroundColorForSelected:NO];
[backgroundImageColor set];
@@ -354,6 +360,22 @@ const CGFloat kRapidCloseDist = 2.5;
else
NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
+ // If the theme is not the default theme, it may provide a custom overlay
+ // image. The overlay image is aligned with the top of the tab.
+ NSColor* overlayImageColor = nil;
+ if (themeProvider &&
+ themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND_OVERLAY)) {
+ overlayImageColor = themeProvider->GetNSImageColorNamed(
+ IDR_THEME_TAB_BACKGROUND_OVERLAY);
+ }
+ if (overlayImageColor) {
+ position = [[self window]
+ themeImagePositionForAlignment:THEME_IMAGE_ALIGN_WITH_TAB_STRIP];
+ [context cr_setPatternPhase:position forView:self];
+ [overlayImageColor set];
+ NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
+ }
+
// Draw the glow for hover and the overlay for alerts.
CGFloat hoverAlpha = [self hoverAlpha];
CGFloat alertAlpha = [self alertAlpha];
@@ -374,7 +396,7 @@ const CGFloat kRapidCloseDist = 2.5;
// theme machinery will make one if given a frame image. See
// BrowserThemePack::GenerateTabBackgroundImages for details.
BOOL hasCustomTheme = themeProvider &&
- (themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND) ||
+ (themeProvider->HasCustomImage(IDR_THEME_TAB_BACKGROUND_OVERLAY) ||
themeProvider->HasCustomImage(IDR_THEME_FRAME));
// Draw a mouse hover gradient for the default themes.
if (hoverAlpha > 0) {
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm ('k') | chrome/browser/ui/cocoa/themed_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698