mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Allow to change the toolbar height when changing the pref toolbar.density in Firefox (bug 1171799)
It's a first step to just dispatch the pref change to the toolbar. The second one, to effectively use it, will come after PR #18385 is merged.
This commit is contained in:
parent
e777ae2258
commit
0910f17a58
4 changed files with 32 additions and 3 deletions
|
@ -393,7 +393,7 @@ const PDFViewerApplication = {
|
||||||
const { appConfig, externalServices, l10n } = this;
|
const { appConfig, externalServices, l10n } = this;
|
||||||
let eventBus;
|
let eventBus;
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
eventBus = new FirefoxEventBus(
|
eventBus = this.preferences.eventBus = new FirefoxEventBus(
|
||||||
await this._allowedGlobalEventsPromise,
|
await this._allowedGlobalEventsPromise,
|
||||||
externalServices,
|
externalServices,
|
||||||
AppOptions.get("isInAutomation")
|
AppOptions.get("isInAutomation")
|
||||||
|
@ -569,7 +569,11 @@ const PDFViewerApplication = {
|
||||||
await this._nimbusDataPromise
|
await this._nimbusDataPromise
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.toolbar = new Toolbar(appConfig.toolbar, eventBus);
|
this.toolbar = new Toolbar(
|
||||||
|
appConfig.toolbar,
|
||||||
|
eventBus,
|
||||||
|
AppOptions.get("toolbarDensity")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,11 @@ const defaultOptions = {
|
||||||
value: true,
|
value: true,
|
||||||
kind: OptionKind.BROWSER,
|
kind: OptionKind.BROWSER,
|
||||||
},
|
},
|
||||||
|
toolbarDensity: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: 0, // 0 = "normal", 1 = "compact", 2 = "touch"
|
||||||
|
kind: OptionKind.BROWSER,
|
||||||
|
},
|
||||||
|
|
||||||
annotationEditorMode: {
|
annotationEditorMode: {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
|
|
|
@ -37,6 +37,8 @@ class BasePreferences {
|
||||||
|
|
||||||
#initializedPromise = null;
|
#initializedPromise = null;
|
||||||
|
|
||||||
|
static #eventToDispatch = new Set(["toolbarDensity"]);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
if (this.constructor === BasePreferences) {
|
if (this.constructor === BasePreferences) {
|
||||||
throw new Error("Cannot initialize BasePreferences.");
|
throw new Error("Cannot initialize BasePreferences.");
|
||||||
|
@ -73,6 +75,10 @@ class BasePreferences {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
this.eventBus = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,6 +119,10 @@ class BasePreferences {
|
||||||
return; // Invalid preference.
|
return; // Invalid preference.
|
||||||
}
|
}
|
||||||
AppOptions.set(name, value);
|
AppOptions.set(name, value);
|
||||||
|
|
||||||
|
if (BasePreferences.#eventToDispatch.has(name)) {
|
||||||
|
this.eventBus?.dispatch(name.toLowerCase(), { source: this, value });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,8 +50,13 @@ class Toolbar {
|
||||||
/**
|
/**
|
||||||
* @param {ToolbarOptions} options
|
* @param {ToolbarOptions} options
|
||||||
* @param {EventBus} eventBus
|
* @param {EventBus} eventBus
|
||||||
|
* @param {number} toolbarDensity - The toolbar density value.
|
||||||
|
* The possible values are:
|
||||||
|
* - 0 (default) - The regular toolbar size.
|
||||||
|
* - 1 (compact) - The small toolbar size.
|
||||||
|
* - 2 (touch) - The large toolbar size.
|
||||||
*/
|
*/
|
||||||
constructor(options, eventBus) {
|
constructor(options, eventBus, toolbarDensity = 0) {
|
||||||
this.#opts = options;
|
this.#opts = options;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
const buttons = [
|
const buttons = [
|
||||||
|
@ -136,9 +141,14 @@ class Toolbar {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eventBus._on("toolbardensity", this.#updateToolbarDensity.bind(this));
|
||||||
|
this.#updateToolbarDensity({ value: toolbarDensity });
|
||||||
|
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#updateToolbarDensity() {}
|
||||||
|
|
||||||
#setAnnotationEditorUIManager(uiManager, parentContainer) {
|
#setAnnotationEditorUIManager(uiManager, parentContainer) {
|
||||||
const colorPicker = new ColorPicker({ uiManager });
|
const colorPicker = new ColorPicker({ uiManager });
|
||||||
uiManager.setMainHighlightColorPicker(colorPicker);
|
uiManager.setMainHighlightColorPicker(colorPicker);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue