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

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

Issue 1909453004: [Mac][Material Design] Adjust EV chip to match Material Design spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/ev_bubble_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm b/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
index 0547d31263d4c6743a557055be5c0b5c770ca383..ea894c30e90a253a2e159c75a8b9367708b6f860 100644
--- a/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.mm
@@ -7,8 +7,10 @@
#import "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
+#import "chrome/browser/ui/cocoa/themed_window.h"
#include "grit/theme_resources.h"
#include "skia/ext/skia_utils_mac.h"
+#import "ui/base/cocoa/nsview_additions.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/font_list.h"
@@ -16,6 +18,9 @@
namespace {
+// This is used to increase the right margin of this decoration.
+const CGFloat kRightSideMargin = 1.0;
+
// TODO(shess): In general, decorations that don't fit in the
// available space are omitted. This one never goes to omitted, it
// sticks at 150px, which AFAICT follows the Windows code. Since the
@@ -54,6 +59,10 @@ EVBubbleDecoration::EVBubbleDecoration(LocationIconDecoration* location_icon)
: location_icon_(location_icon) {
if (ui::MaterialDesignController::IsModeMaterial()) {
SetTextColor(GetBackgroundBorderColor());
+ // The EV chip text in Material Design uses a slightly smaller font than the
+ // default, and has to be moved down slightly.
+ SetFont([NSFont systemFontOfSize:11]);
tapted 2016/04/22 00:41:52 `const int kMaterialFontSize = 11;` in the anon na
shrike 2016/04/26 18:03:40 I think kMaterialFontSize is best - the spec calls
tapted 2016/04/27 02:37:39 hehe - specs tend not to consider that users can "
+ SetBaselineOffset(1);
} else {
// Color tuples stolen from location_bar_view_gtk.cc.
SetTextColor(ColorWithRGBBytes(0x07, 0x95, 0x00));
@@ -71,6 +80,46 @@ void EVBubbleDecoration::SetFullLabel(NSString* label) {
SetLabel(full_label_);
}
+void EVBubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame,
+ NSRect frame,
+ NSView* control_view) {
+ if (!ui::MaterialDesignController::IsModeMaterial()) {
+ BubbleDecoration::DrawWithBackgroundInFrame(background_frame,
+ frame,
+ control_view);
+ return;
+ }
+
+ NSRect rect = NSInsetRect(background_frame, 0, 3);
+ rect.size.width -= kRightSideMargin;
+
+ CGFloat lineWidth = [control_view cr_lineWidth];
tapted 2016/04/22 00:41:52 nit: since this isn't between @implementation/@end
shrike 2016/04/26 18:03:40 Done.
+ bool inDarkMode = [[control_view window] inIncognitoModeWithSystemTheme];
+ // Only adjust the path rect by 1/2 the line width if it's going to be
+ // stroked (so that the stroke lines fall along pixel lines).
+ if (!inDarkMode) {
+ rect = NSInsetRect(rect, lineWidth / 2., lineWidth / 2.);
+ }
+ NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:rect
+ xRadius:2
tapted 2016/04/22 00:41:52 `const CFGloat kMaterialBorderRadius = 2;` in anon
shrike 2016/04/26 18:03:40 Done.
+ yRadius:2];
+ [path setLineWidth:lineWidth];
+ if (inDarkMode) {
+ [[NSColor whiteColor] set];
+ [path fill];
+ } else {
+ [[NSColor colorWithCalibratedRed:46 / 255.
tapted 2016/04/22 00:41:52 This will use the wrong colorspace (assuming the v
shrike 2016/04/22 05:46:30 The comment you quote is only in reference to colo
tapted 2016/04/22 06:09:48 If it's left as is the color will be wrong, see e.
shrike 2016/04/22 06:24:15 Yes, you are correct the color will be wrong. But
tapted 2016/04/25 21:48:10 Ah, yep - definitely go for consistency with the e
shrike 2016/04/26 18:03:40 In Cocoa I call NSImageFromImageSkia() to convert
+ green:135 / 255.
+ blue:50 / 255.
+ alpha:0.05] set];
+ [path fill];
+ [GetBackgroundBorderColor() set];
+ [path stroke];
+ }
+
+ DrawInFrame(frame, control_view);
+}
+
NSPoint EVBubbleDecoration::GetBubblePointInFrame(NSRect frame) {
NSRect image_rect = GetImageRectInFrame(frame);
return NSMakePoint(NSMidX(image_rect),

Powered by Google App Engine
This is Rietveld 408576698