Title: [254930] trunk/Source/WebCore
Revision
254930
Author
[email protected]
Date
2020-01-22 11:29:49 -0800 (Wed, 22 Jan 2020)

Log Message

Stop doing synchronous DecidePolicyForNavigationActionSync IPCs for initially empty document loads
https://bugs.webkit.org/show_bug.cgi?id=206458

Reviewed by Alex Christensen.

Stop doing synchronous DecidePolicyForNavigationActionSync IPCs for initially empty document loads. Instead, we
now do regular asynchronous DecidePolicyForNavigationAction IPCs for such loads and we ignore the response from
the client, allowing WebCore to proceed with the load synchronously.

* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254929 => 254930)


--- trunk/Source/WebCore/ChangeLog	2020-01-22 18:55:45 UTC (rev 254929)
+++ trunk/Source/WebCore/ChangeLog	2020-01-22 19:29:49 UTC (rev 254930)
@@ -1,3 +1,17 @@
+2020-01-22  Chris Dumez  <[email protected]>
+
+        Stop doing synchronous DecidePolicyForNavigationActionSync IPCs for initially empty document loads
+        https://bugs.webkit.org/show_bug.cgi?id=206458
+
+        Reviewed by Alex Christensen.
+
+        Stop doing synchronous DecidePolicyForNavigationActionSync IPCs for initially empty document loads. Instead, we
+        now do regular asynchronous DecidePolicyForNavigationAction IPCs for such loads and we ignore the response from
+        the client, allowing WebCore to proceed with the load synchronously.
+
+        * loader/PolicyChecker.cpp:
+        (WebCore::PolicyChecker::checkNavigationPolicy):
+
 2020-01-22  Zalan Bujtas  <[email protected]>
 
         [LFC] Do not create a FormattingContext unless there's content to layout.

Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (254929 => 254930)


--- trunk/Source/WebCore/loader/PolicyChecker.cpp	2020-01-22 18:55:45 UTC (rev 254929)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp	2020-01-22 19:29:49 UTC (rev 254930)
@@ -159,10 +159,6 @@
 
     loader->setLastCheckedRequest(ResourceRequest(request));
 
-    // Initial 'about:blank' load needs to happen synchronously so the policy check needs to be synchronous in this case.
-    if (!m_frame.loader().stateMachine().committedFirstRealDocumentLoad() && request.url().protocolIsAbout() && !substituteData.isValid())
-        policyDecisionMode = PolicyDecisionMode::Synchronous;
-
 #if USE(QUICK_LOOK)
     // Always allow QuickLook-generated URLs based on the protocol scheme.
     if (!request.isNull() && isQuickLookPreviewURL(request.url()))
@@ -185,13 +181,12 @@
 
     auto blobURLLifetimeExtension = policyDecisionMode == PolicyDecisionMode::Asynchronous ? extendBlobURLLifetimeIfNecessary(request) : CompletionHandlerCallingScope { };
 
+    bool isInitialEmptyDocumentLoad = !m_frame.loader().stateMachine().committedFirstRealDocumentLoad() && request.url().protocolIsAbout() && !substituteData.isValid();
     auto requestIdentifier = PolicyCheckIdentifier::create();
     m_delegateIsDecidingNavigationPolicy = true;
     String suggestedFilename = action.downloadAttribute().isEmpty() ? nullAtom() : action.downloadAttribute();
-    m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, redirectResponse, formState.get(), policyDecisionMode, requestIdentifier,
-        [this, function = WTFMove(function), request = ResourceRequest(request), formState = WTFMove(formState), suggestedFilename = WTFMove(suggestedFilename),
+    FramePolicyFunction decisionHandler = [this, function = WTFMove(function), request = ResourceRequest(request), formState = WTFMove(formState), suggestedFilename = WTFMove(suggestedFilename),
          blobURLLifetimeExtension = WTFMove(blobURLLifetimeExtension), requestIdentifier] (PolicyAction policyAction, PolicyCheckIdentifier responseIdentifier) mutable {
-
         if (!responseIdentifier.isValidFor(requestIdentifier))
             return function({ }, nullptr, NavigationPolicyDecision::IgnoreLoad);
 
@@ -215,7 +210,14 @@
             return function(WTFMove(request), makeWeakPtr(formState.get()), NavigationPolicyDecision::ContinueLoad);
         }
         ASSERT_NOT_REACHED();
-    });
+    };
+
+    if (isInitialEmptyDocumentLoad) {
+        // We ignore the response from the client for initial empty document loads and proceed with the load synchronously.
+        m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, redirectResponse, formState.get(), policyDecisionMode, requestIdentifier, [](PolicyAction, PolicyCheckIdentifier) { });
+        decisionHandler(PolicyAction::Use, requestIdentifier);
+    } else
+        m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, redirectResponse, formState.get(), policyDecisionMode, requestIdentifier, WTFMove(decisionHandler));
 }
 
 void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, ResourceRequest&& request, RefPtr<FormState>&& formState, const String& frameName, NewWindowPolicyDecisionFunction&& function)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to