tor-browser

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

DragTargetChildContext.sys.mjs (1239B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 import { DragChildContextBase } from "./DragChildContextBase.sys.mjs";
      7 
      8 export class DragTargetChildContext extends DragChildContextBase {
      9  constructor(aDragWindow, aParams) {
     10    super("dragTarget", aDragWindow, aParams);
     11  }
     12 
     13  async checkDropOrDragLeave() {
     14    let expectedMessage = this.expectDragLeave ? "dragleave" : "drop";
     15    this.ok(!!this.events[expectedMessage][0], "drop or drag leave existed");
     16    if (this.events[expectedMessage][0]) {
     17      this.ok(
     18        this.nodeIsFlattenedTreeDescendantOf(
     19          this.events[expectedMessage][0].composedTarget,
     20          this.dragElement
     21        ),
     22        `event target of ${expectedMessage} is targetElement or a descendant`
     23      );
     24    }
     25    await this.checkExpected();
     26  }
     27 }
     28 
     29 export function createDragTargetChildContext(
     30  aDragWindow,
     31  aParams,
     32  aOk,
     33  aIs,
     34  aInfo
     35 ) {
     36  aDragWindow.dragTarget = new DragTargetChildContext(aDragWindow, {
     37    ...aParams,
     38    ok: aOk,
     39    is: aIs,
     40    info: aInfo,
     41  });
     42 }