Title: [261741] trunk
Revision
261741
Author
grao...@webkit.org
Date
2020-05-15 06:19:29 -0700 (Fri, 15 May 2020)

Log Message

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

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/events/mouse-cursor-udpate-during-raf.html

Update cursors after rAF callbacks have been serviced and layout has been updated.

* page/Page.cpp:
(WebCore::Page::updateRendering):
(WebCore::Page::doAfterUpdateRendering):

LayoutTests:

Add a new test that checks that changing cursor during a rAF callback is applied on the immediate next run loop.

* fast/events/mouse-cursor-no-mousemove.html: Since cursor update happens in Page::updateRendering() after
rAF callbacks have been serviced, wait until the next run loop after an animation frame to check the new cursor.
* fast/events/mouse-cursor-udpate-during-raf-expected.txt: Added.
* fast/events/mouse-cursor-udpate-during-raf.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261740 => 261741)


--- trunk/LayoutTests/ChangeLog	2020-05-15 12:40:44 UTC (rev 261740)
+++ trunk/LayoutTests/ChangeLog	2020-05-15 13:19:29 UTC (rev 261741)
@@ -1,3 +1,18 @@
+2020-05-15  Antoine Quint  <grao...@apple.com>
+
+        Cursor should not update on a 20ms timer
+        https://bugs.webkit.org/show_bug.cgi?id=211884
+        <rdar://problem/63220368>
+
+        Reviewed by Simon Fraser.
+
+        Add a new test that checks that changing cursor during a rAF callback is applied on the immediate next run loop.
+
+        * fast/events/mouse-cursor-no-mousemove.html: Since cursor update happens in Page::updateRendering() after
+        rAF callbacks have been serviced, wait until the next run loop after an animation frame to check the new cursor.
+        * fast/events/mouse-cursor-udpate-during-raf-expected.txt: Added.
+        * fast/events/mouse-cursor-udpate-during-raf.html: Added.
+
 2020-05-15  Diego Pino Garcia  <dp...@igalia.com>
 
         [GTK] Gardening, update test expectations after 261730

Modified: trunk/LayoutTests/fast/events/mouse-cursor-no-mousemove.html (261740 => 261741)


--- trunk/LayoutTests/fast/events/mouse-cursor-no-mousemove.html	2020-05-15 12:40:44 UTC (rev 261740)
+++ trunk/LayoutTests/fast/events/mouse-cursor-no-mousemove.html	2020-05-15 13:19:29 UTC (rev 261741)
@@ -43,8 +43,9 @@
     });
     node.style.cursor = 'help';
 
-    // Cursor will be updated during the next animation frame.
+    // Cursor will be updated immediately after the next animation frame.
     await new Promise(requestAnimationFrame);
+    await new Promise(setTimeout);
     debug('Cursor Info: ' + window.internals.getCurrentCursorInfo());
     debug('');
 

Added: trunk/LayoutTests/fast/events/mouse-cursor-udpate-during-raf-expected.txt (0 => 261741)


--- trunk/LayoutTests/fast/events/mouse-cursor-udpate-during-raf-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/mouse-cursor-udpate-during-raf-expected.txt	2020-05-15 13:19:29 UTC (rev 261741)
@@ -0,0 +1,19 @@
+Test that changing the 'cursor' property during a requestAnimationFrame callback is applied by the next run loop.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Moved pointer over the target, cursor should be Pointer.
+Cursor info: type=Pointer hotSpot=0,0
+
+Setting cursor via CSS during next animation frame, cursor should be Pointer still.
+Cursor info: type=Pointer hotSpot=0,0
+
+Waited until next run loop, cursor should be Help.
+Cursor info: type=Help hotSpot=0,0
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/mouse-cursor-udpate-during-raf.html (0 => 261741)


--- trunk/LayoutTests/fast/events/mouse-cursor-udpate-during-raf.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/mouse-cursor-udpate-during-raf.html	2020-05-15 13:19:29 UTC (rev 261741)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style type="text/css">
+</style>
+</head>
+<body>
+<p id="description"></p>
+<div id="target" style="position: absolute; top: 0; left: 0; width: 100px; height: 100px;"></div>
+<br/>
+<div id="console"></div>
+<script>
+
+description("Test that changing the 'cursor' property during a requestAnimationFrame callback is applied by the next run loop.");
+
+if (!window.eventSender) {
+    testFailed('This test requires DumpRenderTree');
+}
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    window.jsTestIsAsync = true;
+}
+
+(async function()
+{
+    // Can't do anything useful here without eventSender
+    if (!window.eventSender)
+        return;
+
+    const target = document.getElementById("target");
+    eventSender.mouseMoveTo(target.offsetLeft + 3, target.offsetTop + 3);
+    debug("Moved pointer over the target, cursor should be Pointer.");
+    debug(`Cursor info: ${window.internals.getCurrentCursorInfo()}`);
+
+    await new Promise(requestAnimationFrame);
+    debug("");
+    debug("Setting cursor via CSS during next animation frame, cursor should be Pointer still.");
+    debug(`Cursor info: ${window.internals.getCurrentCursorInfo()}`);
+    target.style.cursor = 'help';
+
+    await new Promise(setTimeout);
+    debug("");
+    debug("Waited until next run loop, cursor should be Help.");
+    debug(`Cursor info: ${window.internals.getCurrentCursorInfo()}`);
+
+    debug("");
+    target.remove();
+    finishJSTest();
+})();
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (261740 => 261741)


--- trunk/Source/WebCore/ChangeLog	2020-05-15 12:40:44 UTC (rev 261740)
+++ trunk/Source/WebCore/ChangeLog	2020-05-15 13:19:29 UTC (rev 261741)
@@ -1,3 +1,19 @@
+2020-05-15  Antoine Quint  <grao...@apple.com>
+
+        Cursor should not update on a 20ms timer
+        https://bugs.webkit.org/show_bug.cgi?id=211884
+        <rdar://problem/63220368>
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/events/mouse-cursor-udpate-during-raf.html
+
+        Update cursors after rAF callbacks have been serviced and layout has been updated.
+
+        * page/Page.cpp:
+        (WebCore::Page::updateRendering):
+        (WebCore::Page::doAfterUpdateRendering):
+
 2020-05-15  Andres Gonzalez  <andresg...@apple.com>
 
         Update the isolated tree only if isolated tree mode is enabled.

Modified: trunk/Source/WebCore/page/Page.cpp (261740 => 261741)


--- trunk/Source/WebCore/page/Page.cpp	2020-05-15 12:40:44 UTC (rev 261740)
+++ trunk/Source/WebCore/page/Page.cpp	2020-05-15 13:19:29 UTC (rev 261741)
@@ -1364,11 +1364,6 @@
     // Flush autofocus candidates
 
     forEachDocument([] (Document& document) {
-        if (auto* frame = document.frame())
-            frame->eventHandler().updateCursorIfNeeded();
-    });
-
-    forEachDocument([] (Document& document) {
         document.runResizeSteps();
     });
 
@@ -1426,6 +1421,11 @@
     // layout to be up-to-date. It should not run script, trigger layout, or dirty layout.
 
     forEachDocument([] (Document& document) {
+        if (auto* frame = document.frame())
+            frame->eventHandler().updateCursorIfNeeded();
+    });
+
+    forEachDocument([] (Document& document) {
         document.enqueuePaintTimingEntryIfNeeded();
     });
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to