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

A couple of small scripting/XFA-related tweaks in the worker-code

- Use `PDFManager.ensureDoc`, rather than `PDFManager.ensure`, in a couple of spots in the code. If there exists a short-hand format, we should obviously use it whenever possible.

 - Fix a unit-test helper, to account for the previous changes. (Also, converts a function to be `async` instead.)

 - Add one more exists-check in `PDFDocument.loadXfaFonts`, which I missed to suggest in PR 13146, to prevent any possible errors if the method is ever called in a situation where it shouldn't be.
   Also, print a warning if the actual font-loading fails since that could help future debugging. (Finally, reduce overall indentation in the loop.)

 - Slightly unrelated, but make a small tweak of a comment in `src/core/fonts.js` to reduce possible confusion.
This commit is contained in:
Jonas Jenwald 2021-04-17 10:13:42 +02:00
parent ac3fa1e3d7
commit f560fe6875
4 changed files with 43 additions and 35 deletions

View file

@ -53,18 +53,18 @@ describe("document", function () {
get docId() {
return "d0";
},
ensureDoc(prop, args) {
return pdfManager.ensure(pdfDocument, prop, args);
},
ensureCatalog(prop, args) {
return pdfManager.ensure(catalog, prop, args);
},
ensure(obj, prop, args) {
return new Promise(function (resolve) {
const value = obj[prop];
if (typeof value === "function") {
resolve(value.apply(obj, args));
} else {
resolve(value);
}
});
async ensure(obj, prop, args) {
const value = obj[prop];
if (typeof value === "function") {
return value.apply(obj, args);
}
return value;
},
};
const pdfDocument = new PDFDocument(pdfManager, stream);