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

Side by Side Diff: ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.mm

Issue 2615883002: Fix for voice-over accessibility issue with tab switcher. (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #import "ios/chrome/browser/tabs/tab.h" 8 #import "ios/chrome/browser/tabs/tab.h"
9 #import "ios/chrome/browser/ui/fade_truncated_label.h" 9 #import "ios/chrome/browser/ui/fade_truncated_label.h"
10 #import "ios/chrome/browser/ui/image_util.h" 10 #import "ios/chrome/browser/ui/image_util.h"
(...skipping 13 matching lines...) Expand all
24 namespace gfx { 24 namespace gfx {
25 class ImageSkia; 25 class ImageSkia;
26 } 26 }
27 27
28 namespace { 28 namespace {
29 const CGFloat kFontSize = 16; 29 const CGFloat kFontSize = 16;
30 const CGFloat kCellCornerRadius = 2; 30 const CGFloat kCellCornerRadius = 2;
31 const CGFloat kBarHeight = 44; 31 const CGFloat kBarHeight = 44;
32 const CGFloat kTitleLabelTextAlpha = .54; 32 const CGFloat kTitleLabelTextAlpha = .54;
33 const CGFloat kNewTabIconAlpha = .87; 33 const CGFloat kNewTabIconAlpha = .87;
34 } // Anonymous namespace 34 }
35 35
36 CGFloat tabSwitcherLocalSessionCellTopBarHeight() { 36 CGFloat tabSwitcherLocalSessionCellTopBarHeight() {
37 return kBarHeight; 37 return kBarHeight;
38 } 38 }
39 39
40 @interface TabSwitcherSessionCell () 40 @interface TabSwitcherSessionCell ()
41 41
42 // Returns the container view with rounded corners to which all cell subviews 42 // Returns the container view with rounded corners to which all cell subviews
43 // should be added. 43 // should be added.
44 - (UIView*)containerView; 44 - (UIView*)containerView;
45 45
46 @end 46 @end
47 47
48 @implementation TabSwitcherSessionCell { 48 @implementation TabSwitcherSessionCell {
49 base::scoped_nsobject<UIView> _containerView; 49 base::scoped_nsobject<UIView> _containerView;
50 CGSize _cachedShadowSize; 50 CGSize _cachedShadowSize;
51 } 51 }
52 52
53 @synthesize delegate = _delegate;
54
53 // Returns the cell's identifier used for the cell's re-use. 55 // Returns the cell's identifier used for the cell's re-use.
54 + (NSString*)identifier { 56 + (NSString*)identifier {
55 return NSStringFromClass([self class]); 57 return NSStringFromClass([self class]);
56 } 58 }
57 59
58 - (instancetype)initWithFrame:(CGRect)frame { 60 - (instancetype)initWithFrame:(CGRect)frame {
59 self = [super initWithFrame:frame]; 61 self = [super initWithFrame:frame];
60 if (self) { 62 if (self) {
61 [self contentView].isAccessibilityElement = YES; 63 [self contentView].isAccessibilityElement = YES;
62 _containerView.reset([[UIView alloc] initWithFrame:self.bounds]); 64 _containerView.reset([[UIView alloc] initWithFrame:self.bounds]);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 101
100 @implementation TabSwitcherLocalSessionCell { 102 @implementation TabSwitcherLocalSessionCell {
101 base::scoped_nsobject<UIView> _topBar; 103 base::scoped_nsobject<UIView> _topBar;
102 base::scoped_nsobject<UILabel> _titleLabel; 104 base::scoped_nsobject<UILabel> _titleLabel;
103 base::scoped_nsobject<UIImageView> _favicon; 105 base::scoped_nsobject<UIImageView> _favicon;
104 base::scoped_nsobject<UIButton> _closeButton; 106 base::scoped_nsobject<UIButton> _closeButton;
105 base::scoped_nsobject<UIImageView> _shadow; 107 base::scoped_nsobject<UIImageView> _shadow;
106 base::scoped_nsobject<UIImageView> _snapshot; 108 base::scoped_nsobject<UIImageView> _snapshot;
107 base::scoped_nsobject<TabSwitcherButton> _snapshotButton; 109 base::scoped_nsobject<TabSwitcherButton> _snapshotButton;
108 PendingSnapshotRequest _currentPendingSnapshotRequest; 110 PendingSnapshotRequest _currentPendingSnapshotRequest;
109 id<SessionCellDelegate> _delegate; // weak
110 } 111 }
111 112
112 - (instancetype)initWithFrame:(CGRect)frame { 113 - (instancetype)initWithFrame:(CGRect)frame {
113 self = [super initWithFrame:frame]; 114 self = [super initWithFrame:frame];
114 if (self) { 115 if (self) {
115 // Top bar. 116 // Top bar.
116 _topBar.reset([[UIView alloc] initWithFrame:CGRectZero]); 117 _topBar.reset([[UIView alloc] initWithFrame:CGRectZero]);
117 [_topBar setTranslatesAutoresizingMaskIntoConstraints:NO]; 118 [_topBar setTranslatesAutoresizingMaskIntoConstraints:NO];
118 [[self containerView] addSubview:_topBar]; 119 [[self containerView] addSubview:_topBar];
119 120
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 textColor = [[MDCPalette greyPalette] tint700]; 256 textColor = [[MDCPalette greyPalette] tint700];
256 snapshotBackgroundColor = [UIColor whiteColor]; 257 snapshotBackgroundColor = [UIColor whiteColor];
257 } 258 }
258 [_topBar setBackgroundColor:topBarBackgroundColor]; 259 [_topBar setBackgroundColor:topBarBackgroundColor];
259 [[_closeButton imageView] setTintColor:closeButtonTintColor]; 260 [[_closeButton imageView] setTintColor:closeButtonTintColor];
260 [_titleLabel setTextColor:textColor]; 261 [_titleLabel setTextColor:textColor];
261 [_titleLabel setBackgroundColor:topBarBackgroundColor]; 262 [_titleLabel setBackgroundColor:topBarBackgroundColor];
262 [_snapshot setBackgroundColor:snapshotBackgroundColor]; 263 [_snapshot setBackgroundColor:snapshotBackgroundColor];
263 } 264 }
264 265
265 - (void)setDelegate:(id<SessionCellDelegate>)delegate {
266 _delegate = delegate;
267 }
268
269 - (void)snapshotPressed { 266 - (void)snapshotPressed {
270 [_delegate cellPressed:self]; 267 [self.delegate cellPressed:self];
271 } 268 }
272 269
273 - (void)closeButtonPressed { 270 - (void)closeButtonPressed {
274 [_delegate deleteButtonPressedForCell:self]; 271 [self.delegate deleteButtonPressedForCell:self];
275 } 272 }
276 273
277 - (void)prepareForReuse { 274 - (void)prepareForReuse {
278 [[self cache] cancelPendingSnapshotRequest:_currentPendingSnapshotRequest]; 275 [[self cache] cancelPendingSnapshotRequest:_currentPendingSnapshotRequest];
279 _currentPendingSnapshotRequest.clear(); 276 _currentPendingSnapshotRequest.clear();
280 [_snapshot setImage:nil]; 277 [_snapshot setImage:nil];
281 [_snapshotButton resetState]; 278 [_snapshotButton resetState];
282 [super prepareForReuse]; 279 [super prepareForReuse];
283 } 280 }
284 281
285 - (TabSwitcherCache*)cache { 282 - (TabSwitcherCache*)cache {
286 return [_delegate tabSwitcherCache]; 283 return [self.delegate tabSwitcherCache];
287 } 284 }
288 285
289 #pragma mark - UIAccessibilityAction 286 #pragma mark - UIAccessibilityAction
290 287
291 - (NSArray*)accessibilityCustomActions { 288 - (NSArray*)accessibilityCustomActions {
292 base::scoped_nsobject<NSMutableArray> customActions( 289 base::scoped_nsobject<NSMutableArray> customActions(
293 [[NSMutableArray alloc] init]); 290 [[NSMutableArray alloc] init]);
294 base::scoped_nsobject<UIAccessibilityCustomAction> customAction( 291 base::scoped_nsobject<UIAccessibilityCustomAction> customAction(
295 [[UIAccessibilityCustomAction alloc] 292 [[UIAccessibilityCustomAction alloc]
296 initWithName:l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_CLOSE_TAB) 293 initWithName:l10n_util::GetNSString(IDS_IOS_TAB_SWITCHER_CLOSE_TAB)
297 target:self 294 target:self
298 selector:@selector(closeButtonPressed)]); 295 selector:@selector(closeButtonPressed)]);
299 [customActions addObject:customAction.autorelease()]; 296 [customActions addObject:customAction.autorelease()];
300 return customActions.autorelease(); 297 return customActions.autorelease();
301 } 298 }
302 299
303 @end 300 @end
304 301
305 @implementation TabSwitcherDistantSessionCell { 302 @implementation TabSwitcherDistantSessionCell {
306 base::scoped_nsobject<UILabel> _titleLabel; 303 base::scoped_nsobject<UILabel> _titleLabel;
307 base::scoped_nsobject<UIImageView> _favicon; 304 base::scoped_nsobject<UIImageView> _favicon;
308 base::scoped_nsobject<UIImageView> _newTabIcon; 305 base::scoped_nsobject<UIImageView> _newTabIcon;
309 base::scoped_nsobject<UIView> _verticallyCenteredView; 306 base::scoped_nsobject<UIView> _verticallyCenteredView;
310 base::scoped_nsobject<TabSwitcherButton> _raisedButton; 307 base::scoped_nsobject<TabSwitcherButton> _raisedButton;
311 base::scoped_nsobject<NSOperation> _faviconObtainer; 308 base::scoped_nsobject<NSOperation> _faviconObtainer;
312 id<SessionCellDelegate> _delegate; // weak
313 } 309 }
314 310
315 - (instancetype)initWithFrame:(CGRect)frame { 311 - (instancetype)initWithFrame:(CGRect)frame {
316 self = [super initWithFrame:frame]; 312 self = [super initWithFrame:frame];
317 if (self) { 313 if (self) {
318 // Create and add the button that contains all other subviews. 314 // Create and add the button that contains all other subviews.
319 _raisedButton.reset([[TabSwitcherButton alloc] initWithFrame:CGRectZero]); 315 _raisedButton.reset([[TabSwitcherButton alloc] initWithFrame:CGRectZero]);
320 [_raisedButton setTranslatesAutoresizingMaskIntoConstraints:NO]; 316 [_raisedButton setTranslatesAutoresizingMaskIntoConstraints:NO];
321 [_raisedButton addTarget:self 317 [_raisedButton addTarget:self
322 action:@selector(cellPressed) 318 action:@selector(cellPressed)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 }]; 419 }];
424 }; 420 };
425 GURL gurlCopy = gurl; 421 GURL gurlCopy = gurl;
426 _faviconObtainer.reset([[NSBlockOperation blockOperationWithBlock:^{ 422 _faviconObtainer.reset([[NSBlockOperation blockOperationWithBlock:^{
427 TabSwitcherGetFavicon(gurlCopy, browserState, block); 423 TabSwitcherGetFavicon(gurlCopy, browserState, block);
428 }] retain]); 424 }] retain]);
429 NSOperationQueue* operationQueue = [NSOperationQueue mainQueue]; 425 NSOperationQueue* operationQueue = [NSOperationQueue mainQueue];
430 [operationQueue addOperation:_faviconObtainer]; 426 [operationQueue addOperation:_faviconObtainer];
431 } 427 }
432 428
433 - (void)setDelegate:(id<SessionCellDelegate>)delegate {
434 _delegate = delegate;
435 }
436
437 - (void)cellPressed { 429 - (void)cellPressed {
438 [_delegate cellPressed:self]; 430 [self.delegate cellPressed:self];
439 } 431 }
440 432
441 - (void)prepareForReuse { 433 - (void)prepareForReuse {
442 [_newTabIcon setAlpha:0]; 434 [_newTabIcon setAlpha:0];
443 [_faviconObtainer cancel]; 435 [_faviconObtainer cancel];
444 _faviconObtainer.reset(); 436 _faviconObtainer.reset();
445 [_raisedButton setAlpha:0]; 437 [_raisedButton setAlpha:0];
446 [_raisedButton resetState]; 438 [_raisedButton resetState];
447 [super prepareForReuse]; 439 [super prepareForReuse];
448 } 440 }
449 441
450 @end 442 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698