| OLD | NEW |
| 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/toolbar/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 - (NSPoint)saveCreditCardBubblePoint { | 1048 - (NSPoint)saveCreditCardBubblePoint { |
| 1049 return locationBarView_->GetSaveCreditCardBubblePoint(); | 1049 return locationBarView_->GetSaveCreditCardBubblePoint(); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 - (NSPoint)translateBubblePoint { | 1052 - (NSPoint)translateBubblePoint { |
| 1053 return locationBarView_->GetTranslateBubblePoint(); | 1053 return locationBarView_->GetTranslateBubblePoint(); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 - (CGFloat)baseToolbarHeight { | 1056 - (CGFloat)baseToolbarHeight { |
| 1057 // Height of the toolbar in pixels when the bookmark bar is closed. | 1057 // Height of the toolbar in pixels when the bookmark bar is closed. |
| 1058 const CGFloat baseToolbarHeightNormal = | 1058 const bool kIsModeMaterial = ui::MaterialDesignController::IsModeMaterial(); |
| 1059 ui::MaterialDesignController::IsModeMaterial() ? 37 : 35; | 1059 const CGFloat kBaseToolbarHeightNormal = kIsModeMaterial ? 37 : 35; |
| 1060 | 1060 |
| 1061 // Not all lines are drawn at 2x normal height when running on Retina, which | 1061 // Not all lines are drawn at 2x normal height when running on Retina, which |
| 1062 // causes the toolbar controls to be visually 1pt too high within the toolbar | 1062 // causes the toolbar controls to be visually 1pt too high within the toolbar |
| 1063 // area. It's not possible to adjust the control y-positions by 0.5pt and have | 1063 // area. It's not possible to adjust the control y-positions by 0.5pt and have |
| 1064 // them appear 0.5pt lower (they are still drawn at their original locations), | 1064 // them appear 0.5pt lower (they are still drawn at their original locations), |
| 1065 // so instead shave off 1pt from the bottom of the toolbar. Note that there's | 1065 // so instead shave off 1pt from the bottom of the toolbar. Note that there's |
| 1066 // an offsetting change in -[BookmarkBarController preferredHeight] to | 1066 // an offsetting change in -[BookmarkBarController preferredHeight] to |
| 1067 // maintain the proper spacing between bookmark icons and toolbar items. See | 1067 // maintain the proper spacing between bookmark icons and toolbar items. See |
| 1068 // https://crbug.com/326245 . | 1068 // https://crbug.com/326245 . |
| 1069 return [[self view] cr_lineWidth] == 0.5 ? baseToolbarHeightNormal - 1 | 1069 const CGFloat kLineWidth = [[self view] cr_lineWidth]; |
| 1070 : baseToolbarHeightNormal; | 1070 const BOOL kIsRetina = (kLineWidth < 1); |
| 1071 BOOL reduceHeight = YES; |
| 1072 |
| 1073 // If Material Design and Retina, no height adjustment is needed. |
| 1074 if (kIsModeMaterial && kIsRetina) { |
| 1075 reduceHeight = NO; |
| 1076 } |
| 1077 |
| 1078 return reduceHeight ? kBaseToolbarHeightNormal - 1 |
| 1079 : kBaseToolbarHeightNormal; |
| 1071 } | 1080 } |
| 1072 | 1081 |
| 1073 - (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight { | 1082 - (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight { |
| 1074 // With no toolbar, just ignore the compression. | 1083 // With no toolbar, just ignore the compression. |
| 1075 if (!hasToolbar_) | 1084 if (!hasToolbar_) |
| 1076 return NSHeight([locationBar_ frame]); | 1085 return NSHeight([locationBar_ frame]); |
| 1077 | 1086 |
| 1078 return [self baseToolbarHeight] - compressByHeight; | 1087 return [self baseToolbarHeight] - compressByHeight; |
| 1079 } | 1088 } |
| 1080 | 1089 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1160 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 1152 // Do nothing. | 1161 // Do nothing. |
| 1153 } | 1162 } |
| 1154 | 1163 |
| 1155 // (URLDropTargetController protocol) | 1164 // (URLDropTargetController protocol) |
| 1156 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1165 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 1157 return drag_util::IsUnsupportedDropData(profile_, info); | 1166 return drag_util::IsUnsupportedDropData(profile_, info); |
| 1158 } | 1167 } |
| 1159 | 1168 |
| 1160 @end | 1169 @end |
| OLD | NEW |