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