Chromium Code Reviews| Index: ios/web/web_state/ui/crw_web_controller.mm |
| diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
| index 5204ae4a1656e50bb3cc2cd284f5a327bef4315b..8215dc2c46c1c9b55c346b560d02d8ea8b2bc2ee 100644 |
| --- a/ios/web/web_state/ui/crw_web_controller.mm |
| +++ b/ios/web/web_state/ui/crw_web_controller.mm |
| @@ -512,6 +512,8 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) { |
| // Creates a web view if it's not yet created. |
| - (void)ensureWebViewCreated; |
| +// Creates and configures |_containerView|. |
| +- (void)createContainerView; |
| // Creates a web view with given |config|. No-op if web view is already created. |
| - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; |
| // Returns a new autoreleased web view created with given configuration. |
| @@ -1842,7 +1844,7 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
| // If the content view doesn't exist, the tab has either been evicted, or |
| // never displayed. Bail, and let the URL be loaded when the tab is shown. |
|
sdefresne
2017/03/29 09:59:01
I think this comment is now incorrect (since the c
|
| if (!_containerView) |
| - return; |
| + [self createContainerView]; |
| // Reset current WebUI if one exists. |
| [self clearWebUI]; |
| @@ -1903,31 +1905,7 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
| - (void)triggerPendingLoad { |
| if (!_containerView) { |
| DCHECK(!_isBeingDestroyed); |
| - // Create the top-level parent view, which will contain the content (whether |
| - // native or web). Note, this needs to be created with a non-zero size |
| - // to allow for (native) subviews with autosize constraints to be correctly |
| - // processed. |
| - _containerView.reset( |
| - [[CRWWebControllerContainerView alloc] initWithDelegate:self]); |
| - |
| - // This will be resized later, but matching the final frame will minimize |
| - // re-rendering. Use the screen size because the application's key window |
| - // may still be nil. |
| - // TODO(crbug.com/688259): Stop subtracting status bar height. |
| - CGFloat statusBarHeight = |
| - [[UIApplication sharedApplication] statusBarFrame].size.height; |
| - CGRect containerViewFrame = [UIScreen mainScreen].bounds; |
| - containerViewFrame.origin.y += statusBarHeight; |
| - containerViewFrame.size.height -= statusBarHeight; |
| - _containerView.get().frame = containerViewFrame; |
| - DCHECK(!CGRectIsEmpty(_containerView.get().frame)); |
| - |
| - // TODO(crbug.com/691116): Remove this workaround once tests are no longer |
| - // dependent upon this accessibility ID. |
| - if (!base::ios::IsRunningOnIOS10OrLater()) |
| - [_containerView setAccessibilityIdentifier:@"Container View"]; |
| - |
| - [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; |
| + [self createContainerView]; |
| // Is |currentUrl| a web scheme or native chrome scheme. |
| web::NavigationItem* item = self.currentNavItem; |
| const GURL currentNavigationURL = |
| @@ -4004,6 +3982,34 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
| [self loadCancelled]; |
| } |
| +- (void)createContainerView { |
| + // Create the top-level parent view, which will contain the content (whether |
| + // native or web). Note, this needs to be created with a non-zero size |
| + // to allow for (native) subviews with autosize constraints to be correctly |
| + // processed. |
| + _containerView.reset( |
| + [[CRWWebControllerContainerView alloc] initWithDelegate:self]); |
| + |
| + // This will be resized later, but matching the final frame will minimize |
| + // re-rendering. Use the screen size because the application's key window |
| + // may still be nil. |
| + // TODO(crbug.com/688259): Stop subtracting status bar height. |
| + CGFloat statusBarHeight = |
| + [[UIApplication sharedApplication] statusBarFrame].size.height; |
| + CGRect containerViewFrame = [UIScreen mainScreen].bounds; |
| + containerViewFrame.origin.y += statusBarHeight; |
| + containerViewFrame.size.height -= statusBarHeight; |
| + _containerView.get().frame = containerViewFrame; |
| + DCHECK(!CGRectIsEmpty(_containerView.get().frame)); |
| + |
| + // TODO(crbug.com/691116): Remove this workaround once tests are no longer |
| + // dependent upon this accessibility ID. |
| + if (!base::ios::IsRunningOnIOS10OrLater()) |
| + [_containerView setAccessibilityIdentifier:@"Container View"]; |
| + |
| + [_containerView addGestureRecognizer:[self touchTrackingRecognizer]]; |
| +} |
| + |
| - (void)ensureWebViewCreated { |
| WKWebViewConfiguration* config = |
| [self webViewConfigurationProvider].GetWebViewConfiguration(); |