diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2018-05-24 09:45:15 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2018-05-25 08:58:49 +0000 |
commit | 2957239985e6e343bf2e3f3b9a08c6c5ff379bda (patch) | |
tree | 660f2bca2bbc93f6cb6f057201fd6bcc7750a2a3 | |
parent | 9456f41c932cffd82e60389adf5b2b429fb98e34 (diff) |
Apply settings on pending RVH too
This is an improvement of:
bab4abab Keep settings synchronized when RVH swaps
Updating settings during RVH swap is flaky because it happens after
the load start of RenderFrame thus it is not guaranteed the
ViewMsg_UpdateWebPreferences message is received by the render process
before the load finishes. This means that the setting might not be applied
on the current page if it was set during the navigation.
The new RVH is created at the very beginning of the navigation, so access
it via the pending or speculative main frame of the page thereby make it
possible to update its settings before the load of RenderFrame starts.
Task-number: QTBUG-66656
Task-number: QTBUG-68424
Change-Id: I4fbba597579551bb3329936ccd7b357cf8daa4ea
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
-rw-r--r-- | src/core/web_contents_adapter.cpp | 9 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 11 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.h | 1 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginesettings/BLACKLIST | 2 |
4 files changed, 9 insertions, 14 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 4ebed8fc9..63cda7fa1 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1052,6 +1052,15 @@ void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & we Q_D(WebContentsAdapter); CHECK_INITIALIZED(); d->webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences); + + // In case of updating preferences during navigation, there might be a pending RVH what will + // be active on successful navigation. + content::RenderFrameHost *pendingRFH = (static_cast<content::WebContentsImpl*>(d->webContents.get()))->GetPendingMainFrame(); + if (pendingRFH) { + content::RenderViewHost *pendingRVH = pendingRFH->GetRenderViewHost(); + Q_ASSERT(pendingRVH); + pendingRVH->UpdateWebkitPreferences(webPreferences); + } } void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName, diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 7f3ced8aa..aae7f4a43 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -527,17 +527,6 @@ void WebContentsDelegateQt::ActivateContents(content::WebContents* contents) contents->Focus(); } -void WebContentsDelegateQt::RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) -{ - Q_ASSERT(new_host); - - // The old RVH can be nullptr if it was shut down. - if (!old_host) - return; - - new_host->UpdateWebkitPreferences(old_host->GetWebkitPreferences()); -} - void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) { Q_UNUSED(user_gesture); diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 43badf60e..2ef87ccd8 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -139,7 +139,6 @@ public: void WasShown() override; void DidFirstVisuallyNonEmptyPaint() override; void ActivateContents(content::WebContents* contents) override; - void RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) override; void didFailLoad(const QUrl &url, int errorCode, const QString &errorDescription); void overrideWebPreferences(content::WebContents *, content::WebPreferences*); diff --git a/tests/auto/widgets/qwebenginesettings/BLACKLIST b/tests/auto/widgets/qwebenginesettings/BLACKLIST deleted file mode 100644 index 81226540d..000000000 --- a/tests/auto/widgets/qwebenginesettings/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[setInAcceptNavigationRequest] -* |