Index: chrome/browser/ui/cocoa/history_overlay_controller.mm |
diff --git a/chrome/browser/ui/cocoa/history_overlay_controller.mm b/chrome/browser/ui/cocoa/history_overlay_controller.mm |
index 88237a3c6f771d1cc37f5bb940f9d954df5a9270..005913b7fc007e631552059b92c2d165df7ad77b 100644 |
--- a/chrome/browser/ui/cocoa/history_overlay_controller.mm |
+++ b/chrome/browser/ui/cocoa/history_overlay_controller.mm |
@@ -5,6 +5,7 @@ |
#import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
#include "base/logging.h" |
+#include "base/mac/scoped_cftyperef.h" |
#import "chrome/browser/ui/cocoa/browser_window_controller.h" |
#include "grit/theme_resources.h" |
#include "ui/base/resource/resource_bundle.h" |
@@ -52,6 +53,10 @@ const CGFloat kShieldHeightCompletionAdjust = 10; |
if ((self = [super initWithFrame:frame])) { |
mode_ = mode; |
+ // A layer-hosting view. |
+ [self setLayer:[CALayer layer]]; |
+ [self setWantsLayer:YES]; |
+ |
// If going backward, the arrow needs to be in the right half of the circle, |
// so offset the X position. |
CGFloat offset = mode_ == kHistoryOverlayModeBack ? kShieldRadius : 0; |
@@ -67,11 +72,18 @@ const CGFloat kShieldHeightCompletionAdjust = 10; |
return self; |
} |
-- (void)drawRect:(NSRect)dirtyRect { |
- NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:self.bounds]; |
- NSColor* fillColor = [NSColor colorWithCalibratedWhite:0 alpha:shieldAlpha_]; |
- [fillColor set]; |
- [path fill]; |
+- (void)setFrameSize:(CGSize)frameSize { |
+ [super setFrameSize:frameSize]; |
+ // Draw an oval. |
+ CGFloat radius = std::min(frameSize.width, frameSize.height) / 2.0; |
Robert Sesek
2015/02/04 00:21:13
Why min here instead of just always width?
Andre
2015/02/04 01:08:55
height >= width always, so that would work.
Done.
|
+ [[self layer] setCornerRadius:radius]; |
+} |
+ |
+- (void)setShieldAlpha:(CGFloat)shieldAlpha { |
+ shieldAlpha_ = shieldAlpha; |
+ base::ScopedCFTypeRef<CGColorRef> fillColor( |
+ CGColorCreateGenericGray(0, shieldAlpha)); |
+ [[self layer] setBackgroundColor:fillColor]; |
} |
@end |
@@ -129,7 +141,6 @@ const CGFloat kShieldHeightCompletionAdjust = 10; |
self.view.frame = frame; |
[contentView_ setShieldAlpha:shieldAlpha]; |
- [contentView_ setNeedsDisplay:YES]; |
} |
- (void)showPanelForView:(NSView*)view { |