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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm

Issue 2741413005: [ObjC ARC] Converts ios/chrome/browser/ui/bookmarks:bookmarks_arc to ARC. (Closed)
Patch Set: 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 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/bookmarks/bookmark_collection_cells.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/objc_property_releaser.h" 10
11 #include "base/mac/scoped_nsobject.h"
12 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h" 11 #import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h"
13 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h" 12 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h"
14 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 13 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
15 #import "ios/chrome/browser/ui/rtl_geometry.h" 14 #import "ios/chrome/browser/ui/rtl_geometry.h"
16 #import "ios/chrome/browser/ui/uikit_ui_util.h" 15 #import "ios/chrome/browser/ui/uikit_ui_util.h"
17 #include "ios/chrome/grit/ios_strings.h" 16 #include "ios/chrome/grit/ios_strings.h"
18 #include "ios/chrome/grit/ios_theme_resources.h" 17 #include "ios/chrome/grit/ios_theme_resources.h"
19 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h" 18 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h"
20 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 19 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
21 #include "ui/base/l10n/l10n_util_mac.h" 20 #include "ui/base/l10n/l10n_util_mac.h"
22 #import "ui/gfx/ios/NSString+CrStringDrawing.h" 21 #import "ui/gfx/ios/NSString+CrStringDrawing.h"
23 #include "url/gurl.h" 22 #include "url/gurl.h"
24 23
24 #if !defined(__has_feature) || !__has_feature(objc_arc)
25 #error "This file requires ARC support."
26 #endif
27
25 namespace { 28 namespace {
26 const CGFloat kBookmarkItemCellDefaultImageSize = 40.0; 29 const CGFloat kBookmarkItemCellDefaultImageSize = 40.0;
27 const CGFloat kBookmarkFolderCellDefaultImageSize = 24.0; 30 const CGFloat kBookmarkFolderCellDefaultImageSize = 24.0;
28 } // namespace 31 } // namespace
29 32
30 @interface BookmarkCell () { 33 @interface BookmarkCell ()
31 @protected
32 // Subclasses should set these in the constructor with the wanted values.
33 CGFloat _imageSize;
34
35 @private
36 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkCell;
37 }
38 // Redefined to be read-write. 34 // Redefined to be read-write.
39 @property(nonatomic, retain) UILabel* titleLabel; 35 @property(nonatomic, strong) UILabel* titleLabel;
40 // Redefined to readwrite. 36 // Redefined to readwrite.
41 @property(nonatomic, retain) UIImageView* imageView; 37 @property(nonatomic, strong) UIImageView* imageView;
42 // Label to show placeholder text when there is no image displayed. 38 // Label to show placeholder text when there is no image displayed.
43 @property(nonatomic, retain) UILabel* placeholderLabel; 39 @property(nonatomic, strong) UILabel* placeholderLabel;
44 // When the cell is selected for editing, a cover is shown with a blue color. 40 // When the cell is selected for editing, a cover is shown with a blue color.
45 // Subclasses should insert new views below this view. 41 // Subclasses should insert new views below this view.
46 @property(nonatomic, retain) UIView* highlightCover; 42 @property(nonatomic, strong) UIView* highlightCover;
47 // Lists the accessibility elements that are to be seen by UIAccessibility. 43 // Lists the accessibility elements that are to be seen by UIAccessibility.
48 @property(nonatomic, readonly) NSMutableArray* accessibilityElements; 44 @property(nonatomic, readonly) NSMutableArray* accessibilityElements;
49 // Location of the last touch on the cell. 45 // Location of the last touch on the cell.
50 @property(nonatomic, assign) CGPoint touchLocation; 46 @property(nonatomic, assign) CGPoint touchLocation;
51 // The view doing the highlight animation. Only set while the cell is 47 // The view doing the highlight animation. Only set while the cell is
52 // highlighted. 48 // highlighted.
53 @property(nonatomic, retain) MDCInkView* touchFeedbackView; 49 @property(nonatomic, strong) MDCInkView* touchFeedbackView;
54 @property(nonatomic, retain) BookmarkExtendedButton* button; 50 @property(nonatomic, strong) BookmarkExtendedButton* button;
55 @property(nonatomic, assign) SEL buttonAction; 51 @property(nonatomic, assign) SEL buttonAction;
56 @property(nonatomic, assign) id buttonTarget; 52 @property(nonatomic, weak) id buttonTarget;
53 // Side of a square image. Subclasses should set this to desired size.
54 @property(nonatomic, assign) CGFloat imageSize;
57 @end 55 @end
58 56
59 @implementation BookmarkCell 57 @implementation BookmarkCell
60 @synthesize accessibilityElements = _accessibilityElements; 58 @synthesize accessibilityElements = _accessibilityElements;
61 @synthesize titleLabel = _titleLabel; 59 @synthesize titleLabel = _titleLabel;
62 @synthesize imageView = _imageView; 60 @synthesize imageView = _imageView;
63 @synthesize highlightCover = _highlightCover; 61 @synthesize highlightCover = _highlightCover;
64 @synthesize shouldAnimateImageChanges = _shouldAnimateImageChanges; 62 @synthesize shouldAnimateImageChanges = _shouldAnimateImageChanges;
65 @synthesize touchLocation = _touchLocation; 63 @synthesize touchLocation = _touchLocation;
66 @synthesize touchFeedbackView = _touchFeedbackView; 64 @synthesize touchFeedbackView = _touchFeedbackView;
67 @synthesize button = _button; 65 @synthesize button = _button;
68 @synthesize buttonAction = _buttonAction; 66 @synthesize buttonAction = _buttonAction;
69 @synthesize buttonTarget = _buttonTarget; 67 @synthesize buttonTarget = _buttonTarget;
70 @synthesize placeholderLabel = _placeholderLabel; 68 @synthesize placeholderLabel = _placeholderLabel;
69 @synthesize imageSize = _imageSize;
71 70
72 + (NSString*)reuseIdentifier { 71 + (NSString*)reuseIdentifier {
73 NOTREACHED(); 72 NOTREACHED();
74 return nil; 73 return nil;
75 } 74 }
76 75
77 - (instancetype)initWithFrame:(CGRect)frame { 76 - (instancetype)initWithFrame:(CGRect)frame {
78 self = [super initWithFrame:frame]; 77 self = [super initWithFrame:frame];
79 if (self) { 78 if (self) {
80 _propertyReleaser_BookmarkCell.Init(self, [BookmarkCell class]);
81 self.exclusiveTouch = YES; 79 self.exclusiveTouch = YES;
82 self.backgroundColor = [UIColor whiteColor]; 80 self.backgroundColor = [UIColor whiteColor];
83 81
84 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 82 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
85 _titleLabel.textColor = bookmark_utils_ios::darkTextColor(); 83 _titleLabel.textColor = bookmark_utils_ios::darkTextColor();
86 self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO; 84 self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
87 [self.contentView addSubview:_titleLabel]; 85 [self.contentView addSubview:_titleLabel];
88 86
89 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; 87 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
90 _imageView.clipsToBounds = YES; 88 _imageView.clipsToBounds = YES;
91 self.imageView.translatesAutoresizingMaskIntoConstraints = NO; 89 self.imageView.translatesAutoresizingMaskIntoConstraints = NO;
92 [self.contentView addSubview:_imageView]; 90 [self.contentView addSubview:_imageView];
93 91
94 _placeholderLabel = [[UILabel alloc] init]; 92 _placeholderLabel = [[UILabel alloc] init];
95 _placeholderLabel.textAlignment = NSTextAlignmentCenter; 93 _placeholderLabel.textAlignment = NSTextAlignmentCenter;
96 [self.contentView addSubview:_placeholderLabel]; 94 [self.contentView addSubview:_placeholderLabel];
97 95
98 _highlightCover = [[UIView alloc] initWithFrame:CGRectZero]; 96 _highlightCover = [[UIView alloc] initWithFrame:CGRectZero];
99 _highlightCover.backgroundColor = 97 _highlightCover.backgroundColor =
100 [bookmark_utils_ios::blueColor() colorWithAlphaComponent:0.7]; 98 [bookmark_utils_ios::blueColor() colorWithAlphaComponent:0.7];
101 _highlightCover.hidden = YES; 99 _highlightCover.hidden = YES;
102 _highlightCover.translatesAutoresizingMaskIntoConstraints = NO; 100 _highlightCover.translatesAutoresizingMaskIntoConstraints = NO;
103 [self.contentView addSubview:_highlightCover]; 101 [self.contentView addSubview:_highlightCover];
104 102
105 self.button = base::scoped_nsobject<BookmarkExtendedButton>( 103 self.button = [[BookmarkExtendedButton alloc] init];
106 [[BookmarkExtendedButton alloc] init]);
107 self.button.contentMode = UIViewContentModeCenter; 104 self.button.contentMode = UIViewContentModeCenter;
108 self.button.backgroundColor = [UIColor clearColor]; 105 self.button.backgroundColor = [UIColor clearColor];
109 [self.button addTarget:self 106 [self.button addTarget:self
110 action:@selector(buttonTapped:) 107 action:@selector(buttonTapped:)
111 forControlEvents:UIControlEventTouchUpInside]; 108 forControlEvents:UIControlEventTouchUpInside];
112 self.button.translatesAutoresizingMaskIntoConstraints = NO; 109 self.button.translatesAutoresizingMaskIntoConstraints = NO;
113 [self.contentView insertSubview:self.button 110 [self.contentView insertSubview:self.button
114 belowSubview:self.highlightCover]; 111 belowSubview:self.highlightCover];
115 112
116 _accessibilityElements = [[NSMutableArray alloc] init]; 113 _accessibilityElements = [[NSMutableArray alloc] init];
117 self.contentView.isAccessibilityElement = YES; 114 self.contentView.isAccessibilityElement = YES;
118 self.contentView.accessibilityTraits |= UIAccessibilityTraitButton; 115 self.contentView.accessibilityTraits |= UIAccessibilityTraitButton;
119 [_accessibilityElements addObject:self.contentView]; 116 [_accessibilityElements addObject:self.contentView];
120 [self.accessibilityElements addObject:self.button]; 117 [self.accessibilityElements addObject:self.button];
121 } 118 }
122 return self; 119 return self;
123 } 120 }
124 121
125 + (BOOL)requiresConstraintBasedLayout { 122 + (BOOL)requiresConstraintBasedLayout {
126 return YES; 123 return YES;
127 } 124 }
128 125
129 - (void)updateConstraints { 126 - (void)updateConstraints {
130 if (_imageSize) { 127 if (self.imageSize) {
131 // Create constraints. 128 // Create constraints.
132 129
133 // Align all the views on the same horizontal line. 130 // Align all the views on the same horizontal line.
134 AddSameCenterYConstraint(self.contentView, self.titleLabel); 131 AddSameCenterYConstraint(self.contentView, self.titleLabel);
135 AddSameCenterYConstraint(self.contentView, self.imageView); 132 AddSameCenterYConstraint(self.contentView, self.imageView);
136 AddSameCenterYConstraint(self.contentView, self.button); 133 AddSameCenterYConstraint(self.contentView, self.button);
137 134
138 // clang-format off 135 // clang-format off
139 ApplyVisualConstraintsWithMetrics( 136 ApplyVisualConstraintsWithMetrics(
140 @[ 137 @[
141 @"H:|-leadingImageMargin-[image(imageSize)]", 138 @"H:|-leadingImageMargin-[image(imageSize)]",
142 @"H:|-leadingMargin-[title]-[button(buttonSize)]|", 139 @"H:|-leadingMargin-[title]-[button(buttonSize)]|",
143 @"V:[image(imageSize)]", 140 @"V:[image(imageSize)]",
144 @"V:[button(buttonSize)]", 141 @"V:[button(buttonSize)]",
145 @"H:|[highlight]|", 142 @"H:|[highlight]|",
146 @"V:|[highlight]|" 143 @"V:|[highlight]|"
147 ], 144 ],
148 @{ 145 @{
149 @"title" : self.titleLabel, 146 @"title" : self.titleLabel,
150 @"image" : self.imageView, 147 @"image" : self.imageView,
151 @"button" : self.button, 148 @"button" : self.button,
152 @"highlight" : self.highlightCover 149 @"highlight" : self.highlightCover
153 }, 150 },
154 @{ 151 @{
155 @"buttonSize" : [NSNumber numberWithFloat:32.0], 152 @"buttonSize" :@32.0,
156 @"leadingImageMargin" : [NSNumber numberWithFloat:16.0], 153 @"leadingImageMargin" : @16.0,
157 @"leadingMargin" : [NSNumber numberWithFloat:64.0], 154 @"leadingMargin" : @64.0,
158 @"imageSize" : [NSNumber numberWithFloat:_imageSize], 155 @"imageSize" : @(self.imageSize),
159 }, 156 },
160 self.contentView); 157 self.contentView);
161 // clang-format on 158 // clang-format on
162 } 159 }
163 160
164 [NSLayoutConstraint activateConstraints:@[ 161 [NSLayoutConstraint activateConstraints:@[
165 [self.placeholderLabel.leadingAnchor 162 [self.placeholderLabel.leadingAnchor
166 constraintEqualToAnchor:self.imageView.leadingAnchor], 163 constraintEqualToAnchor:self.imageView.leadingAnchor],
167 [self.placeholderLabel.trailingAnchor 164 [self.placeholderLabel.trailingAnchor
168 constraintEqualToAnchor:self.imageView.trailingAnchor], 165 constraintEqualToAnchor:self.imageView.trailingAnchor],
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 237
241 - (void)setHighlighted:(BOOL)highlighted { 238 - (void)setHighlighted:(BOOL)highlighted {
242 [super setHighlighted:highlighted]; 239 [super setHighlighted:highlighted];
243 240
244 // To prevent selection messing up with ink, immediately remove ink. 241 // To prevent selection messing up with ink, immediately remove ink.
245 [self.touchFeedbackView removeFromSuperview]; 242 [self.touchFeedbackView removeFromSuperview];
246 self.touchFeedbackView = nil; 243 self.touchFeedbackView = nil;
247 244
248 if (highlighted) { 245 if (highlighted) {
249 // Creates an ink feedback and animates it. 246 // Creates an ink feedback and animates it.
250 base::scoped_nsobject<MDCInkView> touchFeedbackView( 247 MDCInkView* touchFeedbackView =
251 [[MDCInkView alloc] initWithFrame:self.bounds]); 248 [[MDCInkView alloc] initWithFrame:self.bounds];
252 [self addSubview:touchFeedbackView]; 249 [self addSubview:touchFeedbackView];
253 self.touchFeedbackView = touchFeedbackView; 250 self.touchFeedbackView = touchFeedbackView;
254 [self.touchFeedbackView startTouchBeganAnimationAtPoint:self.touchLocation 251 [self.touchFeedbackView startTouchBeganAnimationAtPoint:self.touchLocation
255 completion:nil]; 252 completion:nil];
256 } else { 253 } else {
257 [self.touchFeedbackView startTouchEndedAnimationAtPoint:self.touchLocation 254 [self.touchFeedbackView startTouchEndedAnimationAtPoint:self.touchLocation
258 completion:nil]; 255 completion:nil];
259 } 256 }
260 } 257 }
261 258
262 - (void)updateWithTitle:(NSString*)title { 259 - (void)updateWithTitle:(NSString*)title {
263 self.titleLabel.text = title; 260 self.titleLabel.text = title;
264 [self setNeedsLayout]; 261 [self setNeedsLayout];
265 [self updateAccessibilityValues]; 262 [self updateAccessibilityValues];
266 } 263 }
267 264
268 #pragma mark - Button 265 #pragma mark - Button
269 - (void)setButtonTarget:(id)target action:(SEL)action { 266 - (void)setButtonTarget:(id)target action:(SEL)action {
270 self.buttonTarget = target; 267 self.buttonTarget = target;
271 self.buttonAction = action; 268 self.buttonAction = action;
272 } 269 }
273 270
274 - (void)buttonTapped:(id)target { 271 - (void)buttonTapped:(id)target {
272 #pragma clang diagnostic push
273 #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
275 [self.buttonTarget performSelector:self.buttonAction 274 [self.buttonTarget performSelector:self.buttonAction
276 withObject:self 275 withObject:self
277 withObject:target]; 276 withObject:target];
277 #pragma clang diagnostic pop
278 } 278 }
279 279
280 - (void)showButtonOfType:(bookmark_cell::ButtonType)buttonType 280 - (void)showButtonOfType:(bookmark_cell::ButtonType)buttonType
281 animated:(BOOL)animated { 281 animated:(BOOL)animated {
282 switch (buttonType) { 282 switch (buttonType) {
283 case bookmark_cell::ButtonNone: 283 case bookmark_cell::ButtonNone:
284 [self removeButtonAnimated:animated]; 284 [self removeButtonAnimated:animated];
285 break; 285 break;
286 286
287 case bookmark_cell::ButtonMenu: { 287 case bookmark_cell::ButtonMenu: {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 349
350 - (NSInteger)indexOfAccessibilityElement:(id)element { 350 - (NSInteger)indexOfAccessibilityElement:(id)element {
351 return [self.accessibilityElements indexOfObject:element]; 351 return [self.accessibilityElements indexOfObject:element];
352 } 352 }
353 353
354 @end 354 @end
355 355
356 #pragma mark - BookmarkItemCell 356 #pragma mark - BookmarkItemCell
357 357
358 @interface BookmarkItemCell () {
359 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkItemCell;
360 }
361 @end
362
363 @implementation BookmarkItemCell 358 @implementation BookmarkItemCell
364 359
365 + (NSString*)reuseIdentifier { 360 + (NSString*)reuseIdentifier {
366 return @"BookmarkItemCell"; 361 return @"BookmarkItemCell";
367 } 362 }
368 363
369 + (CGFloat)preferredImageSize { 364 + (CGFloat)preferredImageSize {
370 return kBookmarkItemCellDefaultImageSize; 365 return kBookmarkItemCellDefaultImageSize;
371 } 366 }
372 367
373 - (instancetype)initWithFrame:(CGRect)frame { 368 - (instancetype)initWithFrame:(CGRect)frame {
374 self = [super initWithFrame:frame]; 369 self = [super initWithFrame:frame];
375 if (self) { 370 if (self) {
376 _propertyReleaser_BookmarkItemCell.Init(self, [BookmarkItemCell class]);
377
378 // Set the non-layout properties of the titles. 371 // Set the non-layout properties of the titles.
379 UIFont* font = [MDCTypography subheadFont]; 372 UIFont* font = [MDCTypography subheadFont];
380 self.titleLabel.font = font; 373 self.titleLabel.font = font;
381 self.titleLabel.backgroundColor = [UIColor clearColor]; 374 self.titleLabel.backgroundColor = [UIColor clearColor];
382 self.titleLabel.numberOfLines = 1; 375 self.titleLabel.numberOfLines = 1;
383 376
384 _imageSize = kBookmarkItemCellDefaultImageSize; 377 self.imageSize = kBookmarkItemCellDefaultImageSize;
385 } 378 }
386 return self; 379 return self;
387 } 380 }
388 381
389 - (void)updateWithTitle:(NSString*)title { 382 - (void)updateWithTitle:(NSString*)title {
390 [super updateWithTitle:title]; 383 [super updateWithTitle:title];
391 [self updateAccessibilityValues]; 384 [self updateAccessibilityValues];
392 } 385 }
393 386
394 - (void)updateAccessibilityValues { 387 - (void)updateAccessibilityValues {
395 [super updateAccessibilityValues]; 388 [super updateAccessibilityValues];
396 self.contentView.accessibilityLabel = 389 self.contentView.accessibilityLabel =
397 [NSString stringWithFormat:@"%@", self.titleLabel.text]; 390 [NSString stringWithFormat:@"%@", self.titleLabel.text];
398 self.contentView.accessibilityIdentifier = self.titleLabel.text; 391 self.contentView.accessibilityIdentifier = self.titleLabel.text;
399 } 392 }
400 393
401 - (void)prepareForReuse { 394 - (void)prepareForReuse {
402 [super prepareForReuse]; 395 [super prepareForReuse];
403 [self updateAccessibilityValues]; 396 [self updateAccessibilityValues];
404 } 397 }
405 398
406 @end 399 @end
407 400
408 #pragma mark - BookmarkFolderCell 401 #pragma mark - BookmarkFolderCell
409
410 @interface BookmarkFolderCell () {
411 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkFolderCell;
412 }
413
414 @end
415
416 @implementation BookmarkFolderCell 402 @implementation BookmarkFolderCell
417 403
418 + (NSString*)reuseIdentifier { 404 + (NSString*)reuseIdentifier {
419 return @"BookmarkFolderCell"; 405 return @"BookmarkFolderCell";
420 } 406 }
421 407
422 - (instancetype)initWithFrame:(CGRect)frame { 408 - (instancetype)initWithFrame:(CGRect)frame {
423 self = [super initWithFrame:frame]; 409 self = [super initWithFrame:frame];
424 if (self) { 410 if (self) {
425 _propertyReleaser_BookmarkFolderCell.Init(self, [BookmarkFolderCell class]);
426
427 self.imageView.image = [UIImage imageNamed:@"bookmark_gray_folder"]; 411 self.imageView.image = [UIImage imageNamed:@"bookmark_gray_folder"];
428 self.titleLabel.font = [MDCTypography subheadFont]; 412 self.titleLabel.font = [MDCTypography subheadFont];
429 413
430 _imageSize = kBookmarkFolderCellDefaultImageSize; 414 self.imageSize = kBookmarkFolderCellDefaultImageSize;
431 } 415 }
432 return self; 416 return self;
433 } 417 }
434 418
435 - (void)prepareForReuse { 419 - (void)prepareForReuse {
436 [super prepareForReuse]; 420 [super prepareForReuse];
437 [self setImage:[UIImage imageNamed:@"bookmark_gray_folder"]]; 421 [self setImage:[UIImage imageNamed:@"bookmark_gray_folder"]];
438 } 422 }
439 423
440 - (void)updateWithTitle:(NSString*)title { 424 - (void)updateWithTitle:(NSString*)title {
441 [super updateWithTitle:title]; 425 [super updateWithTitle:title];
442 426
443 self.contentView.accessibilityLabel = title; 427 self.contentView.accessibilityLabel = title;
444 self.contentView.accessibilityIdentifier = title; 428 self.contentView.accessibilityIdentifier = title;
445 } 429 }
446 430
447 @end 431 @end
448 432
449 #pragma mark - BookmarkHeaderView 433 #pragma mark - BookmarkHeaderView
450 434
451 @interface BookmarkHeaderView () { 435 @interface BookmarkHeaderView ()
452 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHeaderView; 436 @property(nonatomic, strong) UILabel* titleLabel;
453 }
454 @property(nonatomic, retain) UILabel* titleLabel;
455 @end 437 @end
456 438
457 @implementation BookmarkHeaderView 439 @implementation BookmarkHeaderView
458 @synthesize titleLabel = _titleLabel; 440 @synthesize titleLabel = _titleLabel;
441
459 + (NSString*)reuseIdentifier { 442 + (NSString*)reuseIdentifier {
460 return @"BookmarkHeaderView"; 443 return @"BookmarkHeaderView";
461 } 444 }
462 445
463 + (CGFloat)handsetHeight { 446 + (CGFloat)handsetHeight {
464 return 47.0; 447 return 47.0;
465 } 448 }
466 449
467 - (instancetype)initWithFrame:(CGRect)frame { 450 - (instancetype)initWithFrame:(CGRect)frame {
468 self = [super initWithFrame:frame]; 451 self = [super initWithFrame:frame];
469 if (self) { 452 if (self) {
470 _propertyReleaser_BookmarkHeaderView.Init(self, [BookmarkHeaderView class]); 453 UILabel* titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
471 base::scoped_nsobject<UILabel> titleLabel(
472 [[UILabel alloc] initWithFrame:CGRectZero]);
473 self.titleLabel = titleLabel; 454 self.titleLabel = titleLabel;
474 UIFont* font = [MDCTypography body2Font]; 455 UIFont* font = [MDCTypography body2Font];
475 self.titleLabel.font = font; 456 self.titleLabel.font = font;
476 self.titleLabel.textColor = bookmark_utils_ios::lightTextColor(); 457 self.titleLabel.textColor = bookmark_utils_ios::lightTextColor();
477 self.titleLabel.backgroundColor = [UIColor clearColor]; 458 self.titleLabel.backgroundColor = [UIColor clearColor];
478 self.titleLabel.accessibilityTraits |= UIAccessibilityTraitHeader; 459 self.titleLabel.accessibilityTraits |= UIAccessibilityTraitHeader;
479 [self addSubview:self.titleLabel]; 460 [self addSubview:self.titleLabel];
480 } 461 }
481 return self; 462 return self;
482 } 463 }
(...skipping 17 matching lines...) Expand all
500 - (void)updateLayoutWithLeftMargin:(CGFloat)leftMargin { 481 - (void)updateLayoutWithLeftMargin:(CGFloat)leftMargin {
501 self.titleLabel.frame = 482 self.titleLabel.frame =
502 CGRectMake(leftMargin, 0, self.bounds.size.width - leftMargin, 483 CGRectMake(leftMargin, 0, self.bounds.size.width - leftMargin,
503 self.bounds.size.height); 484 self.bounds.size.height);
504 } 485 }
505 486
506 @end 487 @end
507 488
508 #pragma mark - BookmarkHeaderSeparatorView 489 #pragma mark - BookmarkHeaderSeparatorView
509 490
510 @interface BookmarkHeaderSeparatorView () { 491 @interface BookmarkHeaderSeparatorView ()
511 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHeaderSeparatorView;
512 }
513 // The bottom separator line. 492 // The bottom separator line.
514 @property(nonatomic, retain) UIView* lineView; 493 @property(nonatomic, strong) UIView* lineView;
515 @end 494 @end
516 495
517 @implementation BookmarkHeaderSeparatorView 496 @implementation BookmarkHeaderSeparatorView
518 497
519 @synthesize lineView = _lineView; 498 @synthesize lineView = _lineView;
520 499
521 + (NSString*)reuseIdentifier { 500 + (NSString*)reuseIdentifier {
522 return NSStringFromClass(self); 501 return NSStringFromClass(self);
523 } 502 }
524 503
525 + (CGFloat)preferredHeight { 504 + (CGFloat)preferredHeight {
526 return 16; 505 return 16;
527 } 506 }
528 507
529 - (instancetype)initWithFrame:(CGRect)frame { 508 - (instancetype)initWithFrame:(CGRect)frame {
530 self = [super initWithFrame:frame]; 509 self = [super initWithFrame:frame];
531 if (self) { 510 if (self) {
532 _propertyReleaser_BookmarkHeaderSeparatorView.Init(
533 self, [BookmarkHeaderSeparatorView class]);
534 _lineView = [[UIView alloc] init]; 511 _lineView = [[UIView alloc] init];
535 _lineView.backgroundColor = bookmark_utils_ios::separatorColor(); 512 _lineView.backgroundColor = bookmark_utils_ios::separatorColor();
536 [self addSubview:_lineView]; 513 [self addSubview:_lineView];
537 } 514 }
538 return self; 515 return self;
539 } 516 }
540 517
541 - (void)layoutSubviews { 518 - (void)layoutSubviews {
542 CGFloat lineHeight = 1; 519 CGFloat lineHeight = 1;
543 CGFloat lineY = self.bounds.size.height - lineHeight - 8; 520 CGFloat lineY = self.bounds.size.height - lineHeight - 8;
544 _lineView.frame = CGRectMake(0, lineY, self.bounds.size.width, lineHeight); 521 _lineView.frame = CGRectMake(0, lineY, self.bounds.size.width, lineHeight);
545 } 522 }
546 523
547 @end 524 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698