Enable the caching of XBL documents in the XUL cache. Not yet

used.  r=hyatt.
This commit is contained in:
bryner%uiuc.edu 2000-05-28 07:30:48 +00:00
parent acec0c92c0
commit 3ac747e4ce
4 changed files with 148 additions and 2 deletions

View File

@ -33,6 +33,8 @@
class nsICSSStyleSheet;
class nsIURI;
class nsIXULPrototypeDocument;
class nsCString;
class nsIDocument;
// {3A0A0FC0-8349-11d3-BE47-00104BDE6048}
#define NS_IXULPROTOTYPECACHE_IID \
@ -52,6 +54,14 @@ public:
NS_IMETHOD PutStyleSheet(nsICSSStyleSheet* aStyleSheet) = 0;
NS_IMETHOD FlushStyleSheets() = 0;
NS_IMETHOD GetXBLDocument(const nsCString& aString, nsIDocument** _result) = 0;
NS_IMETHOD PutXBLDocument(nsIDocument* aDocument) = 0;
NS_IMETHOD GetXBLDocScriptAccess(const nsCString& aString, nsIDocument** _result) = 0;
NS_IMETHOD PutXBLDocScriptAccess(nsIDocument* aDocument) = 0;
NS_IMETHOD FlushXBLInformation() = 0;
/**
* Flush the cache; remove all XUL prototype documents, style
* sheets, and scripts.

View File

@ -37,6 +37,7 @@
#include "nsHashtable.h"
#include "nsXPIDLString.h"
#include "plstr.h"
#include "nsIDocument.h"
class nsXULPrototypeCache : public nsIXULPrototypeCache
@ -53,6 +54,14 @@ public:
NS_IMETHOD PutStyleSheet(nsICSSStyleSheet* aStyleSheet);
NS_IMETHOD FlushStyleSheets();
NS_IMETHOD GetXBLDocument(const nsCString& aString, nsIDocument** _result);
NS_IMETHOD PutXBLDocument(nsIDocument* aDocument);
NS_IMETHOD GetXBLDocScriptAccess(const nsCString& aString, nsIDocument** _result);
NS_IMETHOD PutXBLDocScriptAccess(nsIDocument* aDocument);
NS_IMETHOD FlushXBLInformation();
NS_IMETHOD Flush();
protected:
@ -64,7 +73,8 @@ protected:
nsSupportsHashtable mPrototypeTable;
nsSupportsHashtable mStyleSheetTable;
nsSupportsHashtable mXBLDocTable;
nsSupportsHashtable mScriptAccessTable;
class nsIURIKey : public nsHashKey {
protected:
@ -188,6 +198,50 @@ nsXULPrototypeCache::PutStyleSheet(nsICSSStyleSheet* aStyleSheet)
}
NS_IMETHODIMP
nsXULPrototypeCache::GetXBLDocument(const nsCString& aString, nsIDocument** _result)
{
nsStringKey key(aString);
*_result = NS_STATIC_CAST(nsIDocument*, mXBLDocTable.Get(&key));
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::PutXBLDocument(nsIDocument *aDocument)
{
nsCOMPtr<nsIURI> uri(aDocument->GetDocumentURL());
char* aString;
uri->GetSpec(&aString);
nsStringKey key(aString);
nsIDocument* olddoc = NS_STATIC_CAST(nsIDocument*, mXBLDocTable.Put(&key, aDocument));
NS_IF_RELEASE(olddoc);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::GetXBLDocScriptAccess(const nsCString& aString, nsIDocument** _result)
{
nsStringKey key(aString);
*_result = NS_STATIC_CAST(nsIDocument*, mScriptAccessTable.Get(&key));
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::PutXBLDocScriptAccess(nsIDocument *aDocument)
{
nsCOMPtr<nsIURI> uri(aDocument->GetDocumentURL());
char* aString;
uri->GetSpec(&aString);
nsStringKey key(aString);
nsIDocument* olddoc = NS_STATIC_CAST(nsIDocument*, mScriptAccessTable.Put(&key, aDocument));
NS_IF_RELEASE(olddoc);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::FlushStyleSheets()
{
@ -196,11 +250,20 @@ nsXULPrototypeCache::FlushStyleSheets()
}
NS_IMETHODIMP
nsXULPrototypeCache::FlushXBLInformation()
{
mXBLDocTable.Reset();
mScriptAccessTable.Reset();
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::Flush()
{
FlushPrototypes();
FlushStyleSheets();
FlushXBLInformation();
return NS_OK;
}

View File

@ -33,6 +33,8 @@
class nsICSSStyleSheet;
class nsIURI;
class nsIXULPrototypeDocument;
class nsCString;
class nsIDocument;
// {3A0A0FC0-8349-11d3-BE47-00104BDE6048}
#define NS_IXULPROTOTYPECACHE_IID \
@ -52,6 +54,14 @@ public:
NS_IMETHOD PutStyleSheet(nsICSSStyleSheet* aStyleSheet) = 0;
NS_IMETHOD FlushStyleSheets() = 0;
NS_IMETHOD GetXBLDocument(const nsCString& aString, nsIDocument** _result) = 0;
NS_IMETHOD PutXBLDocument(nsIDocument* aDocument) = 0;
NS_IMETHOD GetXBLDocScriptAccess(const nsCString& aString, nsIDocument** _result) = 0;
NS_IMETHOD PutXBLDocScriptAccess(nsIDocument* aDocument) = 0;
NS_IMETHOD FlushXBLInformation() = 0;
/**
* Flush the cache; remove all XUL prototype documents, style
* sheets, and scripts.

View File

@ -37,6 +37,7 @@
#include "nsHashtable.h"
#include "nsXPIDLString.h"
#include "plstr.h"
#include "nsIDocument.h"
class nsXULPrototypeCache : public nsIXULPrototypeCache
@ -53,6 +54,14 @@ public:
NS_IMETHOD PutStyleSheet(nsICSSStyleSheet* aStyleSheet);
NS_IMETHOD FlushStyleSheets();
NS_IMETHOD GetXBLDocument(const nsCString& aString, nsIDocument** _result);
NS_IMETHOD PutXBLDocument(nsIDocument* aDocument);
NS_IMETHOD GetXBLDocScriptAccess(const nsCString& aString, nsIDocument** _result);
NS_IMETHOD PutXBLDocScriptAccess(nsIDocument* aDocument);
NS_IMETHOD FlushXBLInformation();
NS_IMETHOD Flush();
protected:
@ -64,7 +73,8 @@ protected:
nsSupportsHashtable mPrototypeTable;
nsSupportsHashtable mStyleSheetTable;
nsSupportsHashtable mXBLDocTable;
nsSupportsHashtable mScriptAccessTable;
class nsIURIKey : public nsHashKey {
protected:
@ -188,6 +198,50 @@ nsXULPrototypeCache::PutStyleSheet(nsICSSStyleSheet* aStyleSheet)
}
NS_IMETHODIMP
nsXULPrototypeCache::GetXBLDocument(const nsCString& aString, nsIDocument** _result)
{
nsStringKey key(aString);
*_result = NS_STATIC_CAST(nsIDocument*, mXBLDocTable.Get(&key));
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::PutXBLDocument(nsIDocument *aDocument)
{
nsCOMPtr<nsIURI> uri(aDocument->GetDocumentURL());
char* aString;
uri->GetSpec(&aString);
nsStringKey key(aString);
nsIDocument* olddoc = NS_STATIC_CAST(nsIDocument*, mXBLDocTable.Put(&key, aDocument));
NS_IF_RELEASE(olddoc);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::GetXBLDocScriptAccess(const nsCString& aString, nsIDocument** _result)
{
nsStringKey key(aString);
*_result = NS_STATIC_CAST(nsIDocument*, mScriptAccessTable.Get(&key));
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::PutXBLDocScriptAccess(nsIDocument *aDocument)
{
nsCOMPtr<nsIURI> uri(aDocument->GetDocumentURL());
char* aString;
uri->GetSpec(&aString);
nsStringKey key(aString);
nsIDocument* olddoc = NS_STATIC_CAST(nsIDocument*, mScriptAccessTable.Put(&key, aDocument));
NS_IF_RELEASE(olddoc);
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::FlushStyleSheets()
{
@ -196,11 +250,20 @@ nsXULPrototypeCache::FlushStyleSheets()
}
NS_IMETHODIMP
nsXULPrototypeCache::FlushXBLInformation()
{
mXBLDocTable.Reset();
mScriptAccessTable.Reset();
return NS_OK;
}
NS_IMETHODIMP
nsXULPrototypeCache::Flush()
{
FlushPrototypes();
FlushStyleSheets();
FlushXBLInformation();
return NS_OK;
}