Changeset 268476 in webkit


Ignore:
Timestamp:
Oct 14, 2020 11:06:37 AM (4 years ago)
Author:
Simon Fraser
Message:

Allow passive mouse wheel event listeners to not force synchronous scrolling
https://bugs.webkit.org/show_bug.cgi?id=158439
<rdar://problem/28265360>

Reviewed by Tim Horton.
Source/WebCore:

Turn on ENABLE_WHEEL_EVENT_REGIONS for macOS, and hit-test the passive and active regions
in ScrollingTree::determineWheelEventProcessin() to determine whether scrolling needs to
happen on the main thread, communicating via WheelEventProcessingSteps.

Now that we use EventRegion to store wheel event region information, we no longer need
to consult wheel event targets im ScrollingCoordinator::absoluteEventTrackingRegionsForFrame(),
but the non-fast region does still contain rectangles for non-fast-scrollable overflow
if async overflow scrolling is disabled.

Frame::invalidateContentEventRegionsIfNeeded() needs a fix to ensure that when wheel
event handlers in non-fast-scrollable subframes change we invalidate event regions.

RenderLayerBacking::updateEventRegion() needs a fix so that the event region for the root
(for handlers registered on the document or window) covers the entire root layer; painting
code only covered the RenderView, which is too small (and root background painting is complex).

Finally, when the processing steps given to EventHandler::handleWheelEvent() do not
include MainThreadForScrolling, then we shouldn't scroll here. The check in
EventHandler::handleWheelEvent() applies to frames, and the one in EventHandler::defaultWheelEventHandler()
applies to overflow:scroll.

Test: fast/scrolling/mac/slow-scrolling-overflow.html

  • page/EventHandler.cpp:

(WebCore::EventHandler::handleWheelEvent):
(WebCore::EventHandler::defaultWheelEventHandler):

  • page/Frame.cpp:

(WebCore::Frame::invalidateContentEventRegionsIfNeeded):

  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::ScrollingCoordinator::absoluteEventTrackingRegionsForFrame const):

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::determineWheelEventProcessing):

Source/WTF:

Define ENABLE_WHEEL_EVENT_REGIONS for macOS.

  • wtf/PlatformEnableCocoa.h:

LayoutTests:

Change tests that relied on dumping the non-fast scrollable rects for wheel handlers
to dump layer trees with event regions instead. They also need to wait for a
rendering update, since wheel event regions are updated once per frame.

slow-scrolling-overflow.html tests that an overflow:scroll that's forced into slow
scrolling because of background-attachment:fixed still scrolls.

  • fast/scrolling/mac/slow-scrolling-overflow-expected.txt: Added.
  • fast/scrolling/mac/slow-scrolling-overflow.html: Added.
  • fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out-expected.txt:
  • fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt:
  • platform/mac-wk2/TestExpectations:
  • tiled-drawing/scrolling/non-fast-region/fixed-div-in-scrollable-page.html:
  • tiled-drawing/scrolling/non-fast-region/handlers-in-iframes-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/handlers-in-iframes.html:
  • tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html:
  • tiled-drawing/scrolling/non-fast-region/resources/wheel-handler-region-helper.js:

(nonFastScrollableRects):
(dumpNonFastScrollableRects):
(async dumpRegionAndNotifyDone):
(rectsAsString): Deleted.
(dumpRegion): Deleted.

  • tiled-drawing/scrolling/non-fast-region/top-content-inset-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/top-content-inset-header-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/top-content-inset-header.html:
  • tiled-drawing/scrolling/non-fast-region/top-content-inset.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-event-plugin.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed.html:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic-expected.txt:
  • tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic.html:
Location:
trunk
Files:
4 added
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r268458 r268476  
     12020-10-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow passive mouse wheel event listeners to not force synchronous scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=158439
     5        <rdar://problem/28265360>
     6
     7        Reviewed by Tim Horton.
     8       
     9        Change tests that relied on dumping the non-fast scrollable rects for wheel handlers
     10        to dump layer trees with event regions instead. They also need to wait for a
     11        rendering update, since wheel event regions are updated once per frame.
     12       
     13        slow-scrolling-overflow.html tests that an overflow:scroll that's forced into slow
     14        scrolling because of background-attachment:fixed still scrolls.
     15
     16        * fast/scrolling/mac/slow-scrolling-overflow-expected.txt: Added.
     17        * fast/scrolling/mac/slow-scrolling-overflow.html: Added.
     18        * fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out-expected.txt:
     19        * fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt:
     20        * platform/mac-wk2/TestExpectations:
     21        * tiled-drawing/scrolling/non-fast-region/fixed-div-in-scrollable-page.html:
     22        * tiled-drawing/scrolling/non-fast-region/handlers-in-iframes-expected.txt:
     23        * tiled-drawing/scrolling/non-fast-region/handlers-in-iframes.html:
     24        * tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt:
     25        * tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html:
     26        * tiled-drawing/scrolling/non-fast-region/resources/wheel-handler-region-helper.js:
     27        (nonFastScrollableRects):
     28        (dumpNonFastScrollableRects):
     29        (async dumpRegionAndNotifyDone):
     30        (rectsAsString): Deleted.
     31        (dumpRegion): Deleted.
     32        * tiled-drawing/scrolling/non-fast-region/top-content-inset-expected.txt:
     33        * tiled-drawing/scrolling/non-fast-region/top-content-inset-header-expected.txt:
     34        * tiled-drawing/scrolling/non-fast-region/top-content-inset-header.html:
     35        * tiled-drawing/scrolling/non-fast-region/top-content-inset.html:
     36        * tiled-drawing/scrolling/non-fast-region/wheel-event-plugin.html:
     37        * tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt:
     38        * tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child.html:
     39        * tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns-expected.txt:
     40        * tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns.html:
     41        * tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll-expected.txt:
     42        * tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll.html:
     43        * tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt:
     44        * tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed.html:
     45        * tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document-expected.txt:
     46        * tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document.html:
     47        * tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt:
     48        * tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed.html:
     49        * tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic-expected.txt:
     50        * tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic.html:
     51
    1522020-10-14  Kate Cheney  <katherine_cheney@apple.com>
    253
  • trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out-expected.txt

    r262337 r268476  
    1919              (event region
    2020                (rect (0,0) width=500 height=500)
    21                 (rect (0,500) width=485 height=2500)
    2221              )
    2322              (children 2
     
    3332                      (drawsContent 1)
    3433                      (event region
    35                         (rect (0,0) width=500 height=500)
    36                         (rect (0,500) width=485 height=2500)
     34                        (rect (0,0) width=485 height=3000)
    3735                      (wheel event listener region
    3836                        (rect (20,528) width=100 height=100)
     
    5250                      (bounds 15.00 500.00)
    5351                      (drawsContent 1)
     52                      (event region
     53                        (rect (0,0) width=15 height=500)
     54                      )
    5455                    )
    5556                  )
  • trunk/LayoutTests/fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-expected.txt

    r262476 r268476  
    1616          (event region
    1717            (rect (0,0) width=204 height=204)
    18             (rect (2,204) width=185 height=188)
    19             (rect (22,392) width=100 height=30)
    20           (wheel event listener region
    21             (rect (22,22) width=100 height=400)
    22             (non-passive
    23               (rect (22,22) width=100 height=400)
    24             )
    25           )
    2618          )
    2719          (children 2
     
    4032                  (drawsContent 1)
    4133                  (event region
    42                     (rect (-2,-2) width=204 height=204)
    43                     (rect (0,202) width=185 height=218)
     34                    (rect (0,0) width=185 height=420)
    4435                  (wheel event listener region
    4536                    (rect (20,20) width=100 height=400)
     
    6051                  (bounds 185.00 15.00)
    6152                  (drawsContent 1)
     53                  (event region
     54                    (rect (0,0) width=185 height=15)
     55                  )
    6256                )
    6357                (GraphicsLayer
     
    6559                  (bounds 15.00 185.00)
    6660                  (drawsContent 1)
     61                  (event region
     62                    (rect (0,0) width=15 height=185)
     63                  )
    6764                )
    6865                (GraphicsLayer
     
    7067                  (bounds 15.00 15.00)
    7168                  (drawsContent 1)
     69                  (event region
     70                    (rect (0,0) width=15 height=15)
     71                  )
    7272                )
    7373              )
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r268438 r268476  
    10671067webkit.org/b/213804 fast/scrolling/mac/scroll-snapping-in-progress.html [ Pass Failure ]
    10681068
    1069 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-basic.html [ Skip ]
    1070 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-document.html [ Skip ]
    1071 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-element-invalidation.html [ Skip ]
    1072 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll-clipped-out.html [ Skip ]
    1073 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-inside-overflow-scroll.html [ Skip ]
    1074 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-layer-offset.html [ Skip ]
    1075 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-root-invalidation.html [ Skip ]
    1076 webkit.org/b/215586 fast/scrolling/mac/wheel-event-listener-region-window.html [ Skip ]
    1077 
    10781069webkit.org/b/214478 [ Debug ] http/wpt/webrtc/generateCertificate.html [ Skip ]
    10791070webkit.org/b/214478 [ Debug ] imported/w3c/web-platform-tests/webrtc/RTCCertificate-postMessage.html [ Skip ]
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/fixed-div-in-scrollable-page.html

    r192193 r268476  
    11<html>
    22<head>
    3     <script src="resources/wheel-handler-region-helper.js"></script>
    43    <style>
    54    body {
     
    2322    }
    2423    </style>
     24    <script src="../../../resources/ui-helper.js"></script>
     25    <script src="resources/wheel-handler-region-helper.js"></script>
    2526    <script>
    26     function dumpRegion()
    27     {
    28         if (window.internals) {
    29             var rects = window.internals.nonFastScrollableRects();
    30             document.getElementById('output').textContent = rectsAsString(rects);
    31         }
    32     }
     27        window.addEventListener('load', dumpNonFastScrollableRects, false);
    3328    </script>
    3429</head>
    35 <body onload="dumpRegion()">
     30<body>
    3631    <div class="fixed">
    3732        <div class="tall"></div>
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/handlers-in-iframes-expected.txt

    r187905 r268476  
    11
    2 32, 24 - 132, 124
     2
     3(GraphicsLayer
     4  (anchor 0.00 0.00)
     5  (bounds 800.00 600.00)
     6  (children 1
     7    (GraphicsLayer
     8      (bounds 800.00 600.00)
     9      (contentsOpaque 1)
     10      (drawsContent 1)
     11      (backgroundColor #FFFFFF)
     12      (event region
     13        (rect (0,0) width=800 height=600)
     14      (wheel event listener region
     15        (rect (28,20) width=108 height=108)
     16        (non-passive
     17          (rect (28,20) width=108 height=108)
     18        )
     19      )
     20      )
     21    )
     22  )
     23)
     24
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/handlers-in-iframes.html

    r187905 r268476  
    99        }
    1010    </style>
     11    <script src="../../../resources/ui-helper.js"></script>
    1112    <script src="resources/wheel-handler-region-helper.js"></script>
    1213    <script>
    13         if (window.testRunner)
    14             testRunner.waitUntilDone();
    15 
    1614        var notificationsPending = 3;
    1715
     
    2927        function receivedNotification()
    3028        {
    31             if (!--notificationsPending) {
    32                 dumpRegion();
    33                 if (window.testRunner)
    34                     testRunner.notifyDone();
    35             }
     29            if (!--notificationsPending)
     30                dumpRegionAndNotifyDone();
    3631        }
    3732       
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe-expected.txt

    r267644 r268476  
    33after hide:
    44after show: 10, 10 - 310, 160
    5 
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/non-fast-scrollable-region-hide-show-iframe.html

    r227011 r268476  
    22<html>
    33<head>
     4<script src="../../../resources/ui-helper.js"></script>
    45<script src="resources/wheel-handler-region-helper.js"></script>
    56<script>
     
    78        testRunner.waitUntilDone();
    89
    9     function dumpRegion(prefix)
    10     {
    11         if (window.internals) {
    12             var rects = window.internals.nonFastScrollableRects();
    13             document.getElementById('output').textContent += prefix + rectsAsString(rects) + '\n';
    14         }
    15     }
    16 
    17     function doTest()
     10    async function doTest()
    1811    {
    1912        var frame = document.getElementById('frame');
    20         dumpRegion('before: ');
     13
     14        await UIHelper.renderingUpdate();
     15        var output = 'before: ';
     16        output += nonFastScrollableRects();
     17       
    2118        frame.style.display = 'none';
    22         dumpRegion('after hide: ');
    2319       
    24         setTimeout(function() {
     20        await UIHelper.renderingUpdate();
     21        output += '\nafter hide: ';
     22        output += nonFastScrollableRects();
     23       
     24        setTimeout(async () => {
    2525            frame.style.display = 'inline';
    26             dumpRegion('after show: ');
     26
     27            await UIHelper.renderingUpdate();
     28            output += '\nafter show: ';
     29            output += nonFastScrollableRects();
     30
     31            document.getElementById('output').textContent = output;
    2732
    2833            if (window.testRunner)
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/resources/wheel-handler-region-helper.js

    r187905 r268476  
    1 if (window.testRunner)
     1if (window.testRunner) {
    22    testRunner.dumpAsText();
     3    testRunner.waitUntilDone();
     4}
    35
    4 function rectsAsString(rects)
     6function nonFastScrollableRects()
    57{
     8    var rects = internals.nonFastScrollableRects();
    69    var result = "";
    710    for (var i = 0; i < rects.length; ++i) {
     
    1417}
    1518
    16 function dumpRegion()
     19function dumpNonFastScrollableRects()
    1720{
     21    if (window.internals)
     22        document.getElementById('output').textContent = nonFastScrollableRects();
     23
     24    if (window.testRunner)
     25        testRunner.notifyDone();   
     26}
     27
     28async function dumpRegionAndNotifyDone()
     29{
     30    await UIHelper.renderingUpdate();
    1831    if (window.internals) {
    19         var rects = window.internals.nonFastScrollableRects();
    20         document.getElementById('output').textContent = rectsAsString(rects);
     32        var output = nonFastScrollableRects() + '\n' + internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_EVENT_REGION + internals.LAYER_TREE_INCLUDES_ROOT_LAYER_PROPERTIES);
     33        document.getElementById('output').textContent = output;
    2134    }
     35
     36    if (window.testRunner)
     37        testRunner.notifyDone();
    2238}
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/top-content-inset-expected.txt

    r187905 r268476  
    11Wheel event rect:
    22
    3 28, 50 - 128, 150
     3
     4(GraphicsLayer
     5  (anchor 0.00 0.00)
     6  (bounds 800.00 540.00)
     7  (children 1
     8    (GraphicsLayer
     9      (bounds 800.00 540.00)
     10      (contentsOpaque 1)
     11      (drawsContent 1)
     12      (backgroundColor #FFFFFF)
     13      (event region
     14        (rect (0,0) width=800 height=540)
     15      (wheel event listener region
     16        (rect (28,50) width=100 height=100)
     17        (non-passive
     18          (rect (28,50) width=100 height=100)
     19        )
     20      )
     21      )
     22    )
     23  )
     24)
     25
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/top-content-inset-header-expected.txt

    r187905 r268476  
    11Wheel event rect:
    22
    3 28, 50 - 128, 150
     3
     4(GraphicsLayer
     5  (position 0.00 46.00)
     6  (anchor 0.00 0.00)
     7  (bounds 800.00 540.00)
     8  (children 1
     9    (GraphicsLayer
     10      (bounds 800.00 540.00)
     11      (contentsOpaque 1)
     12      (drawsContent 1)
     13      (backgroundColor #FFFFFF)
     14      (event region
     15        (rect (0,0) width=800 height=540)
     16      (wheel event listener region
     17        (rect (28,50) width=100 height=100)
     18        (non-passive
     19          (rect (28,50) width=100 height=100)
     20        )
     21      )
     22      )
     23    )
     24  )
     25)
     26
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/top-content-inset-header.html

    r235893 r268476  
    1313       
    1414    </style>
     15    <script src="../../../resources/ui-helper.js"></script>
    1516    <script src="resources/wheel-handler-region-helper.js"></script>
    1617    <script>
    17         if (window.testRunner)
    18             testRunner.waitUntilDone();
    19 
    2018        if (window.internals) {
    2119            internals.setTopContentInset(60);
     
    2523        function doTest()
    2624        {
    27             window.setTimeout(function() {
     25            window.setTimeout(async () => {
    2826                // Scroll to test the mapping from document to view coords.
    2927                document.scrollingElement.scrollTop = 195;
    30                 dumpRegion();
    31                 if (window.testRunner)
    32                     testRunner.notifyDone();
     28                dumpRegionAndNotifyDone();
    3329            }, 0)
    3430        }
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/top-content-inset.html

    r235893 r268476  
    1313       
    1414    </style>
     15    <script src="../../../resources/ui-helper.js"></script>
    1516    <script src="resources/wheel-handler-region-helper.js"></script>
    1617    <script>
    17         if (window.testRunner)
    18             testRunner.waitUntilDone();
    19 
    2018        if (window.internals)
    2119            internals.setTopContentInset(60);
     
    2321        function doTest()
    2422        {
    25             window.setTimeout(function() {
     23            window.setTimeout(async () => {
    2624                // Scroll to test the mapping from document to view coords.
    2725                document.scrollingElement.scrollTop = 195;
    28                 dumpRegion();
    29                 if (window.testRunner)
    30                     testRunner.notifyDone();
     26                dumpRegionAndNotifyDone();
    3127            }, 0)
    3228        }
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-event-plugin.html

    r235893 r268476  
    1717       
    1818    </style>
     19    <script src="../../../resources/ui-helper.js"></script>
    1920    <script src="resources/wheel-handler-region-helper.js"></script>
    2021    <script>
    21         if (window.testRunner)
    22             testRunner.waitUntilDone();
    23 
    2422        if (window.internals) {
    2523            internals.setTopContentInset(60);
     
    2725        }
    2826
    29         function doTest()
     27        async function doTest()
    3028        {
    3129            if (window.internals)
     
    3432            // Scroll to test the mapping from document to view coords.
    3533            document.scrollingElement.scrollTop = 197;
    36             dumpRegion();
    37             if (window.testRunner)
    38                 testRunner.notifyDone();
     34            dumpNonFastScrollableRects();
    3935        }
    4036
     
    4541
    4642<p>Wheel event rect for plug-in:</p>
    47 <embed id="plugin" type="application/x-webkit-test-netscape" drawingmodel="coreanimation"></embed>
     43<embed id="plugin" type="application/x-webkit-test-netscape" drawingmodel="coreanimation">
    4844<pre id="output"></pre>
    4945
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child-expected.txt

    r192193 r268476  
    1 50, 50 - 150, 178
     1
     2(GraphicsLayer
     3  (anchor 0.00 0.00)
     4  (bounds 785.00 628.00)
     5  (children 1
     6    (GraphicsLayer
     7      (bounds 785.00 628.00)
     8      (contentsOpaque 1)
     9      (drawsContent 1)
     10      (backgroundColor #FFFFFF)
     11      (event region
     12        (rect (0,0) width=785 height=628)
     13      )
     14      (children 1
     15        (GraphicsLayer
     16          (position 50.00 50.00)
     17          (bounds 100.00 100.00)
     18          (contentsOpaque 1)
     19          (event region
     20            (rect (0,0) width=100 height=100)
     21          (wheel event listener region
     22            (rect (0,0) width=100 height=100)
     23            (non-passive
     24              (rect (0,0) width=100 height=100)
     25            )
     26          )
     27          )
     28        )
     29      )
     30    )
     31  )
     32)
     33
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-fixed-child.html

    r187905 r268476  
    2525        }
    2626    </style>
     27    <script src="../../../resources/ui-helper.js"></script>
    2728    <script src="resources/wheel-handler-region-helper.js"></script>
    2829    <script>
    29         function dumpRegion()
    30         {
    31             if (window.internals) {
    32                 var rects = window.internals.nonFastScrollableRects();
    33                 document.getElementById('output').textContent = rectsAsString(rects);
    34             }
    35         }
    36 
    37         window.addEventListener('load', dumpRegion, false);
     30        window.addEventListener('load', dumpRegionAndNotifyDone, false);
    3831    </script>
    3932</head>
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns-expected.txt

    r187905 r268476  
    55Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    66
    7 28, 20 - 567, 380
     7
     8(GraphicsLayer
     9  (anchor 0.00 0.00)
     10  (bounds 800.00 600.00)
     11  (children 1
     12    (GraphicsLayer
     13      (bounds 800.00 600.00)
     14      (contentsOpaque 1)
     15      (drawsContent 1)
     16      (backgroundColor #FFFFFF)
     17      (event region
     18        (rect (443,-1060) width=124 height=360)
     19        (rect (305,-700) width=123 height=360)
     20        (rect (443,-700) width=124 height=360)
     21        (rect (166,-340) width=124 height=340)
     22        (rect (305,-340) width=123 height=340)
     23        (rect (443,-340) width=124 height=340)
     24        (rect (0,0) width=800 height=600)
     25        (rect (28,600) width=123 height=336)
     26        (rect (166,600) width=124 height=336)
     27        (rect (28,936) width=123 height=360)
     28      (wheel event listener region
     29        (rect (305,-380) width=123 height=360)
     30        (rect (166,-20) width=124 height=166)
     31        (rect (305,-20) width=123 height=166)
     32        (rect (166,146) width=124 height=194)
     33        (rect (28,340) width=123 height=166)
     34        (rect (166,340) width=124 height=166)
     35        (rect (28,506) width=123 height=360)
     36        (non-passive
     37          (rect (305,-380) width=123 height=360)
     38          (rect (166,-20) width=124 height=166)
     39          (rect (305,-20) width=123 height=166)
     40          (rect (166,146) width=124 height=194)
     41          (rect (28,340) width=123 height=166)
     42          (rect (166,340) width=124 height=166)
     43          (rect (28,506) width=123 height=360)
     44        )
     45      )
     46      )
     47    )
     48  )
     49)
     50
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-in-columns.html

    r187905 r268476  
    1414        }
    1515    </style>
     16    <script src="../../../resources/ui-helper.js"></script>
    1617    <script src="resources/wheel-handler-region-helper.js"></script>
    1718    <script>
    18         function doTest()
    19         {
    20             dumpRegion();
    21         }
    22 
    23         window.addEventListener('load', doTest);
     19        window.addEventListener('load', dumpRegionAndNotifyDone);
    2420    </script>
    2521</head>
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll-expected.txt

    r187905 r268476  
    88
    998, 8 - 310, 310
     10(GraphicsLayer
     11  (anchor 0.00 0.00)
     12  (bounds 800.00 600.00)
     13  (children 1
     14    (GraphicsLayer
     15      (bounds 800.00 600.00)
     16      (contentsOpaque 1)
     17      (drawsContent 1)
     18      (backgroundColor #FFFFFF)
     19      (event region
     20        (rect (0,0) width=800 height=600)
     21      (wheel event listener region
     22        (rect (9,9) width=250 height=9)
     23        (rect (9,18) width=243 height=18)
     24        (rect (9,36) width=271 height=18)
     25        (rect (9,54) width=246 height=18)
     26        (rect (9,72) width=262 height=1)
     27        (rect (9,73) width=285 height=198)
     28        (non-passive
     29          (rect (9,9) width=250 height=9)
     30          (rect (9,18) width=243 height=18)
     31          (rect (9,36) width=271 height=18)
     32          (rect (9,54) width=246 height=18)
     33          (rect (9,72) width=262 height=1)
     34          (rect (9,73) width=285 height=198)
     35        )
     36      )
     37      )
     38    )
     39  )
     40)
     41
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-in-overflow-scroll.html

    r187905 r268476  
    1414        }
    1515    </style>
     16    <script src="../../../resources/ui-helper.js"></script>
    1617    <script src="resources/wheel-handler-region-helper.js"></script>
    1718    <script>
    18         if (window.testRunner)
    19             testRunner.waitUntilDone();
    20 
    2119        function doTest()
    2220        {
    23             window.setTimeout(function() {
     21            window.setTimeout(async () => {
    2422                var scroller = document.getElementById('container');
    2523                scroller.scrollTop = 200;
    26                 dumpRegion();
    27                 if (window.testRunner)
    28                     testRunner.notifyDone();
     24                dumpRegionAndNotifyDone();
    2925            }, 0)
    3026        }
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed-expected.txt

    r192193 r268476  
    1 60, 60 - 160, 160
     1
     2(GraphicsLayer
     3  (anchor 0.00 0.00)
     4  (bounds 800.00 600.00)
     5  (children 1
     6    (GraphicsLayer
     7      (bounds 800.00 600.00)
     8      (contentsOpaque 1)
     9      (drawsContent 1)
     10      (backgroundColor #FFFFFF)
     11      (event region
     12        (rect (0,0) width=800 height=600)
     13      )
     14      (children 1
     15        (GraphicsLayer
     16          (position 10.00 10.00)
     17          (bounds 150.00 150.00)
     18          (drawsContent 1)
     19          (event region
     20            (rect (0,0) width=100 height=50)
     21            (rect (0,50) width=150 height=50)
     22            (rect (50,100) width=100 height=50)
     23          (wheel event listener region
     24            (rect (50,50) width=100 height=100)
     25            (non-passive
     26              (rect (50,50) width=100 height=100)
     27            )
     28          )
     29          )
     30        )
     31      )
     32    )
     33  )
     34)
     35
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-inside-fixed.html

    r187905 r268476  
    2525        }
    2626    </style>
     27    <script src="../../../resources/ui-helper.js"></script>
    2728    <script src="resources/wheel-handler-region-helper.js"></script>
    2829    <script>
    29         window.addEventListener('load', dumpRegion, false);
     30        window.addEventListener('load', dumpRegionAndNotifyDone, false);
    3031    </script>
    3132</head>
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document-expected.txt

    r187905 r268476  
    1 0, 0 - 800, 600
     1
     2(GraphicsLayer
     3  (anchor 0.00 0.00)
     4  (bounds 800.00 600.00)
     5  (children 1
     6    (GraphicsLayer
     7      (bounds 800.00 600.00)
     8      (contentsOpaque 1)
     9      (drawsContent 1)
     10      (backgroundColor #FFFFFF)
     11      (event region
     12        (rect (0,0) width=800 height=600)
     13      (wheel event listener region
     14        (rect (0,0) width=800 height=600)
     15        (non-passive
     16          (rect (0,0) width=800 height=600)
     17        )
     18      )
     19      )
     20    )
     21  )
     22)
     23
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-document.html

    r187905 r268476  
    33<html>
    44<head>
     5    <script src="../../../resources/ui-helper.js"></script>
    56    <script src="resources/wheel-handler-region-helper.js"></script>
    67    <script>
    7         function doTest()
     8        async function doTest()
    89        {
    910            document.addEventListener('mousewheel', function() { });
    10             dumpRegion();
     11            dumpRegionAndNotifyDone();
    1112        }
    1213
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed-expected.txt

    r192193 r268476  
    1 10, 10 - 110, 110
     1
     2(GraphicsLayer
     3  (anchor 0.00 0.00)
     4  (bounds 800.00 600.00)
     5  (children 1
     6    (GraphicsLayer
     7      (bounds 800.00 600.00)
     8      (contentsOpaque 1)
     9      (drawsContent 1)
     10      (backgroundColor #FFFFFF)
     11      (event region
     12        (rect (0,0) width=800 height=600)
     13      )
     14      (children 1
     15        (GraphicsLayer
     16          (position 10.00 10.00)
     17          (bounds 100.00 100.00)
     18          (contentsOpaque 1)
     19          (event region
     20            (rect (0,0) width=100 height=100)
     21          (wheel event listener region
     22            (rect (0,0) width=100 height=100)
     23            (non-passive
     24              (rect (0,0) width=100 height=100)
     25            )
     26          )
     27          )
     28        )
     29      )
     30    )
     31  )
     32)
     33
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-on-fixed.html

    r187905 r268476  
    1919        }
    2020    </style>
     21    <script src="../../../resources/ui-helper.js"></script>
    2122    <script src="resources/wheel-handler-region-helper.js"></script>
    2223    <script>
    23         window.addEventListener('load', dumpRegion, false);
     24        window.addEventListener('load', dumpRegionAndNotifyDone, false);
    2425    </script>
    2526</head>
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic-expected.txt

    r231717 r268476  
    77Intermediate
    88Child
    9 8, 8 - 777, 329
    10 9, 369 - 290, 425
    11 9, 501 - 290, 601
     9
     10(GraphicsLayer
     11  (anchor 0.00 0.00)
     12  (bounds 785.00 672.00)
     13  (children 1
     14    (GraphicsLayer
     15      (bounds 785.00 672.00)
     16      (contentsOpaque 1)
     17      (drawsContent 1)
     18      (backgroundColor #FFFFFF)
     19      (event region
     20        (rect (0,0) width=785 height=672)
     21      (wheel event listener region
     22        (rect (0,0) width=81 height=18)
     23        (rect (8,18) width=65 height=8)
     24        (rect (8,26) width=769 height=108)
     25        (rect (8,134) width=28 height=18)
     26        (rect (300,134) width=226 height=18)
     27        (rect (300,152) width=226 height=13)
     28        (rect (297,165) width=229 height=16)
     29        (rect (288,181) width=238 height=15)
     30        (rect (279,196) width=247 height=16)
     31        (rect (270,212) width=256 height=50)
     32        (rect (279,262) width=247 height=14)
     33        (rect (279,276) width=178 height=34)
     34        (rect (9,369) width=81 height=36)
     35        (rect (209,407) width=81 height=18)
     36        (rect (8,500) width=83 height=57)
     37        (rect (8,557) width=83 height=18)
     38        (rect (209,557) width=81 height=18)
     39        (rect (8,575) width=83 height=27)
     40        (non-passive
     41          (rect (0,0) width=81 height=18)
     42          (rect (8,18) width=65 height=8)
     43          (rect (8,26) width=769 height=108)
     44          (rect (8,134) width=28 height=18)
     45          (rect (300,134) width=226 height=18)
     46          (rect (300,152) width=226 height=13)
     47          (rect (297,165) width=229 height=16)
     48          (rect (288,181) width=238 height=15)
     49          (rect (279,196) width=247 height=16)
     50          (rect (270,212) width=256 height=50)
     51          (rect (279,262) width=247 height=14)
     52          (rect (279,276) width=178 height=34)
     53          (rect (9,369) width=81 height=36)
     54          (rect (209,407) width=81 height=18)
     55          (rect (8,500) width=83 height=57)
     56          (rect (8,557) width=83 height=18)
     57          (rect (209,557) width=81 height=18)
     58          (rect (8,575) width=83 height=27)
     59        )
     60      )
     61      )
     62    )
     63  )
     64)
     65
  • trunk/LayoutTests/tiled-drawing/scrolling/non-fast-region/wheel-handler-region-basic.html

    r187905 r268476  
    3939        }
    4040    </style>
     41    <script src="../../../resources/ui-helper.js"></script>
    4142    <script src="resources/wheel-handler-region-helper.js"></script>
    4243    <script>
    43         window.addEventListener('load', dumpRegion, false);
     44        window.addEventListener('load', dumpRegionAndNotifyDone, false);
    4445    </script>
    4546</head>
  • trunk/Source/WTF/ChangeLog

    r268459 r268476  
     12020-10-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow passive mouse wheel event listeners to not force synchronous scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=158439
     5        <rdar://problem/28265360>
     6
     7        Reviewed by Tim Horton.
     8
     9        Define ENABLE_WHEEL_EVENT_REGIONS for macOS.
     10
     11        * wtf/PlatformEnableCocoa.h:
     12
    1132020-10-14  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WTF/wtf/PlatformEnableCocoa.h

    r268367 r268476  
    511511#endif
    512512
     513#if !defined(ENABLE_WHEEL_EVENT_REGIONS) && PLATFORM(MAC)
     514#define ENABLE_WHEEL_EVENT_REGIONS 1
     515#endif
     516
    513517#if !defined(ENABLE_UI_SIDE_COMPOSITING)
    514518#define ENABLE_UI_SIDE_COMPOSITING 1
  • trunk/Source/WebCore/ChangeLog

    r268473 r268476  
     12020-10-13  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow passive mouse wheel event listeners to not force synchronous scrolling
     4        https://bugs.webkit.org/show_bug.cgi?id=158439
     5        <rdar://problem/28265360>
     6
     7        Reviewed by Tim Horton.
     8       
     9        Turn on ENABLE_WHEEL_EVENT_REGIONS for macOS, and hit-test the passive and active regions
     10        in ScrollingTree::determineWheelEventProcessin() to determine whether scrolling needs to
     11        happen on the main thread, communicating via WheelEventProcessingSteps.
     12
     13        Now that we use EventRegion to store wheel event region information, we no longer need
     14        to consult wheel event targets im ScrollingCoordinator::absoluteEventTrackingRegionsForFrame(),
     15        but the non-fast region does still contain rectangles for non-fast-scrollable overflow
     16        if async overflow scrolling is disabled.
     17       
     18        Frame::invalidateContentEventRegionsIfNeeded() needs a fix to ensure that when wheel
     19        event handlers in non-fast-scrollable subframes change we invalidate event regions.
     20
     21        Finally, when the processing steps given to EventHandler::handleWheelEvent() do not
     22        include MainThreadForScrolling, then we shouldn't scroll here. The check in
     23        EventHandler::handleWheelEvent() applies to frames, and the one in EventHandler::defaultWheelEventHandler()
     24        applies to overflow:scroll.
     25
     26        Test: fast/scrolling/mac/slow-scrolling-overflow.html
     27
     28        * page/EventHandler.cpp:
     29        (WebCore::EventHandler::handleWheelEvent):
     30        (WebCore::EventHandler::defaultWheelEventHandler):
     31        * page/Frame.cpp:
     32        (WebCore::Frame::invalidateContentEventRegionsIfNeeded):
     33        * page/scrolling/ScrollingCoordinator.cpp:
     34        (WebCore::ScrollingCoordinator::absoluteEventTrackingRegionsForFrame const):
     35        * page/scrolling/ScrollingTree.cpp:
     36        (WebCore::ScrollingTree::determineWheelEventProcessing):
     37
    1382020-10-14  Devin Rousso  <drousso@apple.com>
    239
  • trunk/Source/WebCore/page/EventHandler.cpp

    r268417 r268476  
    28952895
    28962896    m_isHandlingWheelEvent = true;
     2897    auto allowsScrollingState = SetForScope(m_currentWheelEventAllowsScrolling, processingSteps.contains(WheelEventProcessingSteps::MainThreadForScrolling));
     2898   
    28972899    setFrameWasScrolledByUser();
    28982900
     
    29472949    bool allowScrolling = true;
    29482950#if ENABLE(WHEEL_EVENT_LATCHING)
    2949     allowScrolling = m_frame.page()->scrollLatchingController().latchingAllowsScrollingInFrame(m_frame, scrollableArea);
     2951    allowScrolling = m_currentWheelEventAllowsScrolling && m_frame.page()->scrollLatchingController().latchingAllowsScrollingInFrame(m_frame, scrollableArea);
    29502952#endif
    29512953    if (allowScrolling) {
     
    29782980   
    29792981    if (!m_frame.page())
     2982        return;
     2983
     2984    if (!m_currentWheelEventAllowsScrolling)
    29802985        return;
    29812986
  • trunk/Source/WebCore/page/Frame.cpp

    r268313 r268476  
    305305    if (!m_page || !m_doc || !m_doc->renderView())
    306306        return;
     307    bool hasWheelEventHandlers = false;
    307308    bool hasTouchActionElements = false;
    308309    bool hasEditableElements = false;
     310#if ENABLE(WHEEL_EVENT_REGIONS)
     311    hasWheelEventHandlers = m_doc->hasWheelEventHandlers();
     312#endif
    309313#if ENABLE(TOUCH_ACTION_REGIONS)
    310314    hasTouchActionElements = m_doc->mayHaveElementsWithNonAutoTouchAction();
     
    313317    hasEditableElements = m_doc->mayHaveEditableElements() && m_page->shouldBuildEditableRegion();
    314318#endif
    315     // FIXME: This needs to look at wheel event handlers too.
    316     if (!hasTouchActionElements && !hasEditableElements)
     319    if (!hasTouchActionElements && !hasEditableElements && !hasWheelEventHandlers)
    317320        return;
    318321    if (!m_doc->renderView()->compositor().viewNeedsToInvalidateEventRegionOfEnclosingCompositingLayerForRepaint())
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r261052 r268476  
    167167    }
    168168
     169#if !ENABLE(WHEEL_EVENT_REGIONS)
    169170    auto wheelHandlerRegion = frame.document()->absoluteRegionForEventTargets(frame.document()->wheelEventTargets());
    170171    bool wheelHandlerInFixedContent = wheelHandlerRegion.second;
     
    176177   
    177178    nonFastScrollableRegion.unite(wheelHandlerRegion.first);
     179#endif
    178180
    179181    // FIXME: If this is not the main frame, we could clip the region to the frame's bounds.
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r268417 r268476  
    9595    }
    9696
     97#if ENABLE(WHEEL_EVENT_REGIONS)
     98    auto eventListenerTypes = eventListenerRegionTypesForPoint(position);
     99    if (eventListenerTypes.contains(EventListenerRegionType::NonPassiveWheel))
     100        return { WheelEventProcessingSteps::MainThreadForScrolling, WheelEventProcessingSteps::MainThreadForDOMEventDispatch };
     101
     102    if (eventListenerTypes.contains(EventListenerRegionType::Wheel))
     103        return { WheelEventProcessingSteps::ScrollingThread, WheelEventProcessingSteps::MainThreadForDOMEventDispatch };
     104#endif
     105
    97106    return { WheelEventProcessingSteps::ScrollingThread };
    98107}
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r268453 r268476  
    17681768        }
    17691769
     1770        if (m_owningLayer.isRenderViewLayer() && (&graphicsLayer == m_graphicsLayer || &graphicsLayer == m_foregroundLayer)) {
     1771            // Event handlers on the root cover the entire layer.
     1772            eventRegionContext.unite(enclosingIntRect(FloatRect(-layerOffset, graphicsLayer.size())), renderer().style());
     1773        }
     1774
    17701775        auto dirtyRect = enclosingIntRect(FloatRect(FloatPoint(graphicsLayer.offsetFromRenderer()), graphicsLayer.size()));
    17711776        paintIntoLayer(&graphicsLayer, nullContext, dirtyRect, { }, &eventRegionContext);
Note: See TracChangeset for help on using the changeset viewer.