Bug 1447131 - Move centerOf() into apz_test_utils.js. r=kats a=RyanVM
authorBotond Ballo <botond@mozilla.com>
Wed, 28 Mar 2018 14:22:42 -0400
changeset 462954 8501641210ea8399fe9246b4153795190a9e47dd
parent 462953 f4d9dd292ecde244e267b1cd9eeee45f57981ce1
child 462955 6237ca74f16021a84bc75a06aa722fe3501d51ce
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, RyanVM
bugs1447131
milestone60.0
Bug 1447131 - Move centerOf() into apz_test_utils.js. r=kats a=RyanVM MozReview-Commit-ID: CwO5SnWmhb9
gfx/layers/apz/test/mochitest/apz_test_utils.js
gfx/layers/apz/test/mochitest/helper_hittest_basic.html
gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -517,16 +517,22 @@ function getHitTestConfig() {
     var utils = SpecialPowers.getDOMWindowUtils(window);
     var isWebRender = (utils.layerManagerType == 'WebRender');
     var isWindows = (getPlatform() == 'windows');
     window.hitTestConfig = { utils, isWebRender, isWindows };
   }
   return window.hitTestConfig;
 }
 
+// Compute the coordinates of the center of the given element.
+function centerOf(element) {
+  var bounds = element.getBoundingClientRect();
+  return { x: bounds.x + (bounds.width / 2), y: bounds.y + (bounds.height / 2) };
+}
+
 // Peform a compositor hit test at the given point and return the result.
 // The returned object has two fields:
 //   hitInfo: a combination of APZHitResultFlags
 //   scrollId: the view-id of the scroll frame that was hit
 function hitTest(point) {
   var utils = getHitTestConfig().utils;
   dump("Hit-testing point (" + point.x + ", " + point.y + ")\n");
   utils.sendMouseEvent("MozMouseHittest", point.x, point.y, 0, 0, 0, true, 0, 0, true, true);
--- a/gfx/layers/apz/test/mochitest/helper_hittest_basic.html
+++ b/gfx/layers/apz/test/mochitest/helper_hittest_basic.html
@@ -12,21 +12,16 @@
   <div id="contents" style="width: 500px; height: 500px; background-image: linear-gradient(blue,red)">
    <div id="apzaware" style="position: relative; width: 100px; height: 100px; top: 300px; background-color: red" onwheel="return false;"></div>
   </div>
  </div>
  <div id="make_root_scrollable" style="height: 5000px"></div>
 </body>
 <script type="application/javascript">
 
-function centerOf(element) {
-  var bounds = element.getBoundingClientRect();
-  return { x: bounds.x + (bounds.width / 2), y: bounds.y + (bounds.height / 2) };
-}
-
 function* test(testDriver) {
   var config = getHitTestConfig();
   var utils = config.utils;
 
   var scroller = document.getElementById('scroller');
   var apzaware = document.getElementById('apzaware');
 
   var {hitInfo, scrollId} = hitTest(centerOf(scroller));
--- a/gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
+++ b/gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
@@ -12,21 +12,16 @@
   <!-- Make the contents tall enough to be sure we can checkerboard -->
   <div id="contents" style="width: 100%; height: 5000px; background-image: linear-gradient(blue,red)">
   </div>
  </div>
  <div id="make_root_scrollable" style="height: 5000px"></div>
 </body>
 <script type="application/javascript">
 
-function centerOf(element) {
-  var bounds = element.getBoundingClientRect();
-  return { x: bounds.x + (bounds.width / 2), y: bounds.y + (bounds.height / 2) };
-}
-
 function* test(testDriver) {
   var config = getHitTestConfig();
   var utils = config.utils;
 
   var scroller = document.getElementById('scroller');
 
   // Activate the scrollframe but keep the main-thread scroll position at 0.
   // Also apply an async scroll offset in the y-direction such that the