Changeset 221122 in webkit


Ignore:
Timestamp:
Aug 23, 2017 5:31:22 PM (7 years ago)
Author:
Ryan Haddad
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

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221116 r221122  
     12017-08-23  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r221109.
     4
     5        This change caused assertion failures on iOS and macOS debug
     6        bots.
     7
     8        Reverted changeset:
     9
     10        "Stop using PolicyCallback for new window policies"
     11        https://bugs.webkit.org/show_bug.cgi?id=175907
     12        http://trac.webkit.org/changeset/221109
     13
    1142017-08-23  Jer Noble  <jer.noble@apple.com>
    215
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r221109 r221122  
    12951295    if (!targetFrame && !frameName.isEmpty()) {
    12961296        action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest));
    1297         policyChecker().checkNewWindowPolicy(WTFMove(action), request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
     1297        policyChecker().checkNewWindowPolicy(action, request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
    12981298            continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
    12991299        });
     
    13651365    if (request.shouldCheckNewWindowPolicy()) {
    13661366        NavigationAction action { request.requester(), request.resourceRequest(), InitiatedByMainFrame::Unknown, NavigationType::Other, request.shouldOpenExternalURLsPolicy() };
    1367         policyChecker().checkNewWindowPolicy(WTFMove(action), request.resourceRequest(), nullptr, request.frameName(), [this] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
     1367        policyChecker().checkNewWindowPolicy(action, request.resourceRequest(), nullptr, request.frameName(), [this] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
    13681368            continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress);
    13691369        });
     
    27702770        }
    27712771
    2772         policyChecker().checkNewWindowPolicy(WTFMove(action), workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
     2772        policyChecker().checkNewWindowPolicy(action, workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
    27732773            continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
    27742774        });
  • trunk/Source/WebCore/loader/PolicyCallback.cpp

    r221109 r221122  
    4646
    4747    m_navigationFunction = WTFMove(function);
     48    m_newWindowFunction = nullptr;
     49}
     50
     51void PolicyCallback::set(const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& navigationAction, NewWindowPolicyDecisionFunction&& function)
     52{
     53    m_request = request;
     54    m_formState = formState;
     55    m_frameName = frameName;
     56    m_navigationAction = navigationAction;
     57
     58    m_navigationFunction = nullptr;
     59    m_newWindowFunction = WTFMove(function);
    4860}
    4961
     
    5264    if (m_navigationFunction)
    5365        m_navigationFunction(m_request, m_formState.get(), shouldContinue);
     66    if (m_newWindowFunction)
     67        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, shouldContinue);
    5468}
    5569
     
    6680    if (m_navigationFunction)
    6781        m_navigationFunction(m_request, m_formState.get(), false);
     82    if (m_newWindowFunction)
     83        m_newWindowFunction(m_request, m_formState.get(), m_frameName, m_navigationAction, false);
    6884}
    6985
  • trunk/Source/WebCore/loader/PolicyCallback.h

    r221109 r221122  
    4343
    4444using NavigationPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, bool shouldContinue)>;
     45using NewWindowPolicyDecisionFunction = Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
    4546
    4647class PolicyCallback {
    4748public:
    4849    void set(const ResourceRequest&, FormState*, NavigationPolicyDecisionFunction&&);
     50    void set(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, NewWindowPolicyDecisionFunction&&);
    4951
    5052    const ResourceRequest& request() const { return m_request; }
     
    6163
    6264    NavigationPolicyDecisionFunction m_navigationFunction;
     65    NewWindowPolicyDecisionFunction m_newWindowFunction;
    6366};
    6467
  • trunk/Source/WebCore/loader/PolicyChecker.cpp

    r221109 r221122  
    154154}
    155155
    156 void PolicyChecker::checkNewWindowPolicy(NavigationAction&& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
     156void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request, FormState* formState, const String& frameName, NewWindowPolicyDecisionFunction function)
    157157{
    158158    if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups))
     
    162162        return continueAfterNavigationPolicy(PolicyIgnore);
    163163
    164     NavigationAction navigationActionCopy = navigationAction;
    165     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) {
    166         switch (policyAction) {
    167         case PolicyDownload:
    168             frame->loader().client().startDownload(request);
    169             FALLTHROUGH;
    170         case PolicyIgnore:
    171             function({ }, nullptr, { }, { }, false);
    172             break;
    173         case PolicyUse:
    174             function(request, formState.get(), frameName, navigationAction, true);
    175             break;
    176         }
    177         ASSERT_NOT_REACHED();
     164    m_callback.set(request, formState, frameName, action, WTFMove(function));
     165    m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(action, request, formState, frameName, [this](PolicyAction action) {
     166        continueAfterNewWindowPolicy(action);
    178167    });
    179168}
     
    236225}
    237226
     227void PolicyChecker::continueAfterNewWindowPolicy(PolicyAction policy)
     228{
     229    PolicyCallback callback = WTFMove(m_callback);
     230
     231    switch (policy) {
     232        case PolicyIgnore:
     233            callback.clearRequest();
     234            break;
     235        case PolicyDownload:
     236            m_frame.loader().client().startDownload(callback.request());
     237            callback.clearRequest();
     238            break;
     239        case PolicyUse:
     240            break;
     241    }
     242
     243    callback.call(policy == PolicyUse);
     244}
     245
    238246void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error)
    239247{
  • trunk/Source/WebCore/loader/PolicyChecker.h

    r221109 r221122  
    4848class ResourceResponse;
    4949
    50 using NewWindowPolicyDecisionFunction = WTF::Function<void(const ResourceRequest&, FormState*, const String& frameName, const NavigationAction&, bool shouldContinue)>;
    51 
    5250class PolicyChecker {
    5351    WTF_MAKE_NONCOPYABLE(PolicyChecker);
     
    5856    void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, DocumentLoader*, FormState*, NavigationPolicyDecisionFunction);
    5957    void checkNavigationPolicy(const ResourceRequest&, bool didReceiveRedirectResponse, NavigationPolicyDecisionFunction);
    60     void checkNewWindowPolicy(NavigationAction&&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
     58    void checkNewWindowPolicy(const NavigationAction&, const ResourceRequest&, FormState*, const String& frameName, NewWindowPolicyDecisionFunction);
    6159
    6260    // FIXME: These are different.  They could use better names.
     
    8785private:
    8886    void continueAfterNavigationPolicy(PolicyAction);
     87    void continueAfterNewWindowPolicy(PolicyAction);
    8988
    9089    void handleUnimplementablePolicy(const ResourceError&);
Note: See TracChangeset for help on using the changeset viewer.