Chromium Code Reviews| Index: chrome/browser/ui/cocoa/background_gradient_view.mm |
| diff --git a/chrome/browser/ui/cocoa/background_gradient_view.mm b/chrome/browser/ui/cocoa/background_gradient_view.mm |
| index 1cb6c2f6b56d21cb76dc4d6955eba1417a48e38c..684759399cd96b942b3cb9a7d8e7c2c70be3d170 100644 |
| --- a/chrome/browser/ui/cocoa/background_gradient_view.mm |
| +++ b/chrome/browser/ui/cocoa/background_gradient_view.mm |
| @@ -124,11 +124,11 @@ |
| if ([self window]) { |
| [[NSNotificationCenter defaultCenter] |
| removeObserver:self |
| - name:NSWindowDidBecomeKeyNotification |
| + name:NSWindowDidBecomeMainNotification |
| object:[self window]]; |
| [[NSNotificationCenter defaultCenter] |
| removeObserver:self |
|
Andre
2015/01/31 01:00:48
This looks like a bug.
|
| - name:NSWindowDidBecomeMainNotification |
| + name:NSWindowDidResignMainNotification |
| object:[self window]]; |
| } |
| if (window) { |
| @@ -150,10 +150,39 @@ |
| [super viewWillMoveToWindow:window]; |
| } |
| +- (void)viewWillStartLiveResize { |
| + [super viewWillStartLiveResize]; |
| + |
| + ui::ThemeProvider* themeProvider = [[self window] themeProvider]; |
| + if (themeProvider && themeProvider->UsingSystemTheme()) { |
| + // The default theme's background image is a subtle texture pattern that |
| + // we can scale without being easily noticed. Optimize this case by |
| + // skipping redraws during live resize. |
| + [self setLayerContentsRedrawPolicy: |
| + NSViewLayerContentsRedrawOnSetNeedsDisplay]; |
|
Robert Sesek
2015/02/02 19:32:16
nit: over-indented
Andre
2015/02/02 21:40:08
Done.
|
| + } |
| +} |
| + |
| +- (void)viewDidEndLiveResize { |
| + [super viewDidEndLiveResize]; |
| + |
| + if ([self layerContentsRedrawPolicy] != |
| + NSViewLayerContentsRedrawDuringViewResize) { |
| + // If we have been scaling the layer during live resize, now is the time to |
| + // redraw the layer. |
| + [self setLayerContentsRedrawPolicy: |
| + NSViewLayerContentsRedrawDuringViewResize]; |
| + [self setNeedsDisplay:YES]; |
| + } |
| +} |
| + |
| - (void)setFrameOrigin:(NSPoint)origin { |
| // The background color depends on the view's vertical position. This impacts |
| // any child views that draw using this view's functions. |
| - if (NSMinY([self frame]) != origin.y) |
| + // When resizing the window, the view's vertical position (NSMinY) may change |
| + // even though our relative position to the nearest window edge is still the |
| + // same. Don't redraw unnecessarily in this case. |
| + if (![self inLiveResize] && NSMinY([self frame]) != origin.y) |
| [self cr_recursivelySetNeedsDisplay:YES]; |
| [super setFrameOrigin:origin]; |