mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Add the possibility to dispatch some pdf.js events at the chrome level (bug 1904585)
This commit is contained in:
parent
11cb3a8e11
commit
35474f8ef4
4 changed files with 72 additions and 24 deletions
22
web/app.js
22
web/app.js
|
@ -57,7 +57,7 @@ import {
|
|||
version,
|
||||
} from "pdfjs-lib";
|
||||
import { AppOptions, OptionKind } from "./app_options.js";
|
||||
import { AutomationEventBus, EventBus } from "./event_utils.js";
|
||||
import { EventBus, FirefoxEventBus } from "./event_utils.js";
|
||||
import { ExternalServices, initCom, MLManager } from "web-external_services";
|
||||
import { LinkTarget, PDFLinkService } from "./pdf_link_service.js";
|
||||
import { AltTextManager } from "web-alt_text_manager";
|
||||
|
@ -156,6 +156,7 @@ const PDFViewerApplication = {
|
|||
isViewerEmbedded: window.parent !== window,
|
||||
url: "",
|
||||
baseUrl: "",
|
||||
_allowedGlobalEventsPromise: null,
|
||||
_downloadUrl: "",
|
||||
_eventBusAbortController: null,
|
||||
_windowAbortController: null,
|
||||
|
@ -186,6 +187,10 @@ const PDFViewerApplication = {
|
|||
// initialize the `L10n`-instance as soon as possible.
|
||||
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) {
|
||||
l10nPromise = this.externalServices.createL10n();
|
||||
if (PDFJSDev.test("MOZCENTRAL")) {
|
||||
this._allowedGlobalEventsPromise =
|
||||
this.externalServices.getGlobalEventNames();
|
||||
}
|
||||
}
|
||||
this.appConfig = appConfig;
|
||||
|
||||
|
@ -386,10 +391,17 @@ const PDFViewerApplication = {
|
|||
*/
|
||||
async _initializeViewerComponents() {
|
||||
const { appConfig, externalServices, l10n } = this;
|
||||
|
||||
const eventBus = AppOptions.get("isInAutomation")
|
||||
? new AutomationEventBus()
|
||||
: new EventBus();
|
||||
let eventBus;
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
eventBus = new FirefoxEventBus(
|
||||
await this._allowedGlobalEventsPromise,
|
||||
externalServices,
|
||||
AppOptions.get("isInAutomation")
|
||||
);
|
||||
this._allowedGlobalEventsPromise = null;
|
||||
} else {
|
||||
eventBus = new EventBus();
|
||||
}
|
||||
this.eventBus = eventBus;
|
||||
|
||||
this.overlayManager = new OverlayManager();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue