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

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

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

Powered by Google App Engine
This is Rietveld 408576698