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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm

Issue 2241323002: [Material][Mac] Incognito Text Color Fix in the Omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <cmath> 5 #include <cmath>
6 6
7 #import "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" 7 #import "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Center the image vertically. 72 // Center the image vertically.
73 const NSSize imageSize = [image_ size]; 73 const NSSize imageSize = [image_ size];
74 74
75 imageRect.origin.y += 75 imageRect.origin.y +=
76 std::floor((NSHeight(frame) - imageSize.height) / 2.0); 76 std::floor((NSHeight(frame) - imageSize.height) / 2.0);
77 imageRect.size = imageSize; 77 imageRect.size = imageSize;
78 } 78 }
79 return imageRect; 79 return imageRect;
80 } 80 }
81 81
82 NSColor* BubbleDecoration::GetDarkModeTextColor() {
83 return skia::SkColorToSRGBNSColor(kMaterialDarkModeTextColor);
84 }
85
82 CGFloat BubbleDecoration::GetWidthForSpace(CGFloat width) { 86 CGFloat BubbleDecoration::GetWidthForSpace(CGFloat width) {
83 const CGFloat all_width = GetWidthForImageAndLabel(image_, label_); 87 const CGFloat all_width = GetWidthForImageAndLabel(image_, label_);
84 if (all_width <= width) 88 if (all_width <= width)
85 return all_width; 89 return all_width;
86 90
87 const CGFloat image_width = GetWidthForImageAndLabel(image_, nil); 91 const CGFloat image_width = GetWidthForImageAndLabel(image_, nil);
88 if (image_width <= width) 92 if (image_width <= width)
89 return image_width; 93 return image_width;
90 94
91 return kOmittedWidth; 95 return kOmittedWidth;
(...skipping 25 matching lines...) Expand all
117 [line moveToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(), 121 [line moveToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(),
118 NSMinY(decoration_frame))]; 122 NSMinY(decoration_frame))];
119 [line lineToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(), 123 [line lineToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(),
120 NSMaxY(decoration_frame))]; 124 NSMaxY(decoration_frame))];
121 125
122 bool in_dark_mode = [[control_view window] inIncognitoModeWithSystemTheme]; 126 bool in_dark_mode = [[control_view window] inIncognitoModeWithSystemTheme];
123 [GetDividerColor(in_dark_mode) set]; 127 [GetDividerColor(in_dark_mode) set];
124 [line stroke]; 128 [line stroke];
125 129
126 NSColor* text_color = 130 NSColor* text_color =
127 in_dark_mode 131 in_dark_mode ? GetDarkModeTextColor() : GetBackgroundBorderColor();
128 ? skia::SkColorToSRGBNSColor(kMaterialDarkModeTextColor)
129 : GetBackgroundBorderColor();
130 SetTextColor(text_color); 132 SetTextColor(text_color);
131 } 133 }
132 134
133 if (label_) { 135 if (label_) {
134 NSRect textRect = frame; 136 NSRect textRect = frame;
135 textRect.origin.x = textOffset; 137 textRect.origin.x = textOffset;
136 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect); 138 textRect.size.width = NSMaxX(decoration_frame) - NSMinX(textRect);
137 // Transform the coordinate system to adjust the baseline on Retina. This is 139 // Transform the coordinate system to adjust the baseline on Retina. This is
138 // the only way to get fractional adjustments. 140 // the only way to get fractional adjustments.
139 gfx::ScopedNSGraphicsContextSaveGState saveGraphicsState; 141 gfx::ScopedNSGraphicsContextSaveGState saveGraphicsState;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName]; 186 [attributes_ setObject:text_color forKey:NSForegroundColorAttributeName];
185 } 187 }
186 188
187 void BubbleDecoration::SetFont(NSFont* font) { 189 void BubbleDecoration::SetFont(NSFont* font) {
188 [attributes_ setObject:font forKey:NSFontAttributeName]; 190 [attributes_ setObject:font forKey:NSFontAttributeName];
189 } 191 }
190 192
191 void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) { 193 void BubbleDecoration::SetRetinaBaselineOffset(CGFloat offset) {
192 retina_baseline_offset_ = offset; 194 retina_baseline_offset_ = offset;
193 } 195 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/bubble_decoration.h ('k') | chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698