зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1563552 (part 2) - remove support for the 'name' attribute from preferencesBindings.js. r=myk,jaws
Depends on D38828 Differential Revision: https://phabricator.services.mozilla.com/D38829 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a9ebcb636e
Коммит
934f15044e
|
@ -344,7 +344,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
window.addEventListener("unload", Preferences, { once: true });
|
||||
|
||||
class Preference extends EventEmitter {
|
||||
constructor({ id, name, type, inverted, disabled }) {
|
||||
constructor({ id, type, inverted, disabled }) {
|
||||
super();
|
||||
this.on("change", this.onChange.bind(this));
|
||||
|
||||
|
@ -354,17 +354,10 @@ const Preferences = (window.Preferences = (function() {
|
|||
this.batching = false;
|
||||
|
||||
this.id = id;
|
||||
this._name = name || this.id;
|
||||
this.type = type;
|
||||
this.inverted = !!inverted;
|
||||
this._disabled = !!disabled;
|
||||
|
||||
// if the element has been inserted without the name attribute set,
|
||||
// we have nothing to do here
|
||||
if (!this.name) {
|
||||
throw new Error(`preference with id '${id}' doesn't have name`);
|
||||
}
|
||||
|
||||
// In non-instant apply mode, we must try and use the last saved state
|
||||
// from any previous opens of a child dialog instead of the value from
|
||||
// preferences, to pick up any edits a user may have made.
|
||||
|
@ -376,7 +369,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
window.opener.document.nodePrincipal.isSystemPrincipal
|
||||
) {
|
||||
// Try to find the preference in the parent window.
|
||||
const preference = window.opener.Preferences.get(this.name);
|
||||
const preference = window.opener.Preferences.get(this.id);
|
||||
|
||||
// Don't use the value setter here, we don't want updateElements to be
|
||||
// prematurely fired.
|
||||
|
@ -392,9 +385,9 @@ const Preferences = (window.Preferences = (function() {
|
|||
}
|
||||
|
||||
_reportUnknownType() {
|
||||
const msg = `Preference with id=${this.id} and name=${
|
||||
this.name
|
||||
} has unknown type ${this.type}.`;
|
||||
const msg = `Preference with id=${this.id} has unknown type ${
|
||||
this.type
|
||||
}.`;
|
||||
Services.console.logStringMessage(msg);
|
||||
}
|
||||
|
||||
|
@ -530,20 +523,6 @@ const Preferences = (window.Preferences = (function() {
|
|||
this.updateElements();
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
set name(val) {
|
||||
if (val == this.name) {
|
||||
return val;
|
||||
}
|
||||
|
||||
this._name = val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
@ -560,7 +539,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
}
|
||||
|
||||
get locked() {
|
||||
return Services.prefs.prefIsLocked(this.name);
|
||||
return Services.prefs.prefIsLocked(this.id);
|
||||
}
|
||||
|
||||
get disabled() {
|
||||
|
@ -589,7 +568,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
|
||||
get hasUserValue() {
|
||||
return (
|
||||
Services.prefs.prefHasUserValue(this.name) && this.value !== undefined
|
||||
Services.prefs.prefHasUserValue(this.id) && this.value !== undefined
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -609,28 +588,28 @@ const Preferences = (window.Preferences = (function() {
|
|||
// Force a resync of value with preferences.
|
||||
switch (this.type) {
|
||||
case "int":
|
||||
return this._branch.getIntPref(this.name);
|
||||
return this._branch.getIntPref(this.id);
|
||||
case "bool": {
|
||||
const val = this._branch.getBoolPref(this.name);
|
||||
const val = this._branch.getBoolPref(this.id);
|
||||
return this.inverted ? !val : val;
|
||||
}
|
||||
case "wstring":
|
||||
return this._branch.getComplexValue(
|
||||
this.name,
|
||||
this.id,
|
||||
Ci.nsIPrefLocalizedString
|
||||
).data;
|
||||
case "string":
|
||||
case "unichar":
|
||||
return this._branch.getStringPref(this.name);
|
||||
return this._branch.getStringPref(this.id);
|
||||
case "fontname": {
|
||||
const family = this._branch.getStringPref(this.name);
|
||||
const family = this._branch.getStringPref(this.id);
|
||||
const fontEnumerator = Cc[
|
||||
"@mozilla.org/gfx/fontenumerator;1"
|
||||
].createInstance(Ci.nsIFontEnumerator);
|
||||
return fontEnumerator.getStandardFamilyName(family);
|
||||
}
|
||||
case "file": {
|
||||
const f = this._branch.getComplexValue(this.name, Ci.nsIFile);
|
||||
const f = this._branch.getComplexValue(this.id, Ci.nsIFile);
|
||||
return f;
|
||||
}
|
||||
default:
|
||||
|
@ -648,17 +627,17 @@ const Preferences = (window.Preferences = (function() {
|
|||
|
||||
// The special value undefined means 'reset preference to default'.
|
||||
if (val === undefined) {
|
||||
Services.prefs.clearUserPref(this.name);
|
||||
Services.prefs.clearUserPref(this.id);
|
||||
return val;
|
||||
}
|
||||
|
||||
// Force a resync of preferences with value.
|
||||
switch (this.type) {
|
||||
case "int":
|
||||
Services.prefs.setIntPref(this.name, val);
|
||||
Services.prefs.setIntPref(this.id, val);
|
||||
break;
|
||||
case "bool":
|
||||
Services.prefs.setBoolPref(this.name, this.inverted ? !val : val);
|
||||
Services.prefs.setBoolPref(this.id, this.inverted ? !val : val);
|
||||
break;
|
||||
case "wstring": {
|
||||
const pls = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
|
||||
|
@ -666,7 +645,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
);
|
||||
pls.data = val;
|
||||
Services.prefs.setComplexValue(
|
||||
this.name,
|
||||
this.id,
|
||||
Ci.nsIPrefLocalizedString,
|
||||
pls
|
||||
);
|
||||
|
@ -675,7 +654,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
case "string":
|
||||
case "unichar":
|
||||
case "fontname":
|
||||
Services.prefs.setStringPref(this.name, val);
|
||||
Services.prefs.setStringPref(this.id, val);
|
||||
break;
|
||||
case "file": {
|
||||
let lf;
|
||||
|
@ -688,7 +667,7 @@ const Preferences = (window.Preferences = (function() {
|
|||
} else {
|
||||
lf = val.QueryInterface(Ci.nsIFile);
|
||||
}
|
||||
Services.prefs.setComplexValue(this.name, Ci.nsIFile, lf);
|
||||
Services.prefs.setComplexValue(this.id, Ci.nsIFile, lf);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
Загрузка…
Ссылка в новой задаче