Skip to content

Commit 3fc6679

Browse files
authored
Merge pull request #1354 from WebPlatformForEmbedded/pgorszkowski/2.38/cancel_fragment_navigation_if_there_is_ongoing_navigation
Fragment navigation should be cancelled if there is ongoing navigation
2 parents a2951d2 + 48afab5 commit 3fc6679

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Source/WebCore/loader/FrameLoader.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,23 @@ void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& ref
13491349
if (m_inStopAllLoaders || m_inClearProvisionalLoadForPolicyCheck)
13501350
return;
13511351

1352+
static bool keepNavigationOnFragmentLoad = false;
1353+
static bool keepNavigationOnFragmentLoadInitialized = false;
1354+
1355+
if (!keepNavigationOnFragmentLoadInitialized) {
1356+
keepNavigationOnFragmentLoad = !!getenv("WPE_KEEP_NAVIGATION_ON_FRAGMENT_LOAD");
1357+
keepNavigationOnFragmentLoadInitialized = true;
1358+
}
1359+
1360+
// If we have a policy or provisional request for a different document, a fragment scroll should be cancelled.
1361+
if (keepNavigationOnFragmentLoad && (m_policyDocumentLoader && !equalIgnoringFragmentIdentifier(m_policyDocumentLoader->request().url(), frameLoadRequest.resourceRequest().url()) ||
1362+
m_provisionalDocumentLoader && !equalIgnoringFragmentIdentifier(m_provisionalDocumentLoader->request().url(), frameLoadRequest.resourceRequest().url()))) {
1363+
const auto fragmentNavigationURL = frameLoadRequest.resourceRequest().url();
1364+
const auto navigationURL = m_policyDocumentLoader ? m_policyDocumentLoader->request().url(): m_provisionalDocumentLoader->request().url();
1365+
FRAMELOADER_RELEASE_LOG(ResourceLoading, "loadURL: fragment navigation: %s is cancelled because of ongoing navigation change to url: %s", fragmentNavigationURL.string().utf8().data(), navigationURL.string().utf8().data());
1366+
return;
1367+
}
1368+
13521369
Ref<Frame> protect(m_frame);
13531370

13541371
// Anchor target is ignored when the download attribute is set since it will download the hyperlink rather than follow it.

0 commit comments

Comments
 (0)