Convert FirefoxPrintService and PDFPrintService into standard classes

Note that both of the affected files are old enough to predate the general availability of `class`.
This commit is contained in:
Jonas Jenwald 2023-04-14 09:51:37 +02:00
parent ebf493f726
commit aeb8e36cdb
2 changed files with 52 additions and 52 deletions

View File

@ -114,7 +114,8 @@ function composePage(
};
}
function FirefoxPrintService(
class FirefoxPrintService {
constructor(
pdfDocument,
pagesOverview,
printContainer,
@ -132,7 +133,6 @@ function FirefoxPrintService(
printAnnotationStoragePromise || Promise.resolve();
}
FirefoxPrintService.prototype = {
layout() {
const {
pdfDocument,
@ -179,7 +179,7 @@ FirefoxPrintService.prototype = {
_printAnnotationStoragePromise
);
}
},
}
destroy() {
this.printContainer.textContent = "";
@ -191,8 +191,8 @@ FirefoxPrintService.prototype = {
this.pageStyleSheet.remove();
this.pageStyleSheet = null;
}
},
};
}
}
PDFPrintServiceFactory.instance = {
get supportsPrinting() {

View File

@ -62,7 +62,8 @@ function renderPage(
});
}
function PDFPrintService(
class PDFPrintService {
constructor(
pdfDocument,
pagesOverview,
printContainer,
@ -85,7 +86,6 @@ function PDFPrintService(
this.scratchCanvas = document.createElement("canvas");
}
PDFPrintService.prototype = {
layout() {
this.throwIfInactive();
@ -114,7 +114,7 @@ PDFPrintService.prototype = {
this.pageStyleSheet = document.createElement("style");
this.pageStyleSheet.textContent = `@page { size: ${width}pt ${height}pt;}`;
body.append(this.pageStyleSheet);
},
}
destroy() {
if (activeService !== this) {
@ -139,7 +139,7 @@ PDFPrintService.prototype = {
overlayManager.close(dialog);
}
});
},
}
renderPages() {
if (this.pdfDocument.isPureXfa) {
@ -172,7 +172,7 @@ PDFPrintService.prototype = {
}, reject);
};
return new Promise(renderNextPage);
},
}
useRenderedPage() {
this.throwIfInactive();
@ -195,7 +195,7 @@ PDFPrintService.prototype = {
img.onload = resolve;
img.onerror = reject;
});
},
}
performPrint() {
this.throwIfInactive();
@ -213,18 +213,18 @@ PDFPrintService.prototype = {
setTimeout(resolve, 20); // Tidy-up.
}, 0);
});
},
}
get active() {
return this === activeService;
},
}
throwIfInactive() {
if (!this.active) {
throw new Error("This print request was cancelled or completed.");
}
},
};
}
}
const print = window.print;
window.print = function () {