Merge pull request #17646 from Snuffleupagus/app-break-import-cycles
Break import cycles, in the viewer, for `PDFViewerApplication`
This commit is contained in:
commit
485e9cecd7
@ -269,7 +269,6 @@ function createWebpackConfig(
|
|||||||
const viewerAlias = {
|
const viewerAlias = {
|
||||||
"web-alt_text_manager": "web/alt_text_manager.js",
|
"web-alt_text_manager": "web/alt_text_manager.js",
|
||||||
"web-annotation_editor_params": "web/annotation_editor_params.js",
|
"web-annotation_editor_params": "web/annotation_editor_params.js",
|
||||||
"web-com": "",
|
|
||||||
"web-download_manager": "",
|
"web-download_manager": "",
|
||||||
"web-external_services": "",
|
"web-external_services": "",
|
||||||
"web-null_l10n": "",
|
"web-null_l10n": "",
|
||||||
@ -291,7 +290,6 @@ function createWebpackConfig(
|
|||||||
libraryAlias["display-fetch_stream"] = "src/display/fetch_stream.js";
|
libraryAlias["display-fetch_stream"] = "src/display/fetch_stream.js";
|
||||||
libraryAlias["display-network"] = "src/display/network.js";
|
libraryAlias["display-network"] = "src/display/network.js";
|
||||||
|
|
||||||
viewerAlias["web-com"] = "web/chromecom.js";
|
|
||||||
viewerAlias["web-download_manager"] = "web/download_manager.js";
|
viewerAlias["web-download_manager"] = "web/download_manager.js";
|
||||||
viewerAlias["web-external_services"] = "web/chromecom.js";
|
viewerAlias["web-external_services"] = "web/chromecom.js";
|
||||||
viewerAlias["web-null_l10n"] = "web/l10n.js";
|
viewerAlias["web-null_l10n"] = "web/l10n.js";
|
||||||
@ -306,7 +304,6 @@ function createWebpackConfig(
|
|||||||
libraryAlias["display-node_stream"] = "src/display/node_stream.js";
|
libraryAlias["display-node_stream"] = "src/display/node_stream.js";
|
||||||
libraryAlias["display-node_utils"] = "src/display/node_utils.js";
|
libraryAlias["display-node_utils"] = "src/display/node_utils.js";
|
||||||
|
|
||||||
viewerAlias["web-com"] = "web/genericcom.js";
|
|
||||||
viewerAlias["web-download_manager"] = "web/download_manager.js";
|
viewerAlias["web-download_manager"] = "web/download_manager.js";
|
||||||
viewerAlias["web-external_services"] = "web/genericcom.js";
|
viewerAlias["web-external_services"] = "web/genericcom.js";
|
||||||
viewerAlias["web-null_l10n"] = "web/genericl10n.js";
|
viewerAlias["web-null_l10n"] = "web/genericl10n.js";
|
||||||
@ -321,7 +318,6 @@ function createWebpackConfig(
|
|||||||
viewerAlias[key] = gvAlias[key] || "web/stubs-geckoview.js";
|
viewerAlias[key] = gvAlias[key] || "web/stubs-geckoview.js";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewerAlias["web-com"] = "web/firefoxcom.js";
|
|
||||||
viewerAlias["web-download_manager"] = "web/firefoxcom.js";
|
viewerAlias["web-download_manager"] = "web/firefoxcom.js";
|
||||||
viewerAlias["web-external_services"] = "web/firefoxcom.js";
|
viewerAlias["web-external_services"] = "web/firefoxcom.js";
|
||||||
viewerAlias["web-null_l10n"] = "web/l10n.js";
|
viewerAlias["web-null_l10n"] = "web/l10n.js";
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
"web-alt_text_manager": "../../web/alt_text_manager.js",
|
"web-alt_text_manager": "../../web/alt_text_manager.js",
|
||||||
"web-annotation_editor_params": "../../web/annotation_editor_params.js",
|
"web-annotation_editor_params": "../../web/annotation_editor_params.js",
|
||||||
"web-com": "../../web/genericcom.js",
|
|
||||||
"web-download_manager": "../../web/download_manager.js",
|
"web-download_manager": "../../web/download_manager.js",
|
||||||
"web-external_services": "../../web/genericcom.js",
|
"web-external_services": "../../web/genericcom.js",
|
||||||
"web-null_l10n": "../../web/genericl10n.js",
|
"web-null_l10n": "../../web/genericl10n.js",
|
||||||
|
25
web/app.js
25
web/app.js
@ -53,12 +53,12 @@ import {
|
|||||||
} from "pdfjs-lib";
|
} from "pdfjs-lib";
|
||||||
import { AppOptions, OptionKind } from "./app_options.js";
|
import { AppOptions, OptionKind } from "./app_options.js";
|
||||||
import { AutomationEventBus, EventBus } from "./event_utils.js";
|
import { AutomationEventBus, EventBus } from "./event_utils.js";
|
||||||
|
import { ExternalServices, initCom } from "web-external_services";
|
||||||
import { LinkTarget, PDFLinkService } from "./pdf_link_service.js";
|
import { LinkTarget, PDFLinkService } from "./pdf_link_service.js";
|
||||||
import { AltTextManager } from "web-alt_text_manager";
|
import { AltTextManager } from "web-alt_text_manager";
|
||||||
import { AnnotationEditorParams } from "web-annotation_editor_params";
|
import { AnnotationEditorParams } from "web-annotation_editor_params";
|
||||||
import { CaretBrowsingMode } from "./caret_browsing.js";
|
import { CaretBrowsingMode } from "./caret_browsing.js";
|
||||||
import { DownloadManager } from "web-download_manager";
|
import { DownloadManager } from "web-download_manager";
|
||||||
import { ExternalServices } from "web-external_services";
|
|
||||||
import { OverlayManager } from "./overlay_manager.js";
|
import { OverlayManager } from "./overlay_manager.js";
|
||||||
import { PasswordPrompt } from "./password_prompt.js";
|
import { PasswordPrompt } from "./password_prompt.js";
|
||||||
import { PDFAttachmentViewer } from "web-pdf_attachment_viewer";
|
import { PDFAttachmentViewer } from "web-pdf_attachment_viewer";
|
||||||
@ -70,6 +70,7 @@ import { PDFHistory } from "./pdf_history.js";
|
|||||||
import { PDFLayerViewer } from "web-pdf_layer_viewer";
|
import { PDFLayerViewer } from "web-pdf_layer_viewer";
|
||||||
import { PDFOutlineViewer } from "web-pdf_outline_viewer";
|
import { PDFOutlineViewer } from "web-pdf_outline_viewer";
|
||||||
import { PDFPresentationMode } from "web-pdf_presentation_mode";
|
import { PDFPresentationMode } from "web-pdf_presentation_mode";
|
||||||
|
import { PDFPrintServiceFactory } from "web-print_service";
|
||||||
import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
|
import { PDFRenderingQueue } from "./pdf_rendering_queue.js";
|
||||||
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
import { PDFScriptingManager } from "./pdf_scripting_manager.js";
|
||||||
import { PDFSidebar } from "web-pdf_sidebar";
|
import { PDFSidebar } from "web-pdf_sidebar";
|
||||||
@ -731,7 +732,7 @@ const PDFViewerApplication = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get supportsPrinting() {
|
get supportsPrinting() {
|
||||||
return PDFPrintServiceFactory.instance.supportsPrinting;
|
return PDFPrintServiceFactory.supportsPrinting;
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportsFullscreen() {
|
get supportsFullscreen() {
|
||||||
@ -1786,7 +1787,7 @@ const PDFViewerApplication = {
|
|||||||
const optionalContentConfigPromise =
|
const optionalContentConfigPromise =
|
||||||
this.pdfViewer.optionalContentConfigPromise;
|
this.pdfViewer.optionalContentConfigPromise;
|
||||||
|
|
||||||
const printService = PDFPrintServiceFactory.instance.createPrintService(
|
const printService = PDFPrintServiceFactory.createPrintService(
|
||||||
this.pdfDocument,
|
this.pdfDocument,
|
||||||
pagesOverview,
|
pagesOverview,
|
||||||
printContainer,
|
printContainer,
|
||||||
@ -2145,6 +2146,12 @@ const PDFViewerApplication = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
initCom(PDFViewerApplication);
|
||||||
|
|
||||||
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
PDFPrintServiceFactory.initGlobals(PDFViewerApplication);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
const HOSTED_VIEWER_ORIGINS = [
|
const HOSTED_VIEWER_ORIGINS = [
|
||||||
"null",
|
"null",
|
||||||
@ -3234,14 +3241,4 @@ function webViewerReportTelemetry({ details }) {
|
|||||||
PDFViewerApplication.externalServices.reportTelemetry(details);
|
PDFViewerApplication.externalServices.reportTelemetry(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Abstract factory for the print service. */
|
export { PDFViewerApplication };
|
||||||
const PDFPrintServiceFactory = {
|
|
||||||
instance: {
|
|
||||||
supportsPrinting: false,
|
|
||||||
createPrintService() {
|
|
||||||
throw new Error("Not implemented: createPrintService");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export { PDFPrintServiceFactory, PDFViewerApplication };
|
|
||||||
|
@ -19,7 +19,6 @@ import { BaseExternalServices } from "./external_services.js";
|
|||||||
import { BasePreferences } from "./preferences.js";
|
import { BasePreferences } from "./preferences.js";
|
||||||
import { GenericL10n } from "./genericl10n.js";
|
import { GenericL10n } from "./genericl10n.js";
|
||||||
import { GenericScripting } from "./generic_scripting.js";
|
import { GenericScripting } from "./generic_scripting.js";
|
||||||
import { PDFViewerApplication } from "./app.js";
|
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -42,10 +41,16 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppOptions.set("defaultUrl", defaultUrl);
|
AppOptions.set("defaultUrl", defaultUrl);
|
||||||
|
})();
|
||||||
|
|
||||||
|
let viewerApp = { initialized: false };
|
||||||
|
function initCom(app) {
|
||||||
|
viewerApp = app;
|
||||||
|
|
||||||
// Ensure that PDFViewerApplication.initialBookmark reflects the current hash,
|
// Ensure that PDFViewerApplication.initialBookmark reflects the current hash,
|
||||||
// in case the URL rewrite above results in a different hash.
|
// in case the URL rewrite above results in a different hash.
|
||||||
PDFViewerApplication.initialBookmark = location.hash.slice(1);
|
viewerApp.initialBookmark = location.hash.slice(1);
|
||||||
})();
|
}
|
||||||
|
|
||||||
const ChromeCom = {
|
const ChromeCom = {
|
||||||
/**
|
/**
|
||||||
@ -77,10 +82,9 @@ const ChromeCom = {
|
|||||||
* Resolves a PDF file path and attempts to detects length.
|
* Resolves a PDF file path and attempts to detects length.
|
||||||
*
|
*
|
||||||
* @param {string} file - Absolute URL of PDF file.
|
* @param {string} file - Absolute URL of PDF file.
|
||||||
* @param {OverlayManager} overlayManager - Manager for the viewer overlays.
|
|
||||||
* @param {Function} callback - A callback with resolved URL and file length.
|
* @param {Function} callback - A callback with resolved URL and file length.
|
||||||
*/
|
*/
|
||||||
resolvePDFFile(file, overlayManager, callback) {
|
resolvePDFFile(file, callback) {
|
||||||
// Expand drive:-URLs to filesystem URLs (Chrome OS)
|
// Expand drive:-URLs to filesystem URLs (Chrome OS)
|
||||||
file = file.replace(
|
file = file.replace(
|
||||||
/^drive:/i,
|
/^drive:/i,
|
||||||
@ -104,13 +108,9 @@ const ChromeCom = {
|
|||||||
// Even without this check, the file load in frames is still blocked,
|
// Even without this check, the file load in frames is still blocked,
|
||||||
// but this may change in the future (https://crbug.com/550151).
|
// but this may change in the future (https://crbug.com/550151).
|
||||||
if (origin && !/^file:|^chrome-extension:/.test(origin)) {
|
if (origin && !/^file:|^chrome-extension:/.test(origin)) {
|
||||||
PDFViewerApplication._documentError(
|
viewerApp._documentError(
|
||||||
"Blocked " +
|
`Blocked ${origin} from loading ${file}. Refused to load ` +
|
||||||
origin +
|
"a local file in a non-local page for security reasons."
|
||||||
" from loading " +
|
|
||||||
file +
|
|
||||||
". Refused to load a local file in a non-local page " +
|
|
||||||
"for security reasons."
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ const ChromeCom = {
|
|||||||
if (isAllowedAccess) {
|
if (isAllowedAccess) {
|
||||||
callback(file);
|
callback(file);
|
||||||
} else {
|
} else {
|
||||||
requestAccessToLocalFile(file, overlayManager, callback);
|
requestAccessToLocalFile(file, viewerApp.overlayManager, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -420,7 +420,6 @@ class ExternalServices extends BaseExternalServices {
|
|||||||
// defaultUrl is set in viewer.js
|
// defaultUrl is set in viewer.js
|
||||||
ChromeCom.resolvePDFFile(
|
ChromeCom.resolvePDFFile(
|
||||||
AppOptions.get("defaultUrl"),
|
AppOptions.get("defaultUrl"),
|
||||||
PDFViewerApplication.overlayManager,
|
|
||||||
function (url, length, originalUrl) {
|
function (url, length, originalUrl) {
|
||||||
callbacks.onOpenWithURL(url, length, originalUrl);
|
callbacks.onOpenWithURL(url, length, originalUrl);
|
||||||
}
|
}
|
||||||
@ -436,4 +435,4 @@ class ExternalServices extends BaseExternalServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ChromeCom, ExternalServices, Preferences };
|
export { ExternalServices, initCom, Preferences };
|
||||||
|
@ -20,7 +20,6 @@ import {
|
|||||||
shadow,
|
shadow,
|
||||||
} from "pdfjs-lib";
|
} from "pdfjs-lib";
|
||||||
import { getXfaHtmlForPrinting } from "./print_utils.js";
|
import { getXfaHtmlForPrinting } from "./print_utils.js";
|
||||||
import { PDFPrintServiceFactory } from "./app.js";
|
|
||||||
|
|
||||||
// Creates a placeholder with div and canvas with right size for the page.
|
// Creates a placeholder with div and canvas with right size for the page.
|
||||||
function composePage(
|
function composePage(
|
||||||
@ -194,15 +193,16 @@ class FirefoxPrintService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFPrintServiceFactory.instance = {
|
/**
|
||||||
get supportsPrinting() {
|
* @implements {IPDFPrintServiceFactory}
|
||||||
|
*/
|
||||||
|
class PDFPrintServiceFactory {
|
||||||
|
static get supportsPrinting() {
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
const value = "mozPrintCallback" in canvas;
|
return shadow(this, "supportsPrinting", "mozPrintCallback" in canvas);
|
||||||
|
}
|
||||||
|
|
||||||
return shadow(this, "supportsPrinting", value);
|
static createPrintService(
|
||||||
},
|
|
||||||
|
|
||||||
createPrintService(
|
|
||||||
pdfDocument,
|
pdfDocument,
|
||||||
pagesOverview,
|
pagesOverview,
|
||||||
printContainer,
|
printContainer,
|
||||||
@ -218,7 +218,7 @@ PDFPrintServiceFactory.instance = {
|
|||||||
optionalContentConfigPromise,
|
optionalContentConfigPromise,
|
||||||
printAnnotationStoragePromise
|
printAnnotationStoragePromise
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export { FirefoxPrintService };
|
export { PDFPrintServiceFactory };
|
||||||
|
@ -18,7 +18,6 @@ import { BaseExternalServices } from "./external_services.js";
|
|||||||
import { BasePreferences } from "./preferences.js";
|
import { BasePreferences } from "./preferences.js";
|
||||||
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
|
import { DEFAULT_SCALE_VALUE } from "./ui_utils.js";
|
||||||
import { L10n } from "./l10n.js";
|
import { L10n } from "./l10n.js";
|
||||||
import { PDFViewerApplication } from "./app.js";
|
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -26,6 +25,11 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let viewerApp = { initialized: false };
|
||||||
|
function initCom(app) {
|
||||||
|
viewerApp = app;
|
||||||
|
}
|
||||||
|
|
||||||
class FirefoxCom {
|
class FirefoxCom {
|
||||||
/**
|
/**
|
||||||
* Creates an event that the extension is listening for and will
|
* Creates an event that the extension is listening for and will
|
||||||
@ -167,14 +171,14 @@ class Preferences extends BasePreferences {
|
|||||||
const findLen = "find".length;
|
const findLen = "find".length;
|
||||||
|
|
||||||
const handleEvent = function ({ type, detail }) {
|
const handleEvent = function ({ type, detail }) {
|
||||||
if (!PDFViewerApplication.initialized) {
|
if (!viewerApp.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type === "findbarclose") {
|
if (type === "findbarclose") {
|
||||||
PDFViewerApplication.eventBus.dispatch(type, { source: window });
|
viewerApp.eventBus.dispatch(type, { source: window });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFViewerApplication.eventBus.dispatch("find", {
|
viewerApp.eventBus.dispatch("find", {
|
||||||
source: window,
|
source: window,
|
||||||
type: type.substring(findLen),
|
type: type.substring(findLen),
|
||||||
query: detail.query,
|
query: detail.query,
|
||||||
@ -194,18 +198,18 @@ class Preferences extends BasePreferences {
|
|||||||
(function listenZoomEvents() {
|
(function listenZoomEvents() {
|
||||||
const events = ["zoomin", "zoomout", "zoomreset"];
|
const events = ["zoomin", "zoomout", "zoomreset"];
|
||||||
const handleEvent = function ({ type, detail }) {
|
const handleEvent = function ({ type, detail }) {
|
||||||
if (!PDFViewerApplication.initialized) {
|
if (!viewerApp.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
|
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
|
||||||
// when using the `Ctrl + 0` keyboard shortcut.
|
// when using the `Ctrl + 0` keyboard shortcut.
|
||||||
if (
|
if (
|
||||||
type === "zoomreset" &&
|
type === "zoomreset" &&
|
||||||
PDFViewerApplication.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE
|
viewerApp.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFViewerApplication.eventBus.dispatch(type, { source: window });
|
viewerApp.eventBus.dispatch(type, { source: window });
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
@ -215,10 +219,10 @@ class Preferences extends BasePreferences {
|
|||||||
|
|
||||||
(function listenSaveEvent() {
|
(function listenSaveEvent() {
|
||||||
const handleEvent = function ({ type, detail }) {
|
const handleEvent = function ({ type, detail }) {
|
||||||
if (!PDFViewerApplication.initialized) {
|
if (!viewerApp.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFViewerApplication.eventBus.dispatch("download", { source: window });
|
viewerApp.eventBus.dispatch("download", { source: window });
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("save", handleEvent);
|
window.addEventListener("save", handleEvent);
|
||||||
@ -226,10 +230,10 @@ class Preferences extends BasePreferences {
|
|||||||
|
|
||||||
(function listenEditingEvent() {
|
(function listenEditingEvent() {
|
||||||
const handleEvent = function ({ detail }) {
|
const handleEvent = function ({ detail }) {
|
||||||
if (!PDFViewerApplication.initialized) {
|
if (!viewerApp.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFViewerApplication.eventBus.dispatch("editingaction", {
|
viewerApp.eventBus.dispatch("editingaction", {
|
||||||
source: window,
|
source: window,
|
||||||
name: detail.name,
|
name: detail.name,
|
||||||
});
|
});
|
||||||
@ -242,9 +246,9 @@ if (PDFJSDev.test("GECKOVIEW")) {
|
|||||||
(function listenQueryEvents() {
|
(function listenQueryEvents() {
|
||||||
window.addEventListener("pdf.js.query", async ({ detail: { queryId } }) => {
|
window.addEventListener("pdf.js.query", async ({ detail: { queryId } }) => {
|
||||||
let result = null;
|
let result = null;
|
||||||
if (queryId === "canDownloadInsteadOfPrint") {
|
if (viewerApp.initialized && queryId === "canDownloadInsteadOfPrint") {
|
||||||
result = false;
|
result = false;
|
||||||
const { pdfDocument, pdfViewer } = PDFViewerApplication;
|
const { pdfDocument, pdfViewer } = viewerApp;
|
||||||
if (pdfDocument) {
|
if (pdfDocument) {
|
||||||
try {
|
try {
|
||||||
const hasUnchangedAnnotations =
|
const hasUnchangedAnnotations =
|
||||||
@ -411,4 +415,4 @@ class ExternalServices extends BaseExternalServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { DownloadManager, ExternalServices, FirefoxCom, Preferences };
|
export { DownloadManager, ExternalServices, initCom, Preferences };
|
||||||
|
@ -25,7 +25,7 @@ if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GenericCom = {};
|
function initCom(app) {}
|
||||||
|
|
||||||
class Preferences extends BasePreferences {
|
class Preferences extends BasePreferences {
|
||||||
async _writeToStorage(prefObj) {
|
async _writeToStorage(prefObj) {
|
||||||
@ -47,4 +47,4 @@ class ExternalServices extends BaseExternalServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ExternalServices, GenericCom, Preferences };
|
export { ExternalServices, initCom, Preferences };
|
||||||
|
@ -217,4 +217,25 @@ class IL10n {
|
|||||||
resume() {}
|
resume() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { IDownloadManager, IL10n, IPDFLinkService, IRenderableView };
|
/**
|
||||||
|
* @interface
|
||||||
|
*/
|
||||||
|
class IPDFPrintServiceFactory {
|
||||||
|
static initGlobals() {}
|
||||||
|
|
||||||
|
static get supportsPrinting() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static createPrintService() {
|
||||||
|
throw new Error("Not implemented: createPrintService");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
IDownloadManager,
|
||||||
|
IL10n,
|
||||||
|
IPDFLinkService,
|
||||||
|
IPDFPrintServiceFactory,
|
||||||
|
IRenderableView,
|
||||||
|
};
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AnnotationMode, PixelsPerInch } from "pdfjs-lib";
|
import { AnnotationMode, PixelsPerInch, shadow } from "pdfjs-lib";
|
||||||
import { PDFPrintServiceFactory, PDFViewerApplication } from "./app.js";
|
|
||||||
import { getXfaHtmlForPrinting } from "./print_utils.js";
|
import { getXfaHtmlForPrinting } from "./print_utils.js";
|
||||||
|
|
||||||
let activeService = null;
|
let activeService = null;
|
||||||
let dialog = null;
|
let dialog = null;
|
||||||
let overlayManager = null;
|
let overlayManager = null;
|
||||||
|
let viewerApp = { initialized: false };
|
||||||
|
|
||||||
// Renders the page to the canvas of the given print service, and returns
|
// Renders the page to the canvas of the given print service, and returns
|
||||||
// the suggested dimensions of the output page.
|
// the suggested dimensions of the output page.
|
||||||
@ -338,7 +338,7 @@ function ensureOverlay() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!overlayPromise) {
|
if (!overlayPromise) {
|
||||||
overlayManager = PDFViewerApplication.overlayManager;
|
overlayManager = viewerApp.overlayManager;
|
||||||
if (!overlayManager) {
|
if (!overlayManager) {
|
||||||
throw new Error("The overlay manager has not yet been initialized.");
|
throw new Error("The overlay manager has not yet been initialized.");
|
||||||
}
|
}
|
||||||
@ -355,10 +355,19 @@ function ensureOverlay() {
|
|||||||
return overlayPromise;
|
return overlayPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFPrintServiceFactory.instance = {
|
/**
|
||||||
supportsPrinting: true,
|
* @implements {IPDFPrintServiceFactory}
|
||||||
|
*/
|
||||||
|
class PDFPrintServiceFactory {
|
||||||
|
static initGlobals(app) {
|
||||||
|
viewerApp = app;
|
||||||
|
}
|
||||||
|
|
||||||
createPrintService(
|
static get supportsPrinting() {
|
||||||
|
return shadow(this, "supportsPrinting", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static createPrintService(
|
||||||
pdfDocument,
|
pdfDocument,
|
||||||
pagesOverview,
|
pagesOverview,
|
||||||
printContainer,
|
printContainer,
|
||||||
@ -378,7 +387,7 @@ PDFPrintServiceFactory.instance = {
|
|||||||
printAnnotationStoragePromise
|
printAnnotationStoragePromise
|
||||||
);
|
);
|
||||||
return activeService;
|
return activeService;
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export { PDFPrintService };
|
export { PDFPrintServiceFactory };
|
||||||
|
@ -60,7 +60,6 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
|
|
||||||
"web-alt_text_manager": "./stubs-geckoview.js",
|
"web-alt_text_manager": "./stubs-geckoview.js",
|
||||||
"web-annotation_editor_params": "./stubs-geckoview.js",
|
"web-annotation_editor_params": "./stubs-geckoview.js",
|
||||||
"web-com": "./genericcom.js",
|
|
||||||
"web-download_manager": "./download_manager.js",
|
"web-download_manager": "./download_manager.js",
|
||||||
"web-external_services": "./genericcom.js",
|
"web-external_services": "./genericcom.js",
|
||||||
"web-null_l10n": "./genericl10n.js",
|
"web-null_l10n": "./genericl10n.js",
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "web-com";
|
|
||||||
import "web-print_service";
|
|
||||||
import { RenderingStates, ScrollMode, SpreadMode } from "./ui_utils.js";
|
import { RenderingStates, ScrollMode, SpreadMode } from "./ui_utils.js";
|
||||||
import { AppOptions } from "./app_options.js";
|
import { AppOptions } from "./app_options.js";
|
||||||
import { LinkTarget } from "./pdf_link_service.js";
|
import { LinkTarget } from "./pdf_link_service.js";
|
||||||
|
@ -69,7 +69,6 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
|
|
||||||
"web-alt_text_manager": "./alt_text_manager.js",
|
"web-alt_text_manager": "./alt_text_manager.js",
|
||||||
"web-annotation_editor_params": "./annotation_editor_params.js",
|
"web-annotation_editor_params": "./annotation_editor_params.js",
|
||||||
"web-com": "./genericcom.js",
|
|
||||||
"web-download_manager": "./download_manager.js",
|
"web-download_manager": "./download_manager.js",
|
||||||
"web-external_services": "./genericcom.js",
|
"web-external_services": "./genericcom.js",
|
||||||
"web-null_l10n": "./genericl10n.js",
|
"web-null_l10n": "./genericl10n.js",
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "web-com";
|
|
||||||
import "web-print_service";
|
|
||||||
import { RenderingStates, ScrollMode, SpreadMode } from "./ui_utils.js";
|
import { RenderingStates, ScrollMode, SpreadMode } from "./ui_utils.js";
|
||||||
import { AppOptions } from "./app_options.js";
|
import { AppOptions } from "./app_options.js";
|
||||||
import { LinkTarget } from "./pdf_link_service.js";
|
import { LinkTarget } from "./pdf_link_service.js";
|
||||||
|
Loading…
Reference in New Issue
Block a user