12017-02-11 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 Add Mac support for history.scrollRestoration, per spec:
10 <https://html.spec.whatwg.org/multipage/browsers.html#dom-history-scroll-restoration>
11
12 This is a new attribute on the History interface. On setting, sets the "shouldRestoreScrollPosition"
13 state on the current history item, and the getter returns that state. pushState() inherits the
14 state from the current item.
15
16 HistoryController::restoreScrollPositionAndViewState() consults this state, and if set to "manual"
17 ("don't restore) it just uses the current scroll position (we need something to pass to
18 setPageScaleFactor() so can't just avoid the restoration).
19
20 FrameLoader::scrollToFragmentWithParentBoundary() also needs to consult the historyItem
21 to know if it's OK to scroll to a fragment, on back/forward same-document loads.
22
23 Tests: fast/history/history-scroll-restoration-attribute.html
24 fast/history/history-scroll-restoration.html
25
26 * history/HistoryItem.cpp:
27 (WebCore::HistoryItem::HistoryItem):
28 (WebCore::HistoryItem::shouldRestoreScrollPosition):
29 (WebCore::HistoryItem::setShouldRestoreScrollPosition):
30 * history/HistoryItem.h:
31 * loader/FrameLoader.cpp:
32 (WebCore::FrameLoader::loadInSameDocument):
33 (WebCore::itemAllowsScrollRestoration):
34 (WebCore::isNavigationOtherThanBackForward):
35 (WebCore::FrameLoader::scrollToFragmentWithParentBoundary):
36 (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
37 * loader/FrameLoader.h:
38 * loader/HistoryController.cpp:
39 (WebCore::HistoryController::restoreScrollPositionAndViewState):
40 (WebCore::HistoryController::pushState):
41 (WebCore::HistoryController::replaceState):
42 * page/History.cpp:
43 (WebCore::History::scrollRestoration):
44 (WebCore::History::setScrollRestoration):
45 * page/History.h:
46 * page/History.idl:
47