Bug 1628476: Add keyboard navigation pref to allow focus mode changes on macOS r=Jamie,fluent-reviewers,settings-reviewers,flod,mconley

Differential Revision: https://phabricator.services.mozilla.com/D182266
This commit is contained in:
Morgan Rae Reschenberg
2023-07-14 23:28:46 +00:00
parent e1bb325239
commit c913819da7
5 changed files with 144 additions and 0 deletions

View File

@@ -129,6 +129,7 @@ Preferences.addAll([
{ id: "general.smoothScroll", type: "bool" },
{ id: "widget.gtk.overlay-scrollbars.enabled", type: "bool", inverted: true },
{ id: "layout.spellcheckDefault", type: "int" },
{ id: "accessibility.tabfocus", type: "int" },
{
id: "browser.preferences.defaultPerformanceSettings.enabled",
@@ -725,6 +726,14 @@ var gMainPane = {
document.getElementById("defaultFont"),
element => FontBuilder.readFontSelection(element)
);
Preferences.addSyncFromPrefListener(
document.getElementById("useFullKeyboardNavigation"),
() => this.readUseFullKeyboardNavigation()
);
Preferences.addSyncToPrefListener(
document.getElementById("useFullKeyboardNavigation"),
() => this.writeUseFullKeyboardNavigation()
);
Preferences.addSyncFromPrefListener(
document.getElementById("checkSpelling"),
() => this.readCheckSpelling()
@@ -2181,6 +2190,50 @@ var gMainPane = {
migrationWizardDialog.showModal();
},
/**
* Stores the original value of the tabfocus preference to enable proper
* restoration if unchanged (since we're mapping an int pref onto a checkbox).
*/
_storedFullKeyboardNavigation: Preferences.get("accessibility.tabfocus"),
/**
* Returns true if any full keyboard nav is enabled and false otherwise, caching
* the current value to enable proper pref restoration if the checkbox is
* never changed.
*
* accessibility.tabfocus
* - an integer controlling the focusability of:
* 1 text controls
* 2 form elements
* 4 links
* 7 all of the above
*/
readUseFullKeyboardNavigation() {
var pref = Preferences.get("accessibility.tabfocus");
this._storedFullKeyboardNavigation = pref.value;
return pref.value == 7;
},
/**
* Returns the value of the full keyboard nav preference represented by UI,
* preserving the preference's "hidden" value if the preference is
* unchanged and represents a value not strictly allowed in UI.
*/
writeUseFullKeyboardNavigation() {
var checkbox = document.getElementById("useFullKeyboardNavigation");
if (checkbox.checked) {
return 7;
}
if (this._storedFullKeyboardNavigation != 7) {
// 1/2/4 values set via about:config should persist
return this._storedFullKeyboardNavigation;
}
// When the checkbox is unchecked, this pref shouldn't exist
// at all.
return undefined;
},
/**
* Stores the original value of the spellchecking preference to enable proper
* restoration if unchanged (since we're mapping a tristate onto a checkbox).