Inline the webViewerOpenFileViaURL function in webViewerInitialized

Given that `webViewerOpenFileViaURL` only has a single call-site, and also isn't a particularly large/complex function, it doesn't seem necessary for this to be a separate function and hence it's simply inlined instead.

Also, changes the "no valid build-target was set"-case to throw unconditionally since the only way that it could ever be hit is if there are bugs in the `gulpfile`-code.
This commit is contained in:
Jonas Jenwald 2022-04-29 17:04:56 +02:00
parent 24d5d5d761
commit 7cce41c26d

View File

@ -2229,7 +2229,18 @@ function webViewerInitialized() {
);
try {
webViewerOpenFileViaURL(file);
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (file) {
PDFViewerApplication.open(file);
} else {
PDFViewerApplication._hideViewBookmark();
}
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
PDFViewerApplication.setTitleUsingUrl(file, /* downloadUrl = */ file);
PDFViewerApplication.initPassiveLoading();
} else {
throw new Error("Not implemented: webViewerInitialized");
}
} catch (reason) {
PDFViewerApplication.l10n.get("loading_error").then(msg => {
PDFViewerApplication._documentError(msg, reason);
@ -2237,25 +2248,6 @@ function webViewerInitialized() {
}
}
function webViewerOpenFileViaURL(file) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (file) {
PDFViewerApplication.open(file);
} else {
PDFViewerApplication._hideViewBookmark();
}
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
PDFViewerApplication.setTitleUsingUrl(file, /* downloadUrl = */ file);
PDFViewerApplication.initPassiveLoading();
} else {
if (file) {
throw new Error("Not implemented: webViewerOpenFileViaURL");
} else {
PDFViewerApplication._hideViewBookmark();
}
}
}
function webViewerPageRendered({ pageNumber, error }) {
// If the page is still visible when it has finished rendering,
// ensure that the page number input loading indicator is hidden.