Bug 1241672 - Add synthesizeWheelAtPoint to avoid styling flush. r?smaug draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Fri, 22 Jan 2016 08:43:50 +0900
changeset 324107 816a9000dbab1f8b3615fb893322244cf4ed80a9
parent 323987 66e07ef46853709e3fa91e7c9ad9fe6abf0d5f06
child 513328 a8f295b07841fb0d263aded1534d8b87c22347d7
push id9848
push userhiikezoe@mozilla-japan.org
push dateThu, 21 Jan 2016 23:44:43 +0000
reviewerssmaug
bugs1241672
milestone46.0a1
Bug 1241672 - Add synthesizeWheelAtPoint to avoid styling flush. r?smaug
testing/mochitest/tests/SimpleTest/EventUtils.js
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -6,16 +6,17 @@
  *  sendChar
  *  sendString
  *  sendKey
  *  sendWheelAndPaint
  *  synthesizeMouse
  *  synthesizeMouseAtCenter
  *  synthesizePointer
  *  synthesizeWheel
+ *  synthesizeWheelAtPoint
  *  synthesizeKey
  *  synthesizeNativeKey
  *  synthesizeMouseExpectEvent
  *  synthesizeKeyExpectEvent
  *  synthesizeNativeClick
  *
  *  When adding methods to this file, please add a performance test for it.
  */
@@ -401,34 +402,33 @@ function synthesizeMouseAtCenter(aTarget
 function synthesizeTouchAtCenter(aTarget, aEvent, aWindow)
 {
   var rect = aTarget.getBoundingClientRect();
   synthesizeTouch(aTarget, rect.width / 2, rect.height / 2, aEvent,
                   aWindow);
 }
 
 /**
- * Synthesize a wheel event on a target. The actual client point is determined
- * by taking the aTarget's client box and offseting it by aOffsetX and
- * aOffsetY.
+ * Synthesize a wheel event without flush layout at a particular point in
+ * aWindow.
  *
  * aEvent is an object which may contain the properties:
  *   shiftKey, ctrlKey, altKey, metaKey, accessKey, deltaX, deltaY, deltaZ,
  *   deltaMode, lineOrPageDeltaX, lineOrPageDeltaY, isMomentum,
  *   isNoLineOrPageDelta, isCustomizedByPrefs, expectedOverflowDeltaX,
  *   expectedOverflowDeltaY
  *
  * deltaMode must be defined, others are ok even if undefined.
  *
  * expectedOverflowDeltaX and expectedOverflowDeltaY take integer value.  The
  * value is just checked as 0 or positive or negative.
  *
  * aWindow is optional, and defaults to the current window object.
  */
-function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
+function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow)
 {
   var utils = _getDOMWindowUtils(aWindow);
   if (!utils) {
     return;
   }
 
   var modifiers = _parseModifiers(aEvent);
   var options = 0;
@@ -475,25 +475,48 @@ function synthesizeWheel(aTarget, aOffse
   var lineOrPageDeltaX =
     aEvent.lineOrPageDeltaX != null ? aEvent.lineOrPageDeltaX :
                   aEvent.deltaX > 0 ? Math.floor(aEvent.deltaX) :
                                       Math.ceil(aEvent.deltaX);
   var lineOrPageDeltaY =
     aEvent.lineOrPageDeltaY != null ? aEvent.lineOrPageDeltaY :
                   aEvent.deltaY > 0 ? Math.floor(aEvent.deltaY) :
                                       Math.ceil(aEvent.deltaY);
-
-  var rect = aTarget.getBoundingClientRect();
-  utils.sendWheelEvent(rect.left + aOffsetX, rect.top + aOffsetY,
+  utils.sendWheelEvent(aLeft, aTop,
                        aEvent.deltaX, aEvent.deltaY, aEvent.deltaZ,
                        aEvent.deltaMode, modifiers,
                        lineOrPageDeltaX, lineOrPageDeltaY, options);
 }
 
 /**
+ * Synthesize a wheel event on a target. The actual client point is determined
+ * by taking the aTarget's client box and offseting it by aOffsetX and
+ * aOffsetY.
+ *
+ * aEvent is an object which may contain the properties:
+ *   shiftKey, ctrlKey, altKey, metaKey, accessKey, deltaX, deltaY, deltaZ,
+ *   deltaMode, lineOrPageDeltaX, lineOrPageDeltaY, isMomentum,
+ *   isNoLineOrPageDelta, isCustomizedByPrefs, expectedOverflowDeltaX,
+ *   expectedOverflowDeltaY
+ *
+ * deltaMode must be defined, others are ok even if undefined.
+ *
+ * expectedOverflowDeltaX and expectedOverflowDeltaY take integer value.  The
+ * value is just checked as 0 or positive or negative.
+ *
+ * aWindow is optional, and defaults to the current window object.
+ */
+function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
+{
+  var rect = aTarget.getBoundingClientRect();
+  synthesizeWheelAtPoint(rect.left + aOffsetX, rect.top + aOffsetY,
+                         aEvent, aWindow);
+}
+
+/**
  * This is a wrapper around synthesizeWheel that waits for the wheel event
  * to be dispatched and for the subsequent layout/paints to be flushed.
  *
  * This requires including paint_listener.js. Tests must call
  * DOMWindowUtils.restoreNormalRefresh() before finishing, if they use this
  * function.
  *
  * If no callback is provided, the caller is assumed to have its own method of