Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Do not do smooth keyboard scrolling on containers with scroll snaps
https://bugs.webkit.org/show_bug.cgi?id=242523 rdar://96681582 Reviewed by Tim Horton. Tests: LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe- horizontal-with-keyboard-smooth-scroll-enabled.html LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe- vertical-with-keyboard-smooth-scroll-enabled.html Currently, smooth keyboard scrolling does not work with scroll snapping. This patch makes it so when the focused scrollable container uses scroll snapping, smooth keyboard scrolling is not used. Anywhere where it is checked that smooth scrolling is enabled, it is now additionally checked that the focused container does not have scroll snaps. Before this change, when the pageUp or pageDown key was pressed, it was checked whether smooth scroll was enabled in WKWebViewMac. To make for easier access to EventHandler::focusedScrollableAreaUsesScrollSnap, checking whether to do smooth scroll for the pageUp and pageDown keys is now performed in WebCore::EditorCommand. Additionally, this patch refactors the smooth keyboard scrolling code so that EventHandler::keyboardScrollRecursively takes ScrollDirection and ScrollGranularity As parameters instead of a KeyboardEvent. This makes it simpler to call EventHandler::keyboardScrollRecursively from EditorCommand because or else an Artificial KeyboardEvent would need to be created. * LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe- horizontal-with-keyboard-smooth-scroll-enabled-expected.txt: Added. * LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe- horizontal-with-keyboard-smooth-scroll-enabled.html: Added. Tests that when smooth scroll is turned on, scroll snapping works with the upArrow, downArrow, pageUp, and pageDown keys. * LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe- vertical-with-keyboard-smooth-scroll-enabled-expected.txt: Added. * LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe- vertical-with-keyboard-smooth-scroll-enabled.html: Added. Tests that when smooth scroll is turned on, scroll snapping works with the leftArrow and rightArrow keys. LayoutTests/TestExpectations LayoutTests/fast/scrolling/keyboard-scrolling-last-timestamp-expected.txt: Deleted. LayoutTests/fast/scrolling/keyboard-scrolling-last-timestamp.html: Deleted. LayoutTests/platform/wk2/TestExpectations This test was added by bugs.webkit.org/show_bug.cgi?id=229784. This patch Reverts the changes to pageUp/pageDown scrolling introduced by it, So the test no longer applies. * Source/WebCore/editing/EditorCommand.cpp: (WebCore::EditorCommand::executeScrollPageBackward): (WebCore::EditorCommand::executeScrollPageForward): If smooth scroll is enabled and focused container has no scroll snaps, calls EventHandler::keyboardScrollRecursively, which starts the smooth scroll animation. * Source/WebCore/page/EventHandler.cpp: (WebCore::EventHandler::defaultKeyboardEventHandler): Refactoring of pageUp and pageDown scrolling. (WebCore::EventHandler::defaultSpaceEventHandler): (WebCore::EventHandler::defaultArrowEventHandler): Now call above two functions to obtain arguments to pass to keyboardScrollRecursively. (WebCore::EventHandler::beginKeyboardScrollGesture): (WebCore::EventHandler::startKeyboardScrollAnimationOnDocument): (WebCore::EventHandler::startKeyboardScrollAnimationOnRenderBoxLayer): (WebCore::EventHandler::startKeyboardScrollAnimationOnRenderBoxAndItsAncestors): (WebCore::EventHandler::startKeyboardScrollAnimationOnEnclosingScrollableContainer): (WebCore::EventHandler::keyboardScrollRecursively): The above functions were refactored to take ScrollDirection and ScrollGranularity as Parameters rather than a KeyboardEvent. (WebCore::EventHandler::focusedScrollableAreaUsesScrollSnap): Returns true if focused container has scroll snaps. (WebCore::EventHandler::shouldUseSmoothKeyboardScrollingOnFocusedScrollableArea): Returns true if setting is turned on and focused container does not have scroll snaps. (WebCore::EventHandler::keyboardScrollRecursively): Now checks if focused container has scroll snaps. * Source/WebCore/page/EventHandler.h: * Source/WebCore/platform/KeyboardScrollingAnimator.cpp: (WebCore::KeyboardScrollingAnimator::keyboardScrollingKeyForKeyboardEvent): Added. Helper function for scrollDirectionForKeyboardEvent and scrollGranularityForKeyboardEvent. (WebCore::KeyboardScrollingAnimator::scrollDirectionForKeyboardEvent): Added. (WebCore::KeyboardScrollingAnimator::scrollGranularityForKeyboardEvent): Added. These functions are called by callers of EventHandler::keyboardScrollRecursively. (WebCore::KeyboardScrollingAnimator::keyboardScrollingKeyFromEvent): Deleted. (WebCore::KeyboardScrollingAnimator::makeKeyboardScroll): Added. (WebCore::KeyboardScrollingAnimator::keyboardScrollForKeyboardEvent): Deleted. (WebCore::KeyboardScrollingAnimator::beginKeyboardScrollGesture): Refactored to not use KeyboardEvent's. Source/WebCore/platform/KeyboardScrollingAnimator.h: * Source/WebCore/platform/ScrollAnimator.h: (Webcore::ScrollAnimator::usesScrollSnap): Gets m_scrollController.usesScrollSnap() for use by EventHandler::focusedScrollableAreaUsesScrollSnap. * Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm: (-[WKWebViewMac scrollPageDown:]): Deleted. (-[WKWebViewMac scrollPageUp:]): Deleted. Refactoring of pageUp and pageDown scrolling. * Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm: (WebKit::WebPage::performNonEditingBehaviorForSelector): Now checks if focused container has scroll snaps. Canonical link: https://commits.webkit.org/252663@main
- Loading branch information