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_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 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 - (void)didMoveToSuperview { | 72 - (void)didMoveToSuperview { |
73 [super didMoveToSuperview]; | 73 [super didMoveToSuperview]; |
74 if (self.superview) { | 74 if (self.superview) { |
75 self.autoresizingMask = | 75 self.autoresizingMask = |
76 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 76 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
77 [self addSubview:_webView]; | 77 [self addSubview:_webView]; |
78 self.backgroundColor = [UIColor colorWithRed:kBackgroundRGBComponents[0] | 78 self.backgroundColor = [UIColor colorWithRed:kBackgroundRGBComponents[0] |
79 green:kBackgroundRGBComponents[1] | 79 green:kBackgroundRGBComponents[1] |
80 blue:kBackgroundRGBComponents[2] | 80 blue:kBackgroundRGBComponents[2] |
81 alpha:1.0]; | 81 alpha:1.0]; |
82 // The frame needs to be set immediately after the web view is added | |
83 // as a subview. The change in the frame triggers drawing operations and | |
84 // if not done after it's added as a subview, the web view exhibits | |
85 // strange behavior where clicks from certain web sites are not triggered. | |
86 // The actual value of the frame doesn't matter as long as it's not | |
87 // CGRectZero. The CRWWebViewContentView's frame will be reset to a correct | |
88 // value in a subsequent layout pass. | |
89 // TODO(crbug.com/577793): This is an undocumented and not-well-understood | |
90 // workaround for this issue. | |
91 const CGRect kDummyRect = CGRectMake(10, 20, 30, 50); | |
92 self.frame = kDummyRect; | |
stuartmorgan
2016/02/09 21:27:50
Would it be worth adding a DCHECK here that the fr
shreyasv1
2016/02/09 21:58:29
The fact that it's non zero is a coincidence from
stuartmorgan
2016/02/09 22:15:19
If having it be non-zero avoids critical bugs, the
kkhorimoto
2016/02/09 22:17:11
I think it'd be better to add a DCHECK in
|-loadRe
| |
93 } | 82 } |
94 } | 83 } |
95 | 84 |
96 - (BOOL)becomeFirstResponder { | 85 - (BOOL)becomeFirstResponder { |
97 return [_webView becomeFirstResponder]; | 86 return [_webView becomeFirstResponder]; |
98 } | 87 } |
99 | 88 |
100 #pragma mark Accessors | 89 #pragma mark Accessors |
101 | 90 |
102 - (UIScrollView*)scrollView { | 91 - (UIScrollView*)scrollView { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 132 |
144 - (void)updateWebViewFrame { | 133 - (void)updateWebViewFrame { |
145 CGRect webViewFrame = self.bounds; | 134 CGRect webViewFrame = self.bounds; |
146 webViewFrame.size.height -= _topContentPadding; | 135 webViewFrame.size.height -= _topContentPadding; |
147 webViewFrame.origin.y += _topContentPadding; | 136 webViewFrame.origin.y += _topContentPadding; |
148 | 137 |
149 self.webView.frame = webViewFrame; | 138 self.webView.frame = webViewFrame; |
150 } | 139 } |
151 | 140 |
152 @end | 141 @end |
OLD | NEW |