Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Content offset in this codepen when switching tabs
https://bugs.webkit.org/show_bug.cgi?id=231989 Reviewed by Tim Horton. Source/WebCore: There were two problems that occurred with async-scrollable iframes when their associated WKWebView was removed and re-added to the view hierarchy (e.g. when switching tabs). These resulted in misplaced position:fixed content, and the first user scroll in the iframe causing the scroll position to jump back to the top. The positon:fixed issue was caused by an ordering problem in ScrollingTreeFrameScrollingNode::commitStateBeforeChildren() which resulted in the layout viewport being computed incorrectly; we called updateViewportForCurrentScrollPosition() before setting the min and max scroll position, so we'd always clamp the layout viewport to a location of 0,0. The second scroll position reset issue was caused by the ScrollingTreeScrollingNode's m_currentScrollPosition reverting to a stale after re-attaching the iframe's scrolling subtree. ScrollingTreeScrollingNode::commitStateBeforeChildren() has code to set m_currentScrollPosition from the state tree node's scroll position on first commit; the issue was that ScrollingStateScrollingNode's scrollPosition() was not updated on every scroll, only when something triggered a scrolling tree commit. Fix by silently updating ScrollingStateScrollingNode's scrollPosition() when we get notifications back from the scrolling thread that a scroll happened. Both fixes are tested by the ScrollingCoordinatorTests.ScrollingTreeAfterDetachReattach API test. * page/scrolling/AsyncScrollingCoordinator.cpp: (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll): * page/scrolling/ScrollingStateScrollingNode.cpp: (WebCore::ScrollingStateScrollingNode::syncScrollPosition): (WebCore::ScrollingStateScrollingNode::hasScrollPositionRequest const): * page/scrolling/ScrollingStateScrollingNode.h: * page/scrolling/ScrollingStateTree.cpp: (WebCore::ScrollingStateTree::insertNode): * page/scrolling/ScrollingTreeFrameScrollingNode.cpp: (WebCore::ScrollingTreeFrameScrollingNode::commitStateBeforeChildren): We need to check state.hasScrollPositionRequest(), otherwise the "cancel animated scroll request" that comes out of Page::stopKeyboardScrollAnimation() prevents scroll position restoration. * page/scrolling/ScrollingTreeScrollingNode.cpp: (WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren): (WebCore::ScrollingTreeScrollingNode::dumpProperties const): * page/scrolling/mac/ScrollingCoordinatorMac.mm: (WebCore::ScrollingCoordinatorMac::commitTreeStateIfNeeded): Tools: API test that scrolls an iframe via wheel events, then detached and re-attaches the view. The two wheel scrolls are necessary to exercise the "stale ScrollingStateScrollingNode scroll position" issue. The scrolling tree dumps validate the layout viewport part of the fix. Also correct some functions where the sense of 'isWaitingForJavaScript' was flipped. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/mac/ScrollingCoordinatorTests.mm: Added. (TestWebKitAPI::synthesizeWheelEvents): (TestWebKitAPI::waitForScrollEventAndReturnScrollY): (TestWebKitAPI::scrollingTreeElidingLastCommittedScrollPosition): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView objectByEvaluatingJavaScript:]): (-[WKWebView objectByEvaluatingJavaScriptWithUserGesture:]): (-[WKWebView objectByCallingAsyncFunction:withArguments:error:]): LayoutTests: New baselines. * tiled-drawing/scrolling/clamp-out-of-bounds-scrolls-expected.txt: * tiled-drawing/scrolling/scrolling-tree-after-scroll-expected.txt: Canonical link: https://commits.webkit.org/243374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284654 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
16 changed files
with
273 additions
and
20 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
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
Oops, something went wrong.