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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/history/favicon_view.mm
diff --git a/ios/chrome/browser/ui/history/favicon_view.mm b/ios/chrome/browser/ui/history/favicon_view.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bef1d0ef5f5b5ba983694017655961dacc70b877
--- /dev/null
+++ b/ios/chrome/browser/ui/history/favicon_view.mm
@@ -0,0 +1,70 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/history/favicon_view.h"
+
+#include "base/mac/objc_property_releaser.h"
+#import "ios/chrome/browser/ui/uikit_ui_util.h"
+
+namespace {
+// Default corner radius for the favicon image view.
+const CGFloat kDefaultCornerRadius = 3;
+}
+
+@interface FaviconView () {
+ // Property releaser for FaviconView.
+ base::mac::ObjCPropertyReleaser _propertyReleaser_FaviconView;
+}
+// Size constraints for the favicon views.
+@property(nonatomic, copy) NSArray* faviconSizeConstraints;
+@end
+
+@implementation FaviconView
+
+@synthesize size = _size;
+@synthesize faviconImage = _faviconImage;
+@synthesize faviconFallbackLabel = _faviconFallbackLabel;
+@synthesize faviconSizeConstraints = _faviconSizeConstraints;
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ _propertyReleaser_FaviconView.Init(self, [FaviconView class]);
+ _faviconImage = [[UIImageView alloc] init];
+ _faviconImage.clipsToBounds = YES;
+ _faviconImage.layer.cornerRadius = kDefaultCornerRadius;
+ _faviconImage.image = nil;
+
+ _faviconFallbackLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ _faviconFallbackLabel.backgroundColor = [UIColor clearColor];
+ _faviconFallbackLabel.textAlignment = NSTextAlignmentCenter;
+ _faviconFallbackLabel.isAccessibilityElement = NO;
+ _faviconFallbackLabel.text = nil;
+
+ [self addSubview:_faviconImage];
+ [self addSubview:_faviconFallbackLabel];
+
+ [_faviconImage setTranslatesAutoresizingMaskIntoConstraints:NO];
+ [_faviconFallbackLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
+ AddSameCenterConstraints(_faviconImage, self);
+ AddSameSizeConstraint(_faviconImage, self);
+ AddSameCenterConstraints(_faviconFallbackLabel, self);
+ AddSameSizeConstraint(_faviconFallbackLabel, self);
+ _faviconSizeConstraints = [@[
+ [self.widthAnchor constraintEqualToConstant:0],
+ [self.heightAnchor constraintEqualToConstant:0],
+ ] retain];
+ [NSLayoutConstraint activateConstraints:_faviconSizeConstraints];
+ }
+ return self;
+}
+
+- (void)setSize:(CGFloat)size {
+ _size = size;
+ for (NSLayoutConstraint* constraint in self.faviconSizeConstraints) {
+ constraint.constant = size;
+ }
+}
+
+@end
« 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