Merge pull request #15998 from Snuffleupagus/limit-removePageBorders

Limit the `removePageBorders` option, in `PDFViewer`, to only GENERIC builds
This commit is contained in:
Jonas Jenwald 2023-02-03 15:04:33 +01:00 committed by GitHub
commit 72bf36ea70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -78,10 +78,12 @@
height: var(--viewer-container-height);
}
/*#if GENERIC*/
.pdfViewer.removePageBorders .page {
margin: 0 auto 10px;
border: none;
}
/*#endif*/
/*#if COMPONENTS*/
.pdfViewer.singlePageView {
@ -107,7 +109,9 @@
white-space: nowrap;
}
/*#if GENERIC*/
.pdfViewer.removePageBorders,
/*#endif*/
.pdfViewer.scrollHorizontal .spread,
.pdfViewer.scrollWrapped .spread {
margin-left: 0;
@ -131,12 +135,14 @@
margin-right: var(--spreadHorizontalWrapped-margin-LR);
}
/*#if GENERIC*/
.pdfViewer.removePageBorders .spread .page,
.pdfViewer.removePageBorders.scrollHorizontal .page,
.pdfViewer.removePageBorders.scrollWrapped .page {
margin-left: 5px;
margin-right: 5px;
}
/*#endif*/
.pdfViewer .page canvas {
margin: 0;

View File

@ -254,7 +254,6 @@ class PDFViewer {
this.downloadManager = options.downloadManager || null;
this.findController = options.findController || null;
this._scriptingManager = options.scriptingManager || null;
this.removePageBorders = options.removePageBorders || false;
this.textLayerMode = options.textLayerMode ?? TextLayerMode.ENABLE;
this.#annotationMode =
options.annotationMode ?? AnnotationMode.ENABLE_FORMS;
@ -266,6 +265,7 @@ class PDFViewer {
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
this.removePageBorders = options.removePageBorders || false;
this.renderer = options.renderer || RendererType.CANVAS;
}
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
@ -307,7 +307,10 @@ class PDFViewer {
this._onBeforeDraw = this._onAfterDraw = null;
this._resetView();
if (this.removePageBorders) {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this.removePageBorders
) {
this.viewer.classList.add("removePageBorders");
}
@ -1183,7 +1186,10 @@ class PDFViewer {
// "doubling" the total border width.
hPadding *= 2;
}
} else if (this.removePageBorders) {
} else if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this.removePageBorders
) {
hPadding = vPadding = 0;
} else if (this._scrollMode === ScrollMode.HORIZONTAL) {
[hPadding, vPadding] = [vPadding, hPadding]; // Swap the padding values.
@ -1350,9 +1356,15 @@ class PDFViewer {
y = destArray[3];
width = destArray[4] - x;
height = destArray[5] - y;
const hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;
const vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;
let hPadding = SCROLLBAR_PADDING,
vPadding = VERTICAL_PADDING;
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
this.removePageBorders
) {
hPadding = vPadding = 0;
}
widthScale =
(this.container.clientWidth - hPadding) /
width /