| Index: chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm
|
| diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm
|
| index 49f9a0df1fa639660a01f6adf533dd1ff55a50dd..b981d7dda9ae2b14825791666b291913e66f7b86 100644
|
| --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm
|
| +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.mm
|
| @@ -4,6 +4,7 @@
|
|
|
| #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h"
|
|
|
| +#import "base/mac/scoped_nsobject.h"
|
| #include "grit/theme_resources.h"
|
| #import "ui/base/cocoa/nsview_additions.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| @@ -32,11 +33,40 @@
|
| return [shadowImage size].height;
|
| }
|
|
|
| +- (instancetype)initWithFrame:(NSRect)frame forDarkTheme:(BOOL)isDarkTheme {
|
| + if ((self = [self initWithFrame:frame])) {
|
| + isDarkTheme_ = isDarkTheme;
|
| + // For dark themes the OmniboxPopupBottomSeparatorView will render a shadow
|
| + // rather than blit a bitmap. Shadows are expensive to draw so use a layer
|
| + // to cache the result.
|
| + if (isDarkTheme_) {
|
| + [self setWantsLayer:YES];
|
| + }
|
| + }
|
| + return self;
|
| +}
|
| +
|
| - (void)drawRect:(NSRect)rect {
|
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| NSRect bounds = [self bounds];
|
|
|
| + if (isDarkTheme_) {
|
| + // There's an image for the shadow the Omnibox casts, but this shadow is
|
| + // an opaque mix of white and black, which makes it look strange against a
|
| + // dark NTP page. For dark mode, draw the shadow in code instead so that
|
| + // it has some transparency.
|
| + base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
|
| + [shadow setShadowBlurRadius:8];
|
| + [shadow setShadowColor:[NSColor blackColor]];
|
| + [shadow set];
|
| +
|
| + // Fill a rect that's out of view to get just the shadow it casts.
|
| + [[NSColor blackColor] set];
|
| + NSRectFill(NSMakeRect(-3, NSMaxY(bounds), NSWidth(bounds) + 6, 5));
|
| + return;
|
| + }
|
| +
|
| // Draw the shadow.
|
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| NSImage* shadowImage =
|
| rb.GetNativeImageNamed(IDR_OVERLAY_DROP_SHADOW).ToNSImage();
|
| [shadowImage drawInRect:bounds
|
|
|