author James Teh <>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 624592 78a43d5ba28e7c42c8380465a793dfa1eb6bf9f2
permissions -rw-r--r--
Bug 1813980: Check IsDoc before Parent in RemoteAccessibleBase::ApplyCrossDocOffset. r=morgan We call this function on every ancestor when calculating bounds. RemoteParent() currently requires a hash lookup, so it's more efficient to early return for !IsDoc() first. This is a micro-optimisation, but it might have some impact given that we call this on every ancestor, especially when hit testing, where we call Bounds() a lot. As a bit of drive-by cleanup, use RemoteParent() rather than calling Parent() and IsRemote/AsRemote(). Differential Revision:

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Skip re-snapping during pan gesture</title>
  <script src="apz_test_utils.js"></script>
  <script src="apz_test_native_event_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
    body {
      margin: 0;
    div {
      position: absolute;
    #scroller {
      width: 100%;
      height: 500px;
      overflow-y: scroll;
      scroll-snap-type: y mandatory;
    .child {
      width: 100%;
      height: 100px;
      background-color: blue;
      scroll-snap-align: start;
  <div id="scroller">
    <div class="child" style="top: 0px;"></div>
    <div id="spacer" style="width: 100%; height: 2000px;"></div>
  <script type="application/javascript">
    async function test() {
      is(scroller.scrollTop, 0, "The initial snap point is at 0px");

      let scrollEventPromise = waitForScrollEvent(scroller);

      // Start a pan gesture downward.
      await promiseNativePanGestureEventAndWaitForObserver(
        1 /* kCGScrollPhaseBegan */);

      await scrollEventPromise;

      ok(scroller.scrollTop > 0, "The pan-start should scroll");

      // Expand the scrollable region during the panning. = "2200px";

      isnot(scroller.scrollTop, 0, "Do not re-snap to the original 0px");
      let previousScrollPosition = scroller.scrollTop;

      scrollEventPromise = waitForScrollEvent(scroller);
      // Finish the pan gesture now.
      await promiseNativePanGestureEventAndWaitForObserver(
        0 /* 0 velocity to avoid further scrolling by this event */,
        4 /* kCGScrollPhaseEnd */);

      await scrollEventPromise;

      // Make sure the new scroll positions have reached to the main-thread.
      await promiseApzFlushedRepaints();

      // There's no good way to tell whether the snapping has finished, has
      // reached to the snap destination, so we just check whether the current
      // scroll position is a bit scrolled back toward the snap destination.
      ok(scroller.scrollTop < previousScrollPosition,
         "The pan-end should trigger snapping toward 0px");

    if (getPlatform() == "mac") {
      .then(subtestDone, subtestFailed);
    } else {
      ok(true, "Skipping test because this test works only on mac");