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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm

Issue 1948963002: [Mac][Material Design] Fix toolbar height on Retina. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #import "base/mac/bundle_locations.h" 9 #import "base/mac/bundle_locations.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "content/public/browser/user_metrics.h" 60 #include "content/public/browser/user_metrics.h"
61 #include "content/public/browser/web_contents.h" 61 #include "content/public/browser/web_contents.h"
62 #include "extensions/browser/extension_registry.h" 62 #include "extensions/browser/extension_registry.h"
63 #include "extensions/common/extension.h" 63 #include "extensions/common/extension.h"
64 #include "extensions/common/extension_set.h" 64 #include "extensions/common/extension_set.h"
65 #include "grit/theme_resources.h" 65 #include "grit/theme_resources.h"
66 #include "ui/base/clipboard/clipboard_util_mac.h" 66 #include "ui/base/clipboard/clipboard_util_mac.h"
67 #import "ui/base/cocoa/cocoa_base_utils.h" 67 #import "ui/base/cocoa/cocoa_base_utils.h"
68 #import "ui/base/cocoa/nsview_additions.h" 68 #import "ui/base/cocoa/nsview_additions.h"
69 #include "ui/base/l10n/l10n_util_mac.h" 69 #include "ui/base/l10n/l10n_util_mac.h"
70 #include "ui/base/material_design/material_design_controller.h"
70 #include "ui/base/resource/resource_bundle.h" 71 #include "ui/base/resource/resource_bundle.h"
71 #include "ui/gfx/image/image.h" 72 #include "ui/gfx/image/image.h"
72 #include "ui/resources/grit/ui_resources.h" 73 #include "ui/resources/grit/ui_resources.h"
73 74
74 using base::UserMetricsAction; 75 using base::UserMetricsAction;
75 using bookmarks::BookmarkModel; 76 using bookmarks::BookmarkModel;
76 using bookmarks::BookmarkNode; 77 using bookmarks::BookmarkNode;
77 using bookmarks::BookmarkNodeData; 78 using bookmarks::BookmarkNodeData;
78 using content::OpenURLParams; 79 using content::OpenURLParams;
79 using content::Referrer; 80 using content::Referrer;
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 seedId_ = 0; 1023 seedId_ = 0;
1023 menuTagMap_.clear(); 1024 menuTagMap_.clear();
1024 } 1025 }
1025 1026
1026 - (int)preferredHeight { 1027 - (int)preferredHeight {
1027 DCHECK(![self isAnimationRunning]); 1028 DCHECK(![self isAnimationRunning]);
1028 1029
1029 if (!barIsEnabled_) 1030 if (!barIsEnabled_)
1030 return 0; 1031 return 0;
1031 1032
1033 CGFloat lineWidth = 0;
1034 BOOL isRetina = NO;
1035 BOOL reduceHeight = YES;
1036
1032 switch (currentState_) { 1037 switch (currentState_) {
1033 case BookmarkBar::SHOW: 1038 case BookmarkBar::SHOW:
1034 // When on a Retina display, -[ToolbarContrller baseToolbarHeight] reduces 1039 // When on a Retina display and not using Material Design,
1035 // the height of the toolbar by 1pt. In this case the bookmark bar needs 1040 // -[ToolbarController baseToolbarHeight] reduces the height of the
1036 // to be 1pt taller to maintain the proper spacing between bookmark icons 1041 // toolbar by 1pt. In this case the bookmark bar needs to add 1pt of space
1037 // and toolbar items. See https://crbug.com/326245 . 1042 // above the bookmark icons in order to maintain the proper distance from
1038 return [[self view] cr_lineWidth] == 0.5 ? chrome::kBookmarkBarHeight + 1 1043 // toolbar items. See https://crbug.com/326245 .
1039 : chrome::kBookmarkBarHeight; 1044 lineWidth = [[self view] cr_lineWidth];
1045 isRetina = (lineWidth < 1);
1046
1047 // If Material Design and Retina, no height adjustment is needed.
1048 if (ui::MaterialDesignController::IsModeMaterial() && isRetina) {
1049 reduceHeight = NO;
1050 }
1051
1052 return reduceHeight ? chrome::kBookmarkBarHeight + 1
1053 : chrome::kBookmarkBarHeight;
1040 case BookmarkBar::DETACHED: 1054 case BookmarkBar::DETACHED:
1041 return chrome::kNTPBookmarkBarHeight; 1055 return chrome::kNTPBookmarkBarHeight;
1042 case BookmarkBar::HIDDEN: 1056 case BookmarkBar::HIDDEN:
1043 return 0; 1057 return 0;
1044 } 1058 }
1045 } 1059 }
1046 1060
1047 // Recursively add the given bookmark node and all its children to 1061 // Recursively add the given bookmark node and all its children to
1048 // menu, one menu item per node. 1062 // menu, one menu item per node.
1049 - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu { 1063 - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu {
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 - (id<BookmarkButtonControllerProtocol>)controllerForNode: 2954 - (id<BookmarkButtonControllerProtocol>)controllerForNode:
2941 (const BookmarkNode*)node { 2955 (const BookmarkNode*)node {
2942 // See if it's in the bar, then if it is in the hierarchy of visible 2956 // See if it's in the bar, then if it is in the hierarchy of visible
2943 // folder menus. 2957 // folder menus.
2944 if (bookmarkModel_->bookmark_bar_node() == node) 2958 if (bookmarkModel_->bookmark_bar_node() == node)
2945 return self; 2959 return self;
2946 return [folderController_ controllerForNode:node]; 2960 return [folderController_ controllerForNode:node];
2947 } 2961 }
2948 2962
2949 @end 2963 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698