tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ScrollDelegateChild.sys.mjs (965B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 import { GeckoViewActorChild } from "resource://gre/modules/GeckoViewActorChild.sys.mjs";
      6 
      7 export class ScrollDelegateChild extends GeckoViewActorChild {
      8  // eslint-disable-next-line complexity
      9  handleEvent(aEvent) {
     10    if (aEvent.originalTarget.ownerGlobal != this.contentWindow) {
     11      return;
     12    }
     13 
     14    debug`handleEvent: ${aEvent.type}`;
     15 
     16    switch (aEvent.type) {
     17      case "mozvisualscroll": {
     18        const x = {};
     19        const y = {};
     20        this.contentWindow.windowUtils.getVisualViewportOffset(x, y);
     21        this.sendAsyncMessage("GeckoView:ScrollChanged", {
     22          scrollX: x.value,
     23          scrollY: y.value,
     24        });
     25        break;
     26      }
     27    }
     28  }
     29 }
     30 
     31 const { debug, warn } = ScrollDelegateChild.initLogging("ScrollDelegate");