From ab02b9082755f5030f63f45cdac59844b88e8dcf Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Sun, 20 Jun 1999 09:11:25 +0000 Subject: [PATCH] When building a subtree from a template, nodes are now unique until we find one with the "uri='...'" attribute set. --- .../xul/templates/src/nsXULTemplateBuilder.cpp | 17 ++++++++++++----- rdf/content/src/nsRDFGenericBuilder.cpp | 17 ++++++++++++----- rdf/content/src/nsRDFGenericBuilder.h | 4 ++-- rdf/content/src/nsXULTemplateBuilder.cpp | 17 ++++++++++++----- 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index 08fd257e6f1..1d646b28f57 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -912,7 +912,7 @@ RDFGenericBuilderImpl::FindTemplateForResource(nsIRDFResource *aNode, nsIContent NS_IMETHODIMP RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIContent *aTemplate, - nsIContent *treeChildren, nsIContent* aElement, nsIRDFResource* aProperty, + nsIContent *treeChildren, nsIContent* aElement, PRBool isUnique, nsIRDFResource* aProperty, nsIRDFResource* aValue, PRInt32 aNaturalOrderPos) { PRInt32 count; @@ -939,6 +939,7 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (idValue.EqualsIgnoreCase("...")) { isContainmentElement = PR_TRUE; + isUnique=PR_FALSE; } } } @@ -947,7 +948,13 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (NS_SUCCEEDED(rv = aTemplateKid->GetTag(*getter_AddRefs(tag)))) { nsCOMPtr treeGrandchild; - if (isContainmentElement == PR_TRUE) + if (isUnique == PR_TRUE) + { + if (NS_FAILED(rv = EnsureElementHasGenericChild(treeChildren, + nameSpaceID, tag, getter_AddRefs(treeGrandchild)))) + continue; + } + else if (isContainmentElement == PR_TRUE) { if (NS_FAILED(rv = CreateElement(nameSpaceID, tag, aValue, getter_AddRefs(treeGrandchild)))) @@ -1154,7 +1161,7 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (numTemplateKids > 0) { rv = PopulateWidgetItemSubtree(aTemplateRoot, aTemplateKid, treeGrandchild, - aElement, aProperty, aValue, aNaturalOrderPos); + aElement, isUnique, aProperty, aValue, aNaturalOrderPos); } } @@ -1244,8 +1251,8 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aP } } } - rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children, - aElement, aProperty, aValue, aNaturalOrderPos); + rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children, aElement, + PR_TRUE, aProperty, aValue, aNaturalOrderPos); } else { diff --git a/rdf/content/src/nsRDFGenericBuilder.cpp b/rdf/content/src/nsRDFGenericBuilder.cpp index 08fd257e6f1..1d646b28f57 100644 --- a/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/rdf/content/src/nsRDFGenericBuilder.cpp @@ -912,7 +912,7 @@ RDFGenericBuilderImpl::FindTemplateForResource(nsIRDFResource *aNode, nsIContent NS_IMETHODIMP RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIContent *aTemplate, - nsIContent *treeChildren, nsIContent* aElement, nsIRDFResource* aProperty, + nsIContent *treeChildren, nsIContent* aElement, PRBool isUnique, nsIRDFResource* aProperty, nsIRDFResource* aValue, PRInt32 aNaturalOrderPos) { PRInt32 count; @@ -939,6 +939,7 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (idValue.EqualsIgnoreCase("...")) { isContainmentElement = PR_TRUE; + isUnique=PR_FALSE; } } } @@ -947,7 +948,13 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (NS_SUCCEEDED(rv = aTemplateKid->GetTag(*getter_AddRefs(tag)))) { nsCOMPtr treeGrandchild; - if (isContainmentElement == PR_TRUE) + if (isUnique == PR_TRUE) + { + if (NS_FAILED(rv = EnsureElementHasGenericChild(treeChildren, + nameSpaceID, tag, getter_AddRefs(treeGrandchild)))) + continue; + } + else if (isContainmentElement == PR_TRUE) { if (NS_FAILED(rv = CreateElement(nameSpaceID, tag, aValue, getter_AddRefs(treeGrandchild)))) @@ -1154,7 +1161,7 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (numTemplateKids > 0) { rv = PopulateWidgetItemSubtree(aTemplateRoot, aTemplateKid, treeGrandchild, - aElement, aProperty, aValue, aNaturalOrderPos); + aElement, isUnique, aProperty, aValue, aNaturalOrderPos); } } @@ -1244,8 +1251,8 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aP } } } - rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children, - aElement, aProperty, aValue, aNaturalOrderPos); + rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children, aElement, + PR_TRUE, aProperty, aValue, aNaturalOrderPos); } else { diff --git a/rdf/content/src/nsRDFGenericBuilder.h b/rdf/content/src/nsRDFGenericBuilder.h index 0aab95c7788..dcf152d91ff 100644 --- a/rdf/content/src/nsRDFGenericBuilder.h +++ b/rdf/content/src/nsRDFGenericBuilder.h @@ -70,8 +70,8 @@ public: NS_IMETHOD FindTemplateForResource(nsIRDFResource *aNode, nsIContent **theTemplate); NS_IMETHOD IsTemplateRuleMatch(nsIRDFResource *aNode, nsIContent *aRule, PRBool *matchingRuleFound); NS_IMETHOD PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIContent *aTemplate, - nsIContent *treeCell, nsIContent* aElement, nsIRDFResource* aProperty, - nsIRDFResource* aValue, PRInt32 aNaturalOrderPos); + nsIContent *treeCell, nsIContent* aElement, PRBool isUnique, + nsIRDFResource* aProperty, nsIRDFResource* aValue, PRInt32 aNaturalOrderPos); NS_IMETHOD CreateWidgetItem(nsIContent* aElement, nsIRDFResource* aProperty, nsIRDFResource* aValue, PRInt32 aNaturalOrderPos); diff --git a/rdf/content/src/nsXULTemplateBuilder.cpp b/rdf/content/src/nsXULTemplateBuilder.cpp index 08fd257e6f1..1d646b28f57 100644 --- a/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/rdf/content/src/nsXULTemplateBuilder.cpp @@ -912,7 +912,7 @@ RDFGenericBuilderImpl::FindTemplateForResource(nsIRDFResource *aNode, nsIContent NS_IMETHODIMP RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIContent *aTemplate, - nsIContent *treeChildren, nsIContent* aElement, nsIRDFResource* aProperty, + nsIContent *treeChildren, nsIContent* aElement, PRBool isUnique, nsIRDFResource* aProperty, nsIRDFResource* aValue, PRInt32 aNaturalOrderPos) { PRInt32 count; @@ -939,6 +939,7 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (idValue.EqualsIgnoreCase("...")) { isContainmentElement = PR_TRUE; + isUnique=PR_FALSE; } } } @@ -947,7 +948,13 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (NS_SUCCEEDED(rv = aTemplateKid->GetTag(*getter_AddRefs(tag)))) { nsCOMPtr treeGrandchild; - if (isContainmentElement == PR_TRUE) + if (isUnique == PR_TRUE) + { + if (NS_FAILED(rv = EnsureElementHasGenericChild(treeChildren, + nameSpaceID, tag, getter_AddRefs(treeGrandchild)))) + continue; + } + else if (isContainmentElement == PR_TRUE) { if (NS_FAILED(rv = CreateElement(nameSpaceID, tag, aValue, getter_AddRefs(treeGrandchild)))) @@ -1154,7 +1161,7 @@ RDFGenericBuilderImpl::PopulateWidgetItemSubtree(nsIContent *aTemplateRoot, nsIC if (numTemplateKids > 0) { rv = PopulateWidgetItemSubtree(aTemplateRoot, aTemplateKid, treeGrandchild, - aElement, aProperty, aValue, aNaturalOrderPos); + aElement, isUnique, aProperty, aValue, aNaturalOrderPos); } } @@ -1244,8 +1251,8 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aP } } } - rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children, - aElement, aProperty, aValue, aNaturalOrderPos); + rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children, aElement, + PR_TRUE, aProperty, aValue, aNaturalOrderPos); } else {