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

Side by Side Diff: ios/chrome/browser/ui/history/favicon_view.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: weak -> assign 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/history/favicon_view.h" 5 #import "ios/chrome/browser/ui/history/favicon_view.h"
6 6
7 #include "base/mac/objc_property_releaser.h" 7 #include "base/mac/objc_release_properties.h"
8 #import "ios/chrome/browser/ui/uikit_ui_util.h" 8 #import "ios/chrome/browser/ui/uikit_ui_util.h"
9 9
10 namespace { 10 namespace {
11 // Default corner radius for the favicon image view. 11 // Default corner radius for the favicon image view.
12 const CGFloat kDefaultCornerRadius = 3; 12 const CGFloat kDefaultCornerRadius = 3;
13 } 13 }
14 14
15 @interface FaviconView () { 15 @interface FaviconView ()
16 // Property releaser for FaviconView.
17 base::mac::ObjCPropertyReleaser _propertyReleaser_FaviconView;
18 }
19 // Size constraints for the favicon views. 16 // Size constraints for the favicon views.
20 @property(nonatomic, copy) NSArray* faviconSizeConstraints; 17 @property(nonatomic, copy) NSArray* faviconSizeConstraints;
21 @end 18 @end
22 19
23 @implementation FaviconView 20 @implementation FaviconView
24 21
25 @synthesize size = _size; 22 @synthesize size = _size;
26 @synthesize faviconImage = _faviconImage; 23 @synthesize faviconImage = _faviconImage;
27 @synthesize faviconFallbackLabel = _faviconFallbackLabel; 24 @synthesize faviconFallbackLabel = _faviconFallbackLabel;
28 @synthesize faviconSizeConstraints = _faviconSizeConstraints; 25 @synthesize faviconSizeConstraints = _faviconSizeConstraints;
29 26
30 - (instancetype)initWithFrame:(CGRect)frame { 27 - (instancetype)initWithFrame:(CGRect)frame {
31 self = [super initWithFrame:frame]; 28 self = [super initWithFrame:frame];
32 if (self) { 29 if (self) {
33 _propertyReleaser_FaviconView.Init(self, [FaviconView class]);
34 _faviconImage = [[UIImageView alloc] init]; 30 _faviconImage = [[UIImageView alloc] init];
35 _faviconImage.clipsToBounds = YES; 31 _faviconImage.clipsToBounds = YES;
36 _faviconImage.layer.cornerRadius = kDefaultCornerRadius; 32 _faviconImage.layer.cornerRadius = kDefaultCornerRadius;
37 _faviconImage.image = nil; 33 _faviconImage.image = nil;
38 34
39 _faviconFallbackLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 35 _faviconFallbackLabel = [[UILabel alloc] initWithFrame:CGRectZero];
40 _faviconFallbackLabel.backgroundColor = [UIColor clearColor]; 36 _faviconFallbackLabel.backgroundColor = [UIColor clearColor];
41 _faviconFallbackLabel.textAlignment = NSTextAlignmentCenter; 37 _faviconFallbackLabel.textAlignment = NSTextAlignmentCenter;
42 _faviconFallbackLabel.isAccessibilityElement = NO; 38 _faviconFallbackLabel.isAccessibilityElement = NO;
43 _faviconFallbackLabel.text = nil; 39 _faviconFallbackLabel.text = nil;
44 40
45 [self addSubview:_faviconImage]; 41 [self addSubview:_faviconImage];
46 [self addSubview:_faviconFallbackLabel]; 42 [self addSubview:_faviconFallbackLabel];
47 43
48 [_faviconImage setTranslatesAutoresizingMaskIntoConstraints:NO]; 44 [_faviconImage setTranslatesAutoresizingMaskIntoConstraints:NO];
49 [_faviconFallbackLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; 45 [_faviconFallbackLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
50 AddSameCenterConstraints(_faviconImage, self); 46 AddSameCenterConstraints(_faviconImage, self);
51 AddSameSizeConstraint(_faviconImage, self); 47 AddSameSizeConstraint(_faviconImage, self);
52 AddSameCenterConstraints(_faviconFallbackLabel, self); 48 AddSameCenterConstraints(_faviconFallbackLabel, self);
53 AddSameSizeConstraint(_faviconFallbackLabel, self); 49 AddSameSizeConstraint(_faviconFallbackLabel, self);
54 _faviconSizeConstraints = [@[ 50 _faviconSizeConstraints = [@[
55 [self.widthAnchor constraintEqualToConstant:0], 51 [self.widthAnchor constraintEqualToConstant:0],
56 [self.heightAnchor constraintEqualToConstant:0], 52 [self.heightAnchor constraintEqualToConstant:0],
57 ] retain]; 53 ] retain];
58 [NSLayoutConstraint activateConstraints:_faviconSizeConstraints]; 54 [NSLayoutConstraint activateConstraints:_faviconSizeConstraints];
59 } 55 }
60 return self; 56 return self;
61 } 57 }
62 58
59 - (void)dealloc {
60 base::mac::ReleaseProperties(self);
61 [super dealloc];
62 }
63
63 - (void)setSize:(CGFloat)size { 64 - (void)setSize:(CGFloat)size {
64 _size = size; 65 _size = size;
65 for (NSLayoutConstraint* constraint in self.faviconSizeConstraints) { 66 for (NSLayoutConstraint* constraint in self.faviconSizeConstraints) {
66 constraint.constant = size; 67 constraint.constant = size;
67 } 68 }
68 } 69 }
69 70
70 @end 71 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698