зеркало из https://github.com/mozilla/pjs.git
Fix for 95422. r/sr=the usuals (brendan et al)
This commit is contained in:
Родитель
ac1917f502
Коммит
918eb7c220
|
@ -643,59 +643,61 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceI
|
||||||
nsCOMPtr<nsIContent> realElement;
|
nsCOMPtr<nsIContent> realElement;
|
||||||
LocateInstance(aChangedElement, content, aAnonymousContent, element, getter_AddRefs(realElement));
|
LocateInstance(aChangedElement, content, aAnonymousContent, element, getter_AddRefs(realElement));
|
||||||
|
|
||||||
xblAttr->GetDstAttribute(getter_AddRefs(dstAttr));
|
if (realElement) {
|
||||||
|
xblAttr->GetDstAttribute(getter_AddRefs(dstAttr));
|
||||||
|
|
||||||
if (aRemoveFlag)
|
if (aRemoveFlag)
|
||||||
realElement->UnsetAttr(aNameSpaceID, dstAttr, PR_TRUE);
|
realElement->UnsetAttr(aNameSpaceID, dstAttr, PR_TRUE);
|
||||||
else {
|
|
||||||
PRBool attrPresent = PR_TRUE;
|
|
||||||
nsAutoString value;
|
|
||||||
// Check to see if the src attribute is xbl:text. If so, then we need to obtain the
|
|
||||||
// children of the real element and get the text nodes' values.
|
|
||||||
if (aAttribute == kXBLTextAtom) {
|
|
||||||
nsXBLBinding::GetTextData(aChangedElement, value);
|
|
||||||
value.StripChar('\n');
|
|
||||||
value.StripChar('\r');
|
|
||||||
nsAutoString stripVal(value);
|
|
||||||
stripVal.StripWhitespace();
|
|
||||||
if (stripVal.IsEmpty())
|
|
||||||
attrPresent = PR_FALSE;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
nsresult result = aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
|
PRBool attrPresent = PR_TRUE;
|
||||||
attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||
|
nsAutoString value;
|
||||||
result == NS_CONTENT_ATTR_HAS_VALUE);
|
// Check to see if the src attribute is xbl:text. If so, then we need to obtain the
|
||||||
|
// children of the real element and get the text nodes' values.
|
||||||
|
if (aAttribute == kXBLTextAtom) {
|
||||||
|
nsXBLBinding::GetTextData(aChangedElement, value);
|
||||||
|
value.StripChar('\n');
|
||||||
|
value.StripChar('\r');
|
||||||
|
nsAutoString stripVal(value);
|
||||||
|
stripVal.StripWhitespace();
|
||||||
|
if (stripVal.IsEmpty())
|
||||||
|
attrPresent = PR_FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nsresult result = aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
|
||||||
|
attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||
|
||||||
|
result == NS_CONTENT_ATTR_HAS_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attrPresent)
|
||||||
|
realElement->SetAttr(aNameSpaceID, dstAttr, value, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrPresent)
|
// See if we're the <html> tag in XUL, and see if value is being
|
||||||
realElement->SetAttr(aNameSpaceID, dstAttr, value, PR_TRUE);
|
// set or unset on us. We may also be a tag that is having
|
||||||
}
|
// xbl:text set on us.
|
||||||
|
nsCOMPtr<nsIAtom> tag;
|
||||||
// See if we're the <html> tag in XUL, and see if value is being
|
realElement->GetTag(*getter_AddRefs(tag));
|
||||||
// set or unset on us. We may also be a tag that is having
|
if (dstAttr.get() == kXBLTextAtom || (tag.get() == kHTMLAtom) && (dstAttr.get() == kValueAtom)) {
|
||||||
// xbl:text set on us.
|
// Flush out all our kids.
|
||||||
nsCOMPtr<nsIAtom> tag;
|
PRInt32 childCount;
|
||||||
realElement->GetTag(*getter_AddRefs(tag));
|
realElement->ChildCount(childCount);
|
||||||
if (dstAttr.get() == kXBLTextAtom || (tag.get() == kHTMLAtom) && (dstAttr.get() == kValueAtom)) {
|
for (PRInt32 i = 0; i < childCount; i++)
|
||||||
// Flush out all our kids.
|
realElement->RemoveChildAt(0, PR_TRUE);
|
||||||
PRInt32 childCount;
|
|
||||||
realElement->ChildCount(childCount);
|
|
||||||
for (PRInt32 i = 0; i < childCount; i++)
|
|
||||||
realElement->RemoveChildAt(0, PR_TRUE);
|
|
||||||
|
|
||||||
if (!aRemoveFlag) {
|
if (!aRemoveFlag) {
|
||||||
// Construct a new text node and insert it.
|
// Construct a new text node and insert it.
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
|
aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
|
||||||
if (!value.IsEmpty()) {
|
if (!value.IsEmpty()) {
|
||||||
nsCOMPtr<nsIDOMText> textNode;
|
nsCOMPtr<nsIDOMText> textNode;
|
||||||
nsCOMPtr<nsIDocument> doc;
|
nsCOMPtr<nsIDocument> doc;
|
||||||
aChangedElement->GetDocument(*getter_AddRefs(doc));
|
aChangedElement->GetDocument(*getter_AddRefs(doc));
|
||||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
|
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
|
||||||
domDoc->CreateTextNode(value, getter_AddRefs(textNode));
|
domDoc->CreateTextNode(value, getter_AddRefs(textNode));
|
||||||
nsCOMPtr<nsIDOMNode> dummy;
|
nsCOMPtr<nsIDOMNode> dummy;
|
||||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(realElement));
|
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(realElement));
|
||||||
domElement->AppendChild(textNode, getter_AddRefs(dummy));
|
domElement->AppendChild(textNode, getter_AddRefs(dummy));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче