From 2957239985e6e343bf2e3f3b9a08c6c5ff379bda Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Thu, 24 May 2018 09:45:15 +0200 Subject: Apply settings on pending RVH too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/core/web_contents_adapter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/core/web_contents_adapter.cpp') 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(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, -- cgit v1.2.3