Chromium Code Reviews| Index: chrome/browser/ui/cocoa/download/download_item_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/download/download_item_controller.mm b/chrome/browser/ui/cocoa/download/download_item_controller.mm |
| index a749d314579c501009632c98c6a7f44a10d4c642..9f08434c363993856d16c3aecc8d168e82f68b3a 100644 |
| --- a/chrome/browser/ui/cocoa/download/download_item_controller.mm |
| +++ b/chrome/browser/ui/cocoa/download/download_item_controller.mm |
| @@ -5,6 +5,7 @@ |
| #import "chrome/browser/ui/cocoa/download/download_item_controller.h" |
| #include "base/mac/bundle_locations.h" |
| +#include "base/mac/mac_util.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/string16.h" |
| #include "base/strings/string_util.h" |
| @@ -129,6 +130,27 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { |
| - (void)awakeFromNib { |
| [progressView_ setController:self]; |
| + // The new system font on Yosemite brings slightly different font metrics. |
| + // The |dangerousDownloadLabel_| is 22 points high with two lines of text |
| + // in the nib, but on Yosemite it needs 24 points to hold that same text. |
| + // The best alternative to hard coding the 2.0pt delta is to have the |
| + // textfield compute the height necessary to display two lines of text. |
| + // In order to disturb as little as possible, the code below only runs on |
| + // Yosemite, and restores the original state of |dangerousDownloadLabel_| |
| + // after the computation (except for, of course, its height). |
|
asanka
2015/02/21 02:14:53
Comment is out of date?
shrike
2015/02/23 20:12:14
It's not, but I rewrote it in the new cl.
|
| + // http://crbug.com/454782 . |
| + if (base::mac::IsOSYosemiteOrLater()) { |
| + NSString* placeholderText = [dangerousDownloadLabel_ stringValue]; |
|
asanka
2015/02/21 02:14:54
Let's move this height adjustment logic into -show
|
| + NSRect labelFrame = [dangerousDownloadLabel_ frame]; |
| + [dangerousDownloadLabel_ setStringValue:@"Two lines\nof text"]; |
|
asanka
2015/02/21 02:14:54
Once this is moved to -showDangerousWarning:, we c
shrike
2015/02/23 20:12:14
The idea behind this change is just to quickly fix
asanka
2015/02/24 03:16:13
showDangerousWarning is called at most once per do
|
| + [dangerousDownloadLabel_ sizeToFit]; |
| + CGFloat heightDelta = [dangerousDownloadLabel_ frame].size.height - |
| + labelFrame.size.height; |
| + labelFrame.origin.y -= heightDelta / 2.0; |
| + labelFrame.size.height += heightDelta; |
| + [dangerousDownloadLabel_ setFrame:labelFrame]; |
| + [dangerousDownloadLabel_ setStringValue:placeholderText]; |
| + } |
| GTMUILocalizerAndLayoutTweaker* localizerAndLayoutTweaker = |
| [[[GTMUILocalizerAndLayoutTweaker alloc] init] autorelease]; |
| [localizerAndLayoutTweaker applyLocalizer:localizer_ tweakingUI:[self view]]; |