Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/cocoa/background_gradient_view.h" | 5 #include "chrome/browser/ui/cocoa/background_gradient_view.h" |
| 6 | 6 |
| 7 #import "chrome/browser/themes/theme_properties.h" | 7 #import "chrome/browser/themes/theme_properties.h" |
| 8 #import "chrome/browser/themes/theme_service.h" | 8 #import "chrome/browser/themes/theme_service.h" |
| 9 #import "chrome/browser/ui/cocoa/themed_window.h" | 9 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 - (void)viewDidMoveToWindow { | 114 - (void)viewDidMoveToWindow { |
| 115 [super viewDidMoveToWindow]; | 115 [super viewDidMoveToWindow]; |
| 116 if ([self window]) { | 116 if ([self window]) { |
| 117 // The new window for the view may have a different focus state than the | 117 // The new window for the view may have a different focus state than the |
| 118 // last window this view was part of. Force a re-draw to ensure that the | 118 // last window this view was part of. Force a re-draw to ensure that the |
| 119 // view draws the right state. | 119 // view draws the right state. |
| 120 [self windowDidChangeActive]; | 120 [self windowDidChangeActive]; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 - (void)viewWillStartLiveResize { | |
| 125 [super viewWillStartLiveResize]; | |
| 126 | |
| 127 ui::ThemeProvider* themeProvider = [[self window] themeProvider]; | |
| 128 if (themeProvider && themeProvider->UsingSystemTheme()) { | |
| 129 // The default theme's background image is a subtle texture pattern that | |
| 130 // we can scale without being easily noticed. Optimize this case by | |
| 131 // skipping redraws during live resize. | |
| 132 [self setLayerContentsRedrawPolicy: | |
| 133 NSViewLayerContentsRedrawOnSetNeedsDisplay]; | |
|
Robert Sesek
2015/02/04 16:13:49
nit: over-indented
Andre
2015/02/04 16:46:26
clang format wanted it that way, it's indenting fr
Robert Sesek
2015/02/04 16:54:56
The most recent patch set is correct. I don't thin
| |
| 134 } | |
| 135 } | |
| 136 | |
| 137 - (void)viewDidEndLiveResize { | |
| 138 [super viewDidEndLiveResize]; | |
| 139 | |
| 140 if ([self layerContentsRedrawPolicy] != | |
| 141 NSViewLayerContentsRedrawDuringViewResize) { | |
| 142 // If we have been scaling the layer during live resize, now is the time to | |
| 143 // redraw the layer. | |
| 144 [self | |
| 145 setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize]; | |
| 146 [self setNeedsDisplay:YES]; | |
| 147 } | |
| 148 } | |
| 149 | |
| 124 - (void)setFrameOrigin:(NSPoint)origin { | 150 - (void)setFrameOrigin:(NSPoint)origin { |
| 125 // The background color depends on the view's vertical position. This impacts | 151 // The background color depends on the view's vertical position. This impacts |
| 126 // any child views that draw using this view's functions. | 152 // any child views that draw using this view's functions. |
| 127 if (NSMinY([self frame]) != origin.y) | 153 // When resizing the window, the view's vertical position (NSMinY) may change |
| 154 // even though our relative position to the nearest window edge is still the | |
| 155 // same. Don't redraw unnecessarily in this case. | |
| 156 if (![self inLiveResize] && NSMinY([self frame]) != origin.y) | |
| 128 [self cr_recursivelySetNeedsDisplay:YES]; | 157 [self cr_recursivelySetNeedsDisplay:YES]; |
| 129 | 158 |
| 130 [super setFrameOrigin:origin]; | 159 [super setFrameOrigin:origin]; |
| 131 } | 160 } |
| 132 | 161 |
| 133 // ThemedWindowDrawing implementation. | 162 // ThemedWindowDrawing implementation. |
| 134 | 163 |
| 135 - (void)windowDidChangeTheme { | 164 - (void)windowDidChangeTheme { |
| 136 [self setNeedsDisplay:YES]; | 165 [self setNeedsDisplay:YES]; |
| 137 } | 166 } |
| 138 | 167 |
| 139 - (void)windowDidChangeActive { | 168 - (void)windowDidChangeActive { |
| 140 [self setNeedsDisplay:YES]; | 169 [self setNeedsDisplay:YES]; |
| 141 } | 170 } |
| 142 | 171 |
| 143 @end | 172 @end |
| OLD | NEW |