Title: [221354] releases/WebKitGTK/webkit-2.18/Source/WebCore
Revision
221354
Author
carlo...@webkit.org
Date
2017-08-30 02:16:37 -0700 (Wed, 30 Aug 2017)

Log Message

Merge r221162 - Stop using PolicyCallback for new window policies
https://bugs.webkit.org/show_bug.cgi?id=175907

Patch by Alex Christensen <achristen...@webkit.org> on 2017-08-24
Reviewed by Andy Estes.

PolicyCallback is an artifact from the days before C++11.  Let's use lambdas instead!
No change in behaviour.

* loader/PolicyCallback.cpp:
(WebCore::PolicyCallback::set):
(WebCore::PolicyCallback::call):
(WebCore::PolicyCallback::cancel):
* loader/PolicyCallback.h:
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNewWindowPolicy):
(WebCore::PolicyChecker::continueAfterNewWindowPolicy): Deleted.
* loader/PolicyChecker.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog (221353 => 221354)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-08-30 09:14:49 UTC (rev 221353)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-08-30 09:16:37 UTC (rev 221354)
@@ -1,3 +1,23 @@
+2017-08-24  Alex Christensen  <achristen...@webkit.org>
+
+        Stop using PolicyCallback for new window policies
+        https://bugs.webkit.org/show_bug.cgi?id=175907
+
+        Reviewed by Andy Estes.
+
+        PolicyCallback is an artifact from the days before C++11.  Let's use lambdas instead!
+        No change in behaviour.
+
+        * loader/PolicyCallback.cpp:
+        (WebCore::PolicyCallback::set):
+        (WebCore::PolicyCallback::call):
+        (WebCore::PolicyCallback::cancel):
+        * loader/PolicyCallback.h:
+        * loader/PolicyChecker.cpp:
+        (WebCore::PolicyChecker::checkNewWindowPolicy):
+        (WebCore::PolicyChecker::continueAfterNewWindowPolicy): Deleted.
+        * loader/PolicyChecker.h:
+
 2017-08-24  Kirill Ovchinnikov  <kirill.ovch...@gmail.com>
 
         HTMLTrackElement behavior violates the standard

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/FrameLoader.cpp (221353 => 221354)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/FrameLoader.cpp	2017-08-30 09:14:49 UTC (rev 221353)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/FrameLoader.cpp	2017-08-30 09:16:37 UTC (rev 221354)
@@ -1294,7 +1294,7 @@
 
     if (!targetFrame && !frameName.isEmpty()) {
         action = "" frameLoadRequest));
-        policyChecker().checkNewWindowPolicy(action, request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(WTFMove(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(action, request.resourceRequest(), nullptr, request.frameName(), [this] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(WTFMove(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(action, workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(WTFMove(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: releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyCallback.cpp (221353 => 221354)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyCallback.cpp	2017-08-30 09:14:49 UTC (rev 221353)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyCallback.cpp	2017-08-30 09:16:37 UTC (rev 221354)
@@ -45,26 +45,12 @@
     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()
@@ -79,8 +65,6 @@
     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: releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyCallback.h (221353 => 221354)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyCallback.h	2017-08-30 09:14:49 UTC (rev 221353)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyCallback.h	2017-08-30 09:16:37 UTC (rev 221354)
@@ -42,12 +42,10 @@
 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();
@@ -62,7 +60,6 @@
     NavigationAction m_navigationAction;
 
     NavigationPolicyDecisionFunction m_navigationFunction;
-    NewWindowPolicyDecisionFunction m_newWindowFunction;
 };
 
 } // namespace WebCore

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyChecker.cpp (221353 => 221354)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyChecker.cpp	2017-08-30 09:14:49 UTC (rev 221353)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyChecker.cpp	2017-08-30 09:16:37 UTC (rev 221354)
@@ -153,7 +153,7 @@
     m_delegateIsDecidingNavigationPolicy = false;
 }
 
-void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
+void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
 {
     if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups))
         return continueAfterNavigationPolicy(PolicyIgnore);
@@ -161,9 +161,19 @@
     if (!DOMWindow::allowPopUp(m_frame))
         return continueAfterNavigationPolicy(PolicyIgnore);
 
-    m_callback.set(request, formState, frameName, action, WTFMove(function));
-    m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(action, request, formState, frameName, [this](PolicyAction action) {
-        continueAfterNewWindowPolicy(action);
+    m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(navigationAction, request, formState, frameName, [frame = makeRef(m_frame), request, formState = makeRefPtr(formState), frameName, navigationAction, function = WTFMove(function)](PolicyAction policyAction) {
+        switch (policyAction) {
+        case PolicyDownload:
+            frame->loader().client().startDownload(request);
+            FALLTHROUGH;
+        case PolicyIgnore:
+            function({ }, nullptr, { }, { }, false);
+            return;
+        case PolicyUse:
+            function(request, formState.get(), frameName, navigationAction, true);
+            return;
+        }
+        ASSERT_NOT_REACHED();
     });
 }
 
@@ -224,25 +234,6 @@
     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: releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyChecker.h (221353 => 221354)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyChecker.h	2017-08-30 09:14:49 UTC (rev 221353)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/loader/PolicyChecker.h	2017-08-30 09:16:37 UTC (rev 221354)
@@ -47,6 +47,8 @@
 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;
@@ -55,7 +57,7 @@
 
     void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction);
     void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
-    void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
+    void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
 
     // FIXME: These are different.  They could use better names.
     void cancelCheck();
@@ -84,7 +86,6 @@
 
 private:
     void continueAfterNavigationPolicy(PolicyAction);
-    void continueAfterNewWindowPolicy(PolicyAction);
 
     void handleUnimplementablePolicy(const ResourceError&);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to