1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Respect maxCanvasPixels when computing canvas dimensions

Ensure that we never round the canvas dimensions above `maxCanvasPixels`
by rounding them to the preceeding multiple of the display ratio rather
than the succeeding one.
This commit is contained in:
Nicolò Ribaudo 2024-06-07 14:08:43 +02:00
parent 12692d2e39
commit de23bb9b82
No known key found for this signature in database
GPG key ID: AAFDA9101C58F338
3 changed files with 20 additions and 15 deletions

View file

@ -279,12 +279,13 @@ describe("PDF viewer", () => {
.withContext(`In ${browserName}`)
.toBeLessThan(originalCanvasSize * factor ** 2);
// Disabled because `canvasSize` is `4_012_800`, which is
// close to the limit but somehow a bit more.
//
// expect(canvasSize)
// .withContext(`In ${browserName}, MAX_CANVAS_PIXELS`)
// .toBeLessThan(MAX_CANVAS_PIXELS.get(browserName));
expect(canvasSize)
.withContext(`In ${browserName}, <= MAX_CANVAS_PIXELS`)
.toBeLessThanOrEqual(MAX_CANVAS_PIXELS.get(browserName));
expect(canvasSize)
.withContext(`In ${browserName}, > MAX_CANVAS_PIXELS * 0.99`)
.toBeGreaterThan(MAX_CANVAS_PIXELS.get(browserName) * 0.99);
})
);
});