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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm

Issue 1866523002: [Mac] Update location bar colors when change themes in Material Design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up for review. Created 4 years, 8 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/location_bar/autocomplete_text_field_editor.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
index 86303014acea83a5152c4932743979a40ed20563..ea6c9090e213bd016cf868434c9b9544cd772db7 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
@@ -69,29 +69,40 @@ BOOL ThePasteboardIsTooDamnBig() {
return self;
}
-- (void)viewDidMoveToWindow {
- // Only care about landing in a window when in Material Design mode.
- if (![self window] || !ui::MaterialDesignController::IsModeMaterial()) {
- return;
- }
-
- // Only care about Incognito mode with a non-custom theme.
- if (![[self window] inIncognitoModeWithSystemTheme]) {
+- (void)updateColorsToMatchTheme {
+ if (![[self window] inIncognitoMode]) {
return;
}
+ bool inDarkMode = [[self window] inIncognitoModeWithSystemTheme];
// Draw a light insertion point for MD Incognito.
- [self setInsertionPointColor:
- [NSColor colorWithCalibratedWhite:1 alpha:0.75]];
- // In MD Incognito the text is light gray against a dark background. When
- // selected, the light gray text against the selection color is illegible.
- // Rather than tweak or change the selection color, make the text black when
- // selected.
+ NSColor* insertionPointColor =
+ inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.75]
+ : [NSColor blackColor];
+ [self setInsertionPointColor:insertionPointColor];
+
NSColor* textSelectionColor = [NSColor selectedTextBackgroundColor];
- [self setSelectedTextAttributes:@{
- NSForegroundColorAttributeName : [NSColor blackColor],
- NSBackgroundColorAttributeName : textSelectionColor
- }];
+ if (inDarkMode) {
+ // In MD Incognito the text is light gray against a dark background. When
+ // selected, the light gray text against the selection color is illegible.
+ // Rather than tweak or change the selection color, make the text black when
+ // selected.
+ [self setSelectedTextAttributes:@{
+ NSForegroundColorAttributeName : [NSColor blackColor],
+ NSBackgroundColorAttributeName : textSelectionColor
+ }];
+ } else {
+ [self setSelectedTextAttributes:@{
+ NSBackgroundColorAttributeName : textSelectionColor
+ }];
+ }
+}
+
+- (void)viewDidMoveToWindow {
+ // Only care about landing in a window when in Material Design mode.
+ if ([self window] && ui::MaterialDesignController::IsModeMaterial()) {
+ [self updateColorsToMatchTheme];
+ }
}
// If the entire field is selected, drag the same data as would be
@@ -570,4 +581,16 @@ BOOL ThePasteboardIsTooDamnBig() {
observer->OnDidDrawRect();
}
+// ThemedWindowDrawing implementation.
+
+- (void)windowDidChangeTheme {
+ if (!ui::MaterialDesignController::IsModeMaterial()) {
+ return;
+ }
+ [self updateColorsToMatchTheme];
+}
+
+- (void)windowDidChangeActive {
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698