mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 12:27:21 +02:00
Compare commits
No commits in common. "3f1ecc1ba9fba371cc35f10b6928eb40536d4f78" and "ca05a0dbfc543ce1edbd0bd610085a8efcb46ed2" have entirely different histories.
3f1ecc1ba9
...
ca05a0dbfc
@ -665,7 +665,13 @@ class OutputScale {
|
|||||||
maxWidthScale = Infinity,
|
maxWidthScale = Infinity,
|
||||||
maxHeightScale = Infinity;
|
maxHeightScale = Infinity;
|
||||||
|
|
||||||
maxPixels = OutputScale.capPixels(maxPixels, capAreaFactor);
|
if (capAreaFactor >= 0) {
|
||||||
|
const cappedWindowArea = OutputScale.getCappedWindowArea(capAreaFactor);
|
||||||
|
maxPixels =
|
||||||
|
maxPixels > 0
|
||||||
|
? Math.min(maxPixels, cappedWindowArea)
|
||||||
|
: cappedWindowArea;
|
||||||
|
}
|
||||||
if (maxPixels > 0) {
|
if (maxPixels > 0) {
|
||||||
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
||||||
}
|
}
|
||||||
@ -687,18 +693,21 @@ class OutputScale {
|
|||||||
return globalThis.devicePixelRatio || 1;
|
return globalThis.devicePixelRatio || 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static capPixels(maxPixels, capAreaFactor) {
|
static getCappedWindowArea(capAreaFactor) {
|
||||||
if (capAreaFactor >= 0) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
||||||
const winPixels = Math.ceil(
|
return Math.ceil(
|
||||||
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")
|
window.innerWidth *
|
||||||
? window.innerWidth * window.innerHeight
|
window.innerHeight *
|
||||||
: window.screen.availWidth * window.screen.availHeight) *
|
|
||||||
this.pixelRatio ** 2 *
|
this.pixelRatio ** 2 *
|
||||||
(1 + capAreaFactor / 100)
|
(1 + capAreaFactor / 100)
|
||||||
);
|
);
|
||||||
return maxPixels > 0 ? Math.min(maxPixels, winPixels) : winPixels;
|
|
||||||
}
|
}
|
||||||
return maxPixels;
|
return Math.ceil(
|
||||||
|
window.screen.availWidth *
|
||||||
|
window.screen.availHeight *
|
||||||
|
this.pixelRatio ** 2 *
|
||||||
|
(1 + capAreaFactor / 100)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -140,10 +140,18 @@ class PDFPageDetailView extends BasePDFPageView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { viewport, maxCanvasPixels, capCanvasAreaFactor } = this.pageView;
|
const { viewport, capCanvasAreaFactor } = this.pageView;
|
||||||
|
|
||||||
const visibleWidth = visibleArea.maxX - visibleArea.minX;
|
const visibleWidth = visibleArea.maxX - visibleArea.minX;
|
||||||
const visibleHeight = visibleArea.maxY - visibleArea.minY;
|
const visibleHeight = visibleArea.maxY - visibleArea.minY;
|
||||||
|
let { maxCanvasPixels } = this.pageView;
|
||||||
|
|
||||||
|
if (capCanvasAreaFactor >= 0) {
|
||||||
|
maxCanvasPixels = Math.min(
|
||||||
|
maxCanvasPixels,
|
||||||
|
OutputScale.getCappedWindowArea(capCanvasAreaFactor)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// "overflowScale" represents which percentage of the width and of the
|
// "overflowScale" represents which percentage of the width and of the
|
||||||
// height the detail area extends outside of the visible area. We want to
|
// height the detail area extends outside of the visible area. We want to
|
||||||
@ -156,8 +164,7 @@ class PDFPageDetailView extends BasePDFPageView {
|
|||||||
const visiblePixels =
|
const visiblePixels =
|
||||||
visibleWidth * visibleHeight * OutputScale.pixelRatio ** 2;
|
visibleWidth * visibleHeight * OutputScale.pixelRatio ** 2;
|
||||||
const maxDetailToVisibleLinearRatio = Math.sqrt(
|
const maxDetailToVisibleLinearRatio = Math.sqrt(
|
||||||
OutputScale.capPixels(maxCanvasPixels, capCanvasAreaFactor) /
|
maxCanvasPixels / visiblePixels
|
||||||
visiblePixels
|
|
||||||
);
|
);
|
||||||
const maxOverflowScale = (maxDetailToVisibleLinearRatio - 1) / 2;
|
const maxOverflowScale = (maxDetailToVisibleLinearRatio - 1) / 2;
|
||||||
let overflowScale = Math.min(1, maxOverflowScale);
|
let overflowScale = Math.min(1, maxOverflowScale);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user