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

Side by Side Diff: ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.mm

Issue 2707963002: [ObjC ARC] Converts ios/chrome/browser/ui/omnibox:omnibox_internal to ARC. (Closed)
Patch Set: ARC in new code Created 3 years, 9 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/omnibox/omnibox_popup_material_row.h" 5 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/objc_property_releaser.h" 8
9 #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h" 9 #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h"
10 #include "ios/chrome/browser/ui/rtl_geometry.h" 10 #include "ios/chrome/browser/ui/rtl_geometry.h"
11 #include "ios/chrome/browser/ui/ui_util.h" 11 #include "ios/chrome/browser/ui/ui_util.h"
12 #import "ios/chrome/browser/ui/uikit_ui_util.h" 12 #import "ios/chrome/browser/ui/uikit_ui_util.h"
13 #include "ios/chrome/grit/ios_theme_resources.h" 13 #include "ios/chrome/grit/ios_theme_resources.h"
14 14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
15 namespace { 19 namespace {
16 const CGFloat kImageDimensionLength = 19.0; 20 const CGFloat kImageDimensionLength = 19.0;
17 const CGFloat kLeadingPaddingIpad = 164; 21 const CGFloat kLeadingPaddingIpad = 164;
18 const CGFloat kLeadingPaddingIpadCompact = 71; 22 const CGFloat kLeadingPaddingIpadCompact = 71;
19 const CGFloat kAppendButtonTrailingMargin = 4; 23 const CGFloat kAppendButtonTrailingMargin = 4;
20 const CGFloat kAppendButtonSize = 48.0; 24 const CGFloat kAppendButtonSize = 48.0;
21 } 25 }
22 26
23 @interface OmniboxPopupMaterialRow () { 27 @interface OmniboxPopupMaterialRow () {
24 BOOL _incognito; 28 BOOL _incognito;
25 base::mac::ObjCPropertyReleaser _propertyReleaser_OmniboxPopupMaterialRow;
26 } 29 }
27 30
28 // Set the append button normal and highlighted images. 31 // Set the append button normal and highlighted images.
29 - (void)updateAppendButtonImages; 32 - (void)updateAppendButtonImages;
30 33
31 @end 34 @end
32 35
33 @implementation OmniboxPopupMaterialRow 36 @implementation OmniboxPopupMaterialRow
34 37
35 @synthesize textTruncatingLabel = _textTruncatingLabel; 38 @synthesize textTruncatingLabel = _textTruncatingLabel;
36 @synthesize detailTruncatingLabel = _detailTruncatingLabel; 39 @synthesize detailTruncatingLabel = _detailTruncatingLabel;
37 @synthesize detailAnswerLabel = _detailAnswerLabel; 40 @synthesize detailAnswerLabel = _detailAnswerLabel;
38 @synthesize appendButton = _appendButton; 41 @synthesize appendButton = _appendButton;
39 @synthesize answerImageView = _answerImageView; 42 @synthesize answerImageView = _answerImageView;
40 @synthesize imageView = _imageView; 43 @synthesize imageView = _imageView;
41 @synthesize rowHeight = _rowHeight; 44 @synthesize rowHeight = _rowHeight;
42 45
43 - (instancetype)initWithStyle:(UITableViewCellStyle)style 46 - (instancetype)initWithStyle:(UITableViewCellStyle)style
44 reuseIdentifier:(NSString*)reuseIdentifier { 47 reuseIdentifier:(NSString*)reuseIdentifier {
45 return [self initWithIncognito:NO]; 48 return [self initWithIncognito:NO];
46 } 49 }
47 50
48 - (instancetype)initWithIncognito:(BOOL)incognito { 51 - (instancetype)initWithIncognito:(BOOL)incognito {
49 self = [super initWithStyle:UITableViewCellStyleDefault 52 self = [super initWithStyle:UITableViewCellStyleDefault
50 reuseIdentifier:@"OmniboxPopupMaterialRow"]; 53 reuseIdentifier:@"OmniboxPopupMaterialRow"];
51 if (self) { 54 if (self) {
52 self.isAccessibilityElement = YES; 55 self.isAccessibilityElement = YES;
53 self.backgroundColor = [UIColor clearColor]; 56 self.backgroundColor = [UIColor clearColor];
54 _incognito = incognito; 57 _incognito = incognito;
55 _propertyReleaser_OmniboxPopupMaterialRow.Init(
56 self, [OmniboxPopupMaterialRow class]);
57 58
58 _textTruncatingLabel = 59 _textTruncatingLabel =
59 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; 60 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero];
60 _textTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; 61 _textTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
61 _textTruncatingLabel.userInteractionEnabled = NO; 62 _textTruncatingLabel.userInteractionEnabled = NO;
62 [self addSubview:_textTruncatingLabel]; 63 [self addSubview:_textTruncatingLabel];
63 64
64 _detailTruncatingLabel = 65 _detailTruncatingLabel =
65 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; 66 [[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero];
66 _detailTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; 67 _detailTruncatingLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
67 _detailTruncatingLabel.userInteractionEnabled = NO; 68 _detailTruncatingLabel.userInteractionEnabled = NO;
68 [self addSubview:_detailTruncatingLabel]; 69 [self addSubview:_detailTruncatingLabel];
69 70
70 // Answers use a UILabel with NSLineBreakByTruncatingTail to produce a 71 // Answers use a UILabel with NSLineBreakByTruncatingTail to produce a
71 // truncation with an ellipse instead of fading on multi-line text. 72 // truncation with an ellipse instead of fading on multi-line text.
72 _detailAnswerLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 73 _detailAnswerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
73 _detailAnswerLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; 74 _detailAnswerLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
74 _detailAnswerLabel.userInteractionEnabled = NO; 75 _detailAnswerLabel.userInteractionEnabled = NO;
75 _detailAnswerLabel.lineBreakMode = NSLineBreakByTruncatingTail; 76 _detailAnswerLabel.lineBreakMode = NSLineBreakByTruncatingTail;
76 [self addSubview:_detailAnswerLabel]; 77 [self addSubview:_detailAnswerLabel];
77 78
78 _appendButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; 79 _appendButton = [UIButton buttonWithType:UIButtonTypeCustom];
79 [_appendButton setContentMode:UIViewContentModeRight]; 80 [_appendButton setContentMode:UIViewContentModeRight];
80 [self updateAppendButtonImages]; 81 [self updateAppendButtonImages];
81 // TODO(justincohen): Consider using the UITableViewCell's accessory view. 82 // TODO(justincohen): Consider using the UITableViewCell's accessory view.
82 // The current implementation is from before using a UITableViewCell. 83 // The current implementation is from before using a UITableViewCell.
83 [self addSubview:_appendButton]; 84 [self addSubview:_appendButton];
84 85
85 // Leading icon is only displayed on iPad. 86 // Leading icon is only displayed on iPad.
86 if (IsIPadIdiom()) { 87 if (IsIPadIdiom()) {
87 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; 88 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
88 _imageView.userInteractionEnabled = NO; 89 _imageView.userInteractionEnabled = NO;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return _textTruncatingLabel.attributedText.string; 173 return _textTruncatingLabel.attributedText.string;
173 } 174 }
174 175
175 - (NSString*)accessibilityValue { 176 - (NSString*)accessibilityValue {
176 return _detailTruncatingLabel.hidden 177 return _detailTruncatingLabel.hidden
177 ? _detailAnswerLabel.attributedText.string 178 ? _detailAnswerLabel.attributedText.string
178 : _detailTruncatingLabel.attributedText.string; 179 : _detailTruncatingLabel.attributedText.string;
179 } 180 }
180 181
181 @end 182 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698