OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/web/public/web_state/ui/crw_generic_content_view.h" | 5 #import "ios/web/public/web_state/ui/crw_generic_content_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." |
| 12 #endif |
| 13 |
10 @interface CRWGenericContentView () { | 14 @interface CRWGenericContentView () { |
11 // The size of the view's bounds at the last call to |-layoutSubviews|. | 15 // The size of the view's bounds at the last call to |-layoutSubviews|. |
12 CGSize _lastLayoutSize; | 16 CGSize _lastLayoutSize; |
13 // Backing objectect for |self.scrollView|. | 17 // Backing objectect for |self.scrollView|. |
14 base::scoped_nsobject<UIScrollView> _scrollView; | 18 base::scoped_nsobject<UIScrollView> _scrollView; |
15 // Backing object for |self.view|. | 19 // Backing object for |self.view|. |
16 base::scoped_nsobject<UIView> _view; | 20 base::scoped_nsobject<UIView> _view; |
17 } | 21 } |
18 | 22 |
19 @end | 23 @end |
20 | 24 |
21 @implementation CRWGenericContentView | 25 @implementation CRWGenericContentView |
22 | 26 |
23 - (instancetype)initWithView:(UIView*)view { | 27 - (instancetype)initWithView:(UIView*)view { |
24 self = [super initWithFrame:CGRectZero]; | 28 self = [super initWithFrame:CGRectZero]; |
25 if (self) { | 29 if (self) { |
26 DCHECK(view); | 30 DCHECK(view); |
27 _lastLayoutSize = CGSizeZero; | 31 _lastLayoutSize = CGSizeZero; |
28 _view.reset([view retain]); | 32 _view.reset(view); |
29 _scrollView.reset([[UIScrollView alloc] initWithFrame:CGRectZero]); | 33 _scrollView.reset([[UIScrollView alloc] initWithFrame:CGRectZero]); |
30 [self addSubview:_scrollView]; | 34 [self addSubview:_scrollView]; |
31 [_scrollView addSubview:_view]; | 35 [_scrollView addSubview:_view]; |
32 [_scrollView setBackgroundColor:[_view backgroundColor]]; | 36 [_scrollView setBackgroundColor:[_view backgroundColor]]; |
33 } | 37 } |
34 return self; | 38 return self; |
35 } | 39 } |
36 | 40 |
37 - (instancetype)initWithCoder:(NSCoder*)decoder { | 41 - (instancetype)initWithCoder:(NSCoder*)decoder { |
38 NOTREACHED(); | 42 NOTREACHED(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 viewSize.height = CGRectGetHeight(contentRect) + singlePixel; | 97 viewSize.height = CGRectGetHeight(contentRect) + singlePixel; |
94 } | 98 } |
95 self.scrollView.contentSize = viewSize; | 99 self.scrollView.contentSize = viewSize; |
96 } | 100 } |
97 | 101 |
98 - (BOOL)isViewAlive { | 102 - (BOOL)isViewAlive { |
99 return YES; | 103 return YES; |
100 } | 104 } |
101 | 105 |
102 @end | 106 @end |
OLD | NEW |