Index: chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm |
diff --git a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm |
index 7eb9a3a4a275171ba7c574ca7cd1c2f3761c5ff6..67a49a644229682c8e667b5aaf08aa11a16f3a10 100644 |
--- a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm |
+++ b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm |
@@ -6,6 +6,7 @@ |
#include <utility> |
+#include "base/command_line.h" |
#include "base/mac/scoped_nsobject.h" |
#include "chrome/browser/devtools/devtools_window.h" |
#import "chrome/browser/themes/theme_properties.h" |
@@ -16,6 +17,8 @@ |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_observer.h" |
#include "content/public/browser/web_contents_view.h" |
+#include "ui/base/cocoa/animation_utils.h" |
+#include "ui/base/ui_base_switches.h" |
#include "ui/gfx/geometry/rect.h" |
using content::WebContents; |
@@ -73,6 +76,8 @@ class FullscreenObserver : public WebContentsObserver { |
@private |
TabContentsController* delegate_; // weak |
} |
+ |
+- (NSColor*)computeBackgroundColor; |
@end |
@implementation TabContentsContainerView |
@@ -80,6 +85,14 @@ class FullscreenObserver : public WebContentsObserver { |
- (id)initWithDelegate:(TabContentsController*)delegate { |
if ((self = [super initWithFrame:NSZeroRect])) { |
delegate_ = delegate; |
+ if (!CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kDisableCoreAnimation)) { |
+ ScopedCAActionDisabler disabler; |
+ base::scoped_nsobject<CALayer> layer([[CALayer alloc] init]); |
+ [layer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
+ [self setLayer:layer]; |
+ [self setWantsLayer:YES]; |
+ } |
} |
return self; |
} |
@@ -90,24 +103,28 @@ class FullscreenObserver : public WebContentsObserver { |
delegate_ = nil; |
} |
+// Fill with a dark tint of the new tab page's background color. This is |
+// only seen when the subview is sized specially for fullscreen tab capture. |
+- (NSColor*)computeBackgroundColor { |
+ NSColor* bgColor = nil; |
+ ThemeService* const theme = |
+ static_cast<ThemeService*>([[self window] themeProvider]); |
+ if (theme) |
+ bgColor = theme->GetNSColor(ThemeProperties::COLOR_NTP_BACKGROUND); |
+ if (!bgColor) |
+ bgColor = [[self window] backgroundColor]; |
+ const float kDarknessFraction = 0.80f; |
+ return [bgColor blendedColorWithFraction:kDarknessFraction |
+ ofColor:[NSColor blackColor]]; |
+} |
+ |
// Override -drawRect to fill the view with a solid color outside of the |
// subview's frame. |
- (void)drawRect:(NSRect)dirtyRect { |
NSView* const contentsView = |
[[self subviews] count] > 0 ? [[self subviews] objectAtIndex:0] : nil; |
if (!contentsView || !NSContainsRect([contentsView frame], dirtyRect)) { |
- // Fill with a dark tint of the new tab page's background color. This is |
- // only seen when the subview is sized specially for fullscreen tab capture. |
- NSColor* bgColor = nil; |
- ThemeService* const theme = |
- static_cast<ThemeService*>([[self window] themeProvider]); |
- if (theme) |
- bgColor = theme->GetNSColor(ThemeProperties::COLOR_NTP_BACKGROUND); |
- if (!bgColor) |
- bgColor = [[self window] backgroundColor]; |
- const float kDarknessFraction = 0.80f; |
- [[bgColor blendedColorWithFraction:kDarknessFraction |
- ofColor:[NSColor blackColor]] setFill]; |
+ [[self computeBackgroundColor] setFill]; |
NSRectFill(dirtyRect); |
} |
[super drawRect:dirtyRect]; |
@@ -125,6 +142,24 @@ class FullscreenObserver : public WebContentsObserver { |
[contentsView setFrame:[delegate_ frameForContentsView]]; |
} |
+// Update the background layer's color whenever the view needs to repaint. |
+- (void)setNeedsDisplayInRect:(NSRect)rect { |
+ [super setNeedsDisplayInRect:rect]; |
+ |
ccameron
2014/04/19 02:45:29
[NSColor CGColor] is a 10.8+ function.
Not sure i
Avi (use Gerrit)
2014/04/19 19:30:49
That's fine. With 10.6, they changed things so tha
|
+ // Convert from an NSColor to a CGColorRef. |
+ NSColor* nsBackgroundColor = [self computeBackgroundColor]; |
+ NSColorSpace* nsColorSpace = [nsBackgroundColor colorSpace]; |
+ CGColorSpaceRef cgColorSpace = [nsColorSpace CGColorSpace]; |
+ const NSInteger numberOfComponents = [nsBackgroundColor numberOfComponents]; |
+ CGFloat components[numberOfComponents]; |
+ [nsBackgroundColor getComponents:components]; |
+ CGColorRef cgBackgroundColor = CGColorCreate(cgColorSpace, components); |
Avi (use Gerrit)
2014/04/19 19:30:49
ScopedCFObject if you must go this route.
ccameron
2014/04/19 22:21:39
Done.
|
+ |
+ ScopedCAActionDisabler disabler; |
+ [[self layer] setBackgroundColor:cgBackgroundColor]; |
+ CGColorRelease(cgBackgroundColor); |
+} |
+ |
@end // @implementation TabContentsContainerView |
@implementation TabContentsController |