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

Side by Side Diff: ios/chrome/browser/ui/ntp/new_tab_page_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 #import "ios/chrome/browser/ui/ntp/new_tab_page_view.h" 5 #import "ios/chrome/browser/ui/ntp/new_tab_page_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/objc_property_releaser.h" 8 #include "base/mac/objc_release_properties.h"
9 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" 9 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h"
10 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h" 10 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h"
11 #import "ios/chrome/browser/ui/rtl_geometry.h" 11 #import "ios/chrome/browser/ui/rtl_geometry.h"
12 #include "ios/chrome/browser/ui/ui_util.h" 12 #include "ios/chrome/browser/ui/ui_util.h"
13 13
14 @implementation NewTabPageView { 14 @implementation NewTabPageView {
15 @private 15 @private
16 // The objects pointed to by |tabBar_| and |scrollView_| are owned as 16 // The objects pointed to by |tabBar_| and |scrollView_| are owned as
17 // subviews already. 17 // subviews already.
18 __unsafe_unretained NewTabPageBar* tabBar_; // weak 18 __unsafe_unretained NewTabPageBar* tabBar_; // weak
19 __unsafe_unretained UIScrollView* scrollView_; // weak 19 __unsafe_unretained UIScrollView* scrollView_; // weak
20
21 base::mac::ObjCPropertyReleaser propertyReleaser_NewTabPageView_;
22 } 20 }
23 21
24 @synthesize scrollView = scrollView_; 22 @synthesize scrollView = scrollView_;
25 @synthesize tabBar = tabBar_; 23 @synthesize tabBar = tabBar_;
26 24
27 - (instancetype)initWithFrame:(CGRect)frame 25 - (instancetype)initWithFrame:(CGRect)frame
28 andScrollView:(UIScrollView*)scrollView 26 andScrollView:(UIScrollView*)scrollView
29 andTabBar:(NewTabPageBar*)tabBar { 27 andTabBar:(NewTabPageBar*)tabBar {
30 self = [super initWithFrame:frame]; 28 self = [super initWithFrame:frame];
31 if (self) { 29 if (self) {
32 propertyReleaser_NewTabPageView_.Init(self, [NewTabPageView class]);
33 [self addSubview:scrollView]; 30 [self addSubview:scrollView];
34 [self addSubview:tabBar]; 31 [self addSubview:tabBar];
35 scrollView_ = scrollView; 32 scrollView_ = scrollView;
36 tabBar_ = tabBar; 33 tabBar_ = tabBar;
37 } 34 }
38 return self; 35 return self;
39 } 36 }
40 37
41 - (instancetype)initWithFrame:(CGRect)frame { 38 - (instancetype)initWithFrame:(CGRect)frame {
42 NOTREACHED(); 39 NOTREACHED();
43 return nil; 40 return nil;
44 } 41 }
45 42
46 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 43 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
47 NOTREACHED(); 44 NOTREACHED();
48 return nil; 45 return nil;
49 } 46 }
50 47
48 - (void)dealloc {
49 base::mac::ReleaseProperties(self);
50 [super dealloc];
51 }
52
51 - (void)setFrame:(CGRect)frame { 53 - (void)setFrame:(CGRect)frame {
52 // When transitioning the iPhone xib to an iPad idiom, the setFrame call below 54 // When transitioning the iPhone xib to an iPad idiom, the setFrame call below
53 // can sometimes fire a scrollViewDidScroll event which changes the 55 // can sometimes fire a scrollViewDidScroll event which changes the
54 // selectedIndex underneath us. Save the selected index and remove the 56 // selectedIndex underneath us. Save the selected index and remove the
55 // delegate so scrollViewDidScroll isn't called. Then fix the scrollView 57 // delegate so scrollViewDidScroll isn't called. Then fix the scrollView
56 // offset after updating the frame. 58 // offset after updating the frame.
57 NSUInteger selectedIndex = self.tabBar.selectedIndex; 59 NSUInteger selectedIndex = self.tabBar.selectedIndex;
58 id<UIScrollViewDelegate> delegate = self.scrollView.delegate; 60 id<UIScrollViewDelegate> delegate = self.scrollView.delegate;
59 self.scrollView.delegate = nil; 61 self.scrollView.delegate = nil;
60 [super setFrame:frame]; 62 [super setFrame:frame];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 - (CGRect)panelFrameForItemAtIndex:(NSUInteger)index { 131 - (CGRect)panelFrameForItemAtIndex:(NSUInteger)index {
130 CGRect contentBounds = CGRectMake(0, 0, self.scrollView.contentSize.width, 132 CGRect contentBounds = CGRectMake(0, 0, self.scrollView.contentSize.width,
131 self.scrollView.contentSize.height); 133 self.scrollView.contentSize.height);
132 LayoutRect layout = 134 LayoutRect layout =
133 LayoutRectForRectInBoundingRect(self.scrollView.bounds, contentBounds); 135 LayoutRectForRectInBoundingRect(self.scrollView.bounds, contentBounds);
134 layout.position.leading = layout.size.width * index; 136 layout.position.leading = layout.size.width * index;
135 return LayoutRectGetRect(layout); 137 return LayoutRectGetRect(layout);
136 } 138 }
137 139
138 @end 140 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698