Make sure history navigations reuse the existing process when necessary.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 16:12:11 +0000 (16:12 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 16:12:11 +0000 (16:12 +0000)
commit8d7b0c729f218fdc2c4bbf6bbec301f1ff642a1d
tree3da2ed98134f1a10012b712e8a0b9c91898e69c2
parent3642519a3c11e0771023195cb11929b525410e53
Make sure history navigations reuse the existing process when necessary.
<rdar://problem/39746516> and https://bugs.webkit.org/show_bug.cgi?id=185532

Reviewed by Ryosuke Niwa.

Source/WebCore:

Covered by new API tests.

In WebCore-land, make sure *all* NavigationActions to a back/forward item are tagged with
the item identifier.

* history/HistoryItem.cpp:
(WebCore::HistoryItem::HistoryItem):
(WebCore::HistoryItem::logString const):
* history/HistoryItem.h:

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadDifferentDocumentItem):

* loader/NavigationAction.cpp:
(WebCore::NavigationAction::setTargetBackForwardItem):

* loader/NavigationAction.h:
(WebCore::NavigationAction::targetBackForwardItemIdentifier const):

Source/WebKit:

If a view navigates to either a data: or blob: URL, it reuses the existing process.

In such cases we need to also ensure that history navigations back will also reuse the existing process.

* Shared/NavigationActionData.cpp:
(WebKit::NavigationActionData::encode const):
(WebKit::NavigationActionData::decode):
* Shared/NavigationActionData.h:

* UIProcess/API/APINavigation.h:
(API::Navigation::setTargetItem):

* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration pageCacheEnabled]):
(-[_WKProcessPoolConfiguration setPageCacheEnabled:]):

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal): If the current and target back/forward items both
  came from the same process, then reuse the existing process.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/history/HistoryItem.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/NavigationAction.cpp
Source/WebCore/loader/NavigationAction.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/NavigationActionData.cpp
Source/WebKit/Shared/NavigationActionData.h
Source/WebKit/UIProcess/API/APINavigation.h
Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm