author James Teh <>
Wed, 01 Feb 2023 05:02:01 +0000
changeset 651150 dd0fdd1daa69783be36acd5c50544f3694eaa8f9
parent 560094 5b314b9c431925a56367a7e3b2a4d64081c1074b
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:

<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8">
<title>Testcase for checkerboarding with displayport multipliers dropped to zero</title>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<meta name="viewport" content="width=device-width"/>
body, html {
    margin: 0;
 <div style="height: 5000px; background-color: green"></div>
<script type="application/javascript">
async function test() {
  var utils = SpecialPowers.getDOMWindowUtils(window);
  var scrollerId = utils.getViewId(document.scrollingElement);

  // Zoom in a bunch
  const scale = 3.0;

  // And now we scroll the visual viewport to cover the range it has inside
  // the layout viewport, plus a bit more so that we also cover the boundary
  // case where the layout viewport has to move.
  // At each scroll position, we make sure there's no checkerboarding.
  // We advance the scroll position on each axis by 43 CSS pixels at a time,
  // because 43 is a non-power-of-two/prime number and should give us reasonable
  // coverage of different displayport tile alignment values. Making the
  // increment too small increases runtime and too large might miss some
  // alignment values so this seems like a good number.

  async function scrollAndCheck(x, y) {
    dump(`Scrolling visual viewport to ${x}, ${y}\n`);
    utils.scrollToVisual(x, y, utils.UPDATE_TYPE_MAIN_THREAD, utils.SCROLL_MODE_INSTANT);
    await promiseApzFlushedRepaints();
    assertNotCheckerboarded(utils, scrollerId, `At ${x}, ${y}`);

  let vv_scrollable_x = window.innerWidth - (window.innerWidth / scale);
  for (var x = 0; x < vv_scrollable_x + 100; x += 43) {
    await scrollAndCheck(x, 0);
  ok(window.scrollX == 0, "Layout viewport couldn't move on the x-axis, page not scrollable that way");
  let vv_scrollable_y = window.innerHeight - (window.innerHeight / scale);
  for (var y = 0; y < vv_scrollable_y + 100; y += 43) {
    await scrollAndCheck(0, y);
  ok(window.scrollY > 0, `Layout viewport moved down to ${window.scrollY} on the y-axis`);

.then(subtestDone, subtestFailed)