More implementation fun. r=neo

This commit is contained in:
hyatt%netscape.com 2000-01-12 09:44:18 +00:00
Родитель c9d8b2bff9
Коммит e124913c6f
2 изменённых файлов: 268 добавлений и 2 удалений

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

@ -1,5 +1,73 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIXBLService.h" #include "nsIXBLService.h"
#include "nsIInputStream.h"
#include "nsINameSpaceManager.h"
#include "nsHashtable.h"
#include "nsIURI.h"
#include "nsIURL.h"
#include "nsIChannel.h"
#include "nsXPIDLString.h"
#include "nsIParser.h"
#include "nsParserCIID.h"
#include "nsNetUtil.h"
#include "plstr.h"
// nsProxyStream
// A helper class used for synchronous parsing of URLs.
class nsProxyStream : public nsIInputStream
{
private:
const char* mBuffer;
PRUint32 mSize;
PRUint32 mIndex;
public:
nsProxyStream(void) : mBuffer(nsnull)
{
NS_INIT_REFCNT();
}
virtual ~nsProxyStream(void) {
}
// nsISupports
NS_DECL_ISUPPORTS
// nsIBaseStream
NS_IMETHOD Close(void) {
return NS_OK;
}
// nsIInputStream
NS_IMETHOD Available(PRUint32 *aLength) {
*aLength = mSize - mIndex;
return NS_OK;
}
NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) {
PRUint32 readCount = 0;
while (mIndex < mSize && aCount > 0) {
*aBuf = mBuffer[mIndex];
aBuf++;
mIndex++;
readCount++;
aCount--;
}
*aReadCount = readCount;
return NS_OK;
}
// Implementation
void SetBuffer(const char* aBuffer, PRUint32 aSize) {
mBuffer = aBuffer;
mSize = aSize;
mIndex = 0;
}
};
NS_IMPL_ISUPPORTS(nsProxyStream, nsIInputStream::GetIID());
//////////////////////////////////////////////////////////////////////////////////////////
class nsXBLService: public nsIXBLService class nsXBLService: public nsIXBLService
{ {
@ -12,17 +80,82 @@ class nsXBLService: public nsIXBLService
// For a given element, returns a flat list of all the anonymous children that need // For a given element, returns a flat list of all the anonymous children that need
// frames built. // frames built.
NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult); NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult);
public:
nsXBLService();
virtual ~nsXBLService();
protected:
// This URIkey class is used to hash URLs into an XBL binding
// cache.
class nsIURIKey : public nsHashKey {
protected:
nsCOMPtr<nsIURI> mKey;
public:
nsIURIKey(nsIURI* key) : mKey(key) {}
~nsIURIKey(void) {}
PRUint32 HashValue(void) const {
nsXPIDLCString spec;
mKey->GetSpec(getter_Copies(spec));
return (PRUint32) PL_HashString(spec);
}
PRBool Equals(const nsHashKey *aKey) const {
PRBool eq;
mKey->Equals( ((nsIURIKey*) aKey)->mKey, &eq );
return eq;
}
nsHashKey *Clone(void) const {
return new nsIURIKey(mKey);
}
};
// MEMBER VARIABLES
protected:
static nsSupportsHashtable* mBindingTable; // This is a table of all the bindings files
// we have loaded
// during this session.
static PRUint32 gRefCnt; // A count of XBLservice instances.
}; };
// Implementation /////////////////////////////////////////////////////////////////
// Static member variable initialization
PRUint32 nsXBLService::gRefCnt = 0;
nsSupportsHashtable* nsXBLService::mBindingTable = nsnull;
// Implement our nsISupports methods
NS_IMPL_ISUPPORTS1(nsXBLService, nsIXBLService) NS_IMPL_ISUPPORTS1(nsXBLService, nsIXBLService)
// Implementation // Constructors/Destructors
nsXBLService::nsXBLService(void)
{
NS_INIT_REFCNT();
gRefCnt++;
if (gRefCnt == 1) {
mBindingTable = new nsSupportsHashtable();
}
}
nsXBLService::~nsXBLService(void)
{
gRefCnt--;
if (gRefCnt == 0)
delete mBindingTable;
}
// This function loads a particular XBL file and installs all of the bindings // This function loads a particular XBL file and installs all of the bindings
// onto the element. // onto the element.
NS_IMETHODIMP NS_IMETHODIMP
nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL)
{ {
return NS_OK; return NS_OK;
} }

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

@ -1,5 +1,73 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIXBLService.h" #include "nsIXBLService.h"
#include "nsIInputStream.h"
#include "nsINameSpaceManager.h"
#include "nsHashtable.h"
#include "nsIURI.h"
#include "nsIURL.h"
#include "nsIChannel.h"
#include "nsXPIDLString.h"
#include "nsIParser.h"
#include "nsParserCIID.h"
#include "nsNetUtil.h"
#include "plstr.h"
// nsProxyStream
// A helper class used for synchronous parsing of URLs.
class nsProxyStream : public nsIInputStream
{
private:
const char* mBuffer;
PRUint32 mSize;
PRUint32 mIndex;
public:
nsProxyStream(void) : mBuffer(nsnull)
{
NS_INIT_REFCNT();
}
virtual ~nsProxyStream(void) {
}
// nsISupports
NS_DECL_ISUPPORTS
// nsIBaseStream
NS_IMETHOD Close(void) {
return NS_OK;
}
// nsIInputStream
NS_IMETHOD Available(PRUint32 *aLength) {
*aLength = mSize - mIndex;
return NS_OK;
}
NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) {
PRUint32 readCount = 0;
while (mIndex < mSize && aCount > 0) {
*aBuf = mBuffer[mIndex];
aBuf++;
mIndex++;
readCount++;
aCount--;
}
*aReadCount = readCount;
return NS_OK;
}
// Implementation
void SetBuffer(const char* aBuffer, PRUint32 aSize) {
mBuffer = aBuffer;
mSize = aSize;
mIndex = 0;
}
};
NS_IMPL_ISUPPORTS(nsProxyStream, nsIInputStream::GetIID());
//////////////////////////////////////////////////////////////////////////////////////////
class nsXBLService: public nsIXBLService class nsXBLService: public nsIXBLService
{ {
@ -12,17 +80,82 @@ class nsXBLService: public nsIXBLService
// For a given element, returns a flat list of all the anonymous children that need // For a given element, returns a flat list of all the anonymous children that need
// frames built. // frames built.
NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult); NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult);
public:
nsXBLService();
virtual ~nsXBLService();
protected:
// This URIkey class is used to hash URLs into an XBL binding
// cache.
class nsIURIKey : public nsHashKey {
protected:
nsCOMPtr<nsIURI> mKey;
public:
nsIURIKey(nsIURI* key) : mKey(key) {}
~nsIURIKey(void) {}
PRUint32 HashValue(void) const {
nsXPIDLCString spec;
mKey->GetSpec(getter_Copies(spec));
return (PRUint32) PL_HashString(spec);
}
PRBool Equals(const nsHashKey *aKey) const {
PRBool eq;
mKey->Equals( ((nsIURIKey*) aKey)->mKey, &eq );
return eq;
}
nsHashKey *Clone(void) const {
return new nsIURIKey(mKey);
}
};
// MEMBER VARIABLES
protected:
static nsSupportsHashtable* mBindingTable; // This is a table of all the bindings files
// we have loaded
// during this session.
static PRUint32 gRefCnt; // A count of XBLservice instances.
}; };
// Implementation /////////////////////////////////////////////////////////////////
// Static member variable initialization
PRUint32 nsXBLService::gRefCnt = 0;
nsSupportsHashtable* nsXBLService::mBindingTable = nsnull;
// Implement our nsISupports methods
NS_IMPL_ISUPPORTS1(nsXBLService, nsIXBLService) NS_IMPL_ISUPPORTS1(nsXBLService, nsIXBLService)
// Implementation // Constructors/Destructors
nsXBLService::nsXBLService(void)
{
NS_INIT_REFCNT();
gRefCnt++;
if (gRefCnt == 1) {
mBindingTable = new nsSupportsHashtable();
}
}
nsXBLService::~nsXBLService(void)
{
gRefCnt--;
if (gRefCnt == 0)
delete mBindingTable;
}
// This function loads a particular XBL file and installs all of the bindings // This function loads a particular XBL file and installs all of the bindings
// onto the element. // onto the element.
NS_IMETHODIMP NS_IMETHODIMP
nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL)
{ {
return NS_OK; return NS_OK;
} }