Go to back/forward list items after a process-swapped navigation.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 22:15:23 +0000 (22:15 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 22:15:23 +0000 (22:15 +0000)
commitb311b1d2bfff0225ddba7ea9185264fc07f9b2e7
tree436180f353845fce89c0c361aa66e4ef8e20517a
parente39c35d2507806f54e2a7a6028403819610fb713
Go to back/forward list items after a process-swapped navigation.
<rdar://problem/38690544> and https://bugs.webkit.org/show_bug.cgi?id=183920

Reviewed by Andy Estes.

Source/WebCore:

Covered by new API test.

Most of the changes to WebCore are teaching HistoryItem navigations to know when they should
do a policy check or not.

* WebCore.xcodeproj/project.pbxproj:

* history/BackForwardController.cpp:
(WebCore::BackForwardController::goBackOrForward):
(WebCore::BackForwardController::goBack):
(WebCore::BackForwardController::goForward):

* history/HistoryItem.cpp:
(WebCore::HistoryItem::setStateObject): Actually push state object changes to the UIProcess.
  This was a long standing bug that made it difficult to effectively test this change.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURLIntoChildFrame):
(WebCore::FrameLoader::loadDifferentDocumentItem):
(WebCore::FrameLoader::loadItem):
(WebCore::FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad):
* loader/FrameLoader.h:
* loader/FrameLoaderTypes.h:

* loader/HistoryController.cpp:
(WebCore::HistoryController::goToItem):
(WebCore::HistoryController::setDefersLoading):
(WebCore::HistoryController::recursiveGoToItem):
* loader/HistoryController.h:

* loader/NavigationPolicyCheck.h:

* page/Page.cpp:
(WebCore::Page::goToItem):
* page/Page.h:

Source/WebKit:

This takes the initial work of "process swap a normal navigation" and extends it to
process swapping for back/forward item navigations.

* Scripts/webkit/messages.py:

Make sure state objects are serialized to the UI Process back/forward list items, as otherwise
they will be lost in process-swap scenarios:
* Shared/SessionState.cpp:
(WebKit::PageState::encode const):
(WebKit::PageState::decode):
* Shared/SessionState.h:

Make a new variant of APINavigation specifically for back/forward list items.
* UIProcess/API/APINavigation.cpp:
(API::Navigation::Navigation):
(API::Navigation::loggingURL const):
* UIProcess/API/APINavigation.h:
(API::Navigation::create):
(API::Navigation::backForwardListItem):
(API::Navigation::backForwardFrameLoadType const):

* UIProcess/API/C/WKPage.cpp:
(WKPageGoToBackForwardListItem):

* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController goToBackForwardListItem:]):

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView goToBackForwardListItem:]):

* UIProcess/WebNavigationState.cpp:
(WebKit::WebNavigationState::createLoadRequestNavigation):
(WebKit::WebNavigationState::createBackForwardNavigation):
* UIProcess/WebNavigationState.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::reattachToWebProcessForReload):
(WebKit::WebPageProxy::reattachToWebProcessWithItem):
(WebKit::WebPageProxy::goForward):
(WebKit::WebPageProxy::goBack):
(WebKit::WebPageProxy::goToBackForwardItem):
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::continueNavigationInNewProcess): Handle back/forward navigations differently than others.
(WebKit::WebPageProxy::restoreFromSessionState):
* UIProcess/WebPageProxy.h:

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addOrUpdateBackForwardItem): Renamed from "addBackForwardItem" for clarity
(WebKit::WebProcessProxy::addBackForwardItem): Deleted.
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:

* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::endSwipeGesture):

* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::endSwipeGesture):

* WebProcess/WebCoreSupport/SessionStateConversion.cpp:
(WebKit::toPageState):
(WebKit::toHistoryItem):

* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::updateBackForwardItem):

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::goToBackForwardItem): Combined "goBack" and "goForward" with this method,
  passing the appropriate FrameLoadType around as needed to remember the specific type.
(WebKit::WebPage::goForward): Deleted.
(WebKit::WebPage::goBack): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView _loadBackForwardListFromOtherView:]):
(-[WebView goToBackForwardItem:]):

Source/WebKitLegacy/win:

* WebView.cpp:
(WebView::goToBackForwardItem):
(WebView::loadBackForwardListFromOtherView):

Tools:

Add a new API test that does some process-swapping navigations (including a back navigation)
and verifies the state of the engine afterwards.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(-[PSONMessageHandler userContentController:didReceiveScriptMessage:]):
(-[PSONScheme initWithBytes:]):
(-[PSONScheme webView:startURLSchemeTask:]):
(log):
(function):
(TEST): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
42 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/history/BackForwardController.cpp
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/FrameLoaderTypes.h
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/loader/HistoryController.h
Source/WebCore/loader/NavigationPolicyCheck.h [new file with mode: 0644]
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/ChangeLog
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/SessionState.cpp
Source/WebKit/Shared/SessionState.h
Source/WebKit/UIProcess/API/APINavigation.cpp
Source/WebKit/UIProcess/API/APINavigation.h
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit/UIProcess/WebNavigationState.cpp
Source/WebKit/UIProcess/WebNavigationState.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/UIProcess/WebProcessProxy.messages.in
Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm
Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.cpp
Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebView.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm