diff --git a/content/xul/templates/public/nsIXULSortService.idl b/content/xul/templates/public/nsIXULSortService.idl index 0ec8dd10735e..0243c476d0c0 100755 --- a/content/xul/templates/public/nsIXULSortService.idl +++ b/content/xul/templates/public/nsIXULSortService.idl @@ -25,7 +25,7 @@ #include "nsIRDFResource.idl" -[ptr] native nsIRDFResourceArray( nsIRDFResource *); +[ptr] native nsIRDFDataSourceHandle( nsIRDFDataSource *); interface nsIContent; interface nsIDOMNode; @@ -35,7 +35,7 @@ interface nsIDOMNode; interface nsIXULSortService : nsISupports { void Sort(in nsIDOMNode node, in string sortResource, in string sortDirection); -[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in nsIRDFDataSource cache, in nsIContent root, in nsIContent trueParent, +[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in nsIRDFDataSourceHandle cacheHandle, in nsIContent root, in nsIContent trueParent, in nsIContent container, in nsIContent node, in boolean aNotify); }; diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp index 0a4fee695cc6..905ed357bae1 100644 --- a/content/xul/templates/src/nsXULSortService.cpp +++ b/content/xul/templates/src/nsXULSortService.cpp @@ -1438,7 +1438,7 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo) NS_IMETHODIMP -XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDataSource *cache, nsIContent *root, +XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDataSource **cacheHandle, nsIContent *root, nsIContent *trueParent, nsIContent *container, nsIContent *node, PRBool aNotify) { nsresult rv; @@ -1449,7 +1449,6 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDat sortInfo.rdfService = gRDFService; sortInfo.db = db; sortInfo.resCache = nsnull; - sortInfo.mInner = cache; /* can be null */ sortInfo.colIndex = -1; sortInfo.parentContainer = trueParent; sortInfo.kTreeCellAtom = kTreeCellAtom; @@ -1457,6 +1456,14 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDat sortInfo.sortProperty = nsnull; sortInfo.sortProperty2 = nsnull; sortInfo.inbetweenSeparatorSort = PR_FALSE; + if (cacheHandle != nsnull) + { + sortInfo.mInner = *cacheHandle; // Note: this can/might be null + } + else + { + sortInfo.mInner = nsnull; + } PRBool sortInfoAvailable = PR_FALSE; @@ -1625,6 +1632,12 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDat { container->AppendChildTo(node, aNotify); } + + if ((cacheHandle) && (sortInfo.mInner) && ((*cacheHandle) != sortInfo.mInner)) + { + *cacheHandle = sortInfo.mInner; + NS_ADDREF(*cacheHandle); + } return(NS_OK); } diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index 647d869cf0b6..eaae9f543e42 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -597,9 +597,6 @@ RDFGenericBuilderImpl::Init() (nsISupports**) &gXULSortService); if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, - nsnull, nsIRDFDataSource::GetIID(), (void **)&mCache); - rv = nsComponentManager::CreateInstance(kHTMLElementFactoryCID, nsnull, kIHTMLElementFactoryIID, @@ -726,9 +723,6 @@ RDFGenericBuilderImpl::SetRootContent(nsIContent* aElement) { // flush (delete) the cache when re-rerooting the generated content mCache = nsnull; - // and then re-create a new, empty cache - nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, - nsnull, nsIRDFDataSource::GetIID(), (void **)&mCache); } return NS_OK; @@ -1212,7 +1206,16 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource, if (mCache) { - mCache->Change(aSource, aProperty, aOldTarget, aNewTarget); + if (aOldTarget) + { + // XXX fix this: in-memory DS doesn't like a null oldTarget + mCache->Change(aSource, aProperty, aOldTarget, aNewTarget); + } + else + { + // XXX should get tv via observer interface + mCache->Assert(aSource, aProperty, aNewTarget, PR_TRUE); + } } nsCOMPtr elements; @@ -2063,8 +2066,14 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = NS_ERROR_UNEXPECTED; if (gXULSortService && isResourceElement) { - rv = gXULSortService->InsertContainerNode(mDB, mCache, + nsCOMPtr tempCache = nsnull; + + rv = gXULSortService->InsertContainerNode(mDB, getter_AddRefs(tempCache), mRoot, trueParent, aRealNode, realKid, aNotify); + if (tempCache) + { + mCache = tempCache; + } } if (NS_FAILED(rv)) { diff --git a/rdf/base/idl/nsIXULSortService.idl b/rdf/base/idl/nsIXULSortService.idl index 0ec8dd10735e..0243c476d0c0 100755 --- a/rdf/base/idl/nsIXULSortService.idl +++ b/rdf/base/idl/nsIXULSortService.idl @@ -25,7 +25,7 @@ #include "nsIRDFResource.idl" -[ptr] native nsIRDFResourceArray( nsIRDFResource *); +[ptr] native nsIRDFDataSourceHandle( nsIRDFDataSource *); interface nsIContent; interface nsIDOMNode; @@ -35,7 +35,7 @@ interface nsIDOMNode; interface nsIXULSortService : nsISupports { void Sort(in nsIDOMNode node, in string sortResource, in string sortDirection); -[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in nsIRDFDataSource cache, in nsIContent root, in nsIContent trueParent, +[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in nsIRDFDataSourceHandle cacheHandle, in nsIContent root, in nsIContent trueParent, in nsIContent container, in nsIContent node, in boolean aNotify); }; diff --git a/rdf/content/src/nsRDFGenericBuilder.cpp b/rdf/content/src/nsRDFGenericBuilder.cpp index 647d869cf0b6..eaae9f543e42 100644 --- a/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/rdf/content/src/nsRDFGenericBuilder.cpp @@ -597,9 +597,6 @@ RDFGenericBuilderImpl::Init() (nsISupports**) &gXULSortService); if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, - nsnull, nsIRDFDataSource::GetIID(), (void **)&mCache); - rv = nsComponentManager::CreateInstance(kHTMLElementFactoryCID, nsnull, kIHTMLElementFactoryIID, @@ -726,9 +723,6 @@ RDFGenericBuilderImpl::SetRootContent(nsIContent* aElement) { // flush (delete) the cache when re-rerooting the generated content mCache = nsnull; - // and then re-create a new, empty cache - nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, - nsnull, nsIRDFDataSource::GetIID(), (void **)&mCache); } return NS_OK; @@ -1212,7 +1206,16 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource, if (mCache) { - mCache->Change(aSource, aProperty, aOldTarget, aNewTarget); + if (aOldTarget) + { + // XXX fix this: in-memory DS doesn't like a null oldTarget + mCache->Change(aSource, aProperty, aOldTarget, aNewTarget); + } + else + { + // XXX should get tv via observer interface + mCache->Assert(aSource, aProperty, aNewTarget, PR_TRUE); + } } nsCOMPtr elements; @@ -2063,8 +2066,14 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = NS_ERROR_UNEXPECTED; if (gXULSortService && isResourceElement) { - rv = gXULSortService->InsertContainerNode(mDB, mCache, + nsCOMPtr tempCache = nsnull; + + rv = gXULSortService->InsertContainerNode(mDB, getter_AddRefs(tempCache), mRoot, trueParent, aRealNode, realKid, aNotify); + if (tempCache) + { + mCache = tempCache; + } } if (NS_FAILED(rv)) { diff --git a/rdf/content/src/nsXULSortService.cpp b/rdf/content/src/nsXULSortService.cpp index 0a4fee695cc6..905ed357bae1 100644 --- a/rdf/content/src/nsXULSortService.cpp +++ b/rdf/content/src/nsXULSortService.cpp @@ -1438,7 +1438,7 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo) NS_IMETHODIMP -XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDataSource *cache, nsIContent *root, +XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDataSource **cacheHandle, nsIContent *root, nsIContent *trueParent, nsIContent *container, nsIContent *node, PRBool aNotify) { nsresult rv; @@ -1449,7 +1449,6 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDat sortInfo.rdfService = gRDFService; sortInfo.db = db; sortInfo.resCache = nsnull; - sortInfo.mInner = cache; /* can be null */ sortInfo.colIndex = -1; sortInfo.parentContainer = trueParent; sortInfo.kTreeCellAtom = kTreeCellAtom; @@ -1457,6 +1456,14 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDat sortInfo.sortProperty = nsnull; sortInfo.sortProperty2 = nsnull; sortInfo.inbetweenSeparatorSort = PR_FALSE; + if (cacheHandle != nsnull) + { + sortInfo.mInner = *cacheHandle; // Note: this can/might be null + } + else + { + sortInfo.mInner = nsnull; + } PRBool sortInfoAvailable = PR_FALSE; @@ -1625,6 +1632,12 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDat { container->AppendChildTo(node, aNotify); } + + if ((cacheHandle) && (sortInfo.mInner) && ((*cacheHandle) != sortInfo.mInner)) + { + *cacheHandle = sortInfo.mInner; + NS_ADDREF(*cacheHandle); + } return(NS_OK); } diff --git a/rdf/content/src/nsXULTemplateBuilder.cpp b/rdf/content/src/nsXULTemplateBuilder.cpp index 647d869cf0b6..eaae9f543e42 100644 --- a/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/rdf/content/src/nsXULTemplateBuilder.cpp @@ -597,9 +597,6 @@ RDFGenericBuilderImpl::Init() (nsISupports**) &gXULSortService); if (NS_FAILED(rv)) return rv; - rv = nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, - nsnull, nsIRDFDataSource::GetIID(), (void **)&mCache); - rv = nsComponentManager::CreateInstance(kHTMLElementFactoryCID, nsnull, kIHTMLElementFactoryIID, @@ -726,9 +723,6 @@ RDFGenericBuilderImpl::SetRootContent(nsIContent* aElement) { // flush (delete) the cache when re-rerooting the generated content mCache = nsnull; - // and then re-create a new, empty cache - nsComponentManager::CreateInstance(kRDFInMemoryDataSourceCID, - nsnull, nsIRDFDataSource::GetIID(), (void **)&mCache); } return NS_OK; @@ -1212,7 +1206,16 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource, if (mCache) { - mCache->Change(aSource, aProperty, aOldTarget, aNewTarget); + if (aOldTarget) + { + // XXX fix this: in-memory DS doesn't like a null oldTarget + mCache->Change(aSource, aProperty, aOldTarget, aNewTarget); + } + else + { + // XXX should get tv via observer interface + mCache->Assert(aSource, aProperty, aNewTarget, PR_TRUE); + } } nsCOMPtr elements; @@ -2063,8 +2066,14 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = NS_ERROR_UNEXPECTED; if (gXULSortService && isResourceElement) { - rv = gXULSortService->InsertContainerNode(mDB, mCache, + nsCOMPtr tempCache = nsnull; + + rv = gXULSortService->InsertContainerNode(mDB, getter_AddRefs(tempCache), mRoot, trueParent, aRealNode, realKid, aNotify); + if (tempCache) + { + mCache = tempCache; + } } if (NS_FAILED(rv)) {