зеркало из https://github.com/mozilla/gecko-dev.git
Move resource cache up from the XUL sort service into the generic builder. Review: me
This commit is contained in:
Родитель
eeceb110d7
Коммит
423ba787b8
|
@ -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 nsIContent root, in nsIContent trueParent,
|
||||
[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in nsIRDFDataSource cache, in nsIContent root, in nsIContent trueParent,
|
||||
in nsIContent container, in nsIContent node, in boolean aNotify);
|
||||
};
|
||||
|
||||
|
|
|
@ -1438,8 +1438,8 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIContent *root, nsIContent *trueParent,
|
||||
nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDataSource *cache, nsIContent *root,
|
||||
nsIContent *trueParent, nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString sortResource, sortDirection, sortResource2;
|
||||
|
@ -1449,7 +1449,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIConten
|
|||
sortInfo.rdfService = gRDFService;
|
||||
sortInfo.db = db;
|
||||
sortInfo.resCache = nsnull;
|
||||
sortInfo.mInner = nsnull;
|
||||
sortInfo.mInner = cache; /* can be null */
|
||||
sortInfo.colIndex = -1;
|
||||
sortInfo.parentContainer = trueParent;
|
||||
sortInfo.kTreeCellAtom = kTreeCellAtom;
|
||||
|
|
|
@ -105,6 +105,7 @@ static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
|||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
|
@ -306,6 +307,7 @@ protected:
|
|||
nsCOMPtr<nsIRDFCompositeDataSource> mDB;
|
||||
nsCOMPtr<nsIContent> mRoot;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
// pseudo-constants
|
||||
|
@ -595,6 +597,9 @@ 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,
|
||||
|
@ -716,6 +721,16 @@ NS_IMETHODIMP
|
|||
RDFGenericBuilderImpl::SetRootContent(nsIContent* aElement)
|
||||
{
|
||||
mRoot = dont_QueryInterface(aElement);
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -941,6 +956,11 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Assert(aSource, aProperty, aTarget, PR_TRUE /* XXX should be value passed in */);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1059,6 +1079,11 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Unassert(aSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1185,6 +1210,11 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Change(aSource, aProperty, aOldTarget, aNewTarget);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1300,6 +1330,12 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
|||
nsIRDFNode* aTarget)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Move(aOldSource, aNewSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -2027,8 +2063,8 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
rv = NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (gXULSortService && isResourceElement) {
|
||||
rv = gXULSortService->InsertContainerNode(mDB, mRoot, trueParent, aRealNode,
|
||||
realKid, aNotify);
|
||||
rv = gXULSortService->InsertContainerNode(mDB, mCache,
|
||||
mRoot, trueParent, aRealNode, realKid, aNotify);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -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 nsIContent root, in nsIContent trueParent,
|
||||
[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in nsIRDFDataSource cache, in nsIContent root, in nsIContent trueParent,
|
||||
in nsIContent container, in nsIContent node, in boolean aNotify);
|
||||
};
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
|||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
|
@ -306,6 +307,7 @@ protected:
|
|||
nsCOMPtr<nsIRDFCompositeDataSource> mDB;
|
||||
nsCOMPtr<nsIContent> mRoot;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
// pseudo-constants
|
||||
|
@ -595,6 +597,9 @@ 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,
|
||||
|
@ -716,6 +721,16 @@ NS_IMETHODIMP
|
|||
RDFGenericBuilderImpl::SetRootContent(nsIContent* aElement)
|
||||
{
|
||||
mRoot = dont_QueryInterface(aElement);
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -941,6 +956,11 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Assert(aSource, aProperty, aTarget, PR_TRUE /* XXX should be value passed in */);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1059,6 +1079,11 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Unassert(aSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1185,6 +1210,11 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Change(aSource, aProperty, aOldTarget, aNewTarget);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1300,6 +1330,12 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
|||
nsIRDFNode* aTarget)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Move(aOldSource, aNewSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -2027,8 +2063,8 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
rv = NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (gXULSortService && isResourceElement) {
|
||||
rv = gXULSortService->InsertContainerNode(mDB, mRoot, trueParent, aRealNode,
|
||||
realKid, aNotify);
|
||||
rv = gXULSortService->InsertContainerNode(mDB, mCache,
|
||||
mRoot, trueParent, aRealNode, realKid, aNotify);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -1438,8 +1438,8 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIContent *root, nsIContent *trueParent,
|
||||
nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIRDFDataSource *cache, nsIContent *root,
|
||||
nsIContent *trueParent, nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString sortResource, sortDirection, sortResource2;
|
||||
|
@ -1449,7 +1449,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsIConten
|
|||
sortInfo.rdfService = gRDFService;
|
||||
sortInfo.db = db;
|
||||
sortInfo.resCache = nsnull;
|
||||
sortInfo.mInner = nsnull;
|
||||
sortInfo.mInner = cache; /* can be null */
|
||||
sortInfo.colIndex = -1;
|
||||
sortInfo.parentContainer = trueParent;
|
||||
sortInfo.kTreeCellAtom = kTreeCellAtom;
|
||||
|
|
|
@ -105,6 +105,7 @@ static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
|||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
|
@ -306,6 +307,7 @@ protected:
|
|||
nsCOMPtr<nsIRDFCompositeDataSource> mDB;
|
||||
nsCOMPtr<nsIContent> mRoot;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
// pseudo-constants
|
||||
|
@ -595,6 +597,9 @@ 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,
|
||||
|
@ -716,6 +721,16 @@ NS_IMETHODIMP
|
|||
RDFGenericBuilderImpl::SetRootContent(nsIContent* aElement)
|
||||
{
|
||||
mRoot = dont_QueryInterface(aElement);
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -941,6 +956,11 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Assert(aSource, aProperty, aTarget, PR_TRUE /* XXX should be value passed in */);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1059,6 +1079,11 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Unassert(aSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1185,6 +1210,11 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Change(aSource, aProperty, aOldTarget, aNewTarget);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsArray> elements;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(elements));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");
|
||||
|
@ -1300,6 +1330,12 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
|||
nsIRDFNode* aTarget)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
|
||||
if (mCache)
|
||||
{
|
||||
mCache->Move(aOldSource, aNewSource, aProperty, aTarget);
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -2027,8 +2063,8 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
|||
rv = NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (gXULSortService && isResourceElement) {
|
||||
rv = gXULSortService->InsertContainerNode(mDB, mRoot, trueParent, aRealNode,
|
||||
realKid, aNotify);
|
||||
rv = gXULSortService->InsertContainerNode(mDB, mCache,
|
||||
mRoot, trueParent, aRealNode, realKid, aNotify);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче