Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS 17: History back sometimes scrolls to top of the page (with app b…
…anner) https://bugs.webkit.org/show_bug.cgi?id=231563 rdar://117107620 Reviewed by Tim Horton. Sometimes, navigating back to a page on iOS would fail to restore the scroll position to the correct location. This happened when `WebPage::restorePageState()` hit the second mismatched `minimumLayoutSizeInScrollViewCoordinates` clause, which made use of `historyItem.unobscuredContentRect()`. This could happen when MobileSafari app banners were hidden or shown. `historyItem.unobscuredContentRect()` had the wrong value in this case, containing a rect that had a 0,0 location which triggered a scroll back to the top. `historyItem.unobscuredContentRect()` was wrong because it was set in `HistoryController::saveScrollPositionAndViewStateToItem()` which runs after we've reset the content size in preparation for the navigation; note that this function uses `frameView->cachedScrollPosition()`. So the fix is to cache `unobscuredContentRect()` and `exposedContentRect()` in the same way. This is messy; ScrollView shouldn't be in the business of storing caches related to page navigation, but fixing that is out of scope for this change. The API test navigates and goes back with a view size change, which triggers the bug. Also add some release logging to help diagnose scroll restoration bugs. * Source/WebCore/dom/Document.cpp: (WebCore::Document::setBackForwardCacheState): * Source/WebCore/loader/HistoryController.cpp: (WebCore::FrameLoader::HistoryController::saveScrollPositionAndViewStateToItem): * Source/WebCore/platform/ScrollView.cpp: (WebCore::ScrollView::cacheCurrentScrollState): * Source/WebCore/platform/ScrollView.h: (WebCore::ScrollView::cachedUnobscuredContentRect const): (WebCore::ScrollView::cachedExposedContentRect const): (WebCore::ScrollView::cacheCurrentScrollPosition): Deleted. * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm: (TestWebKitAPI::TEST): * Tools/TestWebKitAPI/ios/scrollable-page.html: Added. Canonical link: https://commits.webkit.org/269611@main
- Loading branch information
Showing
8 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width"> | ||
<style> | ||
body { | ||
height: 5000px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |