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

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

Issue 1990703002: [Material][Mac] Update Omnibox bubble decorations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm b/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
index 7bdd563e1a2d4fc05c0886bf054690ea4f26ae8e..66fcdd40fc6a92c5ce417ac0197a4827396d6438 100644
--- a/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/bubble_decoration.mm
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
+#include "skia/ext/skia_utils_mac.h"
#import "ui/base/cocoa/nsview_additions.h"
#include "ui/base/material_design/material_design_controller.h"
@@ -19,9 +20,15 @@ const CGFloat kRightSideMargin = 1.0;
// Padding between the icon/label and bubble edges.
CGFloat BubblePadding() {
- return ui::MaterialDesignController::IsModeMaterial() ? 7 : 3;
+ return ui::MaterialDesignController::IsModeMaterial() ? 8.0 : 3.0;
}
+// Additional padding between the divider between the omnibox text and the
+// divider. The desired value is 8px. We get 3px by subtracting the existing
+// padding in location_bar_view from 8px.
+CGFloat DividerPadding() {
+ return ui::MaterialDesignController::IsModeMaterial() ? 3.0 : 0.0;
+}
// Padding between the icon and label.
const CGFloat kIconLabelPadding = 4.0;
@@ -54,7 +61,8 @@ CGFloat BubbleDecoration::GetWidthForImageAndLabel(NSImage* image,
// underestimate, so floor() seems to work better.
const CGFloat label_width =
std::floor([label sizeWithAttributes:attributes_].width);
- return BubblePadding() + image_width + kIconLabelPadding + label_width;
+ return BubblePadding() + image_width + kIconLabelPadding + label_width +
+ DividerPadding();
}
NSRect BubbleDecoration::GetImageRectInFrame(NSRect frame) {
@@ -100,6 +108,26 @@ void BubbleDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
textOffset = NSMaxX(imageRect) + kIconLabelPadding;
}
+ // Draw the divider and set the text color.
+ if (ui::MaterialDesignController::IsModeMaterial()) {
+ NSBezierPath* line = [NSBezierPath bezierPath];
+ [line setLineWidth:1];
+ [line moveToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(),
+ NSMinY(decoration_frame))];
+ [line lineToPoint:NSMakePoint(NSMaxX(decoration_frame) - DividerPadding(),
+ NSMaxY(decoration_frame))];
+
+ bool in_dark_mode = [[control_view window] inIncognitoModeWithSystemTheme];
+ [GetDividerColor(in_dark_mode) set];
+ [line stroke];
+
+ NSColor* text_color =
+ in_dark_mode
+ ? skia::SkColorToCalibratedNSColor(kMaterialDarkModeTextColor)
+ : GetBackgroundBorderColor();
+ SetTextColor(text_color);
+ }
+
if (label_) {
NSRect textRect = frame;
textRect.origin.x = textOffset;
@@ -114,22 +142,7 @@ void BubbleDecoration::DrawWithBackgroundInFrame(NSRect background_frame,
NSView* control_view) {
NSRect rect = NSInsetRect(background_frame, 0, 1);
rect.size.width -= kRightSideMargin;
- if (ui::MaterialDesignController::IsModeMaterial()) {
- CGFloat lineWidth = [control_view cr_lineWidth];
- rect = NSInsetRect(rect, lineWidth / 2., lineWidth / 2.);
- NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:rect
- xRadius:3
- yRadius:3];
- [path setLineWidth:lineWidth];
- bool inDarkMode = [[control_view window] inIncognitoModeWithSystemTheme];
- if (inDarkMode) {
- [[NSColor whiteColor] set];
- [path fill];
- } else {
- [GetBackgroundBorderColor() set];
- [path stroke];
- }
- } else {
+ if (!ui::MaterialDesignController::IsModeMaterial()) {
ui::DrawNinePartImage(
rect, GetBubbleImageIds(), NSCompositeSourceOver, 1.0, true);
}
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698