Merge pull request #17218 from Snuffleupagus/app-open-API-options
Re-factor how some API-options are handled in `PDFViewerApplication.open` (PR 17208 follow-up)
This commit is contained in:
commit
9eb9d3f949
26
web/app.js
26
web/app.js
@ -870,10 +870,10 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
setTitleUsingUrl(url = "", downloadUrl = null) {
|
setTitleUsingUrl(url = "", downloadUrl = null) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.baseUrl = url.split("#")[0];
|
this.baseUrl = url.split("#", 1)[0];
|
||||||
if (downloadUrl) {
|
if (downloadUrl) {
|
||||||
this._downloadUrl =
|
this._downloadUrl =
|
||||||
downloadUrl === url ? this.baseUrl : downloadUrl.split("#")[0];
|
downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0];
|
||||||
}
|
}
|
||||||
if (isDataScheme(url)) {
|
if (isDataScheme(url)) {
|
||||||
this._hideViewBookmark();
|
this._hideViewBookmark();
|
||||||
@ -1020,20 +1020,20 @@ const PDFViewerApplication = {
|
|||||||
/* downloadUrl = */ args.url
|
/* downloadUrl = */ args.url
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// Always set `docBaseUrl` in development mode, and in the (various)
|
||||||
|
// extension builds.
|
||||||
|
if (typeof PDFJSDev === "undefined") {
|
||||||
|
AppOptions.set("docBaseUrl", document.URL.split("#", 1)[0]);
|
||||||
|
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
||||||
|
AppOptions.set("docBaseUrl", this.baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
// Set the necessary API parameters, using all the available options.
|
// Set the necessary API parameters, using all the available options.
|
||||||
const apiParams = AppOptions.getAll(OptionKind.API);
|
const apiParams = AppOptions.getAll(OptionKind.API);
|
||||||
const params = {
|
const loadingTask = getDocument({
|
||||||
canvasMaxAreaInBytes: AppOptions.get("canvasMaxAreaInBytes"),
|
|
||||||
...apiParams,
|
...apiParams,
|
||||||
...args,
|
...args,
|
||||||
};
|
});
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined") {
|
|
||||||
params.docBaseUrl ||= document.URL.split("#")[0];
|
|
||||||
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
|
||||||
params.docBaseUrl ||= this.baseUrl;
|
|
||||||
}
|
|
||||||
const loadingTask = getDocument(params);
|
|
||||||
this.pdfLoadingTask = loadingTask;
|
this.pdfLoadingTask = loadingTask;
|
||||||
|
|
||||||
loadingTask.onPassword = (updateCallback, reason) => {
|
loadingTask.onPassword = (updateCallback, reason) => {
|
||||||
@ -1252,7 +1252,7 @@ const PDFViewerApplication = {
|
|||||||
this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
|
this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||||
const baseUrl = location.href.split("#")[0];
|
const baseUrl = location.href.split("#", 1)[0];
|
||||||
// Ignore "data:"-URLs for performance reasons, even though it may cause
|
// Ignore "data:"-URLs for performance reasons, even though it may cause
|
||||||
// internal links to not work perfectly in all cases (see bug 1803050).
|
// internal links to not work perfectly in all cases (see bug 1803050).
|
||||||
this.pdfLinkService.setDocument(
|
this.pdfLinkService.setDocument(
|
||||||
|
@ -57,7 +57,7 @@ const defaultOptions = {
|
|||||||
canvasMaxAreaInBytes: {
|
canvasMaxAreaInBytes: {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
value: -1,
|
value: -1,
|
||||||
kind: OptionKind.BROWSER,
|
kind: OptionKind.BROWSER + OptionKind.API,
|
||||||
},
|
},
|
||||||
isInAutomation: {
|
isInAutomation: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user