Re-factor BasePreferences to essentially be a wrapper around AppOptions

In the MOZCENTRAL build the `BasePreferences` class is almost unused, since it's only being used to initialize and update the `AppOptions` which means that theoretically we could move the relevant code there.
However for the other build targets (e.g. GENERIC and CHROME) we still need to keep the `BasePreferences` class, although we can re-factor things to move the necessary validation inside of `AppOptions` and thus simplify the code and reduce duplication.

The patch also moves the event dispatching, for changed preference values, into `AppOptions` instead.
This commit is contained in:
Jonas Jenwald 2024-07-09 13:22:14 +02:00
parent 1bdd6920ff
commit d9f0ec0b87
4 changed files with 76 additions and 142 deletions

View file

@ -391,9 +391,10 @@ const PDFViewerApplication = {
*/
async _initializeViewerComponents() {
const { appConfig, externalServices, l10n } = this;
let eventBus;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
eventBus = this.preferences.eventBus = new FirefoxEventBus(
eventBus = AppOptions.eventBus = new FirefoxEventBus(
await this._allowedGlobalEventsPromise,
externalServices,
AppOptions.get("isInAutomation")