mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Remove PDFViewerApplication.initPassiveLoading
and directly invoke the open
-method from the extension-specific code
This old method is essentially just adding, a small amount of, unnecessary indirection and we can easily invoke `PDFViewerApplication.open` directly from the extension-specific code instead.
This commit is contained in:
parent
b5e00e1fae
commit
ea1c910a66
4 changed files with 17 additions and 46 deletions
44
web/app.js
44
web/app.js
|
@ -685,7 +685,9 @@ const PDFViewerApplication = {
|
|||
this._hideViewBookmark();
|
||||
}
|
||||
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
||||
this.initPassiveLoading(file);
|
||||
this.setTitleUsingUrl(file, /* downloadUrl = */ file);
|
||||
|
||||
this.externalServices.initPassiveLoading();
|
||||
} else {
|
||||
throw new Error("Not implemented: run");
|
||||
}
|
||||
|
@ -815,37 +817,6 @@ const PDFViewerApplication = {
|
|||
this._caretBrowsing.moveCaret(isUp, select);
|
||||
},
|
||||
|
||||
initPassiveLoading(file) {
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
!PDFJSDev.test("MOZCENTRAL || CHROME")
|
||||
) {
|
||||
throw new Error("Not implemented: initPassiveLoading");
|
||||
}
|
||||
this.setTitleUsingUrl(file, /* downloadUrl = */ file);
|
||||
|
||||
this.externalServices.initPassiveLoading({
|
||||
onOpenWithTransport: range => {
|
||||
this.open({ range });
|
||||
},
|
||||
onOpenWithData: (data, contentDispositionFilename) => {
|
||||
if (isPdfFile(contentDispositionFilename)) {
|
||||
this._contentDispositionFilename = contentDispositionFilename;
|
||||
}
|
||||
this.open({ data });
|
||||
},
|
||||
onOpenWithURL: (url, length, originalUrl) => {
|
||||
this.open({ url, length, originalUrl });
|
||||
},
|
||||
onError: err => {
|
||||
this._documentError("pdfjs-loading-error", err);
|
||||
},
|
||||
onProgress: (loaded, total) => {
|
||||
this.progress(loaded / total);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
setTitleUsingUrl(url = "", downloadUrl = null) {
|
||||
this.url = url;
|
||||
this.baseUrl = url.split("#", 1)[0];
|
||||
|
@ -987,10 +958,11 @@ const PDFViewerApplication = {
|
|||
const workerParams = AppOptions.getAll(OptionKind.WORKER);
|
||||
Object.assign(GlobalWorkerOptions, workerParams);
|
||||
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
|
||||
args.url
|
||||
) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
if (args.data && isPdfFile(args.filename)) {
|
||||
this._contentDispositionFilename = args.filename;
|
||||
}
|
||||
} else if (args.url) {
|
||||
// The Firefox built-in viewer always calls `setTitleUsingUrl`, before
|
||||
// `initPassiveLoading`, and it never provides an `originalUrl` here.
|
||||
this.setTitleUsingUrl(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue