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

Side by Side Diff: ios/chrome/browser/ui/stack_view/card_view.mm

Issue 2610923005: Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: Rebase Created 3 years, 7 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 // For performance reasons, the composition of the card frame is broken up into 5 // For performance reasons, the composition of the card frame is broken up into
6 // four pieces. The overall structure of the CardView is: 6 // four pieces. The overall structure of the CardView is:
7 // - CardView 7 // - CardView
8 // - Snapshot (UIImageView) 8 // - Snapshot (UIImageView)
9 // - FrameTop (UIImageView) 9 // - FrameTop (UIImageView)
10 // - FrameLeft (UIImageView) 10 // - FrameLeft (UIImageView)
11 // - FrameRight (UIImageView) 11 // - FrameRight (UIImageView)
12 // - FrameBottom (UIImageView) 12 // - FrameBottom (UIImageView)
13 // - CardTabView (UIView::DrawRect) 13 // - CardTabView (UIView::DrawRect)
14 // 14 //
15 // While it would be simpler to put the frame in one transparent UIImageView, 15 // While it would be simpler to put the frame in one transparent UIImageView,
16 // that would make the entire snapshot area needlessly color-blended. Instead 16 // that would make the entire snapshot area needlessly color-blended. Instead
17 // the frame is broken up into four pieces, top, left, bottom, right. 17 // the frame is broken up into four pieces, top, left, bottom, right.
18 // 18 //
19 // The frame's tab gets its own view above everything else (CardTabView) so that 19 // The frame's tab gets its own view above everything else (CardTabView) so that
20 // it can be animated out. It's also transparent since the tab has a curve and 20 // it can be animated out. It's also transparent since the tab has a curve and
21 // a shadow. 21 // a shadow.
22 22
23 #import "ios/chrome/browser/ui/stack_view/card_view.h" 23 #import "ios/chrome/browser/ui/stack_view/card_view.h"
24 24
25 #import <QuartzCore/QuartzCore.h> 25 #import <QuartzCore/QuartzCore.h>
26 #include <algorithm> 26 #include <algorithm>
27 27
28 #import "base/mac/foundation_util.h" 28 #import "base/mac/foundation_util.h"
29 #import "base/mac/objc_property_releaser.h" 29 #include "base/mac/objc_release_properties.h"
30 #import "base/mac/scoped_nsobject.h" 30 #import "base/mac/scoped_nsobject.h"
31 #include "components/strings/grit/components_strings.h" 31 #include "components/strings/grit/components_strings.h"
32 #import "ios/chrome/browser/ui/animation_util.h" 32 #import "ios/chrome/browser/ui/animation_util.h"
33 #import "ios/chrome/browser/ui/reversed_animation.h" 33 #import "ios/chrome/browser/ui/reversed_animation.h"
34 #import "ios/chrome/browser/ui/rtl_geometry.h" 34 #import "ios/chrome/browser/ui/rtl_geometry.h"
35 #import "ios/chrome/browser/ui/stack_view/close_button.h" 35 #import "ios/chrome/browser/ui/stack_view/close_button.h"
36 #import "ios/chrome/browser/ui/stack_view/title_label.h" 36 #import "ios/chrome/browser/ui/stack_view/title_label.h"
37 #import "ios/chrome/browser/ui/ui_util.h" 37 #import "ios/chrome/browser/ui/ui_util.h"
38 #import "ios/chrome/common/material_timing.h" 38 #import "ios/chrome/common/material_timing.h"
39 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 39 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 - (void)cleanUpAnimations; 117 - (void)cleanUpAnimations;
118 118
119 // Initialize a CardTabView with |frame| and |isIncognito| state. 119 // Initialize a CardTabView with |frame| and |isIncognito| state.
120 - (instancetype)initWithFrame:(CGRect)frame 120 - (instancetype)initWithFrame:(CGRect)frame
121 isIncognito:(BOOL)isIncognito NS_DESIGNATED_INITIALIZER; 121 isIncognito:(BOOL)isIncognito NS_DESIGNATED_INITIALIZER;
122 122
123 - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; 123 - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
124 124
125 @end 125 @end
126 126
127 @implementation CardTabView { 127 @implementation CardTabView
128 base::mac::ObjCPropertyReleaser _propertyReleaser_CardTabView;
129 }
130 128
131 #pragma mark - Property Implementation 129 #pragma mark - Property Implementation
132 130
133 @synthesize closeButtonSide = _closeButtonSide; 131 @synthesize closeButtonSide = _closeButtonSide;
134 @synthesize favIconView = _faviconView; 132 @synthesize favIconView = _faviconView;
135 @synthesize favicon = _favicon; 133 @synthesize favicon = _favicon;
136 @synthesize closeButton = _closeButton; 134 @synthesize closeButton = _closeButton;
137 @synthesize titleLabel = _titleLabel; 135 @synthesize titleLabel = _titleLabel;
138 @synthesize isIncognito = _isIncognito; 136 @synthesize isIncognito = _isIncognito;
139 137
140 - (instancetype)initWithFrame:(CGRect)frame { 138 - (instancetype)initWithFrame:(CGRect)frame {
141 return [self initWithFrame:frame isIncognito:NO]; 139 return [self initWithFrame:frame isIncognito:NO];
142 } 140 }
143 141
144 - (instancetype)initWithFrame:(CGRect)frame isIncognito:(BOOL)isIncognito { 142 - (instancetype)initWithFrame:(CGRect)frame isIncognito:(BOOL)isIncognito {
145 self = [super initWithFrame:frame]; 143 self = [super initWithFrame:frame];
146 if (!self) 144 if (!self)
147 return self; 145 return self;
148 146
149 _propertyReleaser_CardTabView.Init(self, [CardTabView class]);
150 _isIncognito = isIncognito; 147 _isIncognito = isIncognito;
151 148
152 UIImage* image = ImageWithName(@"default_favicon", _isIncognito); 149 UIImage* image = ImageWithName(@"default_favicon", _isIncognito);
153 _faviconView = [[UIImageView alloc] initWithImage:image]; 150 _faviconView = [[UIImageView alloc] initWithImage:image];
154 [self addSubview:_faviconView]; 151 [self addSubview:_faviconView];
155 152
156 UIImage* normal = ImageWithName(@"card_close_button", _isIncognito); 153 UIImage* normal = ImageWithName(@"card_close_button", _isIncognito);
157 UIImage* pressed = ImageWithName(@"card_close_button_pressed", _isIncognito); 154 UIImage* pressed = ImageWithName(@"card_close_button_pressed", _isIncognito);
158 155
159 _closeButton = [[CloseButton alloc] initWithFrame:CGRectZero]; 156 _closeButton = [[CloseButton alloc] initWithFrame:CGRectZero];
(...skipping 11 matching lines...) Expand all
171 [self updateTitleColors]; 168 [self updateTitleColors];
172 169
173 return self; 170 return self;
174 } 171 }
175 172
176 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 173 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
177 NOTREACHED(); 174 NOTREACHED();
178 return nil; 175 return nil;
179 } 176 }
180 177
178 - (void)dealloc {
179 base::mac::ReleaseProperties(self);
180 [super dealloc];
181 }
182
181 - (void)setCloseButtonSide:(CardCloseButtonSide)closeButtonSide { 183 - (void)setCloseButtonSide:(CardCloseButtonSide)closeButtonSide {
182 if (_closeButtonSide != closeButtonSide) { 184 if (_closeButtonSide != closeButtonSide) {
183 _closeButtonSide = closeButtonSide; 185 _closeButtonSide = closeButtonSide;
184 [self setNeedsLayout]; 186 [self setNeedsLayout];
185 } 187 }
186 } 188 }
187 189
188 - (void)layoutSubviews { 190 - (void)layoutSubviews {
189 [super layoutSubviews]; 191 [super layoutSubviews];
190 self.favIconView.frame = [self faviconFrameForBounds:self.bounds]; 192 self.favIconView.frame = [self faviconFrameForBounds:self.bounds];
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 DCHECK(!target || [target respondsToSelector:action]); 1028 DCHECK(!target || [target respondsToSelector:action]);
1027 _accessibilityTarget = target; 1029 _accessibilityTarget = target;
1028 _accessibilityAction = action; 1030 _accessibilityAction = action;
1029 } 1031 }
1030 1032
1031 - (void)elementDidBecomeFocused:(id)sender { 1033 - (void)elementDidBecomeFocused:(id)sender {
1032 [_accessibilityTarget performSelector:_accessibilityAction withObject:sender]; 1034 [_accessibilityTarget performSelector:_accessibilityAction withObject:sender];
1033 } 1035 }
1034 1036
1035 @end 1037 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698