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

Code before:
  /**
   * @type {boolean} Returns `true` when scaling is symmetric,
   *   `false` otherwise.
   */
  get symmetric() {
    return this.sx === this.sy;
  }

  /**
   * @returns {boolean} Returns `true` if scaling was limited,
   *   `false` otherwise.
   */
  limitCanvas(width, height, maxPixels, maxDim, capCanvasAreaFactor) {
    let maxAreaScale = Infinity,
      maxWidthScale = Infinity,
      maxHeightScale = Infinity;

    if (capCanvasAreaFactor >= 0) {
      const { innerWidth, innerHeight } = window;
      maxPixels = Math.min(
        maxPixels,
        innerWidth *
          innerHeight *
          (1 + capCanvasAreaFactor / 100) *
          OutputScale.pixelRatio ** 2
      );
    }
    if (maxPixels > 0) {
      maxAreaScale = Math.sqrt(maxPixels / (width * height));
    }
    if (maxDim !== -1) {
      maxWidthScale = maxDim / width;
      maxHeightScale = maxDim / height;
    }
    const maxScale = Math.min(maxAreaScale, maxWidthScale, maxHeightScale);

    if (this.sx > maxScale || this.sy > maxScale) {
      this.sx = maxScale;
      this.sy = maxScale;
      return true;
    }
    return false;
  }

  static get pixelRatio() {
    return globalThis.devicePixelRatio || 1;
  }
}

// See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
// to know which types are supported by the browser.

Review comment (suggestion):
Sorry, but this really won't work if `maxPixels` is either `-1` or `0` both of which are possible/valid values for that parameter (note the condition just below).
```suggestion
      const capPixels = 
        innerWidth *
          innerHeight *
          (1 + capCanvasAreaFactor / 100) *
          OutputScale.pixelRatio ** 2;

      maxPixels = maxPixels > 0 ? Math.min(maxPixels, capPixels) : capPixels;
```

Code after:
  }

  /**
   * @type {boolean} Returns `true` when scaling is symmetric,
   *   `false` otherwise.
   */
  get symmetric() {
    return this.sx === this.sy;
  }

  /**
   * @returns {boolean} Returns `true` if scaling was limited,
   *   `false` otherwise.
   */
  limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {
    let maxAreaScale = Infinity,
      maxWidthScale = Infinity,
      maxHeightScale = Infinity;

    if (capAreaFactor >= 0) {
      const cappedWindowArea = OutputScale.getCappedWindowArea(capAreaFactor);
      maxPixels =
        maxPixels > 0
          ? Math.min(maxPixels, cappedWindowArea)
          : cappedWindowArea;
    }
    if (maxPixels > 0) {
      maxAreaScale = Math.sqrt(maxPixels / (width * height));
    }
    if (maxDim !== -1) {
      maxWidthScale = maxDim / width;
      maxHeightScale = maxDim / height;
    }
    const maxScale = Math.min(maxAreaScale, maxWidthScale, maxHeightScale);

    if (this.sx > maxScale || this.sy > maxScale) {
      this.sx = maxScale;
      this.sy = maxScale;
      return true;
    }
    return false;
  }

  static get pixelRatio() {
    return globalThis.devicePixelRatio || 1;
  }

  static getCappedWindowArea(capAreaFactor) {
    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
      return Math.ceil(
        window.innerWidth *