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

Side by Side Diff: ios/chrome/browser/ui/stack_view/stack_card.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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/stack_view/stack_card.h" 5 #import "ios/chrome/browser/ui/stack_view/stack_card.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/scoped_nsobject.h"
9 #import "ios/chrome/browser/ui/rtl_geometry.h" 8 #import "ios/chrome/browser/ui/rtl_geometry.h"
10 #import "ios/chrome/browser/ui/stack_view/card_view.h" 9 #import "ios/chrome/browser/ui/stack_view/card_view.h"
11 #import "ios/chrome/browser/ui/ui_util.h" 10 #import "ios/chrome/browser/ui/ui_util.h"
12 11
12 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support."
14 #endif
15
13 @interface StackCard () { 16 @interface StackCard () {
14 id<StackCardViewProvider> _viewProvider; 17 __weak id<StackCardViewProvider> _viewProvider;
15 base::scoped_nsobject<CardView> _view; 18 CardView* _view;
16 } 19 }
17 20
18 // The pixel-aligned frame generated by applying |self.layout| under the current 21 // The pixel-aligned frame generated by applying |self.layout| under the current
19 // language direction. 22 // language direction.
20 @property(nonatomic, readonly) CGRect frame; 23 @property(nonatomic, readonly) CGRect frame;
21 24
22 // Applies |self.layout| to the underlying CardView if it exists. 25 // Applies |self.layout| to the underlying CardView if it exists.
23 - (void)applyLayout; 26 - (void)applyLayout;
24 27
25 @end 28 @end
(...skipping 14 matching lines...) Expand all
40 return self; 43 return self;
41 } 44 }
42 45
43 - (instancetype)init { 46 - (instancetype)init {
44 NOTREACHED(); 47 NOTREACHED();
45 return nil; 48 return nil;
46 } 49 }
47 50
48 - (void)releaseView { 51 - (void)releaseView {
49 if (self.viewIsLive) 52 if (self.viewIsLive)
50 _view.reset(); 53 _view = nil;
51 } 54 }
52 55
53 #pragma mark - Properties 56 #pragma mark - Properties
54 57
55 - (CardView*)view { 58 - (CardView*)view {
56 if (!_view) { 59 if (!_view) {
57 _view.reset([[_viewProvider cardViewWithFrame:self.frame forStackCard:self] 60 _view = [_viewProvider cardViewWithFrame:self.frame forStackCard:self];
58 retain]); 61 _view.isActiveTab = _isActiveTab;
59 _view.get().isActiveTab = _isActiveTab;
60 } 62 }
61 return _view.get(); 63 return _view;
62 } 64 }
63 65
64 - (void)setLayout:(LayoutRect)layout { 66 - (void)setLayout:(LayoutRect)layout {
65 if (!LayoutRectEqualToRect(_layout, layout)) { 67 if (!LayoutRectEqualToRect(_layout, layout)) {
66 _layout = layout; 68 _layout = layout;
67 [self applyLayout]; 69 [self applyLayout];
68 } 70 }
69 } 71 }
70 72
71 - (CGSize)size { 73 - (CGSize)size {
(...skipping 12 matching lines...) Expand all
84 86
85 - (void)setSynchronizeView:(BOOL)synchronizeView { 87 - (void)setSynchronizeView:(BOOL)synchronizeView {
86 if (_synchronizeView != synchronizeView) { 88 if (_synchronizeView != synchronizeView) {
87 _synchronizeView = synchronizeView; 89 _synchronizeView = synchronizeView;
88 [self applyLayout]; 90 [self applyLayout];
89 } 91 }
90 } 92 }
91 93
92 - (void)setIsActiveTab:(BOOL)isActiveTab { 94 - (void)setIsActiveTab:(BOOL)isActiveTab {
93 _isActiveTab = isActiveTab; 95 _isActiveTab = isActiveTab;
94 _view.get().isActiveTab = _isActiveTab; 96 _view.isActiveTab = _isActiveTab;
95 } 97 }
96 98
97 - (BOOL)viewIsLive { 99 - (BOOL)viewIsLive {
98 return _view != nil; 100 return _view != nil;
99 } 101 }
100 102
101 - (CGRect)frame { 103 - (CGRect)frame {
102 return AlignRectOriginAndSizeToPixels(LayoutRectGetRect(self.layout)); 104 return AlignRectOriginAndSizeToPixels(LayoutRectGetRect(self.layout));
103 } 105 }
104 106
105 #pragma mark - 107 #pragma mark -
106 108
107 - (void)applyLayout { 109 - (void)applyLayout {
108 if (!self.viewIsLive || !self.synchronizeView) 110 if (!self.viewIsLive || !self.synchronizeView)
109 return; 111 return;
110 self.view.frame = self.frame; 112 self.view.frame = self.frame;
111 } 113 }
112 114
113 @end 115 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/stack_view/page_animation_util.mm ('k') | ios/chrome/browser/ui/stack_view/stack_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698