From 04bb11a37ae554b0cf0942299fdcb7c4d8d32f3e Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Sun, 20 Jun 1999 05:45:40 +0000 Subject: [PATCH] Fix bug #8465 by starting at the parent of the node which is about to be inserted when looking for the "ignore" attribute. Also, save the "id" of the template node used to create node... in preparation for getting onAssert() and onUnassert() working fully with templates. git-svn-id: svn://10.0.0.236/trunk@35970 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xul/templates/src/nsXULTemplateBuilder.cpp | 13 ++++++++++--- mozilla/rdf/content/src/nsRDFGenericBuilder.cpp | 13 ++++++++++--- mozilla/rdf/content/src/nsRDFGenericBuilder.h | 2 +- mozilla/rdf/content/src/nsXULTemplateBuilder.cpp | 13 ++++++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index fda739e5c7f..08fd257e6f1 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -653,7 +653,7 @@ RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID, NS_IMETHODIMP -RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResource *res) +RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aParentNode, nsIContent *aNode, nsIRDFResource *res) { // get all arcs out, and if not a containment property, set attribute nsresult rv = NS_OK; @@ -680,7 +680,8 @@ RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResour } // Ignore any properties set in ignore attribute - if (IsIgnoredProperty(aNode, property)) + // Note: since node isn't in the content model yet, start with its parent + if (IsIgnoredProperty(aParentNode, property)) { continue; } @@ -951,8 +952,14 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (NS_FAILED(rv = CreateElement(nameSpaceID, tag, aValue, getter_AddRefs(treeGrandchild)))) continue; - if (NS_FAILED(rv = SetAllAttributesOnElement(treeGrandchild, aValue))) + if (NS_FAILED(rv = SetAllAttributesOnElement(treeChildren, + treeGrandchild, aValue))) continue; + + // save a reference (its ID) to the template node that was used + nsAutoString templateID(""); + aTemplateKid->GetAttribute(kNameSpaceID_None, kIdAtom, templateID); + treeGrandchild->SetAttribute(kNameSpaceID_None, kTreeTemplateAtom, templateID, PR_FALSE); } else if ((tag.get() == kTextAtom) && (nameSpaceID == kNameSpaceID_XUL)) { diff --git a/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp b/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp index fda739e5c7f..08fd257e6f1 100644 --- a/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/mozilla/rdf/content/src/nsRDFGenericBuilder.cpp @@ -653,7 +653,7 @@ RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID, NS_IMETHODIMP -RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResource *res) +RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aParentNode, nsIContent *aNode, nsIRDFResource *res) { // get all arcs out, and if not a containment property, set attribute nsresult rv = NS_OK; @@ -680,7 +680,8 @@ RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResour } // Ignore any properties set in ignore attribute - if (IsIgnoredProperty(aNode, property)) + // Note: since node isn't in the content model yet, start with its parent + if (IsIgnoredProperty(aParentNode, property)) { continue; } @@ -951,8 +952,14 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (NS_FAILED(rv = CreateElement(nameSpaceID, tag, aValue, getter_AddRefs(treeGrandchild)))) continue; - if (NS_FAILED(rv = SetAllAttributesOnElement(treeGrandchild, aValue))) + if (NS_FAILED(rv = SetAllAttributesOnElement(treeChildren, + treeGrandchild, aValue))) continue; + + // save a reference (its ID) to the template node that was used + nsAutoString templateID(""); + aTemplateKid->GetAttribute(kNameSpaceID_None, kIdAtom, templateID); + treeGrandchild->SetAttribute(kNameSpaceID_None, kTreeTemplateAtom, templateID, PR_FALSE); } else if ((tag.get() == kTextAtom) && (nameSpaceID == kNameSpaceID_XUL)) { diff --git a/mozilla/rdf/content/src/nsRDFGenericBuilder.h b/mozilla/rdf/content/src/nsRDFGenericBuilder.h index c46b6dc8b11..0aab95c7788 100644 --- a/mozilla/rdf/content/src/nsRDFGenericBuilder.h +++ b/mozilla/rdf/content/src/nsRDFGenericBuilder.h @@ -66,7 +66,7 @@ public: nsIRDFResource* aResource, nsIContent** aResult); - NS_IMETHOD SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResource *res); + NS_IMETHOD SetAllAttributesOnElement(nsIContent *aParentNode, nsIContent *aNode, nsIRDFResource *res); NS_IMETHOD FindTemplateForResource(nsIRDFResource *aNode, nsIContent **theTemplate); NS_IMETHOD IsTemplateRuleMatch(nsIRDFResource *aNode, nsIContent *aRule, PRBool *matchingRuleFound); NS_IMETHOD PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIContent *aTemplate, diff --git a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp index fda739e5c7f..08fd257e6f1 100644 --- a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp @@ -653,7 +653,7 @@ RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID, NS_IMETHODIMP -RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResource *res) +RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aParentNode, nsIContent *aNode, nsIRDFResource *res) { // get all arcs out, and if not a containment property, set attribute nsresult rv = NS_OK; @@ -680,7 +680,8 @@ RDFGenericBuilderImpl::SetAllAttributesOnElement(nsIContent *aNode, nsIRDFResour } // Ignore any properties set in ignore attribute - if (IsIgnoredProperty(aNode, property)) + // Note: since node isn't in the content model yet, start with its parent + if (IsIgnoredProperty(aParentNode, property)) { continue; } @@ -951,8 +952,14 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (NS_FAILED(rv = CreateElement(nameSpaceID, tag, aValue, getter_AddRefs(treeGrandchild)))) continue; - if (NS_FAILED(rv = SetAllAttributesOnElement(treeGrandchild, aValue))) + if (NS_FAILED(rv = SetAllAttributesOnElement(treeChildren, + treeGrandchild, aValue))) continue; + + // save a reference (its ID) to the template node that was used + nsAutoString templateID(""); + aTemplateKid->GetAttribute(kNameSpaceID_None, kIdAtom, templateID); + treeGrandchild->SetAttribute(kNameSpaceID_None, kTreeTemplateAtom, templateID, PR_FALSE); } else if ((tag.get() == kTextAtom) && (nameSpaceID == kNameSpaceID_XUL)) {