summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/image_button_cell.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui/cocoa/image_button_cell.mm')
-rw-r--r--chrome/browser/ui/cocoa/image_button_cell.mm24
1 files changed, 8 insertions, 16 deletions
diff --git a/chrome/browser/ui/cocoa/image_button_cell.mm b/chrome/browser/ui/cocoa/image_button_cell.mm
index 1b43e70..ac15515 100644
--- a/chrome/browser/ui/cocoa/image_button_cell.mm
+++ b/chrome/browser/ui/cocoa/image_button_cell.mm
@@ -5,7 +5,6 @@
#import "chrome/browser/ui/cocoa/image_button_cell.h"
#include "base/logging.h"
-#include "base/mac/mac_util.h"
#import "chrome/browser/themes/theme_service.h"
#import "chrome/browser/ui/cocoa/rect_path_utils.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
@@ -84,16 +83,12 @@ const CGFloat kImageNoFocusAlpha = 0.65;
}
}
- [ImageButtonCell drawImage:image inRect:cellFrame alpha:alpha];
-}
-
-+ (void)drawImage:(NSImage*)image inRect:(NSRect)dstRect alpha:(CGFloat)alpha {
NSRect imageRect;
imageRect.size = [image size];
- imageRect.origin.x =
- dstRect.origin.x + roundf((NSWidth(dstRect) - NSWidth(imageRect)) / 2.0);
- imageRect.origin.y = dstRect.origin.y +
- roundf((NSHeight(dstRect) - NSHeight(imageRect)) / 2.0);
+ imageRect.origin.x = cellFrame.origin.x +
+ roundf((NSWidth(cellFrame) - NSWidth(imageRect)) / 2.0);
+ imageRect.origin.y = cellFrame.origin.y +
+ roundf((NSHeight(cellFrame) - NSHeight(imageRect)) / 2.0);
[image drawInRect:imageRect
fromRect:NSZeroRect
@@ -105,7 +100,10 @@ const CGFloat kImageNoFocusAlpha = 0.65;
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
[self drawImageWithFrame:cellFrame inView:controlView];
- [self drawFocusRingWithFrame:cellFrame inView:controlView];
+ // Only draw custom focus ring if the 10.7 focus ring APIs are not available.
+ // TODO(groby): Remove once we build against the 10.7 SDK.
+ if (![self respondsToSelector:@selector(drawFocusRingMaskWithFrame:inView:)])
+ [self drawFocusRingWithFrame:cellFrame inView:controlView];
}
- (void)setImageID:(NSInteger)imageID
@@ -139,12 +137,6 @@ const CGFloat kImageNoFocusAlpha = 0.65;
}
- (void)drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
- // Draw custom focus ring only if AppKit won't draw one automatically.
- // The new focus ring APIs became available with 10.7, but did not get
- // applied to buttons (only editable text fields) until 10.8.
- if (base::mac::IsOSMountainLionOrLater())
- return;
-
if (![self showsFirstResponder])
return;
gfx::ScopedNSGraphicsContextSaveGState scoped_state;