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

Side by Side Diff: chrome/browser/ui/cocoa/chrome_browser_window.mm

Issue 2068243002: [Mac][Material Design] Adjust cutoff for detecting a "dark" theme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import "chrome/browser/ui/cocoa/chrome_browser_window.h" 5 #import "chrome/browser/ui/cocoa/chrome_browser_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/themes/theme_properties.h" 8 #include "chrome/browser/themes/theme_properties.h"
9 #import "chrome/browser/ui/cocoa/themed_window.h" 9 #import "chrome/browser/ui/cocoa/themed_window.h"
10 #include "ui/base/theme_provider.h" 10 #include "ui/base/theme_provider.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // If the custom theme has a custom toolbar color, return YES if it's 59 // If the custom theme has a custom toolbar color, return YES if it's
60 // dark. 60 // dark.
61 if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TOOLBAR)) { 61 if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TOOLBAR)) {
62 NSColor* theColor = 62 NSColor* theColor =
63 themeProvider->GetNSColor(ThemeProperties::COLOR_TOOLBAR); 63 themeProvider->GetNSColor(ThemeProperties::COLOR_TOOLBAR);
64 theColor = 64 theColor =
65 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace]; 65 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace];
66 if (theColor != nil) { 66 if (theColor != nil) {
67 // The white componement cutoff is an empirical value. 67 // The white componement cutoff is an empirical value.
68 return [theColor whiteComponent] < 0.7; 68 return [theColor whiteComponent] < 0.55;
69 } 69 }
70 } 70 }
71 71
72 // If the custom theme has a custom tab text color, assume that a light 72 // If the custom theme has a custom tab text color, assume that a light
73 // color means a dark tab background image, and therefore a dark theme. 73 // color means a dark tab background image, and therefore a dark theme.
74 if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TAB_TEXT)) { 74 if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TAB_TEXT)) {
75 NSColor* theColor = 75 NSColor* theColor =
76 themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT); 76 themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT);
77 theColor = 77 theColor =
78 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace]; 78 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace];
79 if (theColor != nil) { 79 if (theColor != nil) {
80 return [theColor whiteComponent] >= 0.7; 80 return [theColor whiteComponent] >= 0.7;
tapted 2016/06/16 00:45:03 does this need to be changed too? but also these
shrike 2016/06/16 22:50:45 Thank you. And there need to be two numbers becaus
81 } 81 }
82 } 82 }
83 83
84 return NO; 84 return NO;
85 } 85 }
86 86
87 - (BOOL)hasKeyAppearance { 87 - (BOOL)hasKeyAppearance {
88 // If not key, but a non-main child window without its own traffic lights _is_ 88 // If not key, but a non-main child window without its own traffic lights _is_
89 // key, then show this window with key appearance to keep the traffic lights 89 // key, then show this window with key appearance to keep the traffic lights
90 // lit. This does not currently handle WebModal dialogs, since they are 90 // lit. This does not currently handle WebModal dialogs, since they are
91 // children of an overlay window. But WebModals also temporarily lose key 91 // children of an overlay window. But WebModals also temporarily lose key
92 // status while animating closed, so extra logic is needed to avoid flicker. 92 // status while animating closed, so extra logic is needed to avoid flicker.
93 // Start with an early exit, since this is called for every mouseMove and 93 // Start with an early exit, since this is called for every mouseMove and
94 // every cursor blink in an NSTextField. 94 // every cursor blink in an NSTextField.
95 if (![self isKeyWindow]) { 95 if (![self isKeyWindow]) {
96 for (NSWindow* child in [self childWindows]) { 96 for (NSWindow* child in [self childWindows]) {
97 if ([child isKeyWindow] && ![child isMainWindow] && 97 if ([child isKeyWindow] && ![child isMainWindow] &&
98 ([child styleMask] & NSClosableWindowMask) == 0) 98 ([child styleMask] & NSClosableWindowMask) == 0)
99 return YES; 99 return YES;
100 } 100 }
101 } 101 }
102 return [super hasKeyAppearance]; 102 return [super hasKeyAppearance];
103 } 103 }
104 104
105 @end 105 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698