Remove unused parameters from the onOpenWithTransport
method in PDFViewerApplication.initPassiveLoading
The only parameter that we actually need here is the `PDFDataRangeTransport`-instance, since the others are not necessary. - The `url` parameter, as passed to the `getDocument` function in the API, is simply being ignored; see2d87a2eb1c/src/display/api.js (L447-L458)
- The `length` parameter, as passed to the `getDocument` function in the API, is always being overwritten; see2d87a2eb1c/src/display/api.js (L519-L525)
This commit is contained in:
parent
2d87a2eb1c
commit
cf8ee47589
@ -283,28 +283,32 @@ function getDocument(src) {
|
|||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "url":
|
case "url":
|
||||||
if (val instanceof URL) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
params[key] = val.href;
|
continue; // The 'url' is unused with `PDFDataRangeTransport`.
|
||||||
continue;
|
} else {
|
||||||
}
|
if (val instanceof URL) {
|
||||||
try {
|
params[key] = val.href;
|
||||||
// The full path is required in the 'url' field.
|
continue;
|
||||||
params[key] = new URL(val, window.location).href;
|
|
||||||
continue;
|
|
||||||
} catch (ex) {
|
|
||||||
if (
|
|
||||||
typeof PDFJSDev !== "undefined" &&
|
|
||||||
PDFJSDev.test("GENERIC") &&
|
|
||||||
isNodeJS &&
|
|
||||||
typeof val === "string"
|
|
||||||
) {
|
|
||||||
break; // Use the url as-is in Node.js environments.
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
// The full path is required in the 'url' field.
|
||||||
|
params[key] = new URL(val, window.location).href;
|
||||||
|
continue;
|
||||||
|
} catch (ex) {
|
||||||
|
if (
|
||||||
|
typeof PDFJSDev !== "undefined" &&
|
||||||
|
PDFJSDev.test("GENERIC") &&
|
||||||
|
isNodeJS &&
|
||||||
|
typeof val === "string"
|
||||||
|
) {
|
||||||
|
break; // Use the url as-is in Node.js environments.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
"Invalid PDF url data: " +
|
||||||
|
"either string or URL-object is expected in the url property."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
throw new Error(
|
|
||||||
"Invalid PDF url data: " +
|
|
||||||
"either string or URL-object is expected in the url property."
|
|
||||||
);
|
|
||||||
case "range":
|
case "range":
|
||||||
rangeTransport = val;
|
rangeTransport = val;
|
||||||
continue;
|
continue;
|
||||||
|
@ -745,8 +745,8 @@ const PDFViewerApplication = {
|
|||||||
throw new Error("Not implemented: initPassiveLoading");
|
throw new Error("Not implemented: initPassiveLoading");
|
||||||
}
|
}
|
||||||
this.externalServices.initPassiveLoading({
|
this.externalServices.initPassiveLoading({
|
||||||
onOpenWithTransport: (url, length, transport) => {
|
onOpenWithTransport: range => {
|
||||||
this.open({ url, length, range: transport });
|
this.open({ range });
|
||||||
},
|
},
|
||||||
onOpenWithData: (data, contentDispositionFilename) => {
|
onOpenWithData: (data, contentDispositionFilename) => {
|
||||||
if (isPdfFile(contentDispositionFilename)) {
|
if (isPdfFile(contentDispositionFilename)) {
|
||||||
|
@ -347,11 +347,7 @@ class FirefoxExternalServices extends DefaultExternalServices {
|
|||||||
args.filename
|
args.filename
|
||||||
);
|
);
|
||||||
|
|
||||||
callbacks.onOpenWithTransport(
|
callbacks.onOpenWithTransport(pdfDataRangeTransport);
|
||||||
args.pdfUrl,
|
|
||||||
args.length,
|
|
||||||
pdfDataRangeTransport
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case "range":
|
case "range":
|
||||||
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user