Changeset 213590 in webkit
- Timestamp:
- Mar 8, 2017 12:01:15 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r213589 r213590 1 2017-03-08 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 Sam Weinig. 8 9 Sadly history-scroll-restoration.html needs to be cloned for iOS and to use uiController.doAfterPresentationUpdate() 10 there, since restoration involves a trip to the UI process, and this same test did not work for Mac WK1 (dispatch_async() 11 doesn't seem to give the right timing in DRT). 12 13 * TestExpectations: 14 * fast/dom/Window/window-appendages-cleared-expected.txt: 15 * fast/history/history-scroll-restoration-attribute-expected.txt: Added. 16 * fast/history/history-scroll-restoration-attribute.html: Added. 17 * fast/history/history-scroll-restoration-expected.txt: Added. 18 * fast/history/history-scroll-restoration.html: Added. 19 * platform/ios-simulator-wk2/TestExpectations: 20 * platform/ios-simulator/TestExpectations: 21 1 22 2017-03-08 Chris Dumez <cdumez@apple.com> 2 23 -
trunk/LayoutTests/TestExpectations
r213511 r213590 26 26 fast/events/ios [ Skip ] 27 27 fast/events/touch/ios [ Skip ] 28 fast/history/ios [ Skip ] 28 29 fast/scrolling/ios [ Skip ] 29 30 scrollingcoordinator/ios [ Skip ] … … 1059 1060 webkit.org/b/168175 imported/w3c/web-platform-tests/html/browsers/offline/browser-state/navigator_online_online.html [ Pass Failure ] 1060 1061 webkit.org/b/168175 imported/w3c/web-platform-tests/html/semantics/text-level-semantics/the-a-element/a-download-click.html [ Timeout Pass ] 1062 webkit.org/b/169264 imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html [ Failure ] 1061 1063 1062 1064 webkit.org/b/168066 performance-api/performance-now-api.html [ Pass Failure ] -
trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt
r204953 r213590 5 5 PASS history.pushState == "LEFTOVER" is false 6 6 PASS history.replaceState == "LEFTOVER" is false 7 PASS history.scrollRestoration == "LEFTOVER" is false 7 8 PASS history.state == "LEFTOVER" is false 8 9 PASS location.ancestorOrigins == "LEFTOVER" is false -
trunk/LayoutTests/imported/w3c/ChangeLog
r213560 r213590 1 2017-03-08 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 Sam Weinig. 8 9 New passing baselines. 10 11 * web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic-expected.txt: 12 * web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin-expected.txt: 13 * web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin-expected.txt: 14 * web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc-expected.txt: 15 1 16 2017-03-07 Jiewen Tan <jiewen_tan@apple.com> 2 17 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-basic-expected.txt
r204844 r213590 1 1 2 FAIL Default value is "auto" assert_equals: expected (string) "auto" but got (undefined) undefined 2 PASS Default value is "auto" 3 3 PASS It is writable 4 FAIL Invalid values are ignored assert_equals: setting to invalid value (3.1415) should be ignored expected (string) "auto" but got (number) 3.1415 4 PASS Invalid values are ignored 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-cross-origin-expected.txt
r211930 r213590 1 1 Blocked access to external URL http://www.localhost:8800/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/resources/blank1.html 2 CONSOLE MESSAGE: line 2451: Error: assert_equals: navigating back should retain scrollRestoration value expected (string) "manual" but got (undefined) undefined3 2 4 3 5 Harness Error (TIMEOUT), message = null 4 PASS Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation 6 5 7 TIMEOUT Manual scroll restoration should take precedent over scrolling to fragment in cross origin navigation Test timed out8 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-cross-origin-expected.txt
r204844 r213590 1 1 2 2 3 FAIL Navigating to new page should reset to "auto" and navigating back should restore and respect scroll restoration mode assert_equals: new page loads should set scrollRestoration to "auto" expected (string) "auto" but got (undefined) undefined 3 PASS Navigating to new page should reset to "auto" and navigating back should restore and respect scroll restoration mode 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc-expected.txt
r204844 r213590 1 1 2 FAIL history.{push,replace}State retain scroll restoration mode and navigation in the same document respects it assert_equals: scrollX is correct for #4 expected 555 but got 200 2 PASS history.{push,replace}State retain scroll restoration mode and navigation in the same document respects it 3 3 -
trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations
r213476 r213590 7 7 #////////////////////////////////////////////////////////////////////////////////////////// 8 8 9 fast/history/ios [ Pass ] 9 10 fast/scrolling/ios [ Pass ] 10 11 fast/viewport/ios [ Pass ] … … 784 785 fast/history/gesture-before-onload-location-href.html 785 786 fast/history/history_reload.html 787 fast/history/history-scroll-restoration.html [ Skip ] 786 788 fast/history/timed-refresh-in-cached-frame.html 787 789 fast/history/window-open.html -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r213460 r213590 2440 2440 webkit.org/b/153371 imported/w3c/web-platform-tests/XMLHttpRequest/getresponseheader-chunked-trailer.htm [ Pass Failure ] 2441 2441 2442 webkit.org/b/169210 imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-navigation-samedoc.html [ Failure ] 2443 2442 2444 webkit.org/b/153498 svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg [ Pass Timeout ] 2443 2445 -
trunk/Source/WebCore/ChangeLog
r213589 r213590 1 2017-03-08 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 Sam Weinig. 8 9 Add 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::isSameDocumentReload): 35 (WebCore::FrameLoader::scrollToFragmentWithParentBoundary): 36 (WebCore::FrameLoader::continueLoadAfterNavigationPolicy): 37 * loader/FrameLoader.h: 38 * loader/HistoryController.cpp: 39 (WebCore::HistoryController::restoreScrollPositionAndViewState): 40 (WebCore::HistoryController::goToItem): 41 (WebCore::HistoryController::pushState): 42 (WebCore::HistoryController::replaceState): 43 * page/History.cpp: 44 (WebCore::History::scrollRestoration): 45 (WebCore::History::setScrollRestoration): 46 * page/History.h: 47 * page/History.idl: 48 1 49 2017-03-08 Chris Dumez <cdumez@apple.com> 2 50 -
trunk/Source/WebCore/history/HistoryItem.cpp
r207580 r213590 57 57 58 58 HistoryItem::HistoryItem() 59 : m_pageScaleFactor(0) 60 , m_lastVisitWasFailure(false) 61 , m_isTargetItem(false) 62 , m_itemSequenceNumber(generateSequenceNumber()) 59 : m_itemSequenceNumber(generateSequenceNumber()) 63 60 , m_documentSequenceNumber(generateSequenceNumber()) 64 61 , m_pruningReason(PruningReason::None) … … 70 67 , m_originalURLString(urlString) 71 68 , m_title(title) 72 , m_pageScaleFactor(0)73 , m_lastVisitWasFailure(false)74 , m_isTargetItem(false)75 69 , m_itemSequenceNumber(generateSequenceNumber()) 76 70 , m_documentSequenceNumber(generateSequenceNumber()) … … 86 80 , m_displayTitle(alternateTitle) 87 81 , m_pageScaleFactor(0) 88 , m_lastVisitWasFailure(false)89 , m_isTargetItem(false)90 82 , m_itemSequenceNumber(generateSequenceNumber()) 91 83 , m_documentSequenceNumber(generateSequenceNumber()) … … 272 264 } 273 265 266 bool HistoryItem::shouldRestoreScrollPosition() const 267 { 268 return m_shouldRestoreScrollPosition; 269 } 270 271 void HistoryItem::setShouldRestoreScrollPosition(bool shouldRestore) 272 { 273 m_shouldRestoreScrollPosition = shouldRestore; 274 } 275 274 276 float HistoryItem::pageScaleFactor() const 275 277 { -
trunk/Source/WebCore/history/HistoryItem.h
r209292 r213590 103 103 WEBCORE_EXPORT void setScrollPosition(const IntPoint&); 104 104 void clearScrollPosition(); 105 106 WEBCORE_EXPORT bool shouldRestoreScrollPosition() const; 107 WEBCORE_EXPORT void setShouldRestoreScrollPosition(bool); 105 108 106 109 WEBCORE_EXPORT float pageScaleFactor() const; … … 216 219 217 220 IntPoint m_scrollPosition; 218 float m_pageScaleFactor ;221 float m_pageScaleFactor { 0 }; // 0 indicates "unset". 219 222 Vector<String> m_documentState; 220 223 … … 223 226 Vector<Ref<HistoryItem>> m_children; 224 227 225 bool m_lastVisitWasFailure ;226 bool m_isTargetItem ;228 bool m_lastVisitWasFailure { false }; 229 bool m_isTargetItem { false }; 227 230 bool m_wasRestoredFromSession { false }; 231 bool m_shouldRestoreScrollPosition { true }; 228 232 229 233 // If two HistoryItems have the same item sequence number, then they are -
trunk/Source/WebCore/loader/FrameLoader.cpp
r213311 r213590 1056 1056 // We need to scroll to the fragment whether or not a hash change occurred, since 1057 1057 // the user might have scrolled since the previous navigation. 1058 scrollToFragmentWithParentBoundary(url );1058 scrollToFragmentWithParentBoundary(url, isNewNavigation); 1059 1059 1060 1060 m_isComplete = false; … … 2869 2869 } 2870 2870 2871 void FrameLoader::scrollToFragmentWithParentBoundary(const URL& url) 2871 static bool itemAllowsScrollRestoration(HistoryItem* historyItem) 2872 { 2873 return historyItem && historyItem->shouldRestoreScrollPosition(); 2874 } 2875 2876 static bool isSameDocumentReload(bool isNewNavigation, FrameLoadType loadType) 2877 { 2878 return !isNewNavigation && !isBackForwardLoadType(loadType); 2879 } 2880 2881 void FrameLoader::scrollToFragmentWithParentBoundary(const URL& url, bool isNewNavigation) 2872 2882 { 2873 2883 FrameView* view = m_frame.view(); … … 2881 2891 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); 2882 2892 2883 view->scrollToFragment(url); 2893 if (isSameDocumentReload(isNewNavigation, m_loadType) || itemAllowsScrollRestoration(history().currentItem())) 2894 view->scrollToFragment(url); 2884 2895 2885 2896 if (boundaryFrame) … … 3083 3094 3084 3095 // If the navigation request came from the back/forward menu, and we punt on it, we have the 3085 // problem that we have optimistically moved the b/f cursor already, so move it back. For sanity,3096 // problem that we have optimistically moved the b/f cursor already, so move it back. For sanity, 3086 3097 // we only do this when punting a navigation for the target frame or top-level frame. 3087 3098 if ((isTargetItem || m_frame.isMainFrame()) && isBackForwardLoadType(policyChecker().loadType())) { -
trunk/Source/WebCore/loader/FrameLoader.h
r211033 r213590 335 335 336 336 bool shouldPerformFragmentNavigation(bool isFormSubmission, const String& httpMethod, FrameLoadType, const URL&); 337 void scrollToFragmentWithParentBoundary(const URL& );337 void scrollToFragmentWithParentBoundary(const URL&, bool isNewNavigation = true); 338 338 339 339 void checkLoadCompleteForThisFrame(); -
trunk/Source/WebCore/loader/HistoryController.cpp
r212484 r213590 159 159 if (view && !view->wasScrolledByUser()) { 160 160 Page* page = m_frame.page(); 161 auto desiredScrollPosition = m_currentItem->s crollPosition();161 auto desiredScrollPosition = m_currentItem->shouldRestoreScrollPosition() ? m_currentItem->scrollPosition() : view->scrollPosition(); 162 162 LOG(Scrolling, "HistoryController::restoreScrollPositionAndViewState scrolling to %d,%d", desiredScrollPosition.x(), desiredScrollPosition.y()); 163 163 if (page && m_frame.isMainFrame() && m_currentItem->pageScaleFactor()) … … 292 292 void HistoryController::goToItem(HistoryItem& targetItem, FrameLoadType type) 293 293 { 294 LOG(History, "HistoryController %p goToItem %p type=%d", this, &targetItem, type); 295 294 296 ASSERT(!m_frame.tree().parent()); 295 297 … … 854 856 ASSERT(page); 855 857 858 bool shouldRestoreScrollPosition = m_currentItem->shouldRestoreScrollPosition(); 859 856 860 // Get a HistoryItem tree for the current frame tree. 857 861 Ref<HistoryItem> topItem = m_frame.mainFrame().loader().history().createItemTree(m_frame, false); … … 862 866 m_currentItem->setStateObject(WTFMove(stateObject)); 863 867 m_currentItem->setURLString(urlString); 864 865 LOG(History, "HistoryController %p pushState: Adding top item %p, setting url of current item %p to %s", this, topItem.ptr(), m_currentItem.get(), urlString.ascii().data()); 868 m_currentItem->setShouldRestoreScrollPosition(shouldRestoreScrollPosition); 869 870 LOG(History, "HistoryController %p pushState: Adding top item %p, setting url of current item %p to %s, scrollRestoration is %s", this, topItem.ptr(), m_currentItem.get(), urlString.ascii().data(), topItem->shouldRestoreScrollPosition() ? "auto" : "manual"); 866 871 867 872 page->backForward().addItem(WTFMove(topItem)); … … 879 884 return; 880 885 881 LOG(History, "HistoryController %p replaceState: Setting url of current item %p to %s ", this, m_currentItem.get(), urlString.ascii().data());886 LOG(History, "HistoryController %p replaceState: Setting url of current item %p to %s scrollRestoration %s", this, m_currentItem.get(), urlString.ascii().data(), m_currentItem->shouldRestoreScrollPosition() ? "auto" : "manual"); 882 887 883 888 if (!urlString.isEmpty()) -
trunk/Source/WebCore/page/History.cpp
r212250 r213590 60 60 } 61 61 62 ExceptionOr<History::ScrollRestoration> History::scrollRestoration() const 63 { 64 if (!m_frame) 65 return Exception { SECURITY_ERR }; 66 67 auto* historyItem = m_frame->loader().history().currentItem(); 68 if (!historyItem) 69 return ScrollRestoration::Auto; 70 71 return historyItem->shouldRestoreScrollPosition() ? ScrollRestoration::Auto : ScrollRestoration::Manual; 72 } 73 74 ExceptionOr<void> History::setScrollRestoration(ScrollRestoration scrollRestoration) 75 { 76 if (!m_frame) 77 return Exception { SECURITY_ERR }; 78 79 auto* historyItem = m_frame->loader().history().currentItem(); 80 if (historyItem) 81 historyItem->setShouldRestoreScrollPosition(scrollRestoration == ScrollRestoration::Auto); 82 83 return { }; 84 } 85 62 86 SerializedScriptValue* History::state() 63 87 { -
trunk/Source/WebCore/page/History.h
r206976 r213590 42 42 43 43 unsigned length() const; 44 45 enum class ScrollRestoration { 46 Auto, 47 Manual 48 }; 49 50 ExceptionOr<ScrollRestoration> scrollRestoration() const; 51 ExceptionOr<void> setScrollRestoration(ScrollRestoration); 52 44 53 SerializedScriptValue* state(); 45 54 void back(); -
trunk/Source/WebCore/page/History.idl
r206976 r213590 28 28 ] interface History { 29 29 readonly attribute unsigned long length; 30 [SetterMayThrowException, GetterMayThrowException] attribute ScrollRestoration scrollRestoration; 30 31 [CachedAttribute, Custom] readonly attribute SerializedScriptValue state; 31 32 … … 37 38 [Custom, MayThrowException] void replaceState(any data, DOMString title, optional USVString? url = null); 38 39 }; 40 41 enum ScrollRestoration { "auto", "manual" }; -
trunk/Source/WebKit2/ChangeLog
r213586 r213590 1 2017-03-08 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 Sam Weinig. 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 1 64 2017-03-08 Matt Rajca <mrajca@apple.com> 2 65 -
trunk/Source/WebKit2/Shared/SessionState.cpp
r204668 r213590 115 115 116 116 encoder << scrollPosition; 117 encoder << shouldRestoreScrollPosition; 117 118 encoder << pageScaleFactor; 118 119 … … 153 154 if (!decoder.decode(result.scrollPosition)) 154 155 return false; 156 if (!decoder.decode(result.shouldRestoreScrollPosition)) 157 return false; 155 158 if (!decoder.decode(result.pageScaleFactor)) 156 159 return false; -
trunk/Source/WebKit2/Shared/SessionState.h
r208985 r213590 97 97 98 98 WebCore::IntPoint scrollPosition; 99 bool shouldRestoreScrollPosition; 99 100 float pageScaleFactor; 100 101 -
trunk/Source/WebKit2/Shared/WebBackForwardListItem.h
r210042 r213590 53 53 54 54 void setPageState(PageState pageState) { m_itemState.pageState = WTFMove(pageState); } 55 const PageState& pageState() const { return m_itemState.pageState; } 55 56 56 57 const String& originalURL() const { return m_itemState.pageState.mainFrameState.originalURLString; } -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r213272 r213590 252 252 std::optional<CGRect> _frozenUnobscuredContentRect; 253 253 254 BOOL _needsToRestoreScrollPosition;255 254 BOOL _commitDidRestoreScrollPosition; 256 WebCore::FloatPoint_scrollOffsetToRestore;255 std::optional<WebCore::FloatPoint> _scrollOffsetToRestore; 257 256 WebCore::FloatSize _obscuredInsetWhenSaved; 258 257 259 BOOL _needsToRestoreUnobscuredCenter; 260 WebCore::FloatPoint _unobscuredCenterToRestore; 258 std::optional<WebCore::FloatPoint> _unobscuredCenterToRestore; 261 259 uint64_t _firstTransactionIDAfterPageRestore; 262 260 double _scaleToRestore; … … 1370 1368 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 1371 1369 [_contentView setHidden:NO]; 1372 _ needsToRestoreScrollPosition = NO;1373 _ needsToRestoreUnobscuredCenter = NO;1370 _scrollOffsetToRestore = std::nullopt; 1371 _unobscuredCenterToRestore = std::nullopt; 1374 1372 _scrollViewBackgroundColor = WebCore::Color(); 1375 1373 _delayUpdateVisibleContentRects = NO; … … 1491 1489 } 1492 1490 1493 bool isTransactionAfterPageRestore = layerTreeTransaction.transactionID() >= _firstTransactionIDAfterPageRestore; 1494 1495 if (_needsToRestoreScrollPosition && isTransactionAfterPageRestore) { 1496 _needsToRestoreScrollPosition = NO; 1497 1498 if (areEssentiallyEqualAsFloat(contentZoomScale(self), _scaleToRestore)) { 1499 WebCore::FloatPoint scaledScrollOffset = _scrollOffsetToRestore; 1500 scaledScrollOffset.scale(_scaleToRestore); 1501 WebCore::FloatPoint contentOffsetInScrollViewCoordinates = scaledScrollOffset - _obscuredInsetWhenSaved; 1502 1503 changeContentOffsetBoundedInValidRange(_scrollView.get(), contentOffsetInScrollViewCoordinates); 1504 _commitDidRestoreScrollPosition = YES; 1505 1506 if (_gestureController) 1507 _gestureController->didRestoreScrollPosition(); 1491 if (layerTreeTransaction.transactionID() >= _firstTransactionIDAfterPageRestore) { 1492 if (_scrollOffsetToRestore) { 1493 WebCore::FloatPoint scaledScrollOffset = _scrollOffsetToRestore.value(); 1494 _scrollOffsetToRestore = std::nullopt; 1495 1496 if (areEssentiallyEqualAsFloat(contentZoomScale(self), _scaleToRestore)) { 1497 scaledScrollOffset.scale(_scaleToRestore); 1498 WebCore::FloatPoint contentOffsetInScrollViewCoordinates = scaledScrollOffset - _obscuredInsetWhenSaved; 1499 1500 changeContentOffsetBoundedInValidRange(_scrollView.get(), contentOffsetInScrollViewCoordinates); 1501 _commitDidRestoreScrollPosition = YES; 1502 } 1508 1503 } 1509 1504 1505 if (_unobscuredCenterToRestore) { 1506 WebCore::FloatPoint unobscuredCenterToRestore = _unobscuredCenterToRestore.value(); 1507 _unobscuredCenterToRestore = std::nullopt; 1508 1509 if (areEssentiallyEqualAsFloat(contentZoomScale(self), _scaleToRestore)) { 1510 CGRect unobscuredRect = UIEdgeInsetsInsetRect(self.bounds, _obscuredInsets); 1511 WebCore::FloatSize unobscuredContentSizeAtNewScale(unobscuredRect.size.width / _scaleToRestore, unobscuredRect.size.height / _scaleToRestore); 1512 WebCore::FloatPoint topLeftInDocumentCoordinates(unobscuredCenterToRestore.x() - unobscuredContentSizeAtNewScale.width() / 2, unobscuredCenterToRestore.y() - unobscuredContentSizeAtNewScale.height() / 2); 1513 1514 topLeftInDocumentCoordinates.scale(_scaleToRestore); 1515 topLeftInDocumentCoordinates.moveBy(WebCore::FloatPoint(-_obscuredInsets.left, -_obscuredInsets.top)); 1516 1517 changeContentOffsetBoundedInValidRange(_scrollView.get(), topLeftInDocumentCoordinates); 1518 } 1519 } 1520 1510 1521 needUpdateVisbleContentRects = YES; 1511 } 1512 1513 if (_needsToRestoreUnobscuredCenter && isTransactionAfterPageRestore) { 1514 _needsToRestoreUnobscuredCenter = NO; 1515 1516 if (areEssentiallyEqualAsFloat(contentZoomScale(self), _scaleToRestore)) { 1517 CGRect unobscuredRect = UIEdgeInsetsInsetRect(self.bounds, _obscuredInsets); 1518 WebCore::FloatSize unobscuredContentSizeAtNewScale(unobscuredRect.size.width / _scaleToRestore, unobscuredRect.size.height / _scaleToRestore); 1519 WebCore::FloatPoint topLeftInDocumentCoordinates(_unobscuredCenterToRestore.x() - unobscuredContentSizeAtNewScale.width() / 2, _unobscuredCenterToRestore.y() - unobscuredContentSizeAtNewScale.height() / 2); 1520 1521 topLeftInDocumentCoordinates.scale(_scaleToRestore); 1522 topLeftInDocumentCoordinates.moveBy(WebCore::FloatPoint(-_obscuredInsets.left, -_obscuredInsets.top)); 1523 1524 changeContentOffsetBoundedInValidRange(_scrollView.get(), topLeftInDocumentCoordinates); 1525 if (_gestureController) 1526 _gestureController->didRestoreScrollPosition(); 1527 } 1528 1529 needUpdateVisbleContentRects = YES; 1522 1523 if (_gestureController) 1524 _gestureController->didRestoreScrollPosition(); 1530 1525 } 1531 1526 … … 1569 1564 } 1570 1565 1571 - (void)_restorePageScrollPosition:( WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatSize)obscuredInset scale:(double)scale1566 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatSize)obscuredInset scale:(double)scale 1572 1567 { 1573 1568 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) … … 1577 1572 return; 1578 1573 1579 _needsToRestoreUnobscuredCenter = NO;1580 _needsToRestoreScrollPosition = YES;1581 1574 _firstTransactionIDAfterPageRestore = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).nextLayerTreeTransactionID(); 1582 1583 _scrollOffsetToRestore = WebCore::ScrollableArea::scrollOffsetFromPosition(WebCore::FloatPoint(scrollPosition), WebCore::toFloatSize(scrollOrigin)); 1575 if (scrollPosition) 1576 _scrollOffsetToRestore = WebCore::ScrollableArea::scrollOffsetFromPosition(WebCore::FloatPoint(scrollPosition.value()), WebCore::toFloatSize(scrollOrigin)); 1577 else 1578 _scrollOffsetToRestore = std::nullopt; 1579 1584 1580 _obscuredInsetWhenSaved = obscuredInset; 1585 1581 _scaleToRestore = scale; 1586 1582 } 1587 1583 1588 - (void)_restorePageStateToUnobscuredCenter:( WebCore::FloatPoint)center scale:(double)scale1584 - (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale 1589 1585 { 1590 1586 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) … … 1594 1590 return; 1595 1591 1596 _needsToRestoreScrollPosition = NO;1597 _needsToRestoreUnobscuredCenter = YES;1598 1592 _firstTransactionIDAfterPageRestore = downcast<WebKit::RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).nextLayerTreeTransactionID(); 1599 _unobscuredCenterToRestore = center; 1593 _unobscuredCenterToRestore = center.value(); 1594 1600 1595 _scaleToRestore = scale; 1601 1596 } -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
r212459 r213590 82 82 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID; 83 83 - (void)_couldNotRestorePageState; 84 - (void)_restorePageScrollPosition:( WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatSize)topInset scale:(double)scale;85 - (void)_restorePageStateToUnobscuredCenter:( WebCore::FloatPoint)center scale:(double)scale; // FIXME: needs scroll origin?84 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatSize)topInset scale:(double)scale; 85 - (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale; // FIXME: needs scroll origin? 86 86 87 87 - (PassRefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot; -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
r206256 r213590 76 76 } 77 77 78 WebCore::FloatPoint PageClientImpl::viewScrollPosition() 79 { 80 return { }; 81 } 82 78 83 WebCore::IntSize PageClientImpl::viewSize() 79 84 { -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
r206256 r213590 58 58 void setViewNeedsDisplay(const WebCore::Region&) override; 59 59 void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override; 60 WebCore::FloatPoint viewScrollPosition() override; 60 61 WebCore::IntSize viewSize() override; 61 62 bool isViewWindowActive() override; -
trunk/Source/WebKit2/UIProcess/PageClient.h
r213584 r213590 101 101 virtual void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) = 0; 102 102 103 // Return the current scroll position (not necessarily the same as the WebCore scroll position, because of scaling, insets etc.) 104 virtual WebCore::FloatPoint viewScrollPosition() = 0; 105 103 106 // Return the size of the view the page is associated with. 104 107 virtual WebCore::IntSize viewSize() = 0; … … 295 298 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) = 0; 296 299 virtual void couldNotRestorePageState() = 0; 297 virtual void restorePageState( const WebCore::FloatPoint&scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale) = 0;298 virtual void restorePageCenterAndScale( const WebCore::FloatPoint¢er, double scale) = 0;300 virtual void restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale) = 0; 301 virtual void restorePageCenterAndScale(std::optional<WebCore::FloatPoint> center, double scale) = 0; 299 302 300 303 virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r213444 r213590 1436 1436 } 1437 1437 1438 WebCore::FloatPoint WebPageProxy::viewScrollPosition() const 1439 { 1440 return m_pageClient.viewScrollPosition(); 1441 } 1442 1438 1443 void WebPageProxy::setSuppressVisibilityUpdates(bool flag) 1439 1444 { -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r213584 r213590 447 447 void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll); 448 448 449 WebCore::FloatPoint viewScrollPosition() const; 450 449 451 void setDelegatesScrolling(bool delegatesScrolling) { m_delegatesScrolling = delegatesScrolling; } 450 452 bool delegatesScrolling() const { return m_delegatesScrolling; } … … 1512 1514 void dynamicViewportUpdateChangedTarget(double newTargetScale, const WebCore::FloatPoint& newScrollPosition, uint64_t dynamicViewportSizeUpdateID); 1513 1515 void couldNotRestorePageState(); 1514 void restorePageState( const WebCore::FloatPoint&scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale);1515 void restorePageCenterAndScale( const WebCore::FloatPoint&, double scale);1516 void restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale); 1517 void restorePageCenterAndScale(std::optional<WebCore::FloatPoint>, double scale); 1516 1518 1517 1519 void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& geometries, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r213584 r213590 377 377 DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t dynamicViewportSizeUpdateID) 378 378 CouldNotRestorePageState() 379 RestorePageState( WebCore::FloatPointscrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::FloatSize obscuredInsetOnSave, double scale)380 RestorePageCenterAndScale( WebCore::FloatPointunobscuredCenter, double scale)379 RestorePageState(std::optional<WebCore::FloatPoint> scrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::FloatSize obscuredInsetOnSave, double scale) 380 RestorePageCenterAndScale(std::optional<WebCore::FloatPoint> unobscuredCenter, double scale) 381 381 DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius) 382 382 -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
r213584 r213590 52 52 void setViewNeedsDisplay(const WebCore::Region&) override; 53 53 void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override; 54 WebCore::FloatPoint viewScrollPosition() override; 54 55 WebCore::IntSize viewSize() override; 55 56 bool isViewWindowActive() override; … … 122 123 void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override; 123 124 void couldNotRestorePageState() override; 124 void restorePageState( const WebCore::FloatPoint&, const WebCore::FloatPoint&, const WebCore::FloatSize&, double) override;125 void restorePageCenterAndScale( const WebCore::FloatPoint&, double) override;125 void restorePageState(std::optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatSize&, double) override; 126 void restorePageCenterAndScale(std::optional<WebCore::FloatPoint>, double) override; 126 127 127 128 void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) override; -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r213584 r213590 138 138 } 139 139 140 WebCore::FloatPoint PageClientImpl::viewScrollPosition() 141 { 142 if (UIScrollView *scroller = [m_contentView _scroller]) 143 return scroller.contentOffset; 144 145 return { }; 146 } 147 140 148 IntSize PageClientImpl::viewSize() 141 149 { … … 527 535 } 528 536 529 void PageClientImpl::restorePageState( const WebCore::FloatPoint&scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale)537 void PageClientImpl::restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale) 530 538 { 531 539 [m_webView _restorePageScrollPosition:scrollPosition scrollOrigin:scrollOrigin previousObscuredInset:obscuredInsetOnSave scale:scale]; 532 540 } 533 541 534 void PageClientImpl::restorePageCenterAndScale( const WebCore::FloatPoint¢er, double scale)542 void PageClientImpl::restorePageCenterAndScale(std::optional<WebCore::FloatPoint> center, double scale) 535 543 { 536 544 [m_webView _restorePageStateToUnobscuredCenter:center scale:scale]; -
trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm
r211929 r213590 195 195 FloatSize swipeLayerSizeInDeviceCoordinates(liveSwipeViewFrame.size); 196 196 swipeLayerSizeInDeviceCoordinates.scale(deviceScaleFactor); 197 if (snapshot->hasImage() && snapshot->size() == swipeLayerSizeInDeviceCoordinates && deviceScaleFactor == snapshot->deviceScaleFactor()) 197 198 BOOL shouldRestoreScrollPosition = targetItem->pageState().mainFrameState.shouldRestoreScrollPosition; 199 IntPoint currentScrollPosition = roundedIntPoint(m_webPageProxy.viewScrollPosition()); 200 201 if (snapshot->hasImage() && snapshot->size() == swipeLayerSizeInDeviceCoordinates && deviceScaleFactor == snapshot->deviceScaleFactor() && (shouldRestoreScrollPosition || (currentScrollPosition == snapshot->viewScrollPosition()))) 198 202 [m_snapshotView layer].contents = snapshot->asLayerContents(); 199 203 Color coreColor = snapshot->backgroundColor(); -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r213584 r213590 907 907 } 908 908 909 void WebPageProxy::restorePageState( const WebCore::FloatPoint&scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale)909 void WebPageProxy::restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatSize& obscuredInsetOnSave, double scale) 910 910 { 911 911 m_pageClient.restorePageState(scrollPosition, scrollOrigin, obscuredInsetOnSave, scale); 912 912 } 913 913 914 void WebPageProxy::restorePageCenterAndScale( const WebCore::FloatPoint¢er, double scale)914 void WebPageProxy::restorePageCenterAndScale(std::optional<WebCore::FloatPoint> center, double scale) 915 915 { 916 916 m_pageClient.restorePageCenterAndScale(center, scale); -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h
r212669 r213590 65 65 void setViewNeedsDisplay(const WebCore::Region&) override; 66 66 void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override; 67 WebCore::FloatPoint viewScrollPosition() override; 67 68 68 69 WebCore::IntSize viewSize() override; -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm
r212669 r213590 127 127 } 128 128 129 WebCore::FloatPoint PageClientImpl::viewScrollPosition() 130 { 131 return { }; 132 } 133 129 134 IntSize PageClientImpl::viewSize() 130 135 { -
trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h
r206829 r213590 28 28 29 29 #include <WebCore/Color.h> 30 #include <WebCore/IntPoint.h> 30 31 #include <WebCore/IntSize.h> 31 32 #include <WebCore/IOSurface.h> … … 71 72 void setBackgroundColor(WebCore::Color color) { m_backgroundColor = color; } 72 73 WebCore::Color backgroundColor() const { return m_backgroundColor; } 74 75 void setViewScrollPosition(WebCore::IntPoint scrollPosition) { m_viewScrollPosition = scrollPosition; } 76 WebCore::IntPoint viewScrollPosition() const { return m_viewScrollPosition; } 73 77 74 78 void setDeviceScaleFactor(float deviceScaleFactor) { m_deviceScaleFactor = deviceScaleFactor; } … … 105 109 float m_deviceScaleFactor; 106 110 WebCore::Color m_backgroundColor; 111 WebCore::IntPoint m_viewScrollPosition; // Scroll position at snapshot time. Integral to make comparison reliable. 107 112 }; 108 113 -
trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm
r206829 r213590 121 121 snapshot->setDeviceScaleFactor(webPageProxy.deviceScaleFactor()); 122 122 snapshot->setBackgroundColor(webPageProxy.pageExtendedBackgroundColor()); 123 snapshot->setViewScrollPosition(WebCore::roundedIntPoint(webPageProxy.viewScrollPosition())); 123 124 124 125 item.setSnapshot(WTFMove(snapshot)); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/SessionStateConversion.cpp
r208985 r213590 86 86 87 87 frameState.scrollPosition = historyItem.scrollPosition(); 88 frameState.shouldRestoreScrollPosition = historyItem.shouldRestoreScrollPosition(); 88 89 frameState.pageScaleFactor = historyItem.pageScaleFactor(); 89 90 … … 162 163 163 164 historyItem.setScrollPosition(frameState.scrollPosition); 165 historyItem.setShouldRestoreScrollPosition(frameState.shouldRestoreScrollPosition); 164 166 historyItem.setPageScaleFactor(frameState.pageScaleFactor); 165 167 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r212557 r213590 1227 1227 if (m_frame->isMainFrame()) 1228 1228 m_frame->page()->restorePageState(*currentItem); 1229 else if (!view->wasScrolledByUser()) 1229 else if (!view->wasScrolledByUser()) { 1230 WTFLogAlways("WebFrameLoaderClient::restoreViewState restoring scroll position %d,%d", currentItem->scrollPosition().x(), currentItem->scrollPosition().y()); 1230 1231 view->setScrollPosition(currentItem->scrollPosition()); 1232 } 1231 1233 } 1232 1234 #else -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r213584 r213590 313 313 scalePage(boundedScale, IntPoint()); 314 314 315 m_drawingArea->setExposedContentRect(historyItem.exposedContentRect()); 316 317 send(Messages::WebPageProxy::RestorePageState(historyItem.scrollPosition(), frameView.scrollOrigin(), historyItem.obscuredInset(), boundedScale)); 315 std::optional<FloatPoint> scrollPosition; 316 if (historyItem.shouldRestoreScrollPosition()) { 317 m_drawingArea->setExposedContentRect(historyItem.exposedContentRect()); 318 scrollPosition = FloatPoint(historyItem.scrollPosition()); 319 } 320 send(Messages::WebPageProxy::RestorePageState(scrollPosition, frameView.scrollOrigin(), historyItem.obscuredInset(), boundedScale)); 318 321 } else { 319 322 IntSize oldContentSize = historyItem.contentSize(); … … 323 326 double newScale = scaleAfterViewportWidthChange(historyItem.pageScaleFactor(), !historyItem.scaleIsInitial(), m_viewportConfiguration, currentMinimumLayoutSizeInScrollViewCoordinates.width(), newContentSize, oldContentSize, visibleHorizontalFraction); 324 327 325 FloatPoint newCenter; 326 if (!oldContentSize.isEmpty() && !newContentSize.isEmpty() && newContentSize != oldContentSize) 327 newCenter = relativeCenterAfterContentSizeChange(historyItem.unobscuredContentRect(), oldContentSize, newContentSize); 328 else 329 newCenter = FloatRect(historyItem.unobscuredContentRect()).center(); 330 331 FloatSize unobscuredRectAtNewScale = frameView.customSizeForResizeEvent(); 332 unobscuredRectAtNewScale.scale(1 / newScale); 333 334 FloatRect oldExposedRect = frameView.exposedContentRect(); 335 FloatRect adjustedExposedRect = adjustExposedRectForNewScale(oldExposedRect, m_page->pageScaleFactor(), newScale); 336 337 FloatPoint oldCenter = adjustedExposedRect.center(); 338 adjustedExposedRect.move(newCenter - oldCenter); 328 std::optional<FloatPoint> newCenter; 329 if (historyItem.shouldRestoreScrollPosition()) { 330 if (!oldContentSize.isEmpty() && !newContentSize.isEmpty() && newContentSize != oldContentSize) 331 newCenter = relativeCenterAfterContentSizeChange(historyItem.unobscuredContentRect(), oldContentSize, newContentSize); 332 else 333 newCenter = FloatRect(historyItem.unobscuredContentRect()).center(); 334 } 339 335 340 336 scalePage(newScale, IntPoint()); 341 342 337 send(Messages::WebPageProxy::RestorePageCenterAndScale(newCenter, newScale)); 343 338 }
Note: See TracChangeset
for help on using the changeset viewer.