Merge pull request #16744 from Snuffleupagus/app-small-simplifications

A few small `web/app.js` simplifications
This commit is contained in:
Tim van der Meij 2023-07-29 13:41:01 +02:00 committed by GitHub
commit aea13b4478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -694,7 +694,7 @@ const PDFViewerApplication = {
async run(config) { async run(config) {
await this.initialize(config); await this.initialize(config);
const { appConfig, eventBus, l10n } = this; const { appConfig, eventBus } = this;
let file; let file;
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const queryString = document.location.search.substring(1); const queryString = document.location.search.substring(1);
@ -745,7 +745,7 @@ const PDFViewerApplication = {
if (!this.supportsDocumentFonts) { if (!this.supportsDocumentFonts) {
AppOptions.set("disableFontFace", true); AppOptions.set("disableFontFace", true);
l10n.get("web_fonts_disabled").then(msg => { this.l10n.get("web_fonts_disabled").then(msg => {
console.warn(msg); console.warn(msg);
}); });
} }
@ -775,7 +775,6 @@ const PDFViewerApplication = {
true true
); );
try {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (file) { if (file) {
this.open({ url: file }); this.open({ url: file });
@ -787,11 +786,6 @@ const PDFViewerApplication = {
} else { } else {
throw new Error("Not implemented: run"); throw new Error("Not implemented: run");
} }
} catch (reason) {
l10n.get("loading_error").then(msg => {
this._documentError(msg, reason);
});
}
}, },
get initialized() { get initialized() {
@ -1289,13 +1283,13 @@ const PDFViewerApplication = {
// Since the `setInitialView` call below depends on this being resolved, // Since the `setInitialView` call below depends on this being resolved,
// fetch it early to avoid delaying initial rendering of the PDF document. // fetch it early to avoid delaying initial rendering of the PDF document.
const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () { const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {
/* Avoid breaking initial rendering; ignoring errors. */ /* Avoid breaking initial rendering; ignoring errors. */
}); });
const pageModePromise = pdfDocument.getPageMode().catch(function () { const pageModePromise = pdfDocument.getPageMode().catch(() => {
/* Avoid breaking initial rendering; ignoring errors. */ /* Avoid breaking initial rendering; ignoring errors. */
}); });
const openActionPromise = pdfDocument.getOpenAction().catch(function () { const openActionPromise = pdfDocument.getOpenAction().catch(() => {
/* Avoid breaking initial rendering; ignoring errors. */ /* Avoid breaking initial rendering; ignoring errors. */
}); });
@ -1336,7 +1330,6 @@ const PDFViewerApplication = {
}) })
.catch(() => { .catch(() => {
/* Unable to read from storage; ignoring errors. */ /* Unable to read from storage; ignoring errors. */
return Object.create(null);
}); });
firstPagePromise.then(pdfPage => { firstPagePromise.then(pdfPage => {
@ -1369,7 +1362,7 @@ const PDFViewerApplication = {
let scrollMode = AppOptions.get("scrollModeOnLoad"); let scrollMode = AppOptions.get("scrollModeOnLoad");
let spreadMode = AppOptions.get("spreadModeOnLoad"); let spreadMode = AppOptions.get("spreadModeOnLoad");
if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) { if (stored?.page && viewOnLoad !== ViewOnLoad.INITIAL) {
hash = hash =
`page=${stored.page}&zoom=${zoom || stored.zoom},` + `page=${stored.page}&zoom=${zoom || stored.zoom},` +
`${stored.scrollLeft},${stored.scrollTop}`; `${stored.scrollLeft},${stored.scrollTop}`;