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

Side by Side Diff: ios/chrome/browser/ui/ntp/new_tab_page_view.mm

Issue 2881183002: Revert of Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: 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_release_properties.h" 8 #include "base/mac/objc_property_releaser.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_;
20 } 22 }
21 23
22 @synthesize scrollView = scrollView_; 24 @synthesize scrollView = scrollView_;
23 @synthesize tabBar = tabBar_; 25 @synthesize tabBar = tabBar_;
24 26
25 - (instancetype)initWithFrame:(CGRect)frame 27 - (instancetype)initWithFrame:(CGRect)frame
26 andScrollView:(UIScrollView*)scrollView 28 andScrollView:(UIScrollView*)scrollView
27 andTabBar:(NewTabPageBar*)tabBar { 29 andTabBar:(NewTabPageBar*)tabBar {
28 self = [super initWithFrame:frame]; 30 self = [super initWithFrame:frame];
29 if (self) { 31 if (self) {
32 propertyReleaser_NewTabPageView_.Init(self, [NewTabPageView class]);
30 [self addSubview:scrollView]; 33 [self addSubview:scrollView];
31 [self addSubview:tabBar]; 34 [self addSubview:tabBar];
32 scrollView_ = scrollView; 35 scrollView_ = scrollView;
33 tabBar_ = tabBar; 36 tabBar_ = tabBar;
34 } 37 }
35 return self; 38 return self;
36 } 39 }
37 40
38 - (instancetype)initWithFrame:(CGRect)frame { 41 - (instancetype)initWithFrame:(CGRect)frame {
39 NOTREACHED(); 42 NOTREACHED();
40 return nil; 43 return nil;
41 } 44 }
42 45
43 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 46 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
44 NOTREACHED(); 47 NOTREACHED();
45 return nil; 48 return nil;
46 } 49 }
47 50
48 - (void)dealloc {
49 base::mac::ReleaseProperties(self);
50 [super dealloc];
51 }
52
53 - (void)setFrame:(CGRect)frame { 51 - (void)setFrame:(CGRect)frame {
54 // When transitioning the iPhone xib to an iPad idiom, the setFrame call below 52 // When transitioning the iPhone xib to an iPad idiom, the setFrame call below
55 // can sometimes fire a scrollViewDidScroll event which changes the 53 // can sometimes fire a scrollViewDidScroll event which changes the
56 // selectedIndex underneath us. Save the selected index and remove the 54 // selectedIndex underneath us. Save the selected index and remove the
57 // delegate so scrollViewDidScroll isn't called. Then fix the scrollView 55 // delegate so scrollViewDidScroll isn't called. Then fix the scrollView
58 // offset after updating the frame. 56 // offset after updating the frame.
59 NSUInteger selectedIndex = self.tabBar.selectedIndex; 57 NSUInteger selectedIndex = self.tabBar.selectedIndex;
60 id<UIScrollViewDelegate> delegate = self.scrollView.delegate; 58 id<UIScrollViewDelegate> delegate = self.scrollView.delegate;
61 self.scrollView.delegate = nil; 59 self.scrollView.delegate = nil;
62 [super setFrame:frame]; 60 [super setFrame:frame];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 - (CGRect)panelFrameForItemAtIndex:(NSUInteger)index { 129 - (CGRect)panelFrameForItemAtIndex:(NSUInteger)index {
132 CGRect contentBounds = CGRectMake(0, 0, self.scrollView.contentSize.width, 130 CGRect contentBounds = CGRectMake(0, 0, self.scrollView.contentSize.width,
133 self.scrollView.contentSize.height); 131 self.scrollView.contentSize.height);
134 LayoutRect layout = 132 LayoutRect layout =
135 LayoutRectForRectInBoundingRect(self.scrollView.bounds, contentBounds); 133 LayoutRectForRectInBoundingRect(self.scrollView.bounds, contentBounds);
136 layout.position.leading = layout.size.width * index; 134 layout.position.leading = layout.size.width * index;
137 return LayoutRectGetRect(layout); 135 return LayoutRectGetRect(layout);
138 } 136 }
139 137
140 @end 138 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698