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 a11db2cd1f93d34b9d54ca75e09a11516d9a6a6b..1347ec29781df7734dcab484496857b6ae216874 100644 |
| --- a/ios/web/web_state/ui/crw_web_controller.mm |
| +++ b/ios/web/web_state/ui/crw_web_controller.mm |
| @@ -544,6 +544,9 @@ - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config; |
| - (WKWebView*)webViewWithConfiguration:(WKWebViewConfiguration*)config; |
| // Sets the value of the webView property, and performs its basic setup. |
| - (void)setWebView:(WKWebView*)webView; |
| +// Wraps the web view in a CRWWebViewContentView and adds it to the container |
| +// view. |
| +- (void)displayWebView; |
| // Removes webView, optionally tracking the URL of the evicted |
| // page for later cache-based reconstruction. |
| - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache; |
| @@ -4052,13 +4055,18 @@ - (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { |
| _URLOnStartLoading = _defaultURL; |
| - // Add the web toolbars. |
| - [_containerView addToolbars:_webViewToolbars]; |
| + // WKWebViews with invalid or empty frames have exhibited rendering bugs, so |
| + // resize the view to match the container view upon creation. |
| + [_webView setFrame:[_containerView bounds]]; |
| - base::scoped_nsobject<CRWWebViewContentView> webViewContentView( |
| - [[CRWWebViewContentView alloc] initWithWebView:_webView |
| - scrollView:self.webScrollView]); |
| - [_containerView displayWebViewContentView:webViewContentView]; |
| + // If the visible NavigationItem should be loaded in this web view, display |
| + // it immediately. Otherwise, it will be displayed when the pending load is |
| + // committed. |
| + web::NavigationItem* visibleItem = |
| + self.navigationManagerImpl->GetVisibleItem(); |
| + DCHECK(visibleItem); |
| + if (![self shouldLoadURLInNativeView:visibleItem->GetURL()]) |
| + [self displayWebView]; |
| } |
| } |
| @@ -4111,6 +4119,21 @@ - (void)setWebView:(WKWebView*)webView { |
| [self setDocumentURL:_defaultURL]; |
| } |
| +- (void)displayWebView { |
| + if ([_containerView webViewContentView]) |
| + return; |
| + |
| + // Add the web toolbars. |
| + [_containerView addToolbars:_webViewToolbars]; |
| + |
| + // Wrap the WKWebView in a content view and display it in the container. |
| + DCHECK(self.webView); |
|
Eugene But (OOO till 7-30)
2017/04/18 00:20:13
nit: s/self.webView/_webView for consistency with
kkhorimoto
2017/04/18 00:54:13
Done.
|
| + base::scoped_nsobject<CRWWebViewContentView> webViewContentView( |
| + [[CRWWebViewContentView alloc] initWithWebView:_webView |
| + scrollView:self.webScrollView]); |
| + [_containerView displayWebViewContentView:webViewContentView]; |
| +} |
| + |
| - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache { |
| if (!_webView) |
| return; |
| @@ -4523,6 +4546,9 @@ - (void)webView:(WKWebView*)webView |
| - (void)webView:(WKWebView*)webView |
| didCommitNavigation:(WKNavigation*)navigation { |
| + [self displayWebView]; |
| + |
| + // Record the navigation state. |
| [_navigationStates setState:web::WKNavigationState::COMMITTED |
| forNavigation:navigation]; |
| @@ -4930,7 +4956,7 @@ - (BOOL)isLoadRequestPendingForURL:(const GURL&)targetURL { |
| } |
| - (void)loadRequestForCurrentNavigationItem { |
| - DCHECK(_webView && !self.nativeController); |
| + DCHECK(_webView); |
| DCHECK(self.currentNavItem); |
| // If a load is kicked off on a WKWebView with a frame whose size is {0, 0} or |
| // that has a negative dimension for a size, rendering issues occur that |