Bug 397225 - Feed preview is borken. r=gavin.

This commit is contained in:
mozilla.mano@sent.com 2007-09-29 20:40:05 -07:00
Родитель 55c3b477a2
Коммит 33ffa177cc
1 изменённых файлов: 46 добавлений и 14 удалений

Просмотреть файл

@ -47,7 +47,7 @@
</handler> </handler>
</handlers> </handlers>
<implementation implements="nsIDOMXULMenuListElement, nsIAccessibleProvider"> <implementation implements="nsIDOMXULMenuListElement, nsIAccessibleProvider, nsIDOMEventListener">
<constructor> <constructor>
this.setInitialSelection() this.setInitialSelection()
</constructor> </constructor>
@ -189,10 +189,14 @@
if (oldval) { if (oldval) {
oldval.removeAttribute('selected'); oldval.removeAttribute('selected');
document.removeBroadcastListenerFor(oldval, this, "value"); if (document instanceof Components.interfaces.nsIDOMXULDocument) {
document.removeBroadcastListenerFor(oldval, this, "label"); document.removeBroadcastListenerFor(oldval, this, "value");
document.removeBroadcastListenerFor(oldval, this, "image"); document.removeBroadcastListenerFor(oldval, this, "label");
document.removeBroadcastListenerFor(oldval, this, "description"); document.removeBroadcastListenerFor(oldval, this, "image");
document.removeBroadcastListenerFor(oldval, this, "description");
}
else
oldval.removeEventListener("DOMAttrModified", this, false);
} }
this.mSelectedInternal = val; this.mSelectedInternal = val;
@ -202,10 +206,16 @@
this.setAttribute('image', val.getAttribute('image')); this.setAttribute('image', val.getAttribute('image'));
this.setAttribute('label', val.getAttribute('label')); this.setAttribute('label', val.getAttribute('label'));
this.setAttribute('description', val.getAttribute('description')); this.setAttribute('description', val.getAttribute('description'));
document.addBroadcastListenerFor(val, this, "value"); // DOMAttrModified listeners slow down setAttribute calls within
document.addBroadcastListenerFor(val, this, "label"); // the document, see bug 395496
document.addBroadcastListenerFor(val, this, "image"); if (document instanceof Components.interfaces.nsIDOMXULDocument) {
document.addBroadcastListenerFor(val, this, "description"); document.addBroadcastListenerFor(val, this, "value");
document.addBroadcastListenerFor(val, this, "label");
document.addBroadcastListenerFor(val, this, "image");
document.addBroadcastListenerFor(val, this, "description");
}
else
val.addEventListener("DOMAttrModified", this, false);
} }
else { else {
this.removeAttribute('value'); this.removeAttribute('value');
@ -227,6 +237,25 @@
</setter> </setter>
</property> </property>
<method name="handleEvent">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (aEvent.type == "DOMAttrModified" &&
aEvent.target == this.mSelectedInternal) {
var attrName = aEvent.attrName;
switch (attrName) {
case "value":
case "label":
case "image":
case "description":
this.setAttribute(attrName, aEvent.newValue);
}
}
]]>
</body>
</method>
<method name="getIndexOfItem"> <method name="getIndexOfItem">
<parameter name="item"/> <parameter name="item"/>
<body> <body>
@ -345,11 +374,14 @@
<destructor> <destructor>
<![CDATA[ <![CDATA[
if (this.mSelectedInternal) { if (this.mSelectedInternal) {
document.removeBroadcastListenerFor(this.mSelectedInternal, this, "value"); if (document instanceof Components.interfaces.nsIDOMXULDocument) {
document.removeBroadcastListenerFor(this.mSelectedInternal, this, "label"); document.removeBroadcastListenerFor(this.mSelectedInternal, this, "value");
document.removeBroadcastListenerFor(this.mSelectedInternal, this, "image"); document.removeBroadcastListenerFor(this.mSelectedInternal, this, "label");
document.removeBroadcastListenerFor(this.mSelectedInternal, this, "description"); document.removeBroadcastListenerFor(this.mSelectedInternal, this, "image");
document.removeBroadcastListenerFor(this.mSelectedInternal, this, "description");
}
else
this.mSelectedInternal.removeEventListener("DOMAttrModified", this, false);
} }
]]> ]]>
</destructor> </destructor>