Diff
Modified: trunk/Source/WebCore/ChangeLog (239181 => 239182)
--- trunk/Source/WebCore/ChangeLog 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/ChangeLog 2018-12-13 23:17:44 UTC (rev 239182)
@@ -1,3 +1,31 @@
+2018-12-13 Chris Dumez <[email protected]>
+
+ [PSON] We should not need to navigate to 'about:blank' to suspend pages
+ https://bugs.webkit.org/show_bug.cgi?id=192668
+ <rdar://problem/46701466>
+
+ Reviewed by Alex Christensen.
+
+ * history/PageCache.cpp:
+ (WebCore::PageCache::addIfCacheable):
+ * history/PageCache.h:
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::redirectReceived):
+ (WebCore::DocumentLoader::willSendRequest):
+ (WebCore::DocumentLoader::startLoadingMainResource):
+ * loader/DocumentLoader.h:
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::init):
+ (WebCore::FrameLoader::stopAllLoaders):
+ (WebCore::FrameLoader::setDocumentLoader):
+ (WebCore::FrameLoader::commitProvisionalLoad):
+ (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
+ (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
+ * loader/FrameLoaderTypes.h:
+ * loader/PolicyChecker.cpp:
+ (WebCore::PolicyChecker::checkNavigationPolicy):
+ * loader/PolicyChecker.h:
+
2018-12-13 Per Arne Vollan <[email protected]>
[macOS] Inline WebVTT styles should override styles from Captions settings in System Preferences
Modified: trunk/Source/WebCore/history/PageCache.cpp (239181 => 239182)
--- trunk/Source/WebCore/history/PageCache.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/history/PageCache.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -425,13 +425,13 @@
firePageHideEventRecursively(*child);
}
-void PageCache::addIfCacheable(HistoryItem& item, Page* page)
+bool PageCache::addIfCacheable(HistoryItem& item, Page* page)
{
if (item.isInPageCache())
- return;
+ return false;
if (!page || !canCache(*page))
- return;
+ return false;
ASSERT_WITH_MESSAGE(!page->isUtilityPage(), "Utility pages such as SVGImage pages should never go into PageCache");
@@ -449,7 +449,7 @@
// could have altered the page in a way that could prevent caching.
if (!canCache(*page)) {
setPageCacheState(*page, Document::NotInPageCache);
- return;
+ return false;
}
destroyRenderTree(page->mainFrame());
@@ -465,6 +465,7 @@
m_items.add(&item);
}
prune(PruningReason::ReachedMaxSize);
+ return true;
}
std::unique_ptr<CachedPage> PageCache::take(HistoryItem& item, Page* page)
Modified: trunk/Source/WebCore/history/PageCache.h (239181 => 239182)
--- trunk/Source/WebCore/history/PageCache.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/history/PageCache.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -51,7 +51,7 @@
WEBCORE_EXPORT void setMaxSize(unsigned); // number of pages to cache.
unsigned maxSize() const { return m_maxSize; }
- void addIfCacheable(HistoryItem&, Page*); // Prunes if maxSize() is exceeded.
+ WEBCORE_EXPORT bool addIfCacheable(HistoryItem&, Page*); // Prunes if maxSize() is exceeded.
WEBCORE_EXPORT void remove(HistoryItem&);
CachedPage* get(HistoryItem&, Page*);
std::unique_ptr<CachedPage> take(HistoryItem&, Page*);
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (239181 => 239182)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -515,7 +515,7 @@
ASSERT_UNUSED(resource, &resource == m_mainResource);
#if ENABLE(SERVICE_WORKER)
bool isRedirectionFromServiceWorker = redirectResponse.source() == ResourceResponse::Source::ServiceWorker;
- willSendRequest(WTFMove(request), redirectResponse, ShouldContinue::Yes, [isRedirectionFromServiceWorker, completionHandler = WTFMove(completionHandler), protectedThis = makeRef(*this), this] (auto&& request) mutable {
+ willSendRequest(WTFMove(request), redirectResponse, [isRedirectionFromServiceWorker, completionHandler = WTFMove(completionHandler), protectedThis = makeRef(*this), this] (auto&& request) mutable {
ASSERT(!m_substituteData.isValid());
if (request.isNull() || !m_mainDocumentError.isNull() || !m_frame) {
completionHandler({ });
@@ -548,11 +548,11 @@
});
});
#else
- willSendRequest(WTFMove(request), redirectResponse, ShouldContinue::Yes, WTFMove(completionHandler));
+ willSendRequest(WTFMove(request), redirectResponse, WTFMove(completionHandler));
#endif
}
-void DocumentLoader::willSendRequest(ResourceRequest&& newRequest, const ResourceResponse& redirectResponse, ShouldContinue shouldContinue, CompletionHandler<void(ResourceRequest&&)>&& completionHandler)
+void DocumentLoader::willSendRequest(ResourceRequest&& newRequest, const ResourceResponse& redirectResponse, CompletionHandler<void(ResourceRequest&&)>&& completionHandler)
{
// Note that there are no asserts here as there are for the other callbacks. This is due to the
// fact that this "callback" is sent when starting every load, and the state of callback
@@ -560,8 +560,6 @@
// callbacks is meant to prevent.
ASSERT(!newRequest.isNull());
- ASSERT(shouldContinue != ShouldContinue::No);
-
bool didReceiveRedirectResponse = !redirectResponse.isNull();
if (!frameLoader()->checkIfFormActionAllowedByCSP(newRequest.url(), didReceiveRedirectResponse)) {
cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
@@ -628,16 +626,12 @@
setRequest(newRequest);
- if (!didReceiveRedirectResponse && shouldContinue != ShouldContinue::ForSuspension)
+ if (!didReceiveRedirectResponse)
return completionHandler(WTFMove(newRequest));
auto navigationPolicyCompletionHandler = [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] (ResourceRequest&& request, WeakPtr<FormState>&&, ShouldContinue shouldContinue) mutable {
m_waitingForNavigationPolicy = false;
switch (shouldContinue) {
- case ShouldContinue::ForSuspension:
- // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume.
- request = { WTF::blankURL() };
- break;
case ShouldContinue::No:
stopLoadingForPolicyChange();
break;
@@ -651,11 +645,6 @@
ASSERT(!m_waitingForNavigationPolicy);
m_waitingForNavigationPolicy = true;
- if (shouldContinue == ShouldContinue::ForSuspension) {
- navigationPolicyCompletionHandler(WTFMove(newRequest), nullptr, shouldContinue);
- return;
- }
-
frameLoader()->policyChecker().checkNavigationPolicy(WTFMove(newRequest), redirectResponse, WTFMove(navigationPolicyCompletionHandler));
}
@@ -1693,10 +1682,8 @@
return true;
}
-void DocumentLoader::startLoadingMainResource(ShouldContinue shouldContinue)
+void DocumentLoader::startLoadingMainResource()
{
- ASSERT(shouldContinue != ShouldContinue::No);
-
m_mainDocumentError = ResourceError();
timing().markStartTimeAndFetchStart();
ASSERT(!m_mainResource);
@@ -1722,7 +1709,7 @@
ASSERT(timing().startTime());
ASSERT(timing().fetchStart());
- willSendRequest(ResourceRequest(m_request), ResourceResponse(), shouldContinue, [this, protectedThis = WTFMove(protectedThis)] (ResourceRequest&& request) mutable {
+ willSendRequest(ResourceRequest(m_request), ResourceResponse(), [this, protectedThis = WTFMove(protectedThis)] (ResourceRequest&& request) mutable {
m_request = request;
// willSendRequest() may lead to our Frame being detached or cancelling the load via nulling the ResourceRequest.
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (239181 => 239182)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -247,7 +247,7 @@
void setDefersLoading(bool);
void setMainResourceDataBufferingPolicy(DataBufferingPolicy);
- void startLoadingMainResource(ShouldContinue);
+ void startLoadingMainResource();
WEBCORE_EXPORT void cancelMainResourceLoad(const ResourceError&);
void willContinueMainResourceLoadAfterRedirect(const ResourceRequest&);
@@ -367,7 +367,7 @@
void clearArchiveResources();
#endif
- void willSendRequest(ResourceRequest&&, const ResourceResponse&, ShouldContinue, CompletionHandler<void(ResourceRequest&&)>&&);
+ void willSendRequest(ResourceRequest&&, const ResourceResponse&, CompletionHandler<void(ResourceRequest&&)>&&);
void finishedLoading();
void mainReceivedError(const ResourceError&);
WEBCORE_EXPORT void redirectReceived(CachedResource&, ResourceRequest&&, const ResourceResponse&, CompletionHandler<void(ResourceRequest&&)>&&) override;
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (239181 => 239182)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -312,7 +312,7 @@
// This somewhat odd set of steps gives the frame an initial empty document.
setPolicyDocumentLoader(m_client.createDocumentLoader(ResourceRequest(URL({ }, emptyString())), SubstituteData()).ptr());
setProvisionalDocumentLoader(m_policyDocumentLoader.get());
- m_provisionalDocumentLoader->startLoadingMainResource(ShouldContinue::Yes);
+ m_provisionalDocumentLoader->startLoadingMainResource();
Ref<Frame> protect(m_frame);
m_frame.document()->cancelParsing();
@@ -1772,7 +1772,9 @@
void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
{
- ASSERT(!m_frame.document() || m_frame.document()->pageCacheState() != Document::InPageCache);
+ if (m_frame.document() && m_frame.document()->pageCacheState() == Document::InPageCache)
+ return;
+
if (!isStopLoadingAllowed())
return;
@@ -1866,6 +1868,9 @@
{
if (!loader && !m_documentLoader)
return;
+
+ if (loader == m_documentLoader)
+ return;
ASSERT(loader != m_documentLoader);
ASSERT(!loader || loader->frameLoader() == this);
@@ -1953,7 +1958,7 @@
willTransitionToCommitted();
- if (!m_frame.tree().parent() && history().currentItem()) {
+ if (!m_frame.tree().parent() && history().currentItem() && history().currentItem() != history().provisionalItem()) {
// Check to see if we need to cache the page we are navigating away from into the back/forward cache.
// We are doing this here because we know for sure that a new page is about to be loaded.
PageCache::singleton().addIfCacheable(*history().currentItem(), m_frame.page());
@@ -3348,11 +3353,11 @@
diagnosticLoggingClient.logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageCacheKey(), DiagnosticLoggingKeys::retrievalKey(), DiagnosticLoggingResultFail, ShouldSample::Yes);
}
- CompletionHandler<void()> completionHandler = [this, protectedFrame = makeRef(m_frame), shouldContinue] () mutable {
+ CompletionHandler<void()> completionHandler = [this, protectedFrame = makeRef(m_frame)] () mutable {
if (!m_provisionalDocumentLoader)
return;
- prepareForLoadStart([this, protectedFrame = WTFMove(protectedFrame), shouldContinue] {
+ prepareForLoadStart([this, protectedFrame = WTFMove(protectedFrame)] {
// The load might be cancelled inside of prepareForLoadStart(), nulling out the m_provisionalDocumentLoader,
// so we need to null check it again.
@@ -3369,16 +3374,7 @@
m_loadingFromCachedPage = false;
- // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume.
- if (shouldContinue == ShouldContinue::ForSuspension) {
- // Make sure we do a standard load to about:blank instead of reusing whatever the load type was on process swap.
- // For example, using a Back/Forward load to load about blank would cause the current HistoryItem's url to be
- // overwritten with 'about:blank', which we do not want.
- m_loadType = FrameLoadType::Standard;
- m_provisionalDocumentLoader->willContinueMainResourceLoadAfterRedirect({ WTF::blankURL() });
- }
-
- m_provisionalDocumentLoader->startLoadingMainResource(shouldContinue);
+ m_provisionalDocumentLoader->startLoadingMainResource();
});
};
@@ -3393,7 +3389,6 @@
void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& request,
FormState* formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy openerPolicy)
{
- ASSERT(shouldContinue != ShouldContinue::ForSuspension);
if (shouldContinue != ShouldContinue::Yes)
return;
Modified: trunk/Source/WebCore/loader/FrameLoaderTypes.h (239181 => 239182)
--- trunk/Source/WebCore/loader/FrameLoaderTypes.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/loader/FrameLoaderTypes.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -44,7 +44,7 @@
Use,
Download,
Ignore,
- Suspend,
+ Suspend, // FIXME: This is only used by WebKit2 so we shouldn't need this in the WebCore enum.
};
enum class ReloadOption : uint8_t {
Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (239181 => 239182)
--- trunk/Source/WebCore/loader/PolicyChecker.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -183,7 +183,7 @@
case PolicyAction::Ignore:
return function({ }, nullptr, ShouldContinue::No);
case PolicyAction::Suspend:
- return function({ WTF::blankURL() }, nullptr, ShouldContinue::ForSuspension);
+ RELEASE_ASSERT_NOT_REACHED();
case PolicyAction::Use:
if (!m_frame.loader().client().canHandleRequest(request)) {
handleUnimplementablePolicy(m_frame.loader().client().cannotShowURLError(request));
Modified: trunk/Source/WebCore/loader/PolicyChecker.h (239181 => 239182)
--- trunk/Source/WebCore/loader/PolicyChecker.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebCore/loader/PolicyChecker.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -54,8 +54,7 @@
enum class ShouldContinue {
Yes,
- No,
- ForSuspension
+ No
};
enum class PolicyDecisionMode { Synchronous, Asynchronous };
Modified: trunk/Source/WebKit/ChangeLog (239181 => 239182)
--- trunk/Source/WebKit/ChangeLog 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/ChangeLog 2018-12-13 23:17:44 UTC (rev 239182)
@@ -1,3 +1,54 @@
+2018-12-13 Chris Dumez <[email protected]>
+
+ [PSON] We should not need to navigate to 'about:blank' to suspend pages
+ https://bugs.webkit.org/show_bug.cgi?id=192668
+ <rdar://problem/46701466>
+
+ Reviewed by Alex Christensen.
+
+ To support PageCache when process-swap on cross-site navigation is enabled,
+ we've been navigating the previous process to 'about:blank' when swapping.
+ This would trigger PageCaching of the page in the old process. While
+ convenient, this design has led to a lot of bugs because we did not really
+ want a navigation to happen in the old process.
+
+ To address the issue, when a WebPage is asked to suspend (for process-swap),
+ we now attempt to add it to PageCache and save it on the current HistoryItem,
+ *without* triggering any navigation. Any pending navigation gets cancelled
+ and we just suspend in place.
+
+ Later on, when we want to go back to this HistoryItem, we simply leverage the
+ existing WebPage::goToBackForwardItem() code path. The only subtlety is that
+ we're actually asking the WebPage to load a HistoryItem that is the current
+ one in the History. I had to tweak a some logic / assertions to support this
+ as this is not something we usually do. However, it actually works with very
+ little changes and successfully restores the PageCache entry on the current
+ HistoryItem.
+
+ There is no expected overall behavior change and ProcessSwap API tests (which
+ cover PageCache) still pass. This is merely a simpler design because it avoids
+ navigating to about:blank.
+
+ * UIProcess/SuspendedPageProxy.cpp:
+ (WebKit::SuspendedPageProxy::didSuspend):
+ (WebKit::SuspendedPageProxy::didReceiveMessage):
+ * UIProcess/SuspendedPageProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didSuspendAfterProcessSwap):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
+ * WebProcess/WebPage/WebDocumentLoader.cpp:
+ (WebKit::WebDocumentLoader::setNavigationID):
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::didReceivePolicyDecision):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::suspendForProcessSwap):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::origin):
+
2018-12-13 Per Arne Vollan <[email protected]>
[macOS] Remove with-report from 3 services that are currently needed on macOS
Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp (239181 => 239182)
--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -130,14 +130,12 @@
m_process->send(Messages::WebPage::SetIsSuspended(false), m_page.pageID());
}
-void SuspendedPageProxy::didFinishLoad()
+void SuspendedPageProxy::didSuspend()
{
LOG(ProcessSwapping, "SuspendedPageProxy %s from process %i finished transition to suspended", loggingString(), m_process->processIdentifier());
m_finishedSuspending = true;
- m_process->send(Messages::WebProcess::UpdateActivePages(), 0);
-
#if PLATFORM(IOS_FAMILY)
m_suspensionToken = nullptr;
#endif
@@ -159,8 +157,8 @@
{
ASSERT(decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName());
- if (decoder.messageName() == Messages::WebPageProxy::DidFinishLoadForFrame::name()) {
- didFinishLoad();
+ if (decoder.messageName() == Messages::WebPageProxy::DidSuspendAfterProcessSwap::name()) {
+ didSuspend();
return;
}
Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h (239181 => 239182)
--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -55,7 +55,7 @@
#endif
private:
- void didFinishLoad();
+ void didSuspend();
void didFailToSuspend();
// IPC::MessageReceiver
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (239181 => 239182)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -750,6 +750,9 @@
if (processSwapRequestedByClient == ProcessSwapRequestedByClient::Yes)
return false;
+ if (isPageOpenedByDOMShowingInitialEmptyDocument())
+ return false;
+
auto* currentItem = navigation.fromItem();
if (!currentItem) {
LOG(ProcessSwapping, "WebPageProxy %" PRIu64 " unable to create suspended page for process pid %i - No current back/forward item", pageID(), m_process->processIdentifier());
@@ -2626,7 +2629,7 @@
}
if (processForNavigation.ptr() != &process()) {
- policyAction = PolicyAction::Suspend;
+ policyAction = isPageOpenedByDOMShowingInitialEmptyDocument() ? PolicyAction::Ignore : PolicyAction::Suspend;
RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "%p - WebPageProxy::decidePolicyForNavigationAction, swapping process %i with process %i for navigation, reason: %{public}s", this, processIdentifier(), processForNavigation->processIdentifier(), reason.utf8().data());
LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), processForNavigation->processIdentifier(), navigation->navigationID(), navigation->loggingString());
} else
@@ -2744,8 +2747,7 @@
}
};
- bool isInitialNavigationInNewWindow = openedByDOM() && !hasCommittedAnyProvisionalLoads();
- if (!m_process->processPool().configuration().processSwapsOnWindowOpenWithOpener() || !isInitialNavigationInNewWindow || !mainFrameIDInPreviousProcess) {
+ if (!m_process->processPool().configuration().processSwapsOnWindowOpenWithOpener() || !isPageOpenedByDOMShowingInitialEmptyDocument() || !mainFrameIDInPreviousProcess) {
// There is no way we'll be able to return to the page in the previous page so close it.
if (!didSuspendPreviousPage)
previousProcess->send(Messages::WebPage::Close(), m_pageID);
@@ -2759,6 +2761,11 @@
};
}
+bool WebPageProxy::isPageOpenedByDOMShowingInitialEmptyDocument() const
+{
+ return openedByDOM() && !hasCommittedAnyProvisionalLoads();
+}
+
// MSVC gives a redeclaration error if noreturn is used on the definition and not the declaration, while
// Cocoa tests segfault if it is moved to the declaration site (even if we move the definition with it!).
#if !COMPILER(MSVC)
@@ -2770,6 +2777,15 @@
ASSERT_NOT_REACHED();
}
+#if !COMPILER(MSVC)
+NO_RETURN_DUE_TO_ASSERT
+#endif
+void WebPageProxy::didSuspendAfterProcessSwap()
+{
+ // Only the SuspendedPageProxy should be getting this call.
+ ASSERT_NOT_REACHED();
+}
+
void WebPageProxy::setUserAgent(String&& userAgent)
{
if (m_userAgent == userAgent)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (239181 => 239182)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -1392,6 +1392,8 @@
void setDefersLoadingForTesting(bool);
+ bool isPageOpenedByDOMShowingInitialEmptyDocument() const;
+
WebCore::IntRect syncRootViewToScreen(const WebCore::IntRect& viewRect);
#if ENABLE(DATALIST_ELEMENT)
@@ -1567,6 +1569,7 @@
void reattachToWebProcess();
void swapToWebProcess(Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>&&, ShouldDelayAttachingDrawingArea);
void didFailToSuspendAfterProcessSwap();
+ void didSuspendAfterProcessSwap();
void finishAttachingToWebProcess(ShouldDelayAttachingDrawingArea = ShouldDelayAttachingDrawingArea::No);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (239181 => 239182)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-12-13 23:17:44 UTC (rev 239182)
@@ -505,6 +505,7 @@
#endif
DidFailToSuspendAfterProcessSwap()
+ DidSuspendAfterProcessSwap()
ImageOrMediaDocumentSizeChanged(WebCore::IntSize newSize)
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (239181 => 239182)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -2197,9 +2197,8 @@
if (navigation.treatAsSameOriginNavigation())
return completionHandler(page.process(), nullptr, "The treatAsSameOriginNavigation flag is set"_s);
- bool isInitialLoadInNewWindowOpenedByDOM = page.openedByDOM() && !page.hasCommittedAnyProvisionalLoads();
URL sourceURL;
- if (isInitialLoadInNewWindowOpenedByDOM && !navigation.requesterOrigin().isEmpty())
+ if (page.isPageOpenedByDOMShowingInitialEmptyDocument() && !navigation.requesterOrigin().isEmpty())
sourceURL = URL { URL(), navigation.requesterOrigin().toString() };
else
sourceURL = URL { { }, page.pageLoadState().url() };
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (239181 => 239182)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -735,12 +735,6 @@
return;
}
- // For suspension loads to about:blank, no need to ask the SuspendedPageProxy.
- if (request.url() == WTF::blankURL() && webPage->isSuspended()) {
- function(PolicyAction::Use);
- return;
- }
-
RefPtr<API::Object> userData;
// Notify the bundle client.
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp (239181 => 239182)
--- trunk/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebDocumentLoader.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -50,7 +50,6 @@
void WebDocumentLoader::setNavigationID(uint64_t navigationID)
{
ASSERT(navigationID);
- ASSERT(!m_navigationID || m_navigationID == navigationID);
m_navigationID = navigationID;
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp (239181 => 239182)
--- trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -275,7 +275,16 @@
documentLoader->setNavigationID(navigationID);
}
+ bool shouldSuspend = false;
+ if (action == PolicyAction::Suspend) {
+ shouldSuspend = true;
+ action = ""
+ }
+
function(action);
+
+ if (shouldSuspend)
+ page()->suspendForProcessSwap();
}
void WebFrame::startDownload(const WebCore::ResourceRequest& request, const String& suggestedName)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (239181 => 239182)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-12-13 23:17:44 UTC (rev 239182)
@@ -184,6 +184,7 @@
#include <WebCore/MouseEvent.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/Page.h>
+#include <WebCore/PageCache.h>
#include <WebCore/PageConfiguration.h>
#include <WebCore/PingLoader.h>
#include <WebCore/PlatformKeyboardEvent.h>
@@ -1311,6 +1312,27 @@
send(Messages::WebPageProxy::ClosePage(false));
}
+void WebPage::suspendForProcessSwap()
+{
+ auto failedToSuspend = [this, protectedThis = makeRef(*this)] {
+ close();
+ send(Messages::WebPageProxy::DidFailToSuspendAfterProcessSwap());
+ };
+
+ auto* currentHistoryItem = m_mainFrame->coreFrame()->loader().history().currentItem();
+ if (!currentHistoryItem) {
+ failedToSuspend();
+ return;
+ }
+
+ if (!PageCache::singleton().addIfCacheable(*currentHistoryItem, corePage())) {
+ failedToSuspend();
+ return;
+ }
+
+ send(Messages::WebPageProxy::DidSuspendAfterProcessSwap());
+}
+
void WebPage::loadURLInFrame(URL&& url, uint64_t frameID)
{
WebFrame* frame = WebProcess::singleton().webFrame(frameID);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (239181 => 239182)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-12-13 23:17:44 UTC (rev 239182)
@@ -450,6 +450,8 @@
void clearMainFrameName();
void sendClose();
+ void suspendForProcessSwap();
+
void sendSetWindowFrame(const WebCore::FloatRect&);
double textZoomFactor() const;
Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (239181 => 239182)
--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2018-12-13 23:06:49 UTC (rev 239181)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2018-12-13 23:17:44 UTC (rev 239182)
@@ -460,14 +460,6 @@
return nil;
URL mainFrameURL = { URL(), mainFrame->url() };
- if (page.isSuspended()) {
- // Suspended page are navigated to about:blank upon suspension so we really want to report the previous URL.
- if (auto* coreFrame = mainFrame->coreFrame()) {
- if (auto* backHistoryItem = coreFrame->loader().history().previousItem())
- mainFrameURL = { URL(), backHistoryItem->urlString() };
- }
- }
-
Ref<SecurityOrigin> mainFrameOrigin = SecurityOrigin::create(mainFrameURL);
String mainFrameOriginString;
if (!mainFrameOrigin->isUnique())