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

Side by Side Diff: chrome/browser/ui/cocoa/download/download_item_controller.mm

Issue 911303002: Fix text wrapping problem in the download_item_controller on Yosemite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed how compute textfield resize delta Created 5 years, 10 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 | no next file » | 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/download/download_item_controller.h" 5 #import "chrome/browser/ui/cocoa/download/download_item_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/download/chrome_download_manager_delegate.h" 14 #include "chrome/browser/download/chrome_download_manager_delegate.h"
14 #include "chrome/browser/download/download_item_model.h" 15 #include "chrome/browser/download/download_item_model.h"
15 #include "chrome/browser/download/download_shelf_context_menu.h" 16 #include "chrome/browser/download/download_shelf_context_menu.h"
16 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" 17 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
17 #import "chrome/browser/themes/theme_properties.h" 18 #import "chrome/browser/themes/theme_properties.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 [self updateExperienceSamplingEvent:ExperienceSamplingEvent::kIgnore]; 123 [self updateExperienceSamplingEvent:ExperienceSamplingEvent::kIgnore];
123 [[NSNotificationCenter defaultCenter] removeObserver:self]; 124 [[NSNotificationCenter defaultCenter] removeObserver:self];
124 [progressView_ setController:nil]; 125 [progressView_ setController:nil];
125 [[self view] removeFromSuperview]; 126 [[self view] removeFromSuperview];
126 [super dealloc]; 127 [super dealloc];
127 } 128 }
128 129
129 - (void)awakeFromNib { 130 - (void)awakeFromNib {
130 [progressView_ setController:self]; 131 [progressView_ setController:self];
131 132
133 // The new system font on Yosemite brings slightly different font metrics.
134 // The |dangerousDownloadLabel_| is 22 points high with two lines of text
135 // in the nib, but on Yosemite it needs 24 points to hold that same text.
136 // The best alternative to hard coding the 2.0pt delta is to have the
137 // textfield compute the height necessary to display two lines of text.
138 // In order to disturb as little as possible, the code below only runs on
139 // Yosemite, and restores the original state of |dangerousDownloadLabel_|
140 // 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.
141 // http://crbug.com/454782 .
142 if (base::mac::IsOSYosemiteOrLater()) {
143 NSString* placeholderText = [dangerousDownloadLabel_ stringValue];
asanka 2015/02/21 02:14:54 Let's move this height adjustment logic into -show
144 NSRect labelFrame = [dangerousDownloadLabel_ frame];
145 [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
146 [dangerousDownloadLabel_ sizeToFit];
147 CGFloat heightDelta = [dangerousDownloadLabel_ frame].size.height -
148 labelFrame.size.height;
149 labelFrame.origin.y -= heightDelta / 2.0;
150 labelFrame.size.height += heightDelta;
151 [dangerousDownloadLabel_ setFrame:labelFrame];
152 [dangerousDownloadLabel_ setStringValue:placeholderText];
153 }
132 GTMUILocalizerAndLayoutTweaker* localizerAndLayoutTweaker = 154 GTMUILocalizerAndLayoutTweaker* localizerAndLayoutTweaker =
133 [[[GTMUILocalizerAndLayoutTweaker alloc] init] autorelease]; 155 [[[GTMUILocalizerAndLayoutTweaker alloc] init] autorelease];
134 [localizerAndLayoutTweaker applyLocalizer:localizer_ tweakingUI:[self view]]; 156 [localizerAndLayoutTweaker applyLocalizer:localizer_ tweakingUI:[self view]];
135 157
136 [self setStateFromDownload:bridge_->download_model()]; 158 [self setStateFromDownload:bridge_->download_model()];
137 159
138 bridge_->LoadIcon(); 160 bridge_->LoadIcon();
139 [self updateToolTip]; 161 [self updateToolTip];
140 } 162 }
141 163
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 base::scoped_nsobject<DownloadShelfContextMenuController> menuController( 395 base::scoped_nsobject<DownloadShelfContextMenuController> menuController(
374 [[DownloadShelfContextMenuController alloc] 396 [[DownloadShelfContextMenuController alloc]
375 initWithItemController:self 397 initWithItemController:self
376 withDelegate:nil]); 398 withDelegate:nil]);
377 [NSMenu popUpContextMenu:[menuController menu] 399 [NSMenu popUpContextMenu:[menuController menu]
378 withEvent:[NSApp currentEvent] 400 withEvent:[NSApp currentEvent]
379 forView:[self view]]; 401 forView:[self view]];
380 } 402 }
381 403
382 @end 404 @end
OLDNEW
« 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