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

Side by Side Diff: ios/web/web_state/ui/crw_web_view_content_view.mm

Issue 2916473002: [ObjC ARC] Converts ios/web:web to ARC. (Closed)
Patch Set: Fixing silly mistake Created 3 years, 6 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 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_web_view_content_view.h" 5 #import "ios/web/public/web_state/ui/crw_web_view_content_view.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/scoped_nsobject.h" 10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
11 14
12 namespace { 15 namespace {
13 16
14 // Background color RGB values for the content view which is displayed when the 17 // Background color RGB values for the content view which is displayed when the
15 // |_webView| is offset from the screen due to user interaction. Displaying this 18 // |_webView| is offset from the screen due to user interaction. Displaying this
16 // background color is handled by UIWebView but not WKWebView, so it needs to be 19 // background color is handled by UIWebView but not WKWebView, so it needs to be
17 // set in CRWWebViewContentView to support both. The color value matches that 20 // set in CRWWebViewContentView to support both. The color value matches that
18 // used by UIWebView. 21 // used by UIWebView.
19 const CGFloat kBackgroundRGBComponents[] = {0.75f, 0.74f, 0.76f}; 22 const CGFloat kBackgroundRGBComponents[] = {0.75f, 0.74f, 0.76f};
20 23
21 } // namespace 24 } // namespace
22 25
23 @interface CRWWebViewContentView () { 26 @interface CRWWebViewContentView () {
24 // The web view being shown.
25 base::scoped_nsobject<UIView> _webView;
26 // The web view's scroll view.
27 base::scoped_nsobject<UIScrollView> _scrollView;
28 // Backs up property of the same name if |_webView| is a WKWebView. 27 // Backs up property of the same name if |_webView| is a WKWebView.
29 CGFloat _topContentPadding; 28 CGFloat _topContentPadding;
30 } 29 }
31 30
32 // Changes web view frame to match |self.bounds| and optionally accomodates for 31 // Changes web view frame to match |self.bounds| and optionally accomodates for
33 // |_topContentPadding| (iff |_webView| is a WKWebView). 32 // |_topContentPadding| (iff |_webView| is a WKWebView).
34 - (void)updateWebViewFrame; 33 - (void)updateWebViewFrame;
35 34
35 // The web view being shown.
36 @property(nonatomic, strong, readwrite) UIView* webView;
37 // The web view's scroll view.
38 @property(nonatomic, strong, readwrite) UIScrollView* scrollView;
36 @end 39 @end
37 40
38 @implementation CRWWebViewContentView 41 @implementation CRWWebViewContentView
39 42
40 @synthesize shouldUseInsetForTopPadding = _shouldUseInsetForTopPadding; 43 @synthesize shouldUseInsetForTopPadding = _shouldUseInsetForTopPadding;
44 @synthesize webView = _webView;
45 @synthesize scrollView = _scrollView;
41 46
42 - (instancetype)initWithWebView:(UIView*)webView 47 - (instancetype)initWithWebView:(UIView*)webView
43 scrollView:(UIScrollView*)scrollView { 48 scrollView:(UIScrollView*)scrollView {
44 self = [super initWithFrame:CGRectZero]; 49 self = [super initWithFrame:CGRectZero];
45 if (self) { 50 if (self) {
46 DCHECK(webView); 51 DCHECK(webView);
47 DCHECK(scrollView); 52 DCHECK(scrollView);
48 DCHECK([scrollView isDescendantOfView:webView]); 53 DCHECK([scrollView isDescendantOfView:webView]);
49 _webView.reset([webView retain]); 54 _webView = webView;
50 _scrollView.reset([scrollView retain]); 55 _scrollView = scrollView;
51 } 56 }
52 return self; 57 return self;
53 } 58 }
54 59
55 - (instancetype)initForTesting { 60 - (instancetype)initForTesting {
56 return [super initWithFrame:CGRectZero]; 61 return [super initWithFrame:CGRectZero];
57 } 62 }
58 63
59 - (instancetype)initWithCoder:(NSCoder*)decoder { 64 - (instancetype)initWithCoder:(NSCoder*)decoder {
60 NOTREACHED(); 65 NOTREACHED();
(...skipping 29 matching lines...) Expand all
90 [self updateWebViewFrame]; 95 [self updateWebViewFrame];
91 } 96 }
92 97
93 - (void)setBounds:(CGRect)bounds { 98 - (void)setBounds:(CGRect)bounds {
94 if (CGRectEqualToRect(self.bounds, bounds)) 99 if (CGRectEqualToRect(self.bounds, bounds))
95 return; 100 return;
96 [super setBounds:bounds]; 101 [super setBounds:bounds];
97 [self updateWebViewFrame]; 102 [self updateWebViewFrame];
98 } 103 }
99 104
100 #pragma mark Accessors
101
102 - (UIScrollView*)scrollView {
103 return _scrollView.get();
104 }
105
106 - (UIView*)webView {
107 return _webView.get();
108 }
109
110 #pragma mark Layout 105 #pragma mark Layout
111 106
112 - (void)layoutSubviews { 107 - (void)layoutSubviews {
113 [super layoutSubviews]; 108 [super layoutSubviews];
114 [self updateWebViewFrame]; 109 [self updateWebViewFrame];
115 } 110 }
116 111
117 - (BOOL)isViewAlive { 112 - (BOOL)isViewAlive {
118 return YES; 113 return YES;
119 } 114 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 160
166 - (void)updateWebViewFrame { 161 - (void)updateWebViewFrame {
167 CGRect webViewFrame = self.bounds; 162 CGRect webViewFrame = self.bounds;
168 webViewFrame.size.height -= _topContentPadding; 163 webViewFrame.size.height -= _topContentPadding;
169 webViewFrame.origin.y += _topContentPadding; 164 webViewFrame.origin.y += _topContentPadding;
170 165
171 self.webView.frame = webViewFrame; 166 self.webView.frame = webViewFrame;
172 } 167 }
173 168
174 @end 169 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller_container_view.mm ('k') | ios/web/web_state/ui/crw_wk_script_message_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698