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

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

Issue 2944443003: [ObjC ARC] Converts ios/chrome/browser/ui/stack_view:stack_view to ARC. (Closed)
Patch Set: Add and use explicit disconnect in CardSet. 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_set.mm
diff --git a/ios/chrome/browser/ui/stack_view/card_set.mm b/ios/chrome/browser/ui/stack_view/card_set.mm
index 67617e44aa16e96ffe327399377cb7f2c742ac3e..e23f0a2c6a355c8bd17ee8b3062deaefbfef1278 100644
--- a/ios/chrome/browser/ui/stack_view/card_set.mm
+++ b/ios/chrome/browser/ui/stack_view/card_set.mm
@@ -7,7 +7,6 @@
#import <QuartzCore/QuartzCore.h>
#include "base/logging.h"
-#import "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/tabs/tab.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#include "ios/chrome/browser/ui/rtl_geometry.h"
@@ -17,15 +16,19 @@
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace {
const CGFloat kMaxCardStaggerPercentage = 0.35;
}
@interface CardSet ()<StackCardViewProvider, TabModelObserver> {
- base::scoped_nsobject<TabModel> tabModel_;
- base::scoped_nsobject<UIView> view_;
- base::scoped_nsobject<CardStackLayoutManager> stackModel_;
- base::scoped_nsobject<UIImageView> stackShadow_;
+ TabModel* tabModel_;
+ UIView* view_;
+ CardStackLayoutManager* stackModel_;
+ UIImageView* stackShadow_;
}
// Set to |YES| when the card set should draw a shadow around the entire stack.
@@ -61,23 +64,26 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
@synthesize closingCard = closingCard_;
- (CardStackLayoutManager*)stackModel {
- return stackModel_.get();
+ return stackModel_;
}
- (id)initWithModel:(TabModel*)model {
if ((self = [super init])) {
- tabModel_.reset([model retain]);
+ tabModel_ = model;
[tabModel_ addObserver:self];
- stackModel_.reset([[CardStackLayoutManager alloc] init]);
+ stackModel_ = [[CardStackLayoutManager alloc] init];
[self rebuildCards];
self.shouldShowShadow = YES;
}
return self;
}
-- (void)dealloc {
+- (void)disconnect {
[tabModel_ removeObserver:self];
- [super dealloc];
+}
+
+- (void)dealloc {
+ [self disconnect];
}
#pragma mark Properties
@@ -90,7 +96,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
DCHECK([tabModel count] == 0);
DCHECK([tabModel_ count] == 0);
[tabModel_ removeObserver:self];
- tabModel_.reset([tabModel retain]);
+ tabModel_ = tabModel;
if (!ignoresTabModelChanges_)
[tabModel_ addObserver:self];
}
@@ -122,11 +128,11 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
}
- (UIView*)displayView {
- return view_.get();
+ return view_;
}
- (void)setDisplayView:(UIView*)view {
- if (view == view_.get())
+ if (view == view_)
return;
for (StackCard* card in self.cards) {
if (card.viewIsLive) {
@@ -135,7 +141,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
}
}
[stackShadow_ removeFromSuperview];
- view_.reset([view retain]);
+ view_ = view;
// Add the stack shadow view to the new display view.
if (!stackShadow_) {
UIImage* shadowImage = [UIImage imageNamed:kCardShadowImageName];
@@ -145,7 +151,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
shadowImage.size.width / 2.0,
shadowImage.size.height / 2.0,
shadowImage.size.width / 2.0)];
- stackShadow_.reset([[UIImageView alloc] initWithImage:shadowImage]);
+ stackShadow_ = [[UIImageView alloc] initWithImage:shadowImage];
[stackShadow_ setHidden:!self.cards.count];
}
[view_ addSubview:stackShadow_];
@@ -154,7 +160,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
// if/when the view is restored (e.g., if the view was purged due to a memory
// warning while in a modal view and then restored when exiting the modal
// view).
- if (view_.get())
+ if (view_)
[self displayViewSizeWasChanged];
}
@@ -404,7 +410,6 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
- (void)removeCardAtIndex:(NSUInteger)index {
DCHECK(index < [self.cards count]);
StackCard* card = [self.cards objectAtIndex:index];
- [[card retain] autorelease];
[self.observer cardSet:self willRemoveCard:card atIndex:index];
[stackModel_ removeCard:card];
@@ -415,7 +420,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
- (StackCard*)buildCardFromTab:(Tab*)tab {
DCHECK(tab);
- StackCard* card = [[[StackCard alloc] initWithViewProvider:self] autorelease];
+ StackCard* card = [[StackCard alloc] initWithViewProvider:self];
card.size = [stackModel_ cardSize];
card.tabID = reinterpret_cast<NSUInteger>(tab);
@@ -425,7 +430,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
- (void)rebuildCards {
[stackModel_ removeAllCards];
- for (Tab* tab in tabModel_.get()) {
+ for (Tab* tab in tabModel_) {
StackCard* card = [self buildCardFromTab:tab];
[stackModel_ addCard:card];
}
@@ -485,9 +490,8 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
NSString* title = tab.title;
if (![title length])
title = tab.urlDisplayString;
- CardView* view =
- [[[CardView alloc] initWithFrame:frame
- isIncognito:[tabModel_ isOffTheRecord]] autorelease];
+ CardView* view = [[CardView alloc] initWithFrame:frame
+ isIncognito:[tabModel_ isOffTheRecord]];
[view setTitle:title];
[view setFavicon:[tab favicon]];
[tab retrieveSnapshot:^(UIImage* image) {
@@ -592,7 +596,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
}
- (void)setStackModelForTesting:(CardStackLayoutManager*)stackModel {
- stackModel_.reset([stackModel retain]);
+ stackModel_ = stackModel;
}
@end
« no previous file with comments | « ios/chrome/browser/ui/stack_view/card_set.h ('k') | ios/chrome/browser/ui/stack_view/card_stack_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698