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

Unified Diff: ios/chrome/browser/ui/stack_view/card_view.mm

Issue 2944443003: [ObjC ARC] Converts ios/chrome/browser/ui/stack_view:stack_view to ARC. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/stack_view/card_view.mm
diff --git a/ios/chrome/browser/ui/stack_view/card_view.mm b/ios/chrome/browser/ui/stack_view/card_view.mm
index 0ca24d4c40d7edd9d0520efe319fe27cd32f2a07..03f1a60a21641c41839c47a07f1df7572bb673e2 100644
--- a/ios/chrome/browser/ui/stack_view/card_view.mm
+++ b/ios/chrome/browser/ui/stack_view/card_view.mm
@@ -26,8 +26,7 @@
#include <algorithm>
#import "base/mac/foundation_util.h"
-#import "base/mac/objc_property_releaser.h"
-#import "base/mac/scoped_nsobject.h"
+
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/animation_util.h"
#import "ios/chrome/browser/ui/reversed_animation.h"
@@ -43,6 +42,10 @@
#include "ui/gfx/image/image.h"
#import "ui/gfx/ios/uikit_util.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using ios::material::TimingFunction;
const UIEdgeInsets kCardImageInsets = {48.0, 4.0, 4.0, 4.0};
@@ -85,10 +88,10 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
@interface CardTabView : UIView
@property(nonatomic, assign) CardCloseButtonSide closeButtonSide;
-@property(nonatomic, retain) UIImageView* favIconView;
-@property(nonatomic, retain) UIImage* favicon;
-@property(nonatomic, retain) CloseButton* closeButton;
-@property(nonatomic, retain) TitleLabel* titleLabel;
+@property(nonatomic, strong) UIImageView* favIconView;
+@property(nonatomic, strong) UIImage* favicon;
+@property(nonatomic, strong) CloseButton* closeButton;
+@property(nonatomic, strong) TitleLabel* titleLabel;
@property(nonatomic, assign) BOOL isIncognito;
// Layout helper selectors that calculate the frames for subviews given the
@@ -124,9 +127,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
@end
-@implementation CardTabView {
- base::mac::ObjCPropertyReleaser _propertyReleaser_CardTabView;
-}
+@implementation CardTabView
#pragma mark - Property Implementation
@@ -146,7 +147,6 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
if (!self)
return self;
- _propertyReleaser_CardTabView.Init(self, [CardTabView class]);
_isIncognito = isIncognito;
UIImage* image = ImageWithName(@"default_favicon", _isIncognito);
@@ -272,8 +272,6 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
- (void)setFavicon:(UIImage*)favicon {
if (favicon != _favicon) {
- [favicon retain];
- [_favicon release];
_favicon = favicon;
[self updateFaviconImage];
}
@@ -437,8 +435,8 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
#pragma mark -
@interface CardView () {
- base::scoped_nsobject<UIImageView> _contents;
- base::scoped_nsobject<CardTabView> _tab;
+ UIImageView* _contents;
+ CardTabView* _tab;
id _cardCloseTarget; // weak
stkhapugin 2017/06/16 13:17:50 s/"// weak"//__weak
marq (ping after 24h) 2017/06/19 10:34:24 Done.
SEL _cardCloseAction;
id _accessibilityTarget; // weak
stkhapugin 2017/06/16 13:17:50 ditto
marq (ping after 24h) 2017/06/19 10:34:24 Done.
@@ -447,12 +445,12 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
BOOL _isIncognito; // YES if the card should use the incognito styling.
// Pieces of the card frame, split into four UIViews.
- base::scoped_nsobject<UIImageView> _frameLeft;
- base::scoped_nsobject<UIImageView> _frameRight;
- base::scoped_nsobject<UIImageView> _frameTop;
- base::scoped_nsobject<UIImageView> _frameBottom;
- base::scoped_nsobject<UIImageView> _frameShadowImageView;
- base::scoped_nsobject<CALayer> _shadowMask;
+ UIImageView* _frameLeft;
+ UIImageView* _frameRight;
+ UIImageView* _frameTop;
+ UIImageView* _frameBottom;
+ UIImageView* _frameShadowImageView;
+ CALayer* _shadowMask;
}
// The LayoutRect for the CardTabView.
@@ -511,7 +509,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
self.contentMode = UIViewContentModeRedraw;
CGRect shadowFrame = UIEdgeInsetsInsetRect(bounds, kCardShadowLayoutOutsets);
- _frameShadowImageView.reset([[UIImageView alloc] initWithFrame:shadowFrame]);
+ _frameShadowImageView = [[UIImageView alloc] initWithFrame:shadowFrame];
[_frameShadowImageView
setAutoresizingMask:(UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight)];
@@ -526,7 +524,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
[_frameShadowImageView setImage:image];
CGRect snapshotFrame = UIEdgeInsetsInsetRect(bounds, kCardImageInsets);
- _contents.reset([[UIImageView alloc] initWithFrame:snapshotFrame]);
+ _contents = [[UIImageView alloc] initWithFrame:snapshotFrame];
[_contents setClipsToBounds:YES];
[_contents setContentMode:UIViewContentModeScaleAspectFill];
[_contents setFrame:snapshotFrame];
@@ -539,7 +537,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
UIEdgeInsets imageStretchInsets = UIEdgeInsetsMake(
0.5 * image.size.height, 0.0, 0.5 * image.size.height, 0.0);
image = [image resizableImageWithCapInsets:imageStretchInsets];
- _frameLeft.reset([[UIImageView alloc] initWithImage:image]);
+ _frameLeft = [[UIImageView alloc] initWithImage:image];
[self addSubview:_frameLeft];
image = [UIImage imageNamed:isIncognito ? @"border_frame_incognito_right"
@@ -547,7 +545,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
imageStretchInsets = UIEdgeInsetsMake(0.5 * image.size.height, 0.0,
0.5 * image.size.height, 0.0);
image = [image resizableImageWithCapInsets:imageStretchInsets];
- _frameRight.reset([[UIImageView alloc] initWithImage:image]);
+ _frameRight = [[UIImageView alloc] initWithImage:image];
[self addSubview:_frameRight];
image = [UIImage imageNamed:isIncognito ? @"border_frame_incognito_top"
@@ -555,7 +553,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
imageStretchInsets = UIEdgeInsetsMake(0.0, 0.5 * image.size.width, 0.0,
0.5 * image.size.width);
image = [image resizableImageWithCapInsets:imageStretchInsets];
- _frameTop.reset([[UIImageView alloc] initWithImage:image]);
+ _frameTop = [[UIImageView alloc] initWithImage:image];
[self addSubview:_frameTop];
image = [UIImage imageNamed:isIncognito ? @"border_frame_incognito_bottom"
@@ -563,12 +561,11 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
imageStretchInsets = UIEdgeInsetsMake(0.0, 0.5 * image.size.width, 0.0,
0.5 * image.size.width);
image = [image resizableImageWithCapInsets:imageStretchInsets];
- _frameBottom.reset([[UIImageView alloc] initWithImage:image]);
+ _frameBottom = [[UIImageView alloc] initWithImage:image];
[self addSubview:_frameBottom];
- _tab.reset([[CardTabView alloc]
- initWithFrame:LayoutRectGetRect([self tabLayout])
- isIncognito:_isIncognito]);
+ _tab = [[CardTabView alloc] initWithFrame:LayoutRectGetRect([self tabLayout])
+ isIncognito:_isIncognito];
[_tab setCloseButtonSide:IsPortrait() ? CardCloseButtonSide::TRAILING
: CardCloseButtonSide::LEADING];
[[_tab closeButton] addTarget:self
@@ -647,7 +644,10 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
}
- (void)closeButtonWasTapped:(id)sender {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[_cardCloseTarget performSelector:_cardCloseAction withObject:self];
+#pragma clang diagnostic pop
// Disable the tab's close button to prevent touch handling from the button
// while it's animating closed.
[_tab closeButton].enabled = NO;
@@ -679,7 +679,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
}
- (void)updateImageBoundsAndZoom {
- UIImageView* imageView = _contents.get();
+ UIImageView* imageView = _contents;
DCHECK(!CGRectEqualToRect(self.bounds, CGRectZero));
imageView.frame = UIEdgeInsetsInsetRect(self.bounds, kCardImageInsets);
@@ -698,8 +698,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
// Create copy of animation (animations become immutable after they're added
// to the layer).
- base::scoped_nsobject<CAAnimationGroup> updatedAnimation(
- static_cast<CAAnimationGroup*>([snapshotAnimation copy]));
+ CAAnimationGroup* updatedAnimation = [snapshotAnimation copy];
// Extract begin and end sizes of the card.
CAAnimation* cardAnimation =
[self.layer animationForKey:kCardViewAnimationKey];
@@ -746,7 +745,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
if (self.shouldMaskShadow) {
if (!_shadowMask) {
- _shadowMask.reset([[CALayer alloc] init]);
+ _shadowMask = [[CALayer alloc] init];
[_shadowMask setBackgroundColor:[UIColor blackColor].CGColor];
}
[_frameShadowImageView layer].mask = _shadowMask;
@@ -952,7 +951,7 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
forKey:kCardViewAnimationKey];
if (self.shouldMaskShadow) {
frameAnimation = FrameAnimationMake(
- _shadowMask.get(), [self shadowMaskFrameForBounds:beginBounds],
+ _shadowMask, [self shadowMaskFrameForBounds:beginBounds],
[self shadowMaskFrameForBounds:endBounds]);
frameAnimation.duration = frameDuration;
frameAnimation.timingFunction = frameTiming;
@@ -1029,7 +1028,10 @@ UIImage* ImageWithName(NSString* image_name, BOOL is_incognito) {
}
- (void)elementDidBecomeFocused:(id)sender {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[_accessibilityTarget performSelector:_accessibilityAction withObject:sender];
+#pragma clang diagnostic pop
}
@end

Powered by Google App Engine
This is Rietveld 408576698