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
3 // found in the LICENSE file.
5 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h"
7 #include "base/logging.h"
8 #include "base/mac/scoped_nsobject.h"
10 @interface CRWWebViewContentView () {
11 // The web view being shown.
12 base::scoped_nsobject<UIView> _webView;
13 // The web view's scroll view.
14 base::scoped_nsobject<UIScrollView> _scrollView;
19 @implementation CRWWebViewContentView
21 - (instancetype)initWithWebView:(UIView*)webView
22 scrollView:(UIScrollView*)scrollView {
23 self = [super initWithFrame:CGRectZero];
27 DCHECK([scrollView isDescendantOfView:webView]);
28 _webView.reset([webView retain]);
29 _scrollView.reset([scrollView retain]);
30 [self addSubview:_webView];
35 - (instancetype)initForTesting {
36 return [super initWithFrame:CGRectZero];
39 - (instancetype)initWithCoder:(NSCoder*)decoder {
44 - (instancetype)initWithFrame:(CGRect)frame {
49 #pragma mark Accessors
51 - (UIScrollView*)scrollView {
52 return _scrollView.get();
56 return _webView.get();
61 - (void)layoutSubviews {
62 [super layoutSubviews];
63 self.webView.frame = self.bounds;