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

Unified Diff: chrome/browser/ui/cocoa/background_gradient_view.mm

Issue 900613003: Mac: Make it easier for views to correctly draw with a theme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gyp
Patch Set: Created 5 years, 11 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
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..fe583563d12c82fd1f9bb6e30227a9a59cf11d58 100644
--- a/chrome/browser/ui/cocoa/background_gradient_view.mm
+++ b/chrome/browser/ui/cocoa/background_gradient_view.mm
@@ -111,43 +111,14 @@
return themeProvider->GetNSImageColorNamed(IDR_THEME_TOOLBAR);
}
-- (void)windowFocusDidChange:(NSNotification*)notification {
- // Some child views will indirectly use BackgroundGradientView by calling an
- // ancestor's draw function (e.g, BookmarkButtonView). Call setNeedsDisplay
- // on all descendants to ensure that these views re-draw.
- // TODO(ccameron): Enable these views to listen for focus notifications
- // directly.
- [self cr_recursivelySetNeedsDisplay:YES];
-}
-
-- (void)viewWillMoveToWindow:(NSWindow*)window {
+- (void)viewDidMoveToWindow {
Andre 2015/02/03 19:20:37 Views usually call [[self window] isMainWindow] wh
+ [super viewDidMoveToWindow];
if ([self window]) {
- [[NSNotificationCenter defaultCenter]
- removeObserver:self
- name:NSWindowDidBecomeKeyNotification
- object:[self window]];
- [[NSNotificationCenter defaultCenter]
- removeObserver:self
- name:NSWindowDidBecomeMainNotification
- object:[self window]];
- }
- if (window) {
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(windowFocusDidChange:)
- name:NSWindowDidBecomeMainNotification
- object:window];
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(windowFocusDidChange:)
- name:NSWindowDidResignMainNotification
- object:window];
// The new window for the view may have a different focus state than the
// last window this view was part of. Force a re-draw to ensure that the
// view draws the right state.
- [self windowFocusDidChange:nil];
+ [self windowDidChangeActive];
}
- [super viewWillMoveToWindow:window];
}
- (void)setFrameOrigin:(NSPoint)origin {
@@ -159,4 +130,14 @@
[super setFrameOrigin:origin];
}
+// ThemedWindowDrawing implementation.
+
+- (void)windowDidChangeTheme {
+ [self setNeedsDisplay:YES];
+}
+
+- (void)windowDidChangeActive {
+ [self setNeedsDisplay:YES];
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698