Changeset 261686 in webkit


Ignore:
Timestamp:
May 14, 2020 5:31:01 AM (4 years ago)
Author:
graouts@webkit.org
Message:

Cursor should not update on a 20ms timer
https://bugs.webkit.org/show_bug.cgi?id=211884
<rdar://problem/63220368>

Reviewed by Antti Koivisto.

Source/WebCore:

Update the cursor during page rendering rather than using a 20ms timer.

  • page/EventHandler.cpp:

(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::clear):
(WebCore::EventHandler::updateCursorIfNeeded):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::scheduleCursorUpdate):
(WebCore::EventHandler::cursorUpdateTimerFired): Deleted.

  • page/EventHandler.h:
  • page/Page.cpp:

(WebCore::Page::updateRendering):

LayoutTests:

Update a (flaky) test to not use setTimeout() to test a cursor change and instead use requestAnimationFrame()
since cursor updates are now guaranteed to be run before the next requestAnimationFrame() callback.

  • fast/events/mouse-cursor-no-mousemove.html:
  • platform/mac-wk1/TestExpectations:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r261685 r261686  
     12020-05-14  Antoine Quint  <graouts@apple.com>
     2
     3        Cursor should not update on a 20ms timer
     4        https://bugs.webkit.org/show_bug.cgi?id=211884
     5        <rdar://problem/63220368>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Update a (flaky) test to not use setTimeout() to test a cursor change and instead use requestAnimationFrame()
     10        since cursor updates are now guaranteed to be run before the next requestAnimationFrame() callback.
     11
     12        * fast/events/mouse-cursor-no-mousemove.html:
     13        * platform/mac-wk1/TestExpectations:
     14
    1152020-05-14  Philippe Normand  <pnormand@igalia.com>
    216
  • trunk/LayoutTests/fast/events/mouse-cursor-no-mousemove.html

    r158113 r261686  
    1515<div id="console"></div>
    1616<script>
    17 var CURSOR_UPDATE_DELAY = 50;
    1817
    1918description("Test that there is no mousemove event fired when changing cursor.");
     
    2928}
    3029
    31 // Can't do anything useful here without eventSender
    32 if (window.eventSender) {
     30(async function()
     31{
     32    // Can't do anything useful here without eventSender
     33    if (!window.eventSender)
     34        return;
     35
    3336    var node = document.getElementById('target');
    3437    debug('TEST CASE: ' + node.textContent);
     
    4043    });
    4144    node.style.cursor = 'help';
    42     setTimeout(function() {
    43         debug('Cursor Info: ' + window.internals.getCurrentCursorInfo());
    44         debug('');
    45     }, CURSOR_UPDATE_DELAY);
     45
     46    // Cursor will be updated during the next animation frame.
     47    await new Promise(requestAnimationFrame);
     48    debug('Cursor Info: ' + window.internals.getCurrentCursorInfo());
     49    debug('');
    4650
    4751    // Give some time for the change to resolve. Fake mousemove event that caused bug, is using a timer
    48     setTimeout(function() {
    49         document.getElementById('test-container').style.display = 'none';
    50         finishJSTest();
    51     }, 150);
    52 }
     52    await new Promise(resolve => setTimeout(resolve, 100));
     53    document.getElementById('test-container').style.display = 'none';
     54    finishJSTest();
     55})();
    5356
    5457</script>
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r261678 r261686  
    937937webkit.org/b/209353 [ Release ] media/video-background-tab-playback.html [ Pass Failure ]
    938938
    939 webkit.org/b/209494 fast/events/mouse-cursor-no-mousemove.html [ Pass Failure ]
    940 
    941939webkit.org/b/209560 imported/w3c/web-platform-tests/xhr/send-response-upload-event-progress.htm [ Pass Crash Failure ]
    942940
  • trunk/Source/WebCore/ChangeLog

    r261685 r261686  
     12020-05-14  Antoine Quint  <graouts@apple.com>
     2
     3        Cursor should not update on a 20ms timer
     4        https://bugs.webkit.org/show_bug.cgi?id=211884
     5        <rdar://problem/63220368>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Update the cursor during page rendering rather than using a 20ms timer.
     10
     11        * page/EventHandler.cpp:
     12        (WebCore::EventHandler::EventHandler):
     13        (WebCore::EventHandler::clear):
     14        (WebCore::EventHandler::updateCursorIfNeeded):
     15        (WebCore::EventHandler::handleMouseMoveEvent):
     16        (WebCore::EventHandler::scheduleCursorUpdate):
     17        (WebCore::EventHandler::cursorUpdateTimerFired): Deleted.
     18        * page/EventHandler.h:
     19        * page/Page.cpp:
     20        (WebCore::Page::updateRendering):
     21
    1222020-05-14  Philippe Normand  <pnormand@igalia.com>
    223
  • trunk/Source/WebCore/page/EventHandler.cpp

    r261382 r261686  
    396396    : m_frame(frame)
    397397    , m_hoverTimer(*this, &EventHandler::hoverTimerFired)
    398     , m_cursorUpdateTimer(*this, &EventHandler::cursorUpdateTimerFired)
    399398#if PLATFORM(MAC)
    400399    , m_clearLatchingStateTimer(*this, &EventHandler::clearLatchedStateTimerFired)
     
    433432{
    434433    m_hoverTimer.stop();
    435     m_cursorUpdateTimer.stop();
     434    m_hasScheduledCursorUpdate = false;
    436435#if !ENABLE(IOS_TOUCH_EVENTS)
    437436    m_fakeMouseMoveEventTimer.stop();
     
    14171416}
    14181417
    1419 void EventHandler::cursorUpdateTimerFired()
    1420 {
    1421     ASSERT(m_frame.document());
    1422     updateCursor();
     1418void EventHandler::updateCursorIfNeeded()
     1419{
     1420    if (std::exchange(m_hasScheduledCursorUpdate, false))
     1421        updateCursor();
    14231422}
    14241423
     
    19831982        m_hoverTimer.stop();
    19841983
    1985     m_cursorUpdateTimer.stop();
     1984    m_hasScheduledCursorUpdate = false;
    19861985
    19871986#if !ENABLE(IOS_TOUCH_EVENTS)
     
    31423141void EventHandler::scheduleCursorUpdate()
    31433142{
    3144     if (Page* page = m_frame.page()) {
    3145         if (!page->chrome().client().supportsSettingCursor())
    3146             return;
    3147     }
    3148 
    3149     if (!m_cursorUpdateTimer.isActive())
    3150         m_cursorUpdateTimer.startOneShot(cursorUpdateInterval);
     3143    if (m_hasScheduledCursorUpdate)
     3144        return;
     3145
     3146    auto* page = m_frame.page();
     3147    if (!page)
     3148        return;
     3149
     3150    if (!page->chrome().client().supportsSettingCursor())
     3151        return;
     3152
     3153    m_hasScheduledCursorUpdate = true;
     3154    page->scheduleRenderingUpdate();
    31513155}
    31523156
  • trunk/Source/WebCore/page/EventHandler.h

    r261382 r261686  
    320320
    321321    bool useHandCursor(Node*, bool isOverLink, bool shiftKey);
     322    void updateCursorIfNeeded();
    322323    void updateCursor();
    323324
     
    376377
    377378    void hoverTimerFired();
    378     void cursorUpdateTimerFired();
    379379
    380380    bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = nullptr);
     
    534534
    535535    Timer m_hoverTimer;
    536     Timer m_cursorUpdateTimer;
     536    bool m_hasScheduledCursorUpdate { false };
    537537
    538538#if PLATFORM(MAC)
  • trunk/Source/WebCore/page/Page.cpp

    r261663 r261686  
    5353#include "EmptyClients.h"
    5454#include "Event.h"
     55#include "EventHandler.h"
    5556#include "EventNames.h"
    5657#include "ExtensionStyleSheets.h"
     
    13641365
    13651366    forEachDocument([] (Document& document) {
     1367        if (auto* frame = document.frame())
     1368            frame->eventHandler().updateCursorIfNeeded();
     1369    });
     1370
     1371    forEachDocument([] (Document& document) {
    13661372        document.runResizeSteps();
    13671373    });
Note: See TracChangeset for help on using the changeset viewer.