Bug 1433019 - Dispatch scroll events before dispatching animation events. r=botond,mstange
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 30 Jan 2018 08:22:47 +0900
changeset 748778 ced1881a5daa06c9a001619c4e818b86320d4caa
parent 748777 47bb6da4b0d1800b1496910660b1a2155350b155
child 748779 59ae8c3043e832687eee02de7ce66c50cdb5aea3
push id97228
push usersfraser@mozilla.com
push dateTue, 30 Jan 2018 10:21:04 +0000
reviewersbotond, mstange
bugs1433019
milestone60.0a1
Bug 1433019 - Dispatch scroll events before dispatching animation events. r=botond,mstange See 7.6. in the section '8.1.4.2 Processing model'; https://html.spec.whatwg.org/multipage/webappapis.html#processing-model-8 Note that this dispatching scroll events should be done after we process WillRefresh() for FlushType::Style observers since main-thread scroll animations is one of the FlushType::Style observers, that means it affects scroll events. Also test_scroll_event_ordering.html was modified to check scroll events happen before requestAnimationFrame callbacks. MozReview-Commit-ID: LuV157XoRkJ
layout/base/nsRefreshDriver.cpp
layout/base/tests/test_scroll_event_ordering.html
testing/web-platform/meta/html/webappapis/scripting/event-loops/microtask_after_raf.html.ini
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1891,20 +1891,20 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
         StopTimer();
         return;
       }
     }
 
     if (i == 1) {
       // This is the FlushType::Style case.
 
+      DispatchScrollEvents();
       DispatchAnimationEvents();
       DispatchPendingEvents();
       RunFrameRequestCallbacks(aNowTime);
-      DispatchScrollEvents();
 
       if (mPresContext && mPresContext->GetPresShell()) {
         AutoTArray<nsIPresShell*, 16> observers;
         observers.AppendElements(mStyleFlushObservers);
         for (uint32_t j = observers.Length();
              j && mPresContext && mPresContext->GetPresShell(); --j) {
           // Make sure to not process observers which might have been removed
           // during previous iterations.
--- a/layout/base/tests/test_scroll_event_ordering.html
+++ b/layout/base/tests/test_scroll_event_ordering.html
@@ -24,25 +24,25 @@ var smoothScrollPref = "general.smoothSc
 
 var d = document.getElementById("d");
 d.scrollTop = 0;
 var inner = document.getElementById("inner");
 
 var state = "initial";
 
 function onFrame() {
-  is(state, "initial", "Must be in initial state");
-  ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")");
+  is(state, "didOnScroll", "Must have got scroll event already");
   state = "didOnFrame";
+  SimpleTest.finish();
 }
 
 function onScroll() {
-  is(state, "didOnFrame", "Must have got requestAnimationFrame callback already");
+  is(state, "initial", "Must be in initial state");
   ok(d.scrollTop > 0, "Must have scrolled by some amount (got " + d.scrollTop + ")");
-  SimpleTest.finish();
+  state = "didOnScroll";
 }
 
 function doTest() {
   window.getSelection().collapse(inner.firstChild, 0);
   window.requestAnimationFrame(onFrame);
   d.onscroll = onScroll;
   sendKey("DOWN");
 }
deleted file mode 100644
--- a/testing/web-platform/meta/html/webappapis/scripting/event-loops/microtask_after_raf.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[microtask_after_raf.html]
-  [Microtask execute immediately after script]
-    expected: FAIL
-