Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pref to know if the alt-text must be automatically generated (bug 1909310) #18484

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extensions/chromium/preferences_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"type": "boolean",
"default": false
},
"enableGuessAltText": {
"type": "boolean",
"default": true
},
"altTextLearnMoreUrl": {
"type": "string",
"default": ""
Expand Down
20 changes: 10 additions & 10 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ const PDFViewerApplication = {
if (mode) {
document.documentElement.classList.add(mode);
}
} else {
} else if (AppOptions.get("enableAltText")) {
calixteman marked this conversation as resolved.
Show resolved Hide resolved
// We want to load the image-to-text AI engine as soon as possible.
this.mlManager = new MLManager({
enableAltText: AppOptions.get("enableAltText"),
enableGuessAltText: AppOptions.get("enableGuessAltText"),
altTextLearnMoreUrl: AppOptions.get("altTextLearnMoreUrl"),
});
}
Expand Down Expand Up @@ -376,14 +376,14 @@ const PDFViewerApplication = {

let eventBus;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
eventBus =
AppOptions.eventBus =
this.mlManager.eventBus =
new FirefoxEventBus(
AppOptions.get("allowedGlobalEvents"),
externalServices,
AppOptions.get("isInAutomation")
);
eventBus = AppOptions.eventBus = new FirefoxEventBus(
AppOptions.get("allowedGlobalEvents"),
externalServices,
AppOptions.get("isInAutomation")
);
if (this.mlManager) {
this.mlManager.eventBus = eventBus;
}
} else {
eventBus = new EventBus();
}
Expand Down
5 changes: 5 additions & 0 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ const defaultOptions = {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableGuessAltText: {
/** @type {boolean} */
value: true,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
enableHighlightEditor: {
// We'll probably want to make some experiments before enabling this
// in Firefox release, but it has to be temporary.
Expand Down
4 changes: 2 additions & 2 deletions web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ class MLManager {
return FirefoxCom.requestAsync("mlGuess", data);
}

enable({ altTextLearnMoreUrl, enableAltText, listenToProgress }) {
if (enableAltText) {
enable({ altTextLearnMoreUrl, enableGuessAltText, listenToProgress }) {
if (enableGuessAltText) {
this.#loadAltTextEngine(listenToProgress);
}
// The `altTextLearnMoreUrl` is used to provide a link to the user to learn
Expand Down