| 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 2b9979d8cbf14997fea1b4d67c66b26482cd63db..ffeaa811b2b61db2c4b8ac9c57dad2e93dcd4fe0 100644
|
| --- a/ios/web/web_state/ui/crw_web_controller.mm
|
| +++ b/ios/web/web_state/ui/crw_web_controller.mm
|
| @@ -517,6 +517,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;
|
| @@ -4027,13 +4030,19 @@ - (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();
|
| + const GURL& visibleURL =
|
| + visibleItem ? visibleItem->GetURL() : GURL::EmptyGURL();
|
| + if (![self shouldLoadURLInNativeView:visibleURL])
|
| + [self displayWebView];
|
| }
|
| }
|
|
|
| @@ -4086,6 +4095,19 @@ - (void)setWebView:(WKWebView*)webView {
|
| [self setDocumentURL:_defaultURL];
|
| }
|
|
|
| +- (void)displayWebView {
|
| + if (!self.webView || [_containerView webViewContentView])
|
| + return;
|
| +
|
| + // Add the web toolbars.
|
| + [_containerView addToolbars:_webViewToolbars];
|
| +
|
| + base::scoped_nsobject<CRWWebViewContentView> webViewContentView(
|
| + [[CRWWebViewContentView alloc] initWithWebView:_webView
|
| + scrollView:self.webScrollView]);
|
| + [_containerView displayWebViewContentView:webViewContentView];
|
| +}
|
| +
|
| - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache {
|
| if (!_webView)
|
| return;
|
| @@ -4507,6 +4529,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];
|
|
|
| @@ -4938,7 +4963,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
|
|
|