OLD | NEW |
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/favicon_view.h" | 5 #import "ios/chrome/browser/ui/favicon_view.h" |
6 | 6 |
| 7 #include "base/mac/objc_property_releaser.h" |
7 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 8 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
8 | 9 |
9 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
10 #error "This file requires ARC support." | |
11 #endif | |
12 | |
13 namespace { | 10 namespace { |
14 // Default corner radius for the favicon image view. | 11 // Default corner radius for the favicon image view. |
15 const CGFloat kDefaultCornerRadius = 3; | 12 const CGFloat kDefaultCornerRadius = 3; |
16 } | 13 } |
17 | 14 |
18 @interface FaviconViewNew () { | 15 @interface FaviconViewNew () { |
19 // Property releaser for FaviconViewNew. | 16 // Property releaser for FaviconViewNew. |
| 17 base::mac::ObjCPropertyReleaser _propertyReleaser_FaviconViewNew; |
20 } | 18 } |
21 | 19 |
22 // Image view for the favicon. | 20 // Image view for the favicon. |
23 @property(nonatomic, strong) UIImageView* faviconImageView; | 21 @property(nonatomic, retain) UIImageView* faviconImageView; |
24 // Label for fallback favicon placeholder. | 22 // Label for fallback favicon placeholder. |
25 @property(nonatomic, strong) UILabel* faviconFallbackLabel; | 23 @property(nonatomic, retain) UILabel* faviconFallbackLabel; |
26 | 24 |
27 @end | 25 @end |
28 | 26 |
29 @implementation FaviconViewNew | 27 @implementation FaviconViewNew |
30 @synthesize faviconImageView = _faviconImageView; | 28 @synthesize faviconImageView = _faviconImageView; |
31 @synthesize faviconFallbackLabel = _faviconFallbackLabel; | 29 @synthesize faviconFallbackLabel = _faviconFallbackLabel; |
32 | 30 |
33 - (instancetype)initWithFrame:(CGRect)frame { | 31 - (instancetype)initWithFrame:(CGRect)frame { |
34 self = [super initWithFrame:frame]; | 32 self = [super initWithFrame:frame]; |
35 if (self) { | 33 if (self) { |
| 34 _propertyReleaser_FaviconViewNew.Init(self, [FaviconViewNew class]); |
36 _faviconImageView = [[UIImageView alloc] initWithFrame:self.bounds]; | 35 _faviconImageView = [[UIImageView alloc] initWithFrame:self.bounds]; |
37 _faviconImageView.clipsToBounds = YES; | 36 _faviconImageView.clipsToBounds = YES; |
38 _faviconImageView.layer.cornerRadius = kDefaultCornerRadius; | 37 _faviconImageView.layer.cornerRadius = kDefaultCornerRadius; |
39 _faviconImageView.image = nil; | 38 _faviconImageView.image = nil; |
40 | 39 |
41 _faviconFallbackLabel = [[UILabel alloc] initWithFrame:self.bounds]; | 40 _faviconFallbackLabel = [[UILabel alloc] initWithFrame:self.bounds]; |
42 _faviconFallbackLabel.backgroundColor = [UIColor clearColor]; | 41 _faviconFallbackLabel.backgroundColor = [UIColor clearColor]; |
43 _faviconFallbackLabel.textAlignment = NSTextAlignmentCenter; | 42 _faviconFallbackLabel.textAlignment = NSTextAlignmentCenter; |
44 _faviconFallbackLabel.isAccessibilityElement = NO; | 43 _faviconFallbackLabel.isAccessibilityElement = NO; |
45 _faviconFallbackLabel.clipsToBounds = YES; | 44 _faviconFallbackLabel.clipsToBounds = YES; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 self.faviconFallbackLabel.font = font; | 78 self.faviconFallbackLabel.font = font; |
80 } | 79 } |
81 | 80 |
82 #pragma mark - UIView | 81 #pragma mark - UIView |
83 | 82 |
84 - (CGSize)intrinsicContentSize { | 83 - (CGSize)intrinsicContentSize { |
85 return CGSizeMake(kFaviconPreferredSize, kFaviconPreferredSize); | 84 return CGSizeMake(kFaviconPreferredSize, kFaviconPreferredSize); |
86 } | 85 } |
87 | 86 |
88 @end | 87 @end |
OLD | NEW |