Chromium Code Reviews| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
| index 67f2aa5433f113d3b391ed3f95b5982fa315a21b..06aeb23d1e74dcd3d54e44a078efe3c577840ea6 100644 |
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm |
| @@ -7,6 +7,8 @@ |
| #include "base/logging.h" |
| #include "base/strings/sys_string_conversions.h" |
| #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| +#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| +#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view_cocoa.h" |
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| #import "chrome/browser/ui/cocoa/bookmarks/bookmark_context_menu_cocoa_controller.h" |
| #include "chrome/grit/generated_resources.h" |
| @@ -48,6 +50,9 @@ const int kDefaultFontSize = 12; |
| - (NSString*)visibleTitle; |
| // Returns the dictionary of attributes to associate with the button title. |
| - (NSDictionary*)titleTextAttributes; |
| +// Returns the BookmarkBarController for the BookmarkButtonCell's controlView. |
| +- (BookmarkBarController*) |
| + bookmarkBarViewControllerFromControlView:(NSView*)controlView; |
| @end |
| @@ -371,13 +376,34 @@ const int kDefaultFontSize = 12; |
| return kIconLeftPadding + [[self image] size].width + kIconTextSpacer; |
| } |
| +- (BookmarkBarController*) |
| + bookmarkBarViewControllerFromControlView:(NSView*)controlView { |
|
tapted
2016/06/16 05:53:19
having the button cell know much about its parents
shrike
2016/06/16 15:19:09
Great! My original preference was to change the ce
|
| + NSView* nextView = [controlView superview]; |
| + while (nextView) { |
| + if ([nextView isKindOfClass:[BookmarkBarView class]]) { |
| + BookmarkBarView* bookmarkBarView = (BookmarkBarView*)nextView; |
| + return [bookmarkBarView controller]; |
| + } |
| + nextView = [nextView superview]; |
| + } |
| + return nil; |
| +} |
| + |
| - (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame |
| inView:(NSView*)controlView { |
| - // In Material Design we have to move the focus ring over by 2 pts to get it |
| - // to line up with the image. |
| - if (ui::MaterialDesignController::IsModeMaterial() && |
| - [self visibleTitle].length > 0) { |
| - cellFrame.origin.x += 2; |
| + if (ui::MaterialDesignController::IsModeMaterial()) { |
| + // In Material Design we have to move the focus ring over by 2 pts to get it |
| + // to line up with the image. |
| + if ([self visibleTitle].length > 0) { |
| + cellFrame.origin.x += 2; |
| + } |
| + |
| + // We also have to nudge the chevron button's focus ring up 2pts. |
| + BookmarkBarController* bookmarkBarController = |
| + [self bookmarkBarViewControllerFromControlView:controlView]; |
| + if ([bookmarkBarController offTheSideButton] == controlView) { |
| + cellFrame.origin.y -= 2; |
| + } |
| } |
| [super drawFocusRingMaskWithFrame:cellFrame inView:controlView]; |
| } |