OLD | NEW |
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" | |
9 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" | 8 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h" |
10 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h" | 9 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h" |
11 #import "ios/chrome/browser/ui/rtl_geometry.h" | 10 #import "ios/chrome/browser/ui/rtl_geometry.h" |
12 #include "ios/chrome/browser/ui/ui_util.h" | 11 #include "ios/chrome/browser/ui/ui_util.h" |
13 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
14 @implementation NewTabPageView { | 17 @implementation NewTabPageView { |
15 @private | |
16 // The objects pointed to by |tabBar_| and |scrollView_| are owned as | 18 // The objects pointed to by |tabBar_| and |scrollView_| are owned as |
17 // subviews already. | 19 // subviews already. |
18 __unsafe_unretained NewTabPageBar* tabBar_; // weak | 20 __weak NewTabPageBar* tabBar_; |
19 __unsafe_unretained UIScrollView* scrollView_; // weak | 21 __weak UIScrollView* scrollView_; |
20 | |
21 base::mac::ObjCPropertyReleaser propertyReleaser_NewTabPageView_; | |
22 } | 22 } |
23 | 23 |
24 @synthesize scrollView = scrollView_; | 24 @synthesize scrollView = scrollView_; |
25 @synthesize tabBar = tabBar_; | 25 @synthesize tabBar = tabBar_; |
26 | 26 |
27 - (instancetype)initWithFrame:(CGRect)frame | 27 - (instancetype)initWithFrame:(CGRect)frame |
28 andScrollView:(UIScrollView*)scrollView | 28 andScrollView:(UIScrollView*)scrollView |
29 andTabBar:(NewTabPageBar*)tabBar { | 29 andTabBar:(NewTabPageBar*)tabBar { |
30 self = [super initWithFrame:frame]; | 30 self = [super initWithFrame:frame]; |
31 if (self) { | 31 if (self) { |
32 propertyReleaser_NewTabPageView_.Init(self, [NewTabPageView class]); | |
33 [self addSubview:scrollView]; | 32 [self addSubview:scrollView]; |
34 [self addSubview:tabBar]; | 33 [self addSubview:tabBar]; |
35 scrollView_ = scrollView; | 34 scrollView_ = scrollView; |
36 tabBar_ = tabBar; | 35 tabBar_ = tabBar; |
37 } | 36 } |
38 return self; | 37 return self; |
39 } | 38 } |
40 | 39 |
41 - (instancetype)initWithFrame:(CGRect)frame { | 40 - (instancetype)initWithFrame:(CGRect)frame { |
42 NOTREACHED(); | 41 NOTREACHED(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 - (CGRect)panelFrameForItemAtIndex:(NSUInteger)index { | 128 - (CGRect)panelFrameForItemAtIndex:(NSUInteger)index { |
130 CGRect contentBounds = CGRectMake(0, 0, self.scrollView.contentSize.width, | 129 CGRect contentBounds = CGRectMake(0, 0, self.scrollView.contentSize.width, |
131 self.scrollView.contentSize.height); | 130 self.scrollView.contentSize.height); |
132 LayoutRect layout = | 131 LayoutRect layout = |
133 LayoutRectForRectInBoundingRect(self.scrollView.bounds, contentBounds); | 132 LayoutRectForRectInBoundingRect(self.scrollView.bounds, contentBounds); |
134 layout.position.leading = layout.size.width * index; | 133 layout.position.leading = layout.size.width * index; |
135 return LayoutRectGetRect(layout); | 134 return LayoutRectGetRect(layout); |
136 } | 135 } |
137 | 136 |
138 @end | 137 @end |
OLD | NEW |