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

Unified Diff: chrome/browser/ui/cocoa/new_tab_button.mm

Issue 1310183005: Mac: Fix missing focus rings on toolbar, profile, and tab buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@snapshot
Patch Set: Fix extension buttons Created 5 years, 4 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/new_tab_button.mm
diff --git a/chrome/browser/ui/cocoa/new_tab_button.mm b/chrome/browser/ui/cocoa/new_tab_button.mm
index 176c80c063885be46cd7e1fe9b1e95a47141bfc6..dbdd56ef6328f51f3348b5e8e9a778362d4e9537 100644
--- a/chrome/browser/ui/cocoa/new_tab_button.mm
+++ b/chrome/browser/ui/cocoa/new_tab_button.mm
@@ -8,6 +8,15 @@
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
+namespace {
+
+NSImage* GetMaskImage() {
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ return bundle.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage();
+}
+
+}
+
// A simple override of the ImageButtonCell to disable handling of
// -mouseEntered.
@interface NewTabButtonCell : ImageButtonCell
@@ -22,6 +31,11 @@
// Ignore this since the NTB enter is handled by the TabStripController.
}
+- (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame inView:(NSView*)view {
+ // Match the button's shape.
+ [self drawImage:GetMaskImage() withFrame:cellFrame inView:view];
+}
+
@end
@@ -34,9 +48,7 @@
- (BOOL)pointIsOverButton:(NSPoint)point {
NSPoint localPoint = [self convertPoint:point fromView:[self superview]];
NSRect pointRect = NSMakeRect(localPoint.x, localPoint.y, 1, 1);
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- NSImage* buttonMask =
- bundle.GetNativeImageNamed(IDR_NEWTAB_BUTTON_MASK).ToNSImage();
+ NSImage* buttonMask = GetMaskImage();
NSRect destinationRect = NSMakeRect(
(NSWidth(self.bounds) - [buttonMask size].width) / 2,
(NSHeight(self.bounds) - [buttonMask size].height) / 2,
« no previous file with comments | « chrome/browser/ui/cocoa/image_button_cell.mm ('k') | chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698