зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1714428 - Add support for accessing color management prefs via WebExtensions. r=mixedpuppy,jaws
Differential Revision: https://phabricator.services.mozilla.com/D116769
This commit is contained in:
Родитель
b098bbdcc1
Коммит
198804c3db
|
@ -61,6 +61,31 @@ ExtensionPreferencesManager.addSetting("closeTabsByDoubleClick", {
|
|||
},
|
||||
});
|
||||
|
||||
ExtensionPreferencesManager.addSetting("colorManagement.mode", {
|
||||
permission: "browserSettings",
|
||||
prefNames: ["gfx.color_management.mode"],
|
||||
|
||||
setCallback(value) {
|
||||
switch (value) {
|
||||
case "off":
|
||||
return { [this.prefNames[0]]: 0 };
|
||||
case "full":
|
||||
return { [this.prefNames[0]]: 1 };
|
||||
case "tagged_only":
|
||||
return { [this.prefNames[0]]: 2 };
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
ExtensionPreferencesManager.addSetting("colorManagement.useNativeSRGB", {
|
||||
permission: "browserSettings",
|
||||
prefNames: ["gfx.color_management.native_srgb"],
|
||||
|
||||
setCallback(value) {
|
||||
return { [this.prefNames[0]]: value };
|
||||
},
|
||||
});
|
||||
|
||||
ExtensionPreferencesManager.addSetting("contextMenuShowEvent", {
|
||||
permission: "browserSettings",
|
||||
prefNames: ["ui.context_menus.after_mouseup"],
|
||||
|
@ -439,6 +464,31 @@ this.browserSettings = class extends ExtensionAPI {
|
|||
return Services.prefs.getBoolPref("browser.zoom.siteSpecific");
|
||||
},
|
||||
}),
|
||||
colorManagement: {
|
||||
mode: getSettingsAPI({
|
||||
context,
|
||||
name: "colorManagement.mode",
|
||||
callback() {
|
||||
switch (Services.prefs.getIntPref("gfx.color_management.mode")) {
|
||||
case 0:
|
||||
return "off";
|
||||
case 1:
|
||||
return "full";
|
||||
case 2:
|
||||
return "tagged_only";
|
||||
}
|
||||
},
|
||||
}),
|
||||
useNativeSRGB: getSettingsAPI({
|
||||
context,
|
||||
name: "colorManagement.useNativeSRGB",
|
||||
callback() {
|
||||
return Services.prefs.getBoolPref(
|
||||
"gfx.color_management.native_srgb"
|
||||
);
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
"type": "string",
|
||||
"enum": ["mouseup", "mousedown"],
|
||||
"description": "After which mouse event context menus should popup."
|
||||
},
|
||||
{
|
||||
"id": "ColorManagementMode",
|
||||
"type": "string",
|
||||
"enum": ["off", "full", "tagged_only"],
|
||||
"description": "Color management mode."
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
|
@ -108,5 +114,20 @@
|
|||
"description": "This boolean setting controls whether zoom is applied on a per-site basis or to the current tab only. If privacy.resistFingerprinting is true, this setting has no effect and zoom is applied to the current tab only."
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"namespace": "browserSettings.colorManagement",
|
||||
"description": "Use the <code>browserSettings.colorManagement</code> API to query and set items related to color management.",
|
||||
"permissions": ["browserSettings"],
|
||||
"properties": {
|
||||
"mode": {
|
||||
"$ref": "types.Setting",
|
||||
"description": "This setting controls the mode used for color management and must be a string from $(ref:browserSettings.ColorManagementMode)"
|
||||
},
|
||||
"useNativeSRGB": {
|
||||
"$ref": "types.Setting",
|
||||
"description": "This boolean setting controls whether or not native sRGB color management is used."
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -56,7 +56,11 @@ add_task(async function test_browser_settings() {
|
|||
async function background() {
|
||||
let listeners = new Set([]);
|
||||
browser.test.onMessage.addListener(async (msg, apiName, value) => {
|
||||
let apiObj = browser.browserSettings[apiName];
|
||||
let apiObj = browser.browserSettings;
|
||||
let apiNameSplit = apiName.split(".");
|
||||
for (let apiPart of apiNameSplit) {
|
||||
apiObj = apiObj[apiPart];
|
||||
}
|
||||
if (msg == "get") {
|
||||
browser.test.sendMessage("settingData", await apiObj.get({}));
|
||||
return;
|
||||
|
@ -288,6 +292,23 @@ add_task(async function test_browser_settings() {
|
|||
"browser.zoom.siteSpecific": false,
|
||||
});
|
||||
|
||||
await testSetting("colorManagement.mode", "off", {
|
||||
"gfx.color_management.mode": 0,
|
||||
});
|
||||
await testSetting("colorManagement.mode", "full", {
|
||||
"gfx.color_management.mode": 1,
|
||||
});
|
||||
await testSetting("colorManagement.mode", "tagged_only", {
|
||||
"gfx.color_management.mode": 2,
|
||||
});
|
||||
|
||||
await testSetting("colorManagement.useNativeSRGB", false, {
|
||||
"gfx.color_management.native_srgb": false,
|
||||
});
|
||||
await testSetting("colorManagement.useNativeSRGB", true, {
|
||||
"gfx.color_management.native_srgb": true,
|
||||
});
|
||||
|
||||
await extension.unload();
|
||||
await promiseShutdownManager();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче