Changeset 260423 in webkit


Ignore:
Timestamp:
Apr 21, 2020 3:31:08 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Exit early in FrameLoader::loadURL when redirecting to another frame
https://bugs.webkit.org/show_bug.cgi?id=210751

Patch by Rob Buis <rbuis@igalia.com> on 2020-04-21
Reviewed by Geoffrey Garen.

Exit early in FrameLoader::loadURL when redirecting to another frame, previously we were preparing
request needlessly, doing it twice in case of frame redirecting. Also move some variables to
where they are actually used.

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::loadURL):

  • loader/FrameLoader.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r260420 r260423  
     12020-04-21  Rob Buis  <rbuis@igalia.com>
     2
     3        Exit early in FrameLoader::loadURL when redirecting to another frame
     4        https://bugs.webkit.org/show_bug.cgi?id=210751
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Exit early in FrameLoader::loadURL when redirecting to another frame, previously we were preparing
     9        request needlessly, doing it twice in case of frame redirecting. Also move some variables to
     10        where they are actually used.
     11
     12        * loader/FrameLoader.cpp:
     13        (WebCore::FrameLoader::loadURL):
     14        * loader/FrameLoader.h:
     15
    1162020-04-21  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r260351 r260423  
    13531353    // Anchor target is ignored when the download attribute is set since it will download the hyperlink rather than follow it.
    13541354    String effectiveFrameName = frameLoadRequest.downloadAttribute().isNull() ? frameLoadRequest.frameName() : String();
    1355     AllowNavigationToInvalidURL allowNavigationToInvalidURL = frameLoadRequest.allowNavigationToInvalidURL();
    1356     NewFrameOpenerPolicy openerPolicy = frameLoadRequest.newFrameOpenerPolicy();
    1357     LockHistory lockHistory = frameLoadRequest.lockHistory();
    13581355    bool isFormSubmission = formState;
     1356
     1357    // The search for a target frame is done earlier in the case of form submission.
     1358    auto targetFrame = isFormSubmission ? nullptr : makeRefPtr(findFrameForNavigation(effectiveFrameName));
     1359    if (targetFrame && targetFrame != &m_frame) {
     1360        frameLoadRequest.setFrameName("_self");
     1361        targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, WTFMove(formState), WTFMove(adClickAttribution), completionHandlerCaller.release());
     1362        return;
     1363    }
    13591364
    13601365    const URL& newURL = frameLoadRequest.resourceRequest().url();
     
    13671372    ASSERT(newLoadType != FrameLoadType::Same);
    13681373
    1369     // The search for a target frame is done earlier in the case of form submission.
    1370     Frame* targetFrame = isFormSubmission ? nullptr : findFrameForNavigation(effectiveFrameName);
    1371     if (targetFrame && targetFrame != &m_frame) {
    1372         frameLoadRequest.setFrameName("_self");
    1373         targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, WTFMove(formState), WTFMove(adClickAttribution), completionHandlerCaller.release());
    1374         return;
    1375     }
    1376 
    13771374    if (!isNavigationAllowed())
    13781375        return;
    13791376
    13801377    NavigationAction action { frameLoadRequest.requester(), request, frameLoadRequest.initiatedByMainFrame(), newLoadType, isFormSubmission, event, frameLoadRequest.shouldOpenExternalURLsPolicy(), frameLoadRequest.downloadAttribute() };
    1381     action.setLockHistory(lockHistory);
     1378    action.setLockHistory(frameLoadRequest.lockHistory());
    13821379    action.setLockBackForwardList(frameLoadRequest.lockBackForwardList());
    13831380    if (adClickAttribution && m_frame.isMainFrame())
    13841381        action.setAdClickAttribution(WTFMove(*adClickAttribution));
    13851382
     1383    NewFrameOpenerPolicy openerPolicy = frameLoadRequest.newFrameOpenerPolicy();
     1384    AllowNavigationToInvalidURL allowNavigationToInvalidURL = frameLoadRequest.allowNavigationToInvalidURL();
    13861385    if (!targetFrame && !effectiveFrameName.isEmpty()) {
    13871386        action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest));
  • trunk/Source/WebCore/loader/FrameLoader.h

    r260239 r260423  
    282282    FrameLoaderStateMachine& stateMachine() { return m_stateMachine; }
    283283
     284    // FIXME: should return RefPtr.
    284285    WEBCORE_EXPORT Frame* findFrameForNavigation(const AtomString& name, Document* activeDocument = nullptr);
    285286
Note: See TracChangeset for help on using the changeset viewer.