| 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..57703f925e324ecc7d8e8fe4268b075e8c6fe3cd 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,14 +64,14 @@ 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;
|
| }
|
| @@ -77,7 +80,6 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
|
|
|
| - (void)dealloc {
|
| [tabModel_ removeObserver:self];
|
| - [super dealloc];
|
| }
|
|
|
| #pragma mark Properties
|
| @@ -90,7 +92,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 +124,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 +137,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 +147,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 +156,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 +406,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 +416,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 +426,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 +486,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 +592,7 @@ const CGFloat kMaxCardStaggerPercentage = 0.35;
|
| }
|
|
|
| - (void)setStackModelForTesting:(CardStackLayoutManager*)stackModel {
|
| - stackModel_.reset([stackModel retain]);
|
| + stackModel_ = stackModel;
|
| }
|
|
|
| @end
|
|
|