Repository: mozilla/pdf.js
File: src/display/editor/draw.js (JavaScript)

Code before:
        if (CurrentPointer.isSamePointerId(e.pointerId)) {
          this._endDraw(e);
        }
      },
      { signal }
    );
    window.addEventListener(
      "pointercancel",
      e => {
        if (CurrentPointer.isSamePointerId(e.pointerId)) {
          this._currentParent.endDrawingSession();
        }
      },
      { signal }
    );
    window.addEventListener(
      "pointerdown",
      e => {
        if (!CurrentPointer.isSamePointerType(e.pointerType)) {
          // For example, we started with a pen and the user
          // is now using a finger.
          return;
        }

        // For example, the user is using a second finger.
        CurrentPointer.initializeAndAddPointerId(e.pointerId);

        // The first finger created a first point and a second finger just
        // started, so we stop the drawing and remove this only point.
        if (DrawingEditor.#currentDraw.isCancellable()) {
          DrawingEditor.#currentDraw.removeLastElement();
          if (DrawingEditor.#currentDraw.isEmpty()) {
            this._currentParent.endDrawingSession(/* isAborted = */ true);
          } else {
            this._endDraw(null);
          }
        }
      },
      {
        capture: true,
        passive: false,
        signal,
      }
    );
    window.addEventListener("contextmenu", noContextMenu, { signal });
    target.addEventListener("pointermove", this._drawMove.bind(this), {
      signal,
    });
    target.addEventListener(
      "touchmove",
      e => {

Review comment (suggestion):
Ideally, the comment above this line should be copied, pasted and adapted in the new class you introduced.

Code after:
      "pointerup",
      e => {
        if (CurrentPointers.isSamePointerIdOrRemove(e.pointerId)) {
          this._endDraw(e);
        }
      },
      { signal }
    );
    window.addEventListener(
      "pointercancel",
      e => {
        if (CurrentPointers.isSamePointerIdOrRemove(e.pointerId)) {
          this._currentParent.endDrawingSession();
        }
      },
      { signal }
    );
    window.addEventListener(
      "pointerdown",
      e => {
        if (!CurrentPointers.isSamePointerType(e.pointerType)) {
          // For example, we started with a pen and the user
          // is now using a finger.
          return;
        }

        // For example, the user is using a second finger.
        CurrentPointers.initializeAndAddPointerId(e.pointerId);

        // The first finger created a first point and a second finger just
        // started, so we stop the drawing and remove this only point.
        if (DrawingEditor.#currentDraw.isCancellable()) {
          DrawingEditor.#currentDraw.removeLastElement();
          if (DrawingEditor.#currentDraw.isEmpty()) {
            this._currentParent.endDrawingSession(/* isAborted = */ true);
          } else {
            this._endDraw(null);
          }
        }
      },
      {
        capture: true,
        passive: false,
        signal,
      }
    );
    window.addEventListener("contextmenu", noContextMenu, { signal });
    target.addEventListener("pointermove", this._drawMove.bind(this), {
      signal,
    });
    target.addEventListener(