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

Side by Side Diff: ios/chrome/browser/ui/tools_menu/tools_menu_view_item.mm

Issue 2941043002: [ObjC ARC] Converts ios/chrome/browser/ui/tools_menu:tools_menu to ARC. (Closed)
Patch Set: manual review. Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tools_menu/tools_menu_view_item.h" 5 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/mac/objc_property_releaser.h"
9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 8 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
10 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
11 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
12 namespace { 15 namespace {
13 const CGFloat kToolsMenuItemHorizontalMargin = 16; 16 const CGFloat kToolsMenuItemHorizontalMargin = 16;
14 // Increase the margin for RTL so the labels don't overlap the tools icon. 17 // Increase the margin for RTL so the labels don't overlap the tools icon.
15 const CGFloat kToolsMenuItemHorizontalMarginRTL = 25; 18 const CGFloat kToolsMenuItemHorizontalMarginRTL = 25;
16 static NSString* const kMenuItemCellID = @"MenuItemCellID"; 19 static NSString* const kMenuItemCellID = @"MenuItemCellID";
17 } 20 }
18 21
19 @implementation ToolsMenuViewItem { 22 @implementation ToolsMenuViewItem
20 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewItem;
21 }
22
23 @synthesize accessibilityIdentifier = _accessibilityIdentifier; 23 @synthesize accessibilityIdentifier = _accessibilityIdentifier;
24 @synthesize active = _active; 24 @synthesize active = _active;
25 @synthesize title = _title; 25 @synthesize title = _title;
26 @synthesize tag = _tag; 26 @synthesize tag = _tag;
27 @synthesize tableViewCell = _tableViewCell; 27 @synthesize tableViewCell = _tableViewCell;
28 28
29 - (id)init { 29 - (id)init {
30 self = [super init]; 30 self = [super init];
31 if (self) { 31 if (self) {
32 _propertyReleaser_ToolsMenuViewItem.Init(self, [ToolsMenuViewItem class]);
33 _active = YES; 32 _active = YES;
34 } 33 }
35 34
36 return self; 35 return self;
37 } 36 }
38 37
39 + (NSString*)cellID { 38 + (NSString*)cellID {
40 return kMenuItemCellID; 39 return kMenuItemCellID;
41 } 40 }
42 41
43 + (Class)cellClass { 42 + (Class)cellClass {
44 return [ToolsMenuViewCell class]; 43 return [ToolsMenuViewCell class];
45 } 44 }
46 45
47 + (instancetype)menuItemWithTitle:(NSString*)title 46 + (instancetype)menuItemWithTitle:(NSString*)title
48 accessibilityIdentifier:(NSString*)accessibilityIdentifier 47 accessibilityIdentifier:(NSString*)accessibilityIdentifier
49 command:(int)commandID { 48 command:(int)commandID {
50 ToolsMenuViewItem* menuItem = [[[self alloc] init] autorelease]; 49 ToolsMenuViewItem* menuItem = [[self alloc] init];
51 [menuItem setAccessibilityLabel:title]; 50 [menuItem setAccessibilityLabel:title];
52 [menuItem setAccessibilityIdentifier:accessibilityIdentifier]; 51 [menuItem setAccessibilityIdentifier:accessibilityIdentifier];
53 [menuItem setTag:commandID]; 52 [menuItem setTag:commandID];
54 [menuItem setTitle:title]; 53 [menuItem setTitle:title];
55 54
56 return menuItem; 55 return menuItem;
57 } 56 }
58 57
59 @end 58 @end
60 59
61 @implementation ToolsMenuViewCell { 60 @implementation ToolsMenuViewCell
62 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewCell;
63 }
64
65 @synthesize title = _title; 61 @synthesize title = _title;
66 @synthesize horizontalMargin = _horizontalMargin; 62 @synthesize horizontalMargin = _horizontalMargin;
67 63
68 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 64 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
69 self = [super initWithCoder:aDecoder]; 65 self = [super initWithCoder:aDecoder];
70 if (self) 66 if (self)
71 [self commonInitialization]; 67 [self commonInitialization];
72 68
73 return self; 69 return self;
74 } 70 }
75 71
76 - (instancetype)initWithFrame:(CGRect)frame { 72 - (instancetype)initWithFrame:(CGRect)frame {
77 self = [super initWithFrame:frame]; 73 self = [super initWithFrame:frame];
78 if (self) 74 if (self)
79 [self commonInitialization]; 75 [self commonInitialization];
80 76
81 return self; 77 return self;
82 } 78 }
83 79
84 - (void)commonInitialization { 80 - (void)commonInitialization {
85 _propertyReleaser_ToolsMenuViewCell.Init(self, [ToolsMenuViewCell class]);
86 _horizontalMargin = !base::i18n::IsRTL() ? kToolsMenuItemHorizontalMargin 81 _horizontalMargin = !base::i18n::IsRTL() ? kToolsMenuItemHorizontalMargin
87 : kToolsMenuItemHorizontalMarginRTL; 82 : kToolsMenuItemHorizontalMarginRTL;
88 [self setBackgroundColor:[UIColor whiteColor]]; 83 [self setBackgroundColor:[UIColor whiteColor]];
89 [self setOpaque:YES]; 84 [self setOpaque:YES];
90 } 85 }
91 86
92 - (void)prepareForReuse { 87 - (void)prepareForReuse {
93 [super prepareForReuse]; 88 [super prepareForReuse];
94 [_title setText:nil]; 89 [_title setText:nil];
95 [self setAccessibilityIdentifier:nil]; 90 [self setAccessibilityIdentifier:nil];
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 [_title setText:[item title]]; 145 [_title setText:[item title]];
151 [self setAccessibilityIdentifier:[item accessibilityIdentifier]]; 146 [self setAccessibilityIdentifier:[item accessibilityIdentifier]];
152 [self setAccessibilityLabel:[item accessibilityLabel]]; 147 [self setAccessibilityLabel:[item accessibilityLabel]];
153 [self setAccessibilityTraits:traits]; 148 [self setAccessibilityTraits:traits];
154 [self setIsAccessibilityElement:YES]; 149 [self setIsAccessibilityElement:YES];
155 [self setTag:[item tag]]; 150 [self setTag:[item tag]];
156 item.tableViewCell = self; 151 item.tableViewCell = self;
157 } 152 }
158 153
159 @end 154 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698