Bug 26402, try number two. Do event handler recompilation and 'style' attribute fixup in nsXULElement::SetDocument(). Fix uninitialized out params in nsXULElement::GetAttribute() and nsXULElement::GetClasses().

This commit is contained in:
waterson%netscape.com 2000-04-03 05:36:17 +00:00
parent 3dfcdc8d37
commit ea9019498e
4 changed files with 86 additions and 80 deletions

View File

@ -2226,6 +2226,41 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
}
}
}
PRInt32 count;
GetAttributeCount(count);
for (PRInt32 i = 0; i < count; ++i) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attr;
GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr));
PRBool reset = PR_FALSE;
if (nameSpaceID == kNameSpaceID_None) {
nsIID iid;
rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset);
if (NS_FAILED(rv)) return rv;
if (! reset) {
if ((attr.get() == kPopupAtom) ||
(attr.get() == kTooltipAtom) ||
(attr.get() == kContextAtom) ||
(attr.get() == kStyleAtom)) {
reset = PR_TRUE;
}
}
}
if (reset) {
nsAutoString value;
rv = GetAttribute(nameSpaceID, attr, value);
if (NS_FAILED(rv)) return rv;
rv = SetAttribute(nameSpaceID, attr, value, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
}
}
@ -2830,6 +2865,10 @@ nsXULElement::GetAttribute(PRInt32 aNameSpaceID,
}
}
}
else {
aResult.Truncate();
}
return rv;
}
@ -3799,6 +3838,9 @@ nsXULElement::GetClasses(nsVoidArray& aArray) const
else if (mPrototype) {
rv = nsClassList::GetClasses(mPrototype->mClassList, aArray);
}
else {
aArray.Clear();
}
return rv;
}

View File

@ -2826,46 +2826,7 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aElement)
if (NS_FAILED(rv)) return rv;
}
// 4. See if we've got any 'special' attributes that are
// document-specific, and need extra work to be done.
{
PRInt32 count;
aElement->GetAttributeCount(count);
for (PRInt32 i = 0; i < count; ++i) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attr;
aElement->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr));
PRBool reset = PR_FALSE;
if (nameSpaceID == kNameSpaceID_None) {
nsIID iid;
rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset);
if (NS_FAILED(rv)) return rv;
if (! reset) {
if ((attr.get() == kPopupAtom) ||
(attr.get() == kTooltipAtom) ||
(attr.get() == kContextAtom) ||
(attr.get() == kStyleAtom)) {
reset = PR_TRUE;
}
}
}
if (reset) {
nsAutoString value;
rv = aElement->GetAttribute(nameSpaceID, attr, value);
if (NS_FAILED(rv)) return rv;
rv = aElement->SetAttribute(nameSpaceID, attr, value, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
}
// 5. Recurse to children.
// 4. Recurse to children.
PRInt32 count;
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count);

View File

@ -2826,46 +2826,7 @@ nsXULDocument::AddSubtreeToDocument(nsIContent* aElement)
if (NS_FAILED(rv)) return rv;
}
// 4. See if we've got any 'special' attributes that are
// document-specific, and need extra work to be done.
{
PRInt32 count;
aElement->GetAttributeCount(count);
for (PRInt32 i = 0; i < count; ++i) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attr;
aElement->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr));
PRBool reset = PR_FALSE;
if (nameSpaceID == kNameSpaceID_None) {
nsIID iid;
rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset);
if (NS_FAILED(rv)) return rv;
if (! reset) {
if ((attr.get() == kPopupAtom) ||
(attr.get() == kTooltipAtom) ||
(attr.get() == kContextAtom) ||
(attr.get() == kStyleAtom)) {
reset = PR_TRUE;
}
}
}
if (reset) {
nsAutoString value;
rv = aElement->GetAttribute(nameSpaceID, attr, value);
if (NS_FAILED(rv)) return rv;
rv = aElement->SetAttribute(nameSpaceID, attr, value, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
}
// 5. Recurse to children.
// 4. Recurse to children.
PRInt32 count;
nsCOMPtr<nsIXULContent> xulcontent = do_QueryInterface(aElement);
rv = xulcontent ? xulcontent->PeekChildCount(count) : aElement->ChildCount(count);

View File

@ -2226,6 +2226,41 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep)
}
}
}
PRInt32 count;
GetAttributeCount(count);
for (PRInt32 i = 0; i < count; ++i) {
PRInt32 nameSpaceID;
nsCOMPtr<nsIAtom> attr;
GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr));
PRBool reset = PR_FALSE;
if (nameSpaceID == kNameSpaceID_None) {
nsIID iid;
rv = gXULUtils->GetEventHandlerIID(attr, &iid, &reset);
if (NS_FAILED(rv)) return rv;
if (! reset) {
if ((attr.get() == kPopupAtom) ||
(attr.get() == kTooltipAtom) ||
(attr.get() == kContextAtom) ||
(attr.get() == kStyleAtom)) {
reset = PR_TRUE;
}
}
}
if (reset) {
nsAutoString value;
rv = GetAttribute(nameSpaceID, attr, value);
if (NS_FAILED(rv)) return rv;
rv = SetAttribute(nameSpaceID, attr, value, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
}
}
}
@ -2830,6 +2865,10 @@ nsXULElement::GetAttribute(PRInt32 aNameSpaceID,
}
}
}
else {
aResult.Truncate();
}
return rv;
}
@ -3799,6 +3838,9 @@ nsXULElement::GetClasses(nsVoidArray& aArray) const
else if (mPrototype) {
rv = nsClassList::GetClasses(mPrototype->mClassList, aArray);
}
else {
aArray.Clear();
}
return rv;
}