Skip to content

Commit

Permalink
Use smart pointers to access NavigationScheduler
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=276880

Reviewed by Chris Dumez.

Use smart pointers to access NavigationScheduler based
on [alpha.webkit.UncountedCallArgsChecker] warnings.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::open):
(WebCore::Document::implicitClose):
(WebCore::Document::navigateFromServiceWorker):
* Source/WebCore/html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizerLoop):
* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::responseReceived):
* Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::selectCache):
* Source/WebCore/page/Frame.h:
(WebCore::Frame::navigationScheduler const): Deleted.
* Source/WebCore/page/History.cpp:
(WebCore::History::go):
* Source/WebCore/page/RemoteDOMWindow.cpp:
(WebCore::RemoteDOMWindow::setLocation):

Canonical link: https://commits.webkit.org/281239@main
  • Loading branch information
rwlbuis committed Jul 23, 2024
1 parent 47beefb commit 43764db
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Source/WebCore/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3558,7 +3558,7 @@ ExceptionOr<void> Document::open(Document* entryDocument)
}
}

bool isNavigating = frame->loader().policyChecker().delegateIsDecidingNavigationPolicy() || frame->loader().state() == FrameState::Provisional || frame->navigationScheduler().hasQueuedNavigation();
bool isNavigating = frame->loader().policyChecker().delegateIsDecidingNavigationPolicy() || frame->loader().state() == FrameState::Provisional || frame->checkedNavigationScheduler()->hasQueuedNavigation();
if (frame->loader().policyChecker().delegateIsDecidingNavigationPolicy())
frame->loader().policyChecker().stopCheck();
// Null-checking m_frame again as `policyChecker().stopCheck()` may have cleared it.
Expand Down Expand Up @@ -3754,7 +3754,7 @@ void Document::explicitClose()
void Document::implicitClose()
{
RELEASE_ASSERT(!m_inStyleRecalc);
bool wasLocationChangePending = frame() && frame()->navigationScheduler().locationChangePending();
bool wasLocationChangePending = frame() && frame()->checkedNavigationScheduler()->locationChangePending();
bool doload = !parsing() && m_parser && !m_processingLoadEvent && !wasLocationChangePending;

if (!doload)
Expand Down Expand Up @@ -10090,7 +10090,7 @@ void Document::navigateFromServiceWorker(const URL& url, CompletionHandler<void(
callback(ScheduleLocationChangeResult::Stopped);
return;
}
frame->navigationScheduler().scheduleLocationChange(*weakThis, weakThis->securityOrigin(), url, frame->loader().outgoingReferrer(), LockHistory::Yes, LockBackForwardList::No, NavigationHistoryBehavior::Auto, [callback = WTFMove(callback)](auto result) mutable {
frame->checkedNavigationScheduler()->scheduleLocationChange(*weakThis, weakThis->securityOrigin(), url, frame->loader().outgoingReferrer(), LockHistory::Yes, LockBackForwardList::No, NavigationHistoryBehavior::Auto, [callback = WTFMove(callback)](auto result) mutable {
callback(result);
});
});
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/parser/HTMLDocumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ bool HTMLDocumentParser::pumpTokenizerLoop(SynchronousMode mode, bool parsingFra
// how the parser has always handled stopping when the page assigns window.location. What should
// happen instead is that assigning window.location causes the parser to stop parsing cleanly.
// The problem is we're not prepared to do that at every point where we run JavaScript.
if (UNLIKELY(!parsingFragment && document()->frame() && document()->frame()->navigationScheduler().locationChangePending()))
if (UNLIKELY(!parsingFragment && document()->frame() && document()->frame()->checkedNavigationScheduler()->locationChangePending()))
return false;

if (UNLIKELY(mode == SynchronousMode::AllowYield && m_parserScheduler->shouldYieldBeforeToken(session)))
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/loader/DocumentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void DocumentLoader::responseReceived(CachedResource& resource, const ResourceRe
auto firstPartyDomain = RegistrableDomain(response.url());
if (auto loginDomains = NetworkStorageSession::subResourceDomainsInNeedOfStorageAccessForFirstParty(firstPartyDomain)) {
if (!Quirks::hasStorageAccessForAllLoginDomains(*loginDomains, firstPartyDomain)) {
m_frame->navigationScheduler().scheduleRedirect(document, 0, microsoftTeamsRedirectURL(), IsMetaRefresh::No);
m_frame->checkedNavigationScheduler()->scheduleRedirect(document, 0, microsoftTeamsRedirectURL(), IsMetaRefresh::No);
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void ApplicationCacheGroup::selectCache(LocalFrame& frame, const URL& passedMani
// as part of the initial load.
// The navigation will not result in the same resource being loaded, because "foreign" entries are never picked during navigation.
RefPtr document = frame.document();
frame.navigationScheduler().scheduleLocationChange(*document, document->protectedSecurityOrigin(), documentLoader.url(), frame.loader().referrer());
frame.checkedNavigationScheduler()->scheduleLocationChange(*document, document->protectedSecurityOrigin(), documentLoader.url(), frame.loader().referrer());
}
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/page/History.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ ExceptionOr<void> History::go(int distance)
if (!isDocumentFullyActive(frame.get()))
return documentNotFullyActive();

frame->navigationScheduler().scheduleHistoryNavigation(distance);
frame->checkedNavigationScheduler()->scheduleHistoryNavigation(distance);
return { };
}

Expand All @@ -189,7 +189,7 @@ ExceptionOr<void> History::go(Document& document, int distance)
if (!document.canNavigate(frame.get()))
return { };

frame->navigationScheduler().scheduleHistoryNavigation(distance);
frame->checkedNavigationScheduler()->scheduleHistoryNavigation(distance);
return { };
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/RemoteDOMWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void RemoteDOMWindow::setLocation(LocalDOMWindow& activeWindow, const URL& compl
// We want a new history item if we are processing a user gesture.
LockHistory lockHistory = (locking != SetLocationLocking::LockHistoryBasedOnGestureState || !UserGestureIndicator::processingUserGesture()) ? LockHistory::Yes : LockHistory::No;
LockBackForwardList lockBackForwardList = (locking != SetLocationLocking::LockHistoryBasedOnGestureState) ? LockBackForwardList::Yes : LockBackForwardList::No;
frame->navigationScheduler().scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(),
frame->checkedNavigationScheduler()->scheduleLocationChange(*activeDocument, activeDocument->securityOrigin(),
// FIXME: What if activeDocument()->frame() is 0?
completedURL, activeDocument->frame()->loader().outgoingReferrer(),
lockHistory, lockBackForwardList,
Expand Down

0 comments on commit 43764db

Please sign in to comment.