12017-03-07 Simon Fraser <simon.fraser@apple.com>
2
3 Add support for history.scrollRestoration
4 https://bugs.webkit.org/show_bug.cgi?id=147782
5 rdar://problem/22614568
6
7 Reviewed by NOBODY (OOPS!).
8
9 Need to send shouldRestoreScrollPosition to the UI process in SessionState,
10 WKWebView now stores _unobscuredCenterToRestore and _scrollOffsetToRestore as
11 std::optionals, and they will be nullopt if scroll restoration should not happen.
12
13 ViewGestureControllerIOS also needs knowledge of whether scroll restoration will
14 happen, and compares UI-process scroll position vs. the position at snapshot time
15 to know if the snapshot should be shown (this prevents showing a misleading snapshot
16 when swiping back on a navigation where scroll restoration is disabled).
17
18 * Shared/SessionState.cpp:
19 (WebKit::FrameState::encode):
20 (WebKit::FrameState::decode):
21 * Shared/SessionState.h:
22 * Shared/WebBackForwardListItem.h:
23 (WebKit::WebBackForwardListItem::pageState):
24 * UIProcess/API/Cocoa/WKWebView.mm:
25 (-[WKWebView _processDidExit]):
26 (-[WKWebView _didCommitLayerTree:]):
27 (-[WKWebView _restorePageScrollPosition:scrollOrigin:previousObscuredInset:scale:]):
28 (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
29 * UIProcess/API/Cocoa/WKWebViewInternal.h:
30 * UIProcess/API/gtk/PageClientImpl.cpp:
31 (WebKit::PageClientImpl::viewScrollPosition):
32 * UIProcess/API/gtk/PageClientImpl.h:
33 * UIProcess/PageClient.h:
34 * UIProcess/WebPageProxy.cpp:
35 (WebKit::WebPageProxy::viewScrollPosition):
36 * UIProcess/WebPageProxy.h:
37 * UIProcess/WebPageProxy.messages.in:
38 * UIProcess/ios/PageClientImplIOS.h:
39 * UIProcess/ios/PageClientImplIOS.mm:
40 (WebKit::PageClientImpl::viewScrollPosition):
41 (WebKit::PageClientImpl::restorePageState):
42 (WebKit::PageClientImpl::restorePageCenterAndScale):
43 * UIProcess/ios/ViewGestureControllerIOS.mm:
44 (WebKit::ViewGestureController::beginSwipeGesture):
45 * UIProcess/ios/WebPageProxyIOS.mm:
46 (WebKit::WebPageProxy::restorePageState):
47 (WebKit::WebPageProxy::restorePageCenterAndScale):
48 * UIProcess/mac/PageClientImpl.h:
49 * UIProcess/mac/PageClientImpl.mm:
50 (WebKit::PageClientImpl::viewScrollPosition):
51 * UIProcess/mac/ViewSnapshotStore.h:
52 (WebKit::ViewSnapshot::setViewScrollPosition):
53 (WebKit::ViewSnapshot::viewScrollPosition):
54 * UIProcess/mac/ViewSnapshotStore.mm:
55 (WebKit::ViewSnapshotStore::recordSnapshot):
56 * WebProcess/WebCoreSupport/SessionStateConversion.cpp:
57 (WebKit::toFrameState):
58 (WebKit::applyFrameState):
59 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
60 (WebKit::WebFrameLoaderClient::restoreViewState):
61 * WebProcess/WebPage/ios/WebPageIOS.mm:
62 (WebKit::WebPage::restorePageState):
63