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)) {