# HG changeset patch # User Botond Ballo # Date 1522261362 14400 # Node ID baa7a07aaf6444f4ebd200de5db442a7a1388e73 # Parent 1398f8dfd275381a9fe4bd5aec7e2b6499d8a548 Bug 1447131 - Move centerOf() into apz_test_utils.js. r=kats MozReview-Commit-ID: CwO5SnWmhb9 diff --git a/gfx/layers/apz/test/mochitest/apz_test_utils.js b/gfx/layers/apz/test/mochitest/apz_test_utils.js --- 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); diff --git a/gfx/layers/apz/test/mochitest/helper_hittest_basic.html b/gfx/layers/apz/test/mochitest/helper_hittest_basic.html --- a/gfx/layers/apz/test/mochitest/helper_hittest_basic.html +++ b/gfx/layers/apz/test/mochitest/helper_hittest_basic.html @@ -12,21 +12,16 @@