⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280928 in webkit


Ignore:
Timestamp:
Aug 11, 2021, 1:32:32 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

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.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280927 r280928  
     12021-08-11  Dana Estra  <destra@apple.com>
     2
     3        Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
     4        https://bugs.webkit.org/show_bug.cgi?id=228156
     5
     6        Reviewed by Tim Horton.
     7       
     8        Tests check that at least 2 scroll events occur when the downArrow key or pageDown key is pressed, and
     9        that with each event, the page's offset from its original position increases.
     10
     11        * fast/scrolling/keyboard-scrolling-distance-downArrow-expected.txt: Added.
     12        * fast/scrolling/keyboard-scrolling-distance-downArrow.html: Added.
     13        * fast/scrolling/keyboard-scrolling-distance-pageDown-expected.txt: Added.
     14        * fast/scrolling/keyboard-scrolling-distance-pageDown.html: Added.
     15
    1162021-08-11  Aditya Keerthi  <akeerthi@apple.com>
    217
  • trunk/LayoutTests/TestExpectations

    r280904 r280928  
    9393printing/printing-events.html [ Skip ]
    9494fast/forms/enterkeyhint-attribute-values.html [ Skip ]
     95fast/scrolling/keyboard-scrolling-distance-downArrow.html [ Skip ]
     96fast/scrolling/keyboard-scrolling-distance-pageDown.html [ Skip ]
    9597
    9698# Highlighting marked text ranges from layout tests is only supported in WebKit2.
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r280510 r280928  
    861861# WebKit2 only.
    862862js/throw-large-string-oom.html [ Pass ]
     863fast/scrolling/keyboard-scrolling-distance-downArrow.html [ Pass ]
     864fast/scrolling/keyboard-scrolling-distance-pageDown.html [ Pass ]
    863865fast/speechrecognition/permission-error.html [ Pass ]
    864866fast/speechrecognition/start-recognition-then-stop.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r280927 r280928  
     12021-08-11  Dana Estra  <destra@apple.com>
     2
     3        Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
     4        https://bugs.webkit.org/show_bug.cgi?id=228156
     5
     6        Reviewed by Tim Horton.
     7       
     8        UIProcess now no longer handles scrollPageUp and scrollPageDown events. They return to eventHandler as
     9        unhandled and the keyboard scroll animation is started.
     10
     11        Tests: fast/scrolling/keyboard-scrolling-distance-downArrow.html
     12               fast/scrolling/keyboard-scrolling-distance-pageDown.html
     13
     14        * page/EventHandler.cpp:
     15        (WebCore::EventHandler::defaultKeyboardEventHandler):
     16        * platform/KeyboardScrollingAnimator.cpp:
     17        (WebCore::KeyboardScrollingAnimator::keyboardScrollForKeyboardEvent const):
     18
    1192021-08-11  Aditya Keerthi  <akeerthi@apple.com>
    220
  • trunk/Source/WebCore/page/EventHandler.cpp

    r280807 r280928  
    38203820        else if (event.keyIdentifier() == "U+0008")
    38213821            defaultBackspaceEventHandler(event);
     3822        else if (event.keyIdentifier() == "PageUp" || event.keyIdentifier() == "PageDown")
     3823            startKeyboardScrolling(event);
    38223824        else {
    38233825            FocusDirection direction = focusDirectionForKey(event.keyIdentifier());
  • trunk/Source/WebCore/platform/KeyboardScrollingAnimator.cpp

    r280697 r280928  
    143143    }();
    144144
    145     switch (granularity) {
    146     case ScrollGranularity::ScrollByLine:
    147         return scrollbar->lineStep();
    148     case ScrollGranularity::ScrollByPage:
    149         return scrollbar->pageStep();
    150     case ScrollGranularity::ScrollByDocument:
    151         return scrollbar->totalSize();
    152     case ScrollGranularity::ScrollByPixel:
    153         return scrollbar->pixelStep();
     145    if (scrollbar) {
     146        switch (granularity) {
     147        case ScrollGranularity::ScrollByLine:
     148            return scrollbar->lineStep();
     149        case ScrollGranularity::ScrollByPage:
     150            return scrollbar->pageStep();
     151        case ScrollGranularity::ScrollByDocument:
     152            return scrollbar->totalSize();
     153        case ScrollGranularity::ScrollByPixel:
     154            return scrollbar->pixelStep();
     155        }
    154156    }
    155157
     
    161163    // FIXME (bug 227459): This logic does not account for writing-mode.
    162164
    163     enum class Key : uint8_t { LeftArrow, RightArrow, UpArrow, DownArrow, Space };
     165    enum class Key : uint8_t { LeftArrow, RightArrow, UpArrow, DownArrow, Space, PageUp, PageDown };
    164166
    165167    Key key;
     
    174176    else if (event.charCode() == ' ')
    175177        key = Key::Space;
     178    else if (event.keyIdentifier() == "PageUp")
     179        key = Key::PageUp;
     180    else if (event.keyIdentifier() == "PageDown")
     181        key = Key::PageDown;
    176182    else
    177183        return std::nullopt;
     
    190196            return ScrollGranularity::ScrollByLine;
    191197        case Key::Space:
     198        case Key::PageUp:
     199        case Key::PageDown:
    192200            return ScrollGranularity::ScrollByPage;
    193201        };
     
    202210            return ScrollDirection::ScrollRight;
    203211        case Key::UpArrow:
     212        case Key::PageUp:
    204213            return ScrollDirection::ScrollUp;
    205214        case Key::DownArrow:
     215        case Key::PageDown:
    206216            return ScrollDirection::ScrollDown;
    207217        case Key::Space:
     
    212222
    213223    float distance = scrollDistance(direction, granularity);
     224
     225    if (!distance)
     226        return std::nullopt;
    214227
    215228    KeyboardScroll scroll;
  • trunk/Source/WebKit/ChangeLog

    r280925 r280928  
     12021-08-11  Dana Estra  <destra@apple.com>
     2
     3        Start smooth keyboard scrolling animation when pageUp or pageDown key is pressed.
     4        https://bugs.webkit.org/show_bug.cgi?id=228156
     5
     6        Reviewed by Tim Horton.
     7       
     8        UIProcess now no longer handles scrollPageUp and scrollPageDown events. They return
     9        to eventHandler as unhandled and the keyboard scroll animation is started.
     10
     11        * UIProcess/API/mac/WKWebViewMac.mm:
     12        (-[WKWebView scrollPageDown:]):
     13        (-[WKWebView scrollPageUp:]):
     14
    1152021-08-11  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WebKit/UIProcess/API/mac/WKWebViewMac.mm

    r278253 r280928  
    241241WEBCORE_COMMAND(paste)
    242242WEBCORE_COMMAND(pasteAsPlainText)
    243 WEBCORE_COMMAND(scrollPageDown)
    244 WEBCORE_COMMAND(scrollPageUp)
    245243WEBCORE_COMMAND(scrollLineDown)
    246244WEBCORE_COMMAND(scrollLineUp)
     
    266264#undef WEBCORE_COMMAND
    267265
     266- (void)scrollPageDown:(id)sender
     267{
     268    if (_impl->page().preferences().eventHandlerDrivenSmoothKeyboardScrollingEnabled()) {
     269        [self.nextResponder tryToPerform:_cmd with:sender];
     270        return;
     271    }
     272
     273    _impl->executeEditCommandForSelector(_cmd);
     274}
     275
     276- (void)scrollPageUp:(id)sender
     277{
     278    if (_impl->page().preferences().eventHandlerDrivenSmoothKeyboardScrollingEnabled()) {
     279        [self.nextResponder tryToPerform:_cmd with:sender];
     280        return;
     281    }
     282
     283    _impl->executeEditCommandForSelector(_cmd);
     284}
     285
    268286- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
    269287{
Note: See TracChangeset for help on using the changeset viewer.