Title: [221122] trunk/Source/WebCore
Revision
221122
Author
[email protected]
Date
2017-08-23 17:31:22 -0700 (Wed, 23 Aug 2017)

Log Message

Unreviewed, rolling out r221109.

This change caused assertion failures on iOS and macOS debug
bots.

Reverted changeset:

"Stop using PolicyCallback for new window policies"
https://bugs.webkit.org/show_bug.cgi?id=175907
http://trac.webkit.org/changeset/221109

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221121 => 221122)


--- trunk/Source/WebCore/ChangeLog	2017-08-24 00:14:55 UTC (rev 221121)
+++ trunk/Source/WebCore/ChangeLog	2017-08-24 00:31:22 UTC (rev 221122)
@@ -1,3 +1,16 @@
+2017-08-23  Ryan Haddad  <[email protected]>
+
+        Unreviewed, rolling out r221109.
+
+        This change caused assertion failures on iOS and macOS debug
+        bots.
+
+        Reverted changeset:
+
+        "Stop using PolicyCallback for new window policies"
+        https://bugs.webkit.org/show_bug.cgi?id=175907
+        http://trac.webkit.org/changeset/221109
+
 2017-08-23  Jer Noble  <[email protected]>
 
         [EME] WebCoreDecompressionSession should only report having an available frame if it has one for the current time.

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (221121 => 221122)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2017-08-24 00:14:55 UTC (rev 221121)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2017-08-24 00:31:22 UTC (rev 221122)
@@ -1294,7 +1294,7 @@
 
     if (!targetFrame && !frameName.isEmpty()) {
         action = "" frameLoadRequest));
-        policyChecker().checkNewWindowPolicy(WTFMove(action), request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(action, request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
         });
         return;
@@ -1364,7 +1364,7 @@
 
     if (request.shouldCheckNewWindowPolicy()) {
         NavigationAction action { request.requester(), request.resourceRequest(), InitiatedByMainFrame::Unknown, NavigationType::Other, request.shouldOpenExternalURLsPolicy() };
-        policyChecker().checkNewWindowPolicy(WTFMove(action), request.resourceRequest(), nullptr, request.frameName(), [this] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(action, request.resourceRequest(), nullptr, request.frameName(), [this] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress);
         });
 
@@ -2769,7 +2769,7 @@
             return;
         }
 
-        policyChecker().checkNewWindowPolicy(WTFMove(action), workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(action, workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
         });
         return;

Modified: trunk/Source/WebCore/loader/PolicyCallback.cpp (221121 => 221122)


--- trunk/Source/WebCore/loader/PolicyCallback.cpp	2017-08-24 00:14:55 UTC (rev 221121)
+++ trunk/Source/WebCore/loader/PolicyCallback.cpp	2017-08-24 00:31:22 UTC (rev 221122)
@@ -45,12 +45,26 @@
     m_frameName = String();
 
     m_navigationFunction = WTFMove(function);
+    m_newWindowFunction = nullptr;
 }
 
+void PolicyCallback::set(const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& navigationAction, NewWindowPolicyDecisionFunction&& function)
+{
+    m_request = request;
+    m_formState = formState;
+    m_frameName = frameName;
+    m_navigationAction = navigationAction;
+
+    m_navigationFunction = nullptr;
+    m_newWindowFunction = WTFMove(function);
+}
+
 void PolicyCallback::call(bool shouldContinue)
 {
     if (m_navigationFunction)
         m_navigationFunction(m_request, m_formState.get(), shouldContinue);
+    if (m_newWindowFunction)
+        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, shouldContinue);
 }
 
 void PolicyCallback::clearRequest()
@@ -65,6 +79,8 @@
     clearRequest();
     if (m_navigationFunction)
         m_navigationFunction(m_request, m_formState.get(), false);
+    if (m_newWindowFunction)
+        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, false);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/PolicyCallback.h (221121 => 221122)


--- trunk/Source/WebCore/loader/PolicyCallback.h	2017-08-24 00:14:55 UTC (rev 221121)
+++ trunk/Source/WebCore/loader/PolicyCallback.h	2017-08-24 00:31:22 UTC (rev 221122)
@@ -42,10 +42,12 @@
 class FormState;
 
 using NavigationPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, bool shouldContinue)>;
+using NewWindowPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
 
 class PolicyCallback {
 public:
     void set(const ResourceRequest&, FormState*, NavigationPolicyDecisionFunction&&);
+    void set(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, NewWindowPolicyDecisionFunction&&);
 
     const ResourceRequest& request() const { return m_request; }
     void clearRequest();
@@ -60,6 +62,7 @@
     NavigationAction m_navigationAction;
 
     NavigationPolicyDecisionFunction m_navigationFunction;
+    NewWindowPolicyDecisionFunction m_newWindowFunction;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (221121 => 221122)


--- trunk/Source/WebCore/loader/PolicyChecker.cpp	2017-08-24 00:14:55 UTC (rev 221121)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp	2017-08-24 00:31:22 UTC (rev 221122)
@@ -153,7 +153,7 @@
     m_delegateIsDecidingNavigationPolicy = false;
 }
 
-void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
+void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
 {
     if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups))
         return continueAfterNavigationPolicy(PolicyIgnore);
@@ -161,20 +161,9 @@
     if (!DOMWindow::allowPopUp(m_frame))
         return continueAfterNavigationPolicy(PolicyIgnore);
 
-    NavigationAction navigationActionCopy = navigationAction;
-    m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationActionCopy, request, formState, frameName, [frame = makeRef(m_frame), request, formState = makeRefPtr(formState), frameName, navigationAction = WTFMove(navigationAction), function = WTFMove(function)](PolicyAction policyAction) {
-        switch (policyAction) {
-        case PolicyDownload:
-            frame->loader().client().startDownload(request);
-            FALLTHROUGH;
-        case PolicyIgnore:
-            function({ }, nullptr, { }, { }, false);
-            break;
-        case PolicyUse:
-            function(request, formState.get(), frameName, navigationAction, true);
-            break;
-        }
-        ASSERT_NOT_REACHED();
+    m_callback.set(request, formState, frameName, action, WTFMove(function));
+    m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(action, request, formState, frameName, [this](PolicyAction action) {
+        continueAfterNewWindowPolicy(action);
     });
 }
 
@@ -235,6 +224,25 @@
     callback.call(shouldContinue);
 }
 
+void PolicyChecker::continueAfterNewWindowPolicy(PolicyAction policy)
+{
+    PolicyCallback callback = WTFMove(m_callback);
+
+    switch (policy) {
+        case PolicyIgnore:
+            callback.clearRequest();
+            break;
+        case PolicyDownload:
+            m_frame.loader().client().startDownload(callback.request());
+            callback.clearRequest();
+            break;
+        case PolicyUse:
+            break;
+    }
+
+    callback.call(policy == PolicyUse);
+}
+
 void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error)
 {
     m_delegateIsHandlingUnimplementablePolicy = true;

Modified: trunk/Source/WebCore/loader/PolicyChecker.h (221121 => 221122)


--- trunk/Source/WebCore/loader/PolicyChecker.h	2017-08-24 00:14:55 UTC (rev 221121)
+++ trunk/Source/WebCore/loader/PolicyChecker.h	2017-08-24 00:31:22 UTC (rev 221122)
@@ -47,8 +47,6 @@
 class ResourceError;
 class ResourceResponse;
 
-using NewWindowPolicyDecisionFunction = WTF::Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
-
 class PolicyChecker {
     WTF_MAKE_NONCOPYABLE(PolicyChecker);
     WTF_MAKE_FAST_ALLOCATED;
@@ -57,7 +55,7 @@
 
     void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction);
     void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
-    void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
+    void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
 
     // FIXME: These are different.  They could use better names.
     void cancelCheck();
@@ -86,6 +84,7 @@
 
 private:
     void continueAfterNavigationPolicy(PolicyAction);
+    void continueAfterNewWindowPolicy(PolicyAction);
 
     void handleUnimplementablePolicy(const ResourceError&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to