<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[280928] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/280928">280928</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-08-11 13:32:32 -0700 (Wed, 11 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
https://bugs.webkit.org/show_bug.cgi?id=228156

Patch by Dana Estra <destra@apple.com> on 2021-08-11
Reviewed by Tim Horton.

Source/WebCore:

UIProcess now no longer handles scrollPageUp and scrollPageDown events. They return to eventHandler as
unhandled and the keyboard scroll animation is started.

Tests: fast/scrolling/keyboard-scrolling-distance-downArrow.html
       fast/scrolling/keyboard-scrolling-distance-pageDown.html

* page/EventHandler.cpp:
(WebCore::EventHandler::defaultKeyboardEventHandler):
* platform/KeyboardScrollingAnimator.cpp:
(WebCore::KeyboardScrollingAnimator::keyboardScrollForKeyboardEvent const):

Source/WebKit:

UIProcess now no longer handles scrollPageUp and scrollPageDown events. They return
to eventHandler as unhandled and the keyboard scroll animation is started.

* UIProcess/API/mac/WKWebViewMac.mm:
(-[WKWebView scrollPageDown:]):
(-[WKWebView scrollPageUp:]):

LayoutTests:

Tests check that at least 2 scroll events occur when the downArrow key or pageDown key is pressed, and
that with each event, the page's offset from its original position increases.

* fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt: Added.
* fast/scrolling/keyboard-scrolling-distance-downArrow.html: Added.
* fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt: Added.
* fast/scrolling/keyboard-scrolling-distance-pageDown.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwk2TestExpectations">trunk/LayoutTests/platform/wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageEventHandlercpp">trunk/Source/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformKeyboardScrollingAnimatorcpp">trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPImacWKWebViewMacmm">trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastscrollingkeyboardscrollingdistancedownArrowexpectedtxt">trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastscrollingkeyboardscrollingdistancedownArrowhtml">trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow.html</a></li>
<li><a href="#trunkLayoutTestsfastscrollingkeyboardscrollingdistancepageDownexpectedtxt">trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastscrollingkeyboardscrollingdistancepageDownhtml">trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/LayoutTests/ChangeLog 2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-08-11  Dana Estra  <destra@apple.com>
+
+        Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
+        https://bugs.webkit.org/show_bug.cgi?id=228156
+
+        Reviewed by Tim Horton.
+        
+        Tests check that at least 2 scroll events occur when the downArrow key or pageDown key is pressed, and
+        that with each event, the page's offset from its original position increases.
+
+        * fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt: Added.
+        * fast/scrolling/keyboard-scrolling-distance-downArrow.html: Added.
+        * fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt: Added.
+        * fast/scrolling/keyboard-scrolling-distance-pageDown.html: Added.
+
</ins><span class="cx"> 2021-08-11  Aditya Keerthi  <akeerthi@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r273072): Caps lock indicator in password field is too large
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/LayoutTests/TestExpectations  2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -92,6 +92,8 @@
</span><span class="cx"> # WebKit2 only.
</span><span class="cx"> printing/printing-events.html [ Skip ]
</span><span class="cx"> fast/forms/enterkeyhint-attribute-values.html [ Skip ]
</span><ins>+fast/scrolling/keyboard-scrolling-distance-downArrow.html [ Skip ]
+fast/scrolling/keyboard-scrolling-distance-pageDown.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # Highlighting marked text ranges from layout tests is only supported in WebKit2.
</span><span class="cx"> editing/input/composition-highlights.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsfastscrollingkeyboardscrollingdistancedownArrowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt (0 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt                              (rev 0)
+++ trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt 2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+Successful Scroll
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastscrollingkeyboardscrollingdistancedownArrowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow.html (0 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow.html                              (rev 0)
+++ trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-downArrow.html 2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true EventHandlerDrivenSmoothKeyboardScrollingEnabled=true ] -->
+
+<html>
+
+<head>
+    <script src="../../resources/ui-helper.js"></script>
+    <script src="../../resources/js-test-pre.js"></script>
+    <meta name="viewport" content="initial-scale=1.5, user-scalable=no">
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+        
+        function checkSuccessfulScroll(scrollObj)
+        {
+            if (window.scrollY <= scrollObj.offset) {
+                debug("Unsuccessful Scroll - offset does not increase with each scroll event.");
+                testRunner.notifyDone();
+            }
+            
+            scrollObj.offset = window.scrollY;
+            scrollObj.count++;
+            
+            if (scrollObj.count == 2) {
+                debug("Successful Scroll");
+                testRunner.notifyDone();
+            }
+        }
+        
+        async function runTest()
+        {
+            if (!window.testRunner || !testRunner.runUIScript)
+                return;
+                
+            let scrollObj = {
+                count: 0,
+                offset: 0
+            }
+            
+            document.addEventListener("scroll", function () {
+                checkSuccessfulScroll(scrollObj);
+            });
+            
+            await UIHelper.keyDown("downArrow");
+        }
+    </script>
+    <style>
+    #placeholder {
+        width: 100px;
+        height: 5000px;
+    }
+    </style>
+</head>
+
+<body style="margin: 0;" onload="runTest()">
+    <div id="placeholder">
+    <div id="console"></div>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastscrollingkeyboardscrollingdistancepageDownexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt (0 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt                               (rev 0)
+++ trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt  2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+Successful Scroll
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastscrollingkeyboardscrollingdistancepageDownhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown.html (0 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown.html                               (rev 0)
+++ trunk/LayoutTests/fast/scrolling/keyboard-scrolling-distance-pageDown.html  2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true EventHandlerDrivenSmoothKeyboardScrollingEnabled=true ] -->
+
+<html>
+
+<head>
+    <script src="../../resources/ui-helper.js"></script>
+    <script src="../../resources/js-test-pre.js"></script>
+    <meta name="viewport" content="initial-scale=1.5, user-scalable=no">
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+        
+        function checkSuccessfulScroll(scrollObj)
+        {
+            if (window.scrollY <= scrollObj.offset) {
+                debug("Unsuccessful Scroll - offset does not increase with each scroll event.");
+                testRunner.notifyDone();
+            }
+            
+            scrollObj.offset = window.scrollY;
+            scrollObj.count++;
+            
+            if (scrollObj.count == 2) {
+                debug("Successful Scroll");
+                testRunner.notifyDone();
+            }
+        }
+        
+        async function runTest()
+        {
+            if (!window.testRunner || !testRunner.runUIScript)
+                return;
+                
+            let scrollObj = {
+                count: 0,
+                offset: 0
+            }
+            
+            document.addEventListener("scroll", function () {
+                checkSuccessfulScroll(scrollObj);
+            });
+            
+            await UIHelper.keyDown("pageDown");
+        }
+    </script>
+    <style>
+    #placeholder {
+        width: 100px;
+        height: 5000px;
+    }
+    </style>
+</head>
+
+<body style="margin: 0;" onload="runTest()">
+    <div id="placeholder">
+    <div id="console"></div>
+    <script src="../../../resources/js-test-post.js"></script>
+</body>
+
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wk2/TestExpectations (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/wk2/TestExpectations  2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/LayoutTests/platform/wk2/TestExpectations     2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -860,6 +860,8 @@
</span><span class="cx"> 
</span><span class="cx"> # WebKit2 only.
</span><span class="cx"> js/throw-large-string-oom.html [ Pass ]
</span><ins>+fast/scrolling/keyboard-scrolling-distance-downArrow.html [ Pass ]
+fast/scrolling/keyboard-scrolling-distance-pageDown.html [ Pass ]
</ins><span class="cx"> fast/speechrecognition/permission-error.html [ Pass ]
</span><span class="cx"> fast/speechrecognition/start-recognition-then-stop.html [ Pass ]
</span><span class="cx"> fast/speechrecognition/start-second-recognition.html [ Pass ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/Source/WebCore/ChangeLog      2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2021-08-11  Dana Estra  <destra@apple.com>
+
+        Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
+        https://bugs.webkit.org/show_bug.cgi?id=228156
+
+        Reviewed by Tim Horton.
+        
+        UIProcess now no longer handles scrollPageUp and scrollPageDown events. They return to eventHandler as
+        unhandled and the keyboard scroll animation is started.
+
+        Tests: fast/scrolling/keyboard-scrolling-distance-downArrow.html
+               fast/scrolling/keyboard-scrolling-distance-pageDown.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::defaultKeyboardEventHandler):
+        * platform/KeyboardScrollingAnimator.cpp:
+        (WebCore::KeyboardScrollingAnimator::keyboardScrollForKeyboardEvent const):
+
</ins><span class="cx"> 2021-08-11  Aditya Keerthi  <akeerthi@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r273072): Caps lock indicator in password field is too large
</span></span></pre></div>
<a id="trunkSourceWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventHandler.cpp (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventHandler.cpp       2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/Source/WebCore/page/EventHandler.cpp  2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -3819,6 +3819,8 @@
</span><span class="cx">             defaultTabEventHandler(event);
</span><span class="cx">         else if (event.keyIdentifier() == "U+0008")
</span><span class="cx">             defaultBackspaceEventHandler(event);
</span><ins>+        else if (event.keyIdentifier() == "PageUp" || event.keyIdentifier() == "PageDown")
+            startKeyboardScrolling(event);
</ins><span class="cx">         else {
</span><span class="cx">             FocusDirection direction = focusDirectionForKey(event.keyIdentifier());
</span><span class="cx">             if (direction != FocusDirection::None)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformKeyboardScrollingAnimatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp      2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp 2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -142,15 +142,17 @@
</span><span class="cx">         return m_scrollAnimator.scrollableArea().horizontalScrollbar();
</span><span class="cx">     }();
</span><span class="cx"> 
</span><del>-    switch (granularity) {
-    case ScrollGranularity::ScrollByLine:
-        return scrollbar->lineStep();
-    case ScrollGranularity::ScrollByPage:
-        return scrollbar->pageStep();
-    case ScrollGranularity::ScrollByDocument:
-        return scrollbar->totalSize();
-    case ScrollGranularity::ScrollByPixel:
-        return scrollbar->pixelStep();
</del><ins>+    if (scrollbar) {
+        switch (granularity) {
+        case ScrollGranularity::ScrollByLine:
+            return scrollbar->lineStep();
+        case ScrollGranularity::ScrollByPage:
+            return scrollbar->pageStep();
+        case ScrollGranularity::ScrollByDocument:
+            return scrollbar->totalSize();
+        case ScrollGranularity::ScrollByPixel:
+            return scrollbar->pixelStep();
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return 0;
</span><span class="lines">@@ -160,7 +162,7 @@
</span><span class="cx"> {
</span><span class="cx">     // FIXME (bug 227459): This logic does not account for writing-mode.
</span><span class="cx"> 
</span><del>-    enum class Key : uint8_t { LeftArrow, RightArrow, UpArrow, DownArrow, Space };
</del><ins>+    enum class Key : uint8_t { LeftArrow, RightArrow, UpArrow, DownArrow, Space, PageUp, PageDown };
</ins><span class="cx"> 
</span><span class="cx">     Key key;
</span><span class="cx">     if (event.keyIdentifier() == "Left")
</span><span class="lines">@@ -173,6 +175,10 @@
</span><span class="cx">         key = Key::DownArrow;
</span><span class="cx">     else if (event.charCode() == ' ')
</span><span class="cx">         key = Key::Space;
</span><ins>+    else if (event.keyIdentifier() == "PageUp")
+        key = Key::PageUp;
+    else if (event.keyIdentifier() == "PageDown")
+        key = Key::PageDown;
</ins><span class="cx">     else
</span><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><span class="lines">@@ -189,6 +195,8 @@
</span><span class="cx">                 return ScrollGranularity::ScrollByPage;
</span><span class="cx">             return ScrollGranularity::ScrollByLine;
</span><span class="cx">         case Key::Space:
</span><ins>+        case Key::PageUp:
+        case Key::PageDown:
</ins><span class="cx">             return ScrollGranularity::ScrollByPage;
</span><span class="cx">         };
</span><span class="cx">         RELEASE_ASSERT_NOT_REACHED();
</span><span class="lines">@@ -201,8 +209,10 @@
</span><span class="cx">         case Key::RightArrow:
</span><span class="cx">             return ScrollDirection::ScrollRight;
</span><span class="cx">         case Key::UpArrow:
</span><ins>+        case Key::PageUp:
</ins><span class="cx">             return ScrollDirection::ScrollUp;
</span><span class="cx">         case Key::DownArrow:
</span><ins>+        case Key::PageDown:
</ins><span class="cx">             return ScrollDirection::ScrollDown;
</span><span class="cx">         case Key::Space:
</span><span class="cx">             return event.shiftKey() ? ScrollDirection::ScrollUp : ScrollDirection::ScrollDown;
</span><span class="lines">@@ -212,6 +222,9 @@
</span><span class="cx"> 
</span><span class="cx">     float distance = scrollDistance(direction, granularity);
</span><span class="cx"> 
</span><ins>+    if (!distance)
+        return std::nullopt;
+
</ins><span class="cx">     KeyboardScroll scroll;
</span><span class="cx"> 
</span><span class="cx">     scroll.offset = unitVectorForScrollDirection(direction).scaled(distance);
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/Source/WebKit/ChangeLog       2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-08-11  Dana Estra  <destra@apple.com>
+
+        Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
+        https://bugs.webkit.org/show_bug.cgi?id=228156
+
+        Reviewed by Tim Horton.
+        
+        UIProcess now no longer handles scrollPageUp and scrollPageDown events. They return
+        to eventHandler as unhandled and the keyboard scroll animation is started.
+
+        * UIProcess/API/mac/WKWebViewMac.mm:
+        (-[WKWebView scrollPageDown:]):
+        (-[WKWebView scrollPageUp:]):
+
</ins><span class="cx"> 2021-08-11  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Fix iOS debug build after r280875
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPImacWKWebViewMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm (280927 => 280928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm    2021-08-11 20:19:33 UTC (rev 280927)
+++ trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm       2021-08-11 20:32:32 UTC (rev 280928)
</span><span class="lines">@@ -240,8 +240,6 @@
</span><span class="cx"> WEBCORE_COMMAND(pageUpAndModifySelection)
</span><span class="cx"> WEBCORE_COMMAND(paste)
</span><span class="cx"> WEBCORE_COMMAND(pasteAsPlainText)
</span><del>-WEBCORE_COMMAND(scrollPageDown)
-WEBCORE_COMMAND(scrollPageUp)
</del><span class="cx"> WEBCORE_COMMAND(scrollLineDown)
</span><span class="cx"> WEBCORE_COMMAND(scrollLineUp)
</span><span class="cx"> WEBCORE_COMMAND(scrollToBeginningOfDocument)
</span><span class="lines">@@ -265,6 +263,26 @@
</span><span class="cx"> 
</span><span class="cx"> #undef WEBCORE_COMMAND
</span><span class="cx"> 
</span><ins>+- (void)scrollPageDown:(id)sender
+{
+    if (_impl->page().preferences().eventHandlerDrivenSmoothKeyboardScrollingEnabled()) {
+        [self.nextResponder tryToPerform:_cmd with:sender];
+        return;
+    }
+
+    _impl->executeEditCommandForSelector(_cmd);
+}
+
+- (void)scrollPageUp:(id)sender
+{
+    if (_impl->page().preferences().eventHandlerDrivenSmoothKeyboardScrollingEnabled()) {
+        [self.nextResponder tryToPerform:_cmd with:sender];
+        return;
+    }
+
+    _impl->executeEditCommandForSelector(_cmd);
+}
+
</ins><span class="cx"> - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
</span><span class="cx"> {
</span><span class="cx">     return _impl->writeSelectionToPasteboard(pasteboard, types);
</span></span></pre>
</div>
</div>

</body>
</html>