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

Unified Diff: ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm

Issue 2738053008: Revert of [ObjC ARC] Converts ios/chrome/browser/ui/bookmarks:bookmarks_arc_2 to ARC. (Closed)
Patch Set: Created 3 years, 9 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/bookmarks/bookmark_collection_cells.mm
diff --git a/ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm b/ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm
index 315ceedc82523c4487b4fe73e70dd33c232b90ad..38ea80526f47f812abd7a0d07f0106af33e32ee6 100644
--- a/ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm
+++ b/ios/chrome/browser/ui/bookmarks/bookmark_collection_cells.mm
@@ -7,7 +7,8 @@
#import <QuartzCore/QuartzCore.h>
#include "base/logging.h"
-
+#include "base/mac/objc_property_releaser.h"
+#include "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_extended_button.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
@@ -21,37 +22,38 @@
#import "ui/gfx/ios/NSString+CrStringDrawing.h"
#include "url/gurl.h"
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
namespace {
const CGFloat kBookmarkItemCellDefaultImageSize = 40.0;
const CGFloat kBookmarkFolderCellDefaultImageSize = 24.0;
} // namespace
-@interface BookmarkCell ()
+@interface BookmarkCell () {
+ @protected
+ // Subclasses should set these in the constructor with the wanted values.
+ CGFloat _imageSize;
+
+ @private
+ base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkCell;
+}
// Redefined to be read-write.
-@property(nonatomic, strong) UILabel* titleLabel;
+@property(nonatomic, retain) UILabel* titleLabel;
// Redefined to readwrite.
-@property(nonatomic, strong) UIImageView* imageView;
+@property(nonatomic, retain) UIImageView* imageView;
// Label to show placeholder text when there is no image displayed.
-@property(nonatomic, strong) UILabel* placeholderLabel;
+@property(nonatomic, retain) UILabel* placeholderLabel;
// When the cell is selected for editing, a cover is shown with a blue color.
// Subclasses should insert new views below this view.
-@property(nonatomic, strong) UIView* highlightCover;
+@property(nonatomic, retain) UIView* highlightCover;
// Lists the accessibility elements that are to be seen by UIAccessibility.
@property(nonatomic, readonly) NSMutableArray* accessibilityElements;
// Location of the last touch on the cell.
@property(nonatomic, assign) CGPoint touchLocation;
// The view doing the highlight animation. Only set while the cell is
// highlighted.
-@property(nonatomic, strong) MDCInkView* touchFeedbackView;
-@property(nonatomic, strong) BookmarkExtendedButton* button;
+@property(nonatomic, retain) MDCInkView* touchFeedbackView;
+@property(nonatomic, retain) BookmarkExtendedButton* button;
@property(nonatomic, assign) SEL buttonAction;
-@property(nonatomic, weak) id buttonTarget;
-// Side of a square image. Subclasses should set this to desired size.
-@property(nonatomic, assign) CGFloat imageSize;
+@property(nonatomic, assign) id buttonTarget;
@end
@implementation BookmarkCell
@@ -66,7 +68,6 @@
@synthesize buttonAction = _buttonAction;
@synthesize buttonTarget = _buttonTarget;
@synthesize placeholderLabel = _placeholderLabel;
-@synthesize imageSize = _imageSize;
+ (NSString*)reuseIdentifier {
NOTREACHED();
@@ -76,6 +77,7 @@
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
+ _propertyReleaser_BookmarkCell.Init(self, [BookmarkCell class]);
self.exclusiveTouch = YES;
self.backgroundColor = [UIColor whiteColor];
@@ -100,7 +102,8 @@
_highlightCover.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_highlightCover];
- self.button = [[BookmarkExtendedButton alloc] init];
+ self.button = base::scoped_nsobject<BookmarkExtendedButton>(
+ [[BookmarkExtendedButton alloc] init]);
self.button.contentMode = UIViewContentModeCenter;
self.button.backgroundColor = [UIColor clearColor];
[self.button addTarget:self
@@ -124,7 +127,7 @@
}
- (void)updateConstraints {
- if (self.imageSize) {
+ if (_imageSize) {
// Create constraints.
// Align all the views on the same horizontal line.
@@ -149,10 +152,10 @@
@"highlight" : self.highlightCover
},
@{
- @"buttonSize" :@32.0,
- @"leadingImageMargin" : @16.0,
- @"leadingMargin" : @64.0,
- @"imageSize" : @(self.imageSize),
+ @"buttonSize" : [NSNumber numberWithFloat:32.0],
+ @"leadingImageMargin" : [NSNumber numberWithFloat:16.0],
+ @"leadingMargin" : [NSNumber numberWithFloat:64.0],
+ @"imageSize" : [NSNumber numberWithFloat:_imageSize],
},
self.contentView);
// clang-format on
@@ -244,8 +247,8 @@
if (highlighted) {
// Creates an ink feedback and animates it.
- MDCInkView* touchFeedbackView =
- [[MDCInkView alloc] initWithFrame:self.bounds];
+ base::scoped_nsobject<MDCInkView> touchFeedbackView(
+ [[MDCInkView alloc] initWithFrame:self.bounds]);
[self addSubview:touchFeedbackView];
self.touchFeedbackView = touchFeedbackView;
[self.touchFeedbackView startTouchBeganAnimationAtPoint:self.touchLocation
@@ -269,12 +272,9 @@
}
- (void)buttonTapped:(id)target {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.buttonTarget performSelector:self.buttonAction
withObject:self
withObject:target];
-#pragma clang diagnostic pop
}
- (void)showButtonOfType:(bookmark_cell::ButtonType)buttonType
@@ -355,6 +355,11 @@
#pragma mark - BookmarkItemCell
+@interface BookmarkItemCell () {
+ base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkItemCell;
+}
+@end
+
@implementation BookmarkItemCell
+ (NSString*)reuseIdentifier {
@@ -368,13 +373,15 @@
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
+ _propertyReleaser_BookmarkItemCell.Init(self, [BookmarkItemCell class]);
+
// Set the non-layout properties of the titles.
UIFont* font = [MDCTypography subheadFont];
self.titleLabel.font = font;
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.numberOfLines = 1;
- self.imageSize = kBookmarkItemCellDefaultImageSize;
+ _imageSize = kBookmarkItemCellDefaultImageSize;
}
return self;
}
@@ -399,6 +406,13 @@
@end
#pragma mark - BookmarkFolderCell
+
+@interface BookmarkFolderCell () {
+ base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkFolderCell;
+}
+
+@end
+
@implementation BookmarkFolderCell
+ (NSString*)reuseIdentifier {
@@ -408,10 +422,12 @@
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
+ _propertyReleaser_BookmarkFolderCell.Init(self, [BookmarkFolderCell class]);
+
self.imageView.image = [UIImage imageNamed:@"bookmark_gray_folder"];
self.titleLabel.font = [MDCTypography subheadFont];
- self.imageSize = kBookmarkFolderCellDefaultImageSize;
+ _imageSize = kBookmarkFolderCellDefaultImageSize;
}
return self;
}
@@ -432,13 +448,14 @@
#pragma mark - BookmarkHeaderView
-@interface BookmarkHeaderView ()
-@property(nonatomic, strong) UILabel* titleLabel;
+@interface BookmarkHeaderView () {
+ base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHeaderView;
+}
+@property(nonatomic, retain) UILabel* titleLabel;
@end
@implementation BookmarkHeaderView
@synthesize titleLabel = _titleLabel;
-
+ (NSString*)reuseIdentifier {
return @"BookmarkHeaderView";
}
@@ -450,7 +467,9 @@
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
- UILabel* titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
+ _propertyReleaser_BookmarkHeaderView.Init(self, [BookmarkHeaderView class]);
+ base::scoped_nsobject<UILabel> titleLabel(
+ [[UILabel alloc] initWithFrame:CGRectZero]);
self.titleLabel = titleLabel;
UIFont* font = [MDCTypography body2Font];
self.titleLabel.font = font;
@@ -488,9 +507,11 @@
#pragma mark - BookmarkHeaderSeparatorView
-@interface BookmarkHeaderSeparatorView ()
+@interface BookmarkHeaderSeparatorView () {
+ base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHeaderSeparatorView;
+}
// The bottom separator line.
-@property(nonatomic, strong) UIView* lineView;
+@property(nonatomic, retain) UIView* lineView;
@end
@implementation BookmarkHeaderSeparatorView
@@ -508,6 +529,8 @@
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
+ _propertyReleaser_BookmarkHeaderSeparatorView.Init(
+ self, [BookmarkHeaderSeparatorView class]);
_lineView = [[UIView alloc] init];
_lineView.backgroundColor = bookmark_utils_ios::separatorColor();
[self addSubview:_lineView];

Powered by Google App Engine
This is Rietveld 408576698