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

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

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: Rebase Created 3 years, 7 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" 8 #include "base/mac/objc_release_properties.h"
9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 11
12 namespace { 12 namespace {
13 const CGFloat kToolsMenuItemHorizontalMargin = 16; 13 const CGFloat kToolsMenuItemHorizontalMargin = 16;
14 // Increase the margin for RTL so the labels don't overlap the tools icon. 14 // Increase the margin for RTL so the labels don't overlap the tools icon.
15 const CGFloat kToolsMenuItemHorizontalMarginRTL = 25; 15 const CGFloat kToolsMenuItemHorizontalMarginRTL = 25;
16 static NSString* const kMenuItemCellID = @"MenuItemCellID"; 16 static NSString* const kMenuItemCellID = @"MenuItemCellID";
17 } 17 }
18 18
19 @implementation ToolsMenuViewItem { 19 @implementation ToolsMenuViewItem
20 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewItem;
21 }
22 20
23 @synthesize accessibilityIdentifier = _accessibilityIdentifier; 21 @synthesize accessibilityIdentifier = _accessibilityIdentifier;
24 @synthesize active = _active; 22 @synthesize active = _active;
25 @synthesize title = _title; 23 @synthesize title = _title;
26 @synthesize tag = _tag; 24 @synthesize tag = _tag;
27 @synthesize tableViewCell = _tableViewCell; 25 @synthesize tableViewCell = _tableViewCell;
28 26
29 - (id)init { 27 - (id)init {
30 self = [super init]; 28 self = [super init];
31 if (self) { 29 if (self) {
32 _propertyReleaser_ToolsMenuViewItem.Init(self, [ToolsMenuViewItem class]);
33 _active = YES; 30 _active = YES;
34 } 31 }
35 32
36 return self; 33 return self;
37 } 34 }
38 35
36 - (void)dealloc {
37 base::mac::ReleaseProperties(self);
38 [super dealloc];
39 }
40
39 + (NSString*)cellID { 41 + (NSString*)cellID {
40 return kMenuItemCellID; 42 return kMenuItemCellID;
41 } 43 }
42 44
43 + (Class)cellClass { 45 + (Class)cellClass {
44 return [ToolsMenuViewCell class]; 46 return [ToolsMenuViewCell class];
45 } 47 }
46 48
47 + (instancetype)menuItemWithTitle:(NSString*)title 49 + (instancetype)menuItemWithTitle:(NSString*)title
48 accessibilityIdentifier:(NSString*)accessibilityIdentifier 50 accessibilityIdentifier:(NSString*)accessibilityIdentifier
49 command:(int)commandID { 51 command:(int)commandID {
50 ToolsMenuViewItem* menuItem = [[[self alloc] init] autorelease]; 52 ToolsMenuViewItem* menuItem = [[[self alloc] init] autorelease];
51 [menuItem setAccessibilityLabel:title]; 53 [menuItem setAccessibilityLabel:title];
52 [menuItem setAccessibilityIdentifier:accessibilityIdentifier]; 54 [menuItem setAccessibilityIdentifier:accessibilityIdentifier];
53 [menuItem setTag:commandID]; 55 [menuItem setTag:commandID];
54 [menuItem setTitle:title]; 56 [menuItem setTitle:title];
55 57
56 return menuItem; 58 return menuItem;
57 } 59 }
58 60
59 @end 61 @end
60 62
61 @implementation ToolsMenuViewCell { 63 @implementation ToolsMenuViewCell
62 base::mac::ObjCPropertyReleaser _propertyReleaser_ToolsMenuViewCell;
63 }
64 64
65 @synthesize title = _title; 65 @synthesize title = _title;
66 @synthesize horizontalMargin = _horizontalMargin; 66 @synthesize horizontalMargin = _horizontalMargin;
67 67
68 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 68 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
69 self = [super initWithCoder:aDecoder]; 69 self = [super initWithCoder:aDecoder];
70 if (self) 70 if (self)
71 [self commonInitialization]; 71 [self commonInitialization];
72 72
73 return self; 73 return self;
74 } 74 }
75 75
76 - (instancetype)initWithFrame:(CGRect)frame { 76 - (instancetype)initWithFrame:(CGRect)frame {
77 self = [super initWithFrame:frame]; 77 self = [super initWithFrame:frame];
78 if (self) 78 if (self)
79 [self commonInitialization]; 79 [self commonInitialization];
80 80
81 return self; 81 return self;
82 } 82 }
83 83
84 - (void)commonInitialization { 84 - (void)commonInitialization {
85 _propertyReleaser_ToolsMenuViewCell.Init(self, [ToolsMenuViewCell class]);
86 _horizontalMargin = !base::i18n::IsRTL() ? kToolsMenuItemHorizontalMargin 85 _horizontalMargin = !base::i18n::IsRTL() ? kToolsMenuItemHorizontalMargin
87 : kToolsMenuItemHorizontalMarginRTL; 86 : kToolsMenuItemHorizontalMarginRTL;
88 [self setBackgroundColor:[UIColor whiteColor]]; 87 [self setBackgroundColor:[UIColor whiteColor]];
89 [self setOpaque:YES]; 88 [self setOpaque:YES];
90 } 89 }
91 90
91 - (void)dealloc {
92 base::mac::ReleaseProperties(self);
93 [super dealloc];
94 }
95
92 - (void)prepareForReuse { 96 - (void)prepareForReuse {
93 [super prepareForReuse]; 97 [super prepareForReuse];
94 [_title setText:nil]; 98 [_title setText:nil];
95 [self setAccessibilityIdentifier:nil]; 99 [self setAccessibilityIdentifier:nil];
96 [self setAccessibilityLabel:nil]; 100 [self setAccessibilityLabel:nil];
97 } 101 }
98 102
99 - (void)initializeTitleView { 103 - (void)initializeTitleView {
100 _title = [[UILabel alloc] initWithFrame:self.bounds]; 104 _title = [[UILabel alloc] initWithFrame:self.bounds];
101 [_title setTranslatesAutoresizingMaskIntoConstraints:NO]; 105 [_title setTranslatesAutoresizingMaskIntoConstraints:NO];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 [_title setText:[item title]]; 154 [_title setText:[item title]];
151 [self setAccessibilityIdentifier:[item accessibilityIdentifier]]; 155 [self setAccessibilityIdentifier:[item accessibilityIdentifier]];
152 [self setAccessibilityLabel:[item accessibilityLabel]]; 156 [self setAccessibilityLabel:[item accessibilityLabel]];
153 [self setAccessibilityTraits:traits]; 157 [self setAccessibilityTraits:traits];
154 [self setIsAccessibilityElement:YES]; 158 [self setIsAccessibilityElement:YES];
155 [self setTag:[item tag]]; 159 [self setTag:[item tag]];
156 item.tableViewCell = self; 160 item.tableViewCell = self;
157 } 161 }
158 162
159 @end 163 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698