| 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/web_state/ui/crw_web_controller_container_view.h" | 5 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" |
| 6 | 6 |
| 7 #include "base/ios/weak_nsobject.h" | 7 #include "base/ios/weak_nsobject.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #import "ios/web/public/web_state/ui/crw_content_view.h" | 10 #import "ios/web/public/web_state/ui/crw_content_view.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 #pragma mark Accessors | 153 #pragma mark Accessors |
| 154 | 154 |
| 155 - (CRWWebViewContentView*)webViewContentView { | 155 - (CRWWebViewContentView*)webViewContentView { |
| 156 return _webViewContentView.get(); | 156 return _webViewContentView.get(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 - (void)setWebViewContentView:(CRWWebViewContentView*)webViewContentView { | 159 - (void)setWebViewContentView:(CRWWebViewContentView*)webViewContentView { |
| 160 if (![_webViewContentView isEqual:webViewContentView]) { | 160 if (![_webViewContentView isEqual:webViewContentView]) { |
| 161 [_webViewContentView removeFromSuperview]; | 161 [_webViewContentView removeFromSuperview]; |
| 162 _webViewContentView.reset([webViewContentView retain]); | 162 _webViewContentView.reset([webViewContentView retain]); |
| 163 // UIWebViews that are added in |-layoutSubviews| exhbit a scrolling bug, so | 163 [_webViewContentView setFrame:self.bounds]; |
| 164 // they must be added here in the getter (crbug.com/568097). | 164 [self addSubview:_webViewContentView]; |
| 165 if ([_webViewContentView webViewType] == web::UI_WEB_VIEW_TYPE) { | |
| 166 DCHECK(![_webViewContentView superview]); | |
| 167 [self addSubview:_webViewContentView]; | |
| 168 } | |
| 169 } | 165 } |
| 170 } | 166 } |
| 171 | 167 |
| 172 - (id<CRWNativeContent>)nativeController { | 168 - (id<CRWNativeContent>)nativeController { |
| 173 return _nativeController.get(); | 169 return _nativeController.get(); |
| 174 } | 170 } |
| 175 | 171 |
| 176 - (void)setNativeController:(id<CRWNativeContent>)nativeController { | 172 - (void)setNativeController:(id<CRWNativeContent>)nativeController { |
| 177 if (![_nativeController isEqual:nativeController]) { | 173 if (![_nativeController isEqual:nativeController]) { |
| 178 base::WeakNSProtocol<id> oldController(_nativeController); | 174 base::WeakNSProtocol<id> oldController(_nativeController); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 CGFloat headerHeight = [_delegate headerHeightForContainerView:self]; | 210 CGFloat headerHeight = [_delegate headerHeightForContainerView:self]; |
| 215 return UIEdgeInsetsInsetRect(self.bounds, | 211 return UIEdgeInsetsInsetRect(self.bounds, |
| 216 UIEdgeInsetsMake(headerHeight, 0, 0, 0)); | 212 UIEdgeInsetsMake(headerHeight, 0, 0, 0)); |
| 217 } | 213 } |
| 218 | 214 |
| 219 #pragma mark Layout | 215 #pragma mark Layout |
| 220 | 216 |
| 221 - (void)layoutSubviews { | 217 - (void)layoutSubviews { |
| 222 [super layoutSubviews]; | 218 [super layoutSubviews]; |
| 223 | 219 |
| 224 // WKWebViews added outside of |-layoutSubviews| exhibit a rendering bug that | |
| 225 // erroneously scrolls to an arbitrary offset, so add them here | |
| 226 // (crbug.com/574996). | |
| 227 if (self.webViewContentView.webViewType == web::WK_WEB_VIEW_TYPE && | |
| 228 !self.webViewContentView.superview) { | |
| 229 [self addSubview:self.webViewContentView]; | |
| 230 } | |
| 231 self.webViewContentView.frame = self.bounds; | 220 self.webViewContentView.frame = self.bounds; |
| 232 | 221 |
| 233 // TODO(crbug.com/570114): Move adding of the following subviews to another | 222 // TODO(crbug.com/570114): Move adding of the following subviews to another |
| 234 // place. | 223 // place. |
| 235 | 224 |
| 236 // nativeController layout. | 225 // nativeController layout. |
| 237 if (self.nativeController) { | 226 if (self.nativeController) { |
| 238 UIView* nativeView = [self.nativeController view]; | 227 UIView* nativeView = [self.nativeController view]; |
| 239 if (!nativeView.superview) { | 228 if (!nativeView.superview) { |
| 240 [self addSubview:nativeView]; | 229 [self addSubview:nativeView]; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 else | 327 else |
| 339 self.toolbarContainerView = nil; | 328 self.toolbarContainerView = nil; |
| 340 } | 329 } |
| 341 | 330 |
| 342 - (void)removeAllToolbars { | 331 - (void)removeAllToolbars { |
| 343 // Resetting the property will remove the toolbars from the hierarchy. | 332 // Resetting the property will remove the toolbars from the hierarchy. |
| 344 self.toolbarContainerView = nil; | 333 self.toolbarContainerView = nil; |
| 345 } | 334 } |
| 346 | 335 |
| 347 @end | 336 @end |
| OLD | NEW |