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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm

Issue 2074503002: [Mac][Material Design] Fix bookmark chevron button focus ring location. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698