зеркало из https://github.com/mozilla/gecko-dev.git
Bug 997570 - Trigger onsyncfrompreference handlers during construction of <preferences> tag. r=MattN
This commit is contained in:
Родитель
5a769cb72b
Коммит
70d7281537
|
@ -30,6 +30,25 @@
|
|||
|
||||
<binding id="preferences">
|
||||
<implementation implements="nsIObserver">
|
||||
<method name="_constructAfterChildren">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// This method will be called after each one of the child
|
||||
// <preference> elements is constructed. Its purpose is to propagate
|
||||
// the values to the associated form elements
|
||||
|
||||
var elements = this.getElementsByTagName("preference");
|
||||
for (let element of elements) {
|
||||
if (!element._constructed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (let element of elements) {
|
||||
element.updateElements();
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="observe">
|
||||
<parameter name="aSubject"/>
|
||||
<parameter name="aTopic"/>
|
||||
|
@ -101,6 +120,8 @@
|
|||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this._constructed = true;
|
||||
|
||||
// if the element has been inserted without the name attribute set,
|
||||
// we have nothing to do here
|
||||
if (!this.name)
|
||||
|
@ -126,18 +147,20 @@
|
|||
preference = parentPrefs[l];
|
||||
}
|
||||
}
|
||||
this._setValue(preference ? preference.value
|
||||
: this.valueFromPreferences, false);
|
||||
|
||||
// Don't use the value setter here, we don't want updateElements to be prematurely fired.
|
||||
this._value = preference ? preference.value : this.valueFromPreferences;
|
||||
}
|
||||
else
|
||||
this._setValue(this.valueFromPreferences, false);
|
||||
this._value = this.valueFromPreferences;
|
||||
this.preferences._constructAfterChildren();
|
||||
]]>
|
||||
</constructor>
|
||||
<destructor>
|
||||
this.preferences.rootBranchInternal
|
||||
.removeObserver(this.name, this.preferences);
|
||||
</destructor>
|
||||
|
||||
<field name="_constructed">false</field>
|
||||
<property name="instantApply">
|
||||
<getter>
|
||||
return this.getAttribute("instantApply") == "true" || this.preferences.instantApply;
|
||||
|
@ -169,24 +192,19 @@
|
|||
<field name="_value">null</field>
|
||||
<method name="_setValue">
|
||||
<parameter name="aValue"/>
|
||||
<parameter name="aUpdate"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (aUpdate && this.value !== aValue) {
|
||||
if (this.value !== aValue) {
|
||||
this._value = aValue;
|
||||
if (this.instantApply)
|
||||
this.valueFromPreferences = aValue;
|
||||
this.preferences.fireChangedEvent(this);
|
||||
}
|
||||
else if (!aUpdate) {
|
||||
this._value = aValue;
|
||||
this.updateElements();
|
||||
}
|
||||
return aValue;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<property name="value" onget="return this._value" onset="return this._setValue(val, true);"/>
|
||||
<property name="value" onget="return this._value" onset="return this._setValue(val);"/>
|
||||
|
||||
<property name="locked">
|
||||
<getter>
|
||||
|
|
Загрузка…
Ссылка в новой задаче