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