From a4c33e24fa535d46b074851267ae6adb560b8a48 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Tue, 16 Nov 1999 05:34:13 +0000 Subject: [PATCH] Bug 10469. Remove 'natural order position' stuff. Make sure that nsXULSortService::InsertContainerNode() does the right thing when presented with an unsorted tree. r=rjc --- .../xul/templates/src/nsXULSortService.cpp | 40 ++++--------------- .../templates/src/nsXULTemplateBuilder.cpp | 36 ++++------------- rdf/content/src/nsRDFGenericBuilder.cpp | 36 ++++------------- rdf/content/src/nsXULSortService.cpp | 40 ++++--------------- rdf/content/src/nsXULTemplateBuilder.cpp | 36 ++++------------- 5 files changed, 38 insertions(+), 150 deletions(-) diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp index adb5ae6a3ec..4ebe34c7ce2 100644 --- a/content/xul/templates/src/nsXULSortService.cpp +++ b/content/xul/templates/src/nsXULSortService.cpp @@ -139,7 +139,6 @@ typedef struct _sortStruct { nsCOMPtr rdfService; nsCOMPtr mInner; nsCOMPtr resCache; - nsCOMPtr kNaturalOrderPosAtom; nsCOMPtr kTreeCellAtom; PRInt32 colIndex; PRInt32 kNameSpaceID_XUL; @@ -185,7 +184,6 @@ private: static nsIAtom *kSortResource2Atom; static nsIAtom *kSortDirectionAtom; static nsIAtom *kIdAtom; - static nsIAtom *kNaturalOrderPosAtom; static nsIAtom *kRDF_type; static nsIAtom *kURIAtom; @@ -254,7 +252,6 @@ nsIAtom* XULSortServiceImpl::kSortResourceAtom; nsIAtom* XULSortServiceImpl::kSortResource2Atom; nsIAtom* XULSortServiceImpl::kSortDirectionAtom; nsIAtom* XULSortServiceImpl::kIdAtom; -nsIAtom* XULSortServiceImpl::kNaturalOrderPosAtom; nsIAtom* XULSortServiceImpl::kRDF_type; nsIAtom* XULSortServiceImpl::kURIAtom; @@ -287,7 +284,6 @@ XULSortServiceImpl::XULSortServiceImpl(void) kSortResource2Atom = NS_NewAtom("sortResource2"); kSortDirectionAtom = NS_NewAtom("sortDirection"); kIdAtom = NS_NewAtom("id"); - kNaturalOrderPosAtom = NS_NewAtom("pos"); kRDF_type = NS_NewAtom("type"); kURIAtom = NS_NewAtom("uri"); @@ -394,7 +390,6 @@ XULSortServiceImpl::~XULSortServiceImpl(void) NS_IF_RELEASE(kSortResource2Atom); NS_IF_RELEASE(kSortDirectionAtom); NS_IF_RELEASE(kIdAtom); - NS_IF_RELEASE(kNaturalOrderPosAtom); NS_IF_RELEASE(kRDF_type); NS_IF_RELEASE(kURIAtom); NS_IF_RELEASE(kNC_Name); @@ -1179,10 +1174,6 @@ XULSortServiceImpl::GetNodeValue(nsIContent *node1, nsIRDFResource *sortProperty } } } - if (cellPosVal1.Length() == 0) - { - rv = node1->GetAttribute(kNameSpaceID_None, sortInfo->kNaturalOrderPosAtom, cellPosVal1); - } if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE)) { nsCOMPtr nodePosLiteral; @@ -1288,21 +1279,6 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, PRInt32 colIndex, so if (tag.get() == kTreeItemAtom) { childArray->AppendElement(child); - - // if no pos is specified, set one - nsAutoString pos; - if (NS_FAILED(rv = child->GetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos)) - || (rv != NS_CONTENT_ATTR_HAS_VALUE)) - { - nsAutoString zero("0000"); - pos = ""; - pos.Append(childIndex+1, 10); - if (pos.Length() < 4) - { - pos.Insert(zero, 0, 4-pos.Length()); - } - child->SetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos, PR_FALSE); - } } } } @@ -1438,7 +1414,6 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIConten sortInfo.resCache = nsnull; sortInfo.mInner = nsnull; sortInfo.colIndex = -1; - sortInfo.kNaturalOrderPosAtom = kNaturalOrderPosAtom; sortInfo.kTreeCellAtom = kTreeCellAtom; sortInfo.kNameSpaceID_XUL = kNameSpaceID_XUL; sortInfo.sortProperty = nsnull; @@ -1476,15 +1451,15 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIConten } } - if (sortInfoAvailable != PR_TRUE) - return(NS_ERROR_UNEXPECTED); - - rv = gRDFService->GetResource(nsCAutoString(sortResource), getter_AddRefs(sortInfo.sortProperty)); - if (NS_FAILED(rv)) return(rv); - if (sortResource2.Length() > 0) + if (sortInfoAvailable) { - rv = gRDFService->GetResource(nsCAutoString(sortResource2), getter_AddRefs(sortInfo.sortProperty2)); + rv = gRDFService->GetResource(nsCAutoString(sortResource), getter_AddRefs(sortInfo.sortProperty)); if (NS_FAILED(rv)) return(rv); + if (sortResource2.Length() > 0) + { + rv = gRDFService->GetResource(nsCAutoString(sortResource2), getter_AddRefs(sortInfo.sortProperty2)); + if (NS_FAILED(rv)) return(rv); + } } // set up sort order info @@ -1651,7 +1626,6 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, sortInfo.db = cds; } - sortInfo.kNaturalOrderPosAtom = kNaturalOrderPosAtom; sortInfo.kTreeCellAtom = kTreeCellAtom; sortInfo.kNameSpaceID_XUL = kNameSpaceID_XUL; diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index c66df6ba07e..e58cf453663 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -188,7 +188,6 @@ public: nsIContent *aRealNode, PRBool aIsUnique, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify); nsresult @@ -198,7 +197,6 @@ public: CreateWidgetItem(nsIContent* aElement, nsIRDFResource* aProperty, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify); enum eUpdateAction { eSet, eClear }; @@ -325,7 +323,6 @@ protected: static nsIAtom* kIsEmptyAtom; static nsIAtom* kMenuAtom; static nsIAtom* kMenuPopupAtom; - static nsIAtom* kNaturalOrderPosAtom; static nsIAtom* kOpenAtom; static nsIAtom* kParentAtom; static nsIAtom* kPersistAtom; @@ -370,7 +367,6 @@ nsIAtom* RDFGenericBuilderImpl::kIsContainerAtom; nsIAtom* RDFGenericBuilderImpl::kIsEmptyAtom; nsIAtom* RDFGenericBuilderImpl::kMenuAtom; nsIAtom* RDFGenericBuilderImpl::kMenuPopupAtom; -nsIAtom* RDFGenericBuilderImpl::kNaturalOrderPosAtom; nsIAtom* RDFGenericBuilderImpl::kOpenAtom; nsIAtom* RDFGenericBuilderImpl::kParentAtom; nsIAtom* RDFGenericBuilderImpl::kPersistAtom; @@ -457,7 +453,6 @@ RDFGenericBuilderImpl::~RDFGenericBuilderImpl(void) NS_IF_RELEASE(kIsEmptyAtom); NS_IF_RELEASE(kMenuAtom); NS_IF_RELEASE(kMenuPopupAtom); - NS_IF_RELEASE(kNaturalOrderPosAtom); NS_IF_RELEASE(kOpenAtom); NS_IF_RELEASE(kParentAtom); NS_IF_RELEASE(kPersistAtom); @@ -521,7 +516,6 @@ RDFGenericBuilderImpl::Init() kIsEmptyAtom = NS_NewAtom("isempty"); kMenuAtom = NS_NewAtom("menu"); kMenuPopupAtom = NS_NewAtom("menupopup"); - kNaturalOrderPosAtom = NS_NewAtom("pos"); kOpenAtom = NS_NewAtom("open"); kParentAtom = NS_NewAtom("parent"); kPersistAtom = NS_NewAtom("persist"); @@ -1018,7 +1012,7 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource, // Okay, it's a "live" element, so go ahead and append the new // child to this node. - rv = CreateWidgetItem(element, aProperty, resource, 0, PR_TRUE); + rv = CreateWidgetItem(element, aProperty, resource, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item"); if (NS_FAILED(rv)) return rv; @@ -1268,7 +1262,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource, if (! newresource) return NS_OK; - rv = CreateWidgetItem(element, aProperty, newresource, 0, PR_TRUE); + rv = CreateWidgetItem(element, aProperty, newresource, PR_TRUE); if (NS_FAILED(rv)) return rv; } else { @@ -1682,7 +1676,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, nsIContent *aRealNode, PRBool aIsUnique, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify) { nsresult rv; @@ -1784,7 +1777,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, } // Recurse until we get to the resource element. - rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1, aNotify); + rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, aNotify); if (NS_FAILED(rv)) return rv; } else if (isResourceElement) { @@ -1874,17 +1867,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = realKid->SetAttribute(kNameSpaceID_None, kTemplateAtom, templateID, PR_FALSE); if (NS_FAILED(rv)) return rv; - // set natural order hint - if ((aNaturalOrderPos > 0) && (isResourceElement)) { - nsAutoString pos, zero("0000"); - pos.Append(aNaturalOrderPos, 10); - if (pos.Length() < 4) { - pos.Insert(zero, 0, 4-pos.Length()); - } - - realKid->SetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos, PR_FALSE); - } - // copy all attributes from template to new node PRInt32 numAttribs; rv = tmplKid->GetAttributeCount(numAttribs); @@ -1929,7 +1911,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, // hand" because HTML won't build itself up // lazily. Note that we _don't_ need to notify: we'll // add the entire subtree in a single whack. - rv = BuildContentFromTemplate(tmplKid, realKid, isUnique, aChild, -1, PR_FALSE); + rv = BuildContentFromTemplate(tmplKid, realKid, isUnique, aChild, PR_FALSE); if (NS_FAILED(rv)) return rv; if (isResourceElement) { @@ -1953,7 +1935,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, if (! isUnique) { rv = NS_ERROR_UNEXPECTED; - if ((nsnull != gXULSortService) && (isResourceElement) ) + if ((nsnull != gXULSortService) && (isResourceElement)) { rv = gXULSortService->InsertContainerNode(mDB, mRoot, aRealNode, realKid, aNotify); } @@ -2037,7 +2019,6 @@ nsresult RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aProperty, nsIRDFResource *aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify) { nsCOMPtr tmpl; @@ -2049,8 +2030,7 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, return NS_OK; } - rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNaturalOrderPos, aNotify); - + rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNotify); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to build content from template"); return rv; } @@ -2350,7 +2330,7 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou if (! target) continue; - rv = CreateWidgetItem(aElement, property, target, -1, aNotify); + rv = CreateWidgetItem(aElement, property, target, aNotify); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create item"); if (NS_FAILED(rv)) return rv; } @@ -2417,7 +2397,7 @@ RDFGenericBuilderImpl::CreateTemplateContents(nsIContent* aElement, const nsStri element = parent; } - rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1, PR_FALSE); + rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, PR_FALSE); if (NS_FAILED(rv)) return rv; return NS_OK; diff --git a/rdf/content/src/nsRDFGenericBuilder.cpp b/rdf/content/src/nsRDFGenericBuilder.cpp index c66df6ba07e..e58cf453663 100644 --- a/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/rdf/content/src/nsRDFGenericBuilder.cpp @@ -188,7 +188,6 @@ public: nsIContent *aRealNode, PRBool aIsUnique, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify); nsresult @@ -198,7 +197,6 @@ public: CreateWidgetItem(nsIContent* aElement, nsIRDFResource* aProperty, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify); enum eUpdateAction { eSet, eClear }; @@ -325,7 +323,6 @@ protected: static nsIAtom* kIsEmptyAtom; static nsIAtom* kMenuAtom; static nsIAtom* kMenuPopupAtom; - static nsIAtom* kNaturalOrderPosAtom; static nsIAtom* kOpenAtom; static nsIAtom* kParentAtom; static nsIAtom* kPersistAtom; @@ -370,7 +367,6 @@ nsIAtom* RDFGenericBuilderImpl::kIsContainerAtom; nsIAtom* RDFGenericBuilderImpl::kIsEmptyAtom; nsIAtom* RDFGenericBuilderImpl::kMenuAtom; nsIAtom* RDFGenericBuilderImpl::kMenuPopupAtom; -nsIAtom* RDFGenericBuilderImpl::kNaturalOrderPosAtom; nsIAtom* RDFGenericBuilderImpl::kOpenAtom; nsIAtom* RDFGenericBuilderImpl::kParentAtom; nsIAtom* RDFGenericBuilderImpl::kPersistAtom; @@ -457,7 +453,6 @@ RDFGenericBuilderImpl::~RDFGenericBuilderImpl(void) NS_IF_RELEASE(kIsEmptyAtom); NS_IF_RELEASE(kMenuAtom); NS_IF_RELEASE(kMenuPopupAtom); - NS_IF_RELEASE(kNaturalOrderPosAtom); NS_IF_RELEASE(kOpenAtom); NS_IF_RELEASE(kParentAtom); NS_IF_RELEASE(kPersistAtom); @@ -521,7 +516,6 @@ RDFGenericBuilderImpl::Init() kIsEmptyAtom = NS_NewAtom("isempty"); kMenuAtom = NS_NewAtom("menu"); kMenuPopupAtom = NS_NewAtom("menupopup"); - kNaturalOrderPosAtom = NS_NewAtom("pos"); kOpenAtom = NS_NewAtom("open"); kParentAtom = NS_NewAtom("parent"); kPersistAtom = NS_NewAtom("persist"); @@ -1018,7 +1012,7 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource, // Okay, it's a "live" element, so go ahead and append the new // child to this node. - rv = CreateWidgetItem(element, aProperty, resource, 0, PR_TRUE); + rv = CreateWidgetItem(element, aProperty, resource, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item"); if (NS_FAILED(rv)) return rv; @@ -1268,7 +1262,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource, if (! newresource) return NS_OK; - rv = CreateWidgetItem(element, aProperty, newresource, 0, PR_TRUE); + rv = CreateWidgetItem(element, aProperty, newresource, PR_TRUE); if (NS_FAILED(rv)) return rv; } else { @@ -1682,7 +1676,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, nsIContent *aRealNode, PRBool aIsUnique, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify) { nsresult rv; @@ -1784,7 +1777,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, } // Recurse until we get to the resource element. - rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1, aNotify); + rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, aNotify); if (NS_FAILED(rv)) return rv; } else if (isResourceElement) { @@ -1874,17 +1867,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = realKid->SetAttribute(kNameSpaceID_None, kTemplateAtom, templateID, PR_FALSE); if (NS_FAILED(rv)) return rv; - // set natural order hint - if ((aNaturalOrderPos > 0) && (isResourceElement)) { - nsAutoString pos, zero("0000"); - pos.Append(aNaturalOrderPos, 10); - if (pos.Length() < 4) { - pos.Insert(zero, 0, 4-pos.Length()); - } - - realKid->SetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos, PR_FALSE); - } - // copy all attributes from template to new node PRInt32 numAttribs; rv = tmplKid->GetAttributeCount(numAttribs); @@ -1929,7 +1911,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, // hand" because HTML won't build itself up // lazily. Note that we _don't_ need to notify: we'll // add the entire subtree in a single whack. - rv = BuildContentFromTemplate(tmplKid, realKid, isUnique, aChild, -1, PR_FALSE); + rv = BuildContentFromTemplate(tmplKid, realKid, isUnique, aChild, PR_FALSE); if (NS_FAILED(rv)) return rv; if (isResourceElement) { @@ -1953,7 +1935,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, if (! isUnique) { rv = NS_ERROR_UNEXPECTED; - if ((nsnull != gXULSortService) && (isResourceElement) ) + if ((nsnull != gXULSortService) && (isResourceElement)) { rv = gXULSortService->InsertContainerNode(mDB, mRoot, aRealNode, realKid, aNotify); } @@ -2037,7 +2019,6 @@ nsresult RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aProperty, nsIRDFResource *aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify) { nsCOMPtr tmpl; @@ -2049,8 +2030,7 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, return NS_OK; } - rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNaturalOrderPos, aNotify); - + rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNotify); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to build content from template"); return rv; } @@ -2350,7 +2330,7 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou if (! target) continue; - rv = CreateWidgetItem(aElement, property, target, -1, aNotify); + rv = CreateWidgetItem(aElement, property, target, aNotify); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create item"); if (NS_FAILED(rv)) return rv; } @@ -2417,7 +2397,7 @@ RDFGenericBuilderImpl::CreateTemplateContents(nsIContent* aElement, const nsStri element = parent; } - rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1, PR_FALSE); + rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, PR_FALSE); if (NS_FAILED(rv)) return rv; return NS_OK; diff --git a/rdf/content/src/nsXULSortService.cpp b/rdf/content/src/nsXULSortService.cpp index adb5ae6a3ec..4ebe34c7ce2 100644 --- a/rdf/content/src/nsXULSortService.cpp +++ b/rdf/content/src/nsXULSortService.cpp @@ -139,7 +139,6 @@ typedef struct _sortStruct { nsCOMPtr rdfService; nsCOMPtr mInner; nsCOMPtr resCache; - nsCOMPtr kNaturalOrderPosAtom; nsCOMPtr kTreeCellAtom; PRInt32 colIndex; PRInt32 kNameSpaceID_XUL; @@ -185,7 +184,6 @@ private: static nsIAtom *kSortResource2Atom; static nsIAtom *kSortDirectionAtom; static nsIAtom *kIdAtom; - static nsIAtom *kNaturalOrderPosAtom; static nsIAtom *kRDF_type; static nsIAtom *kURIAtom; @@ -254,7 +252,6 @@ nsIAtom* XULSortServiceImpl::kSortResourceAtom; nsIAtom* XULSortServiceImpl::kSortResource2Atom; nsIAtom* XULSortServiceImpl::kSortDirectionAtom; nsIAtom* XULSortServiceImpl::kIdAtom; -nsIAtom* XULSortServiceImpl::kNaturalOrderPosAtom; nsIAtom* XULSortServiceImpl::kRDF_type; nsIAtom* XULSortServiceImpl::kURIAtom; @@ -287,7 +284,6 @@ XULSortServiceImpl::XULSortServiceImpl(void) kSortResource2Atom = NS_NewAtom("sortResource2"); kSortDirectionAtom = NS_NewAtom("sortDirection"); kIdAtom = NS_NewAtom("id"); - kNaturalOrderPosAtom = NS_NewAtom("pos"); kRDF_type = NS_NewAtom("type"); kURIAtom = NS_NewAtom("uri"); @@ -394,7 +390,6 @@ XULSortServiceImpl::~XULSortServiceImpl(void) NS_IF_RELEASE(kSortResource2Atom); NS_IF_RELEASE(kSortDirectionAtom); NS_IF_RELEASE(kIdAtom); - NS_IF_RELEASE(kNaturalOrderPosAtom); NS_IF_RELEASE(kRDF_type); NS_IF_RELEASE(kURIAtom); NS_IF_RELEASE(kNC_Name); @@ -1179,10 +1174,6 @@ XULSortServiceImpl::GetNodeValue(nsIContent *node1, nsIRDFResource *sortProperty } } } - if (cellPosVal1.Length() == 0) - { - rv = node1->GetAttribute(kNameSpaceID_None, sortInfo->kNaturalOrderPosAtom, cellPosVal1); - } if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE)) { nsCOMPtr nodePosLiteral; @@ -1288,21 +1279,6 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, PRInt32 colIndex, so if (tag.get() == kTreeItemAtom) { childArray->AppendElement(child); - - // if no pos is specified, set one - nsAutoString pos; - if (NS_FAILED(rv = child->GetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos)) - || (rv != NS_CONTENT_ATTR_HAS_VALUE)) - { - nsAutoString zero("0000"); - pos = ""; - pos.Append(childIndex+1, 10); - if (pos.Length() < 4) - { - pos.Insert(zero, 0, 4-pos.Length()); - } - child->SetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos, PR_FALSE); - } } } } @@ -1438,7 +1414,6 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIConten sortInfo.resCache = nsnull; sortInfo.mInner = nsnull; sortInfo.colIndex = -1; - sortInfo.kNaturalOrderPosAtom = kNaturalOrderPosAtom; sortInfo.kTreeCellAtom = kTreeCellAtom; sortInfo.kNameSpaceID_XUL = kNameSpaceID_XUL; sortInfo.sortProperty = nsnull; @@ -1476,15 +1451,15 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIConten } } - if (sortInfoAvailable != PR_TRUE) - return(NS_ERROR_UNEXPECTED); - - rv = gRDFService->GetResource(nsCAutoString(sortResource), getter_AddRefs(sortInfo.sortProperty)); - if (NS_FAILED(rv)) return(rv); - if (sortResource2.Length() > 0) + if (sortInfoAvailable) { - rv = gRDFService->GetResource(nsCAutoString(sortResource2), getter_AddRefs(sortInfo.sortProperty2)); + rv = gRDFService->GetResource(nsCAutoString(sortResource), getter_AddRefs(sortInfo.sortProperty)); if (NS_FAILED(rv)) return(rv); + if (sortResource2.Length() > 0) + { + rv = gRDFService->GetResource(nsCAutoString(sortResource2), getter_AddRefs(sortInfo.sortProperty2)); + if (NS_FAILED(rv)) return(rv); + } } // set up sort order info @@ -1651,7 +1626,6 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, sortInfo.db = cds; } - sortInfo.kNaturalOrderPosAtom = kNaturalOrderPosAtom; sortInfo.kTreeCellAtom = kTreeCellAtom; sortInfo.kNameSpaceID_XUL = kNameSpaceID_XUL; diff --git a/rdf/content/src/nsXULTemplateBuilder.cpp b/rdf/content/src/nsXULTemplateBuilder.cpp index c66df6ba07e..e58cf453663 100644 --- a/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/rdf/content/src/nsXULTemplateBuilder.cpp @@ -188,7 +188,6 @@ public: nsIContent *aRealNode, PRBool aIsUnique, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify); nsresult @@ -198,7 +197,6 @@ public: CreateWidgetItem(nsIContent* aElement, nsIRDFResource* aProperty, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify); enum eUpdateAction { eSet, eClear }; @@ -325,7 +323,6 @@ protected: static nsIAtom* kIsEmptyAtom; static nsIAtom* kMenuAtom; static nsIAtom* kMenuPopupAtom; - static nsIAtom* kNaturalOrderPosAtom; static nsIAtom* kOpenAtom; static nsIAtom* kParentAtom; static nsIAtom* kPersistAtom; @@ -370,7 +367,6 @@ nsIAtom* RDFGenericBuilderImpl::kIsContainerAtom; nsIAtom* RDFGenericBuilderImpl::kIsEmptyAtom; nsIAtom* RDFGenericBuilderImpl::kMenuAtom; nsIAtom* RDFGenericBuilderImpl::kMenuPopupAtom; -nsIAtom* RDFGenericBuilderImpl::kNaturalOrderPosAtom; nsIAtom* RDFGenericBuilderImpl::kOpenAtom; nsIAtom* RDFGenericBuilderImpl::kParentAtom; nsIAtom* RDFGenericBuilderImpl::kPersistAtom; @@ -457,7 +453,6 @@ RDFGenericBuilderImpl::~RDFGenericBuilderImpl(void) NS_IF_RELEASE(kIsEmptyAtom); NS_IF_RELEASE(kMenuAtom); NS_IF_RELEASE(kMenuPopupAtom); - NS_IF_RELEASE(kNaturalOrderPosAtom); NS_IF_RELEASE(kOpenAtom); NS_IF_RELEASE(kParentAtom); NS_IF_RELEASE(kPersistAtom); @@ -521,7 +516,6 @@ RDFGenericBuilderImpl::Init() kIsEmptyAtom = NS_NewAtom("isempty"); kMenuAtom = NS_NewAtom("menu"); kMenuPopupAtom = NS_NewAtom("menupopup"); - kNaturalOrderPosAtom = NS_NewAtom("pos"); kOpenAtom = NS_NewAtom("open"); kParentAtom = NS_NewAtom("parent"); kPersistAtom = NS_NewAtom("persist"); @@ -1018,7 +1012,7 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource, // Okay, it's a "live" element, so go ahead and append the new // child to this node. - rv = CreateWidgetItem(element, aProperty, resource, 0, PR_TRUE); + rv = CreateWidgetItem(element, aProperty, resource, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create widget item"); if (NS_FAILED(rv)) return rv; @@ -1268,7 +1262,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource, if (! newresource) return NS_OK; - rv = CreateWidgetItem(element, aProperty, newresource, 0, PR_TRUE); + rv = CreateWidgetItem(element, aProperty, newresource, PR_TRUE); if (NS_FAILED(rv)) return rv; } else { @@ -1682,7 +1676,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, nsIContent *aRealNode, PRBool aIsUnique, nsIRDFResource* aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify) { nsresult rv; @@ -1784,7 +1777,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, } // Recurse until we get to the resource element. - rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, -1, aNotify); + rv = BuildContentFromTemplate(tmplKid, realKid, PR_TRUE, aChild, aNotify); if (NS_FAILED(rv)) return rv; } else if (isResourceElement) { @@ -1874,17 +1867,6 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = realKid->SetAttribute(kNameSpaceID_None, kTemplateAtom, templateID, PR_FALSE); if (NS_FAILED(rv)) return rv; - // set natural order hint - if ((aNaturalOrderPos > 0) && (isResourceElement)) { - nsAutoString pos, zero("0000"); - pos.Append(aNaturalOrderPos, 10); - if (pos.Length() < 4) { - pos.Insert(zero, 0, 4-pos.Length()); - } - - realKid->SetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos, PR_FALSE); - } - // copy all attributes from template to new node PRInt32 numAttribs; rv = tmplKid->GetAttributeCount(numAttribs); @@ -1929,7 +1911,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, // hand" because HTML won't build itself up // lazily. Note that we _don't_ need to notify: we'll // add the entire subtree in a single whack. - rv = BuildContentFromTemplate(tmplKid, realKid, isUnique, aChild, -1, PR_FALSE); + rv = BuildContentFromTemplate(tmplKid, realKid, isUnique, aChild, PR_FALSE); if (NS_FAILED(rv)) return rv; if (isResourceElement) { @@ -1953,7 +1935,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, if (! isUnique) { rv = NS_ERROR_UNEXPECTED; - if ((nsnull != gXULSortService) && (isResourceElement) ) + if ((nsnull != gXULSortService) && (isResourceElement)) { rv = gXULSortService->InsertContainerNode(mDB, mRoot, aRealNode, realKid, aNotify); } @@ -2037,7 +2019,6 @@ nsresult RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aProperty, nsIRDFResource *aChild, - PRInt32 aNaturalOrderPos, PRBool aNotify) { nsCOMPtr tmpl; @@ -2049,8 +2030,7 @@ RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, return NS_OK; } - rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNaturalOrderPos, aNotify); - + rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNotify); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to build content from template"); return rv; } @@ -2350,7 +2330,7 @@ RDFGenericBuilderImpl::CreateContainerContents(nsIContent* aElement, nsIRDFResou if (! target) continue; - rv = CreateWidgetItem(aElement, property, target, -1, aNotify); + rv = CreateWidgetItem(aElement, property, target, aNotify); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create item"); if (NS_FAILED(rv)) return rv; } @@ -2417,7 +2397,7 @@ RDFGenericBuilderImpl::CreateTemplateContents(nsIContent* aElement, const nsStri element = parent; } - rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, -1, PR_FALSE); + rv = BuildContentFromTemplate(tmpl, aElement, PR_FALSE, resource, PR_FALSE); if (NS_FAILED(rv)) return rv; return NS_OK;