Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2872823002: Display the web view after commit for non-user-initiated loads. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698