Title: [287241] trunk
- Revision
- 287241
- Author
- simon.fra...@apple.com
- Date
- 2021-12-19 10:43:42 -0800 (Sun, 19 Dec 2021)
Log Message
Keyboard shortcut to scroll to top when already at the top of the page moves to the bottom
https://bugs.webkit.org/show_bug.cgi?id=234483
<rdar://86628260>
Reviewed by Dean Jackson.
Source/WebCore:
If the page was scrolled to the top and an "up" keyboard scroll happened,
ScrollAnimator::singleAxisScroll() would trigger an unclamped scroll with a negative delta,
which fed into ScrollAnimationSmooth::startAnimatedScrollToDestination() and would result in
an animation with a zero duration, which resulted in NaNs in animateScroll().
Fix by doing clamping in ScrollAnimator::singleAxisScroll() and protecting against
animations with zero delay in ScrollAnimationSmooth.
Test: fast/scrolling/keyboard-scrolling-home.html
* platform/ScrollAnimationSmooth.cpp:
(WebCore::ScrollAnimationSmooth::startAnimatedScrollToDestination):
(WebCore::ScrollAnimationSmooth::retargetActiveAnimation):
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::singleAxisScroll):
LayoutTests:
* fast/scrolling/keyboard-scrolling-home-expected.txt: Added.
* fast/scrolling/keyboard-scrolling-home.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (287240 => 287241)
--- trunk/LayoutTests/ChangeLog 2021-12-19 12:58:41 UTC (rev 287240)
+++ trunk/LayoutTests/ChangeLog 2021-12-19 18:43:42 UTC (rev 287241)
@@ -1,3 +1,14 @@
+2021-12-19 Simon Fraser <simon.fra...@apple.com>
+
+ Keyboard shortcut to scroll to top when already at the top of the page moves to the bottom
+ https://bugs.webkit.org/show_bug.cgi?id=234483
+ <rdar://86628260>
+
+ Reviewed by Dean Jackson.
+
+ * fast/scrolling/keyboard-scrolling-home-expected.txt: Added.
+ * fast/scrolling/keyboard-scrolling-home.html: Added.
+
2021-12-19 Philippe Normand <pnorm...@igalia.com>
[GTK][WPE][VTT] tests media/track/track-webvtt-* fail on GTK and WPE
Added: trunk/LayoutTests/fast/scrolling/keyboard-scrolling-home-expected.txt (0 => 287241)
--- trunk/LayoutTests/fast/scrolling/keyboard-scrolling-home-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/keyboard-scrolling-home-expected.txt 2021-12-19 18:43:42 UTC (rev 287241)
@@ -0,0 +1,5 @@
+PASS window.scrollY is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Scrolling via the "Home" key should leave this page at the top.
Added: trunk/LayoutTests/fast/scrolling/keyboard-scrolling-home.html (0 => 287241)
--- trunk/LayoutTests/fast/scrolling/keyboard-scrolling-home.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/keyboard-scrolling-home.html 2021-12-19 18:43:42 UTC (rev 287241)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <script src=""
+ <script>
+ jsTestIsAsync = true;
+ async function runTest()
+ {
+ await UIHelper.keyDown("home");
+ await UIHelper.renderingUpdate();
+
+ shouldBeZero("window.scrollY");
+ finishJSTest();
+ }
+
+ window.addEventListener('load', () => {
+ runTest();
+ }, false);
+ </script>
+ <style>
+ body {
+ height: 3000px;
+ }
+ </style>
+</head>
+<body>
+ Scrolling via the "Home" key should leave this page at the top.
+ <script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (287240 => 287241)
--- trunk/Source/WebCore/ChangeLog 2021-12-19 12:58:41 UTC (rev 287240)
+++ trunk/Source/WebCore/ChangeLog 2021-12-19 18:43:42 UTC (rev 287241)
@@ -1,3 +1,27 @@
+2021-12-19 Simon Fraser <simon.fra...@apple.com>
+
+ Keyboard shortcut to scroll to top when already at the top of the page moves to the bottom
+ https://bugs.webkit.org/show_bug.cgi?id=234483
+ <rdar://86628260>
+
+ Reviewed by Dean Jackson.
+
+ If the page was scrolled to the top and an "up" keyboard scroll happened,
+ ScrollAnimator::singleAxisScroll() would trigger an unclamped scroll with a negative delta,
+ which fed into ScrollAnimationSmooth::startAnimatedScrollToDestination() and would result in
+ an animation with a zero duration, which resulted in NaNs in animateScroll().
+
+ Fix by doing clamping in ScrollAnimator::singleAxisScroll() and protecting against
+ animations with zero delay in ScrollAnimationSmooth.
+
+ Test: fast/scrolling/keyboard-scrolling-home.html
+
+ * platform/ScrollAnimationSmooth.cpp:
+ (WebCore::ScrollAnimationSmooth::startAnimatedScrollToDestination):
+ (WebCore::ScrollAnimationSmooth::retargetActiveAnimation):
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::singleAxisScroll):
+
2021-12-19 David Kilzer <ddkil...@apple.com>
Fix pointer to blob data in BlobResourceHandle::readDataSync()
Modified: trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp (287240 => 287241)
--- trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp 2021-12-19 12:58:41 UTC (rev 287240)
+++ trunk/Source/WebCore/platform/ScrollAnimationSmooth.cpp 2021-12-19 18:43:42 UTC (rev 287241)
@@ -50,15 +50,18 @@
bool ScrollAnimationSmooth::startAnimatedScrollToDestination(const FloatPoint& fromOffset, const FloatPoint& destinationOffset)
{
- if (!isActive() && fromOffset == destinationOffset)
- return false;
-
auto extents = m_client.scrollExtentsForAnimation(*this);
- m_startTime = MonotonicTime::now();
m_currentOffset = m_startOffset = fromOffset;
m_destinationOffset = destinationOffset.constrainedBetween(extents.minimumScrollOffset(), extents.maximumScrollOffset());
+
+ if (!isActive() && fromOffset == m_destinationOffset)
+ return false;
+
m_duration = durationFromDistance(m_destinationOffset - m_startOffset);
+ if (!m_duration)
+ return false;
+
downcast<CubicBezierTimingFunction>(*m_timingFunction).setTimingFunctionPreset(CubicBezierTimingFunction::TimingFunctionPreset::EaseInOut);
if (!isActive())
@@ -81,7 +84,7 @@
downcast<CubicBezierTimingFunction>(*m_timingFunction).setTimingFunctionPreset(CubicBezierTimingFunction::TimingFunctionPreset::EaseOut);
m_timingFunction = CubicBezierTimingFunction::create(CubicBezierTimingFunction::TimingFunctionPreset::EaseOut);
- if (m_currentOffset == m_destinationOffset)
+ if (m_currentOffset == m_destinationOffset || !m_duration)
return false;
return true;
Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (287240 => 287241)
--- trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-12-19 12:58:41 UTC (rev 287240)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp 2021-12-19 18:43:42 UTC (rev 287241)
@@ -76,6 +76,13 @@
auto newOffsetOnAxis = m_scrollController.adjustedScrollDestination(axis, newOffset, velocity, valueForAxis(currentOffset, axis));
newOffset = setValueForAxis(newOffset, axis, newOffsetOnAxis);
delta = newOffset - currentOffset;
+ } else {
+ auto newPosition = m_currentPosition + delta;
+ newPosition = newPosition.constrainedBetween(scrollableArea().minimumScrollPosition(), scrollableArea().maximumScrollPosition());
+ if (newPosition == m_currentPosition)
+ return false;
+
+ delta = newPosition - m_currentPosition;
}
if (m_scrollableArea.scrollAnimatorEnabled() && !behavior.contains(ScrollBehavior::NeverAnimate)) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes