Defer creation of resource cache until a sort is imposed. Also, added a temporary working for db->OnChange() not enjoying a null oldTarget.

This commit is contained in:
rjc%netscape.com 2000-01-11 08:38:47 +00:00
Родитель 3eff44b867
Коммит 86f0302402
7 изменённых файлов: 85 добавлений и 32 удалений

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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<nsISupportsArray> elements;
@ -2063,8 +2066,14 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
rv = NS_ERROR_UNEXPECTED;
if (gXULSortService && isResourceElement) {
rv = gXULSortService->InsertContainerNode(mDB, mCache,
nsCOMPtr<nsIRDFDataSource> tempCache = nsnull;
rv = gXULSortService->InsertContainerNode(mDB, getter_AddRefs(tempCache),
mRoot, trueParent, aRealNode, realKid, aNotify);
if (tempCache)
{
mCache = tempCache;
}
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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<nsISupportsArray> elements;
@ -2063,8 +2066,14 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
rv = NS_ERROR_UNEXPECTED;
if (gXULSortService && isResourceElement) {
rv = gXULSortService->InsertContainerNode(mDB, mCache,
nsCOMPtr<nsIRDFDataSource> tempCache = nsnull;
rv = gXULSortService->InsertContainerNode(mDB, getter_AddRefs(tempCache),
mRoot, trueParent, aRealNode, realKid, aNotify);
if (tempCache)
{
mCache = tempCache;
}
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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<nsISupportsArray> elements;
@ -2063,8 +2066,14 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
rv = NS_ERROR_UNEXPECTED;
if (gXULSortService && isResourceElement) {
rv = gXULSortService->InsertContainerNode(mDB, mCache,
nsCOMPtr<nsIRDFDataSource> tempCache = nsnull;
rv = gXULSortService->InsertContainerNode(mDB, getter_AddRefs(tempCache),
mRoot, trueParent, aRealNode, realKid, aNotify);
if (tempCache)
{
mCache = tempCache;
}
}
if (NS_FAILED(rv)) {