Added initializers that can be used from the repository. Export nsIHTMLStyleSheet.h.

This commit is contained in:
waterson%netscape.com 1998-12-03 20:20:35 +00:00
Родитель 07920c6756
Коммит 3cbd2aa561
15 изменённых файлов: 411 добавлений и 67 удалений

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

@ -42,6 +42,7 @@
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsICSSParser.h"
#include "prlog.h"
//#define DEBUG_REFS
//#define DEBUG_RULES
@ -537,13 +538,14 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
CSSStyleSheetImpl(nsIURL* aURL);
CSSStyleSheetImpl();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
// basic style sheet data
NS_IMETHOD Init(nsIURL* aURL);
NS_IMETHOD GetURL(nsIURL*& aURL) const;
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD SetTitle(const nsString& aTitle);
@ -680,7 +682,7 @@ void CSSStyleSheetImpl::operator delete(void* ptr)
static PRInt32 gInstanceCount;
#endif
CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL)
CSSStyleSheetImpl::CSSStyleSheetImpl()
: nsICSSStyleSheet(),
mURL(nsnull), mTitle(), mMedia(nsnull),
mFirstChild(nsnull),
@ -689,7 +691,6 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL)
mRuleHash(nsnull)
{
NS_INIT_REFCNT();
mURL.SetAddRef(aURL);
mParent = nsnull;
mRuleCollection = nsnull;
mImportsCollection = nsnull;
@ -1151,6 +1152,21 @@ PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
return matchCount;
}
NS_IMETHODIMP
CSSStyleSheetImpl::Init(nsIURL* aURL)
{
NS_PRECONDITION(aURL, "null ptr");
if (! aURL)
return NS_ERROR_NULL_POINTER;
NS_ASSERTION(mURL == nsnull, "already initialized");
if (mURL)
return NS_ERROR_ALREADY_INITIALIZED;
mURL.SetAddRef(aURL);
return NS_OK;
}
NS_IMETHODIMP
CSSStyleSheetImpl::GetURL(nsIURL*& aURL) const
{
@ -1668,18 +1684,39 @@ CSSStyleSheetImpl::SetScriptObject(void* aScriptObject)
return NS_OK;
}
// XXX for backwards compatibility and convenience
NS_HTML nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult, nsIURL* aURL)
{
nsICSSStyleSheet* sheet;
nsresult rv;
if (NS_FAILED(rv = NS_NewCSSStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
CSSStyleSheetImpl *it = new CSSStyleSheetImpl(aURL);
CSSStyleSheetImpl *it = new CSSStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kICSSStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -43,13 +43,14 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
HTMLCSSStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument);
HTMLCSSStyleSheetImpl();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
// basic style sheet data
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument);
NS_IMETHOD GetURL(nsIURL*& aURL) const;
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD GetType(nsString& aType) const;
@ -132,13 +133,12 @@ void HTMLCSSStyleSheetImpl::operator delete(void* ptr)
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument)
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
: nsIHTMLCSSStyleSheet(),
mURL(aURL),
mDocument(aDocument)
mURL(nsnull),
mDocument(nsnull)
{
NS_INIT_REFCNT();
NS_ADDREF(mURL);
}
HTMLCSSStyleSheetImpl::~HTMLCSSStyleSheetImpl()
@ -223,6 +223,22 @@ PRInt32 HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
return 0;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::Init(nsIURL* aURL, nsIDocument* aDocument)
{
NS_PRECONDITION(aURL && aDocument, "null ptr");
if (! aURL || ! aDocument)
return NS_ERROR_NULL_POINTER;
if (mURL || mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
mDocument = aDocument; // not refcounted!
mURL = aURL;
NS_ADDREF(mURL);
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetURL(nsIURL*& aURL) const
{
@ -311,20 +327,40 @@ void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
}
// XXX For backwards compatibility and convenience
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument)
{
nsresult rv;
nsIHTMLCSSStyleSheet* sheet;
if (NS_FAILED(rv = NS_NewHTMLCSSStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl(aURL, aDocument);
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLCSSStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -212,7 +212,7 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
HTMLStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument);
HTMLStyleSheetImpl(void);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
@ -245,6 +245,7 @@ public:
nsIStyleContext* aParentContext,
nsISupportsArray* aResults);
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument);
NS_IMETHOD SetLinkColor(nscolor aColor);
NS_IMETHOD SetActiveLinkColor(nscolor aColor);
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
@ -440,17 +441,16 @@ void HTMLStyleSheetImpl::operator delete(void* ptr)
HTMLStyleSheetImpl::HTMLStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument)
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
: nsIHTMLStyleSheet(),
mURL(aURL),
mDocument(aDocument),
mURL(nsnull),
mDocument(nsnull),
mLinkRule(nsnull),
mVisitedRule(nsnull),
mActiveRule(nsnull),
mRecycledAttrs(nsnull)
{
NS_INIT_REFCNT();
NS_ADDREF(mURL);
}
HTMLStyleSheetImpl::~HTMLStyleSheetImpl()
@ -670,10 +670,24 @@ HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const
NS_IMETHODIMP
HTMLStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument)
{
mDocument = aDocument;
mDocument = aDocument; // not refcounted
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::Init(nsIURL* aURL, nsIDocument* aDocument)
{
NS_PRECONDITION(aURL && aDocument, "null ptr");
if (! aURL || ! aDocument)
return NS_ERROR_NULL_POINTER;
if (mURL || mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
mDocument = aDocument; // not refcounted!
mURL = aURL;
NS_ADDREF(mURL);
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
{
@ -2604,19 +2618,40 @@ void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
}
// XXX For convenience and backwards compatibility
NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument)
{
nsresult rv;
nsIHTMLStyleSheet* sheet;
if (NS_FAILED(rv = NS_NewHTMLStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl(aURL, aDocument);
HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -27,11 +27,15 @@
class nsIHTMLCSSStyleSheet : public nsIStyleSheet {
public:
// no methods for now
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument) = 0;
};
// XXX for convenience and backward compatibility
extern NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument);
extern NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult);
#endif /* nsIHTMLCSSStyleSheet_h___ */

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

@ -57,6 +57,7 @@ EXPORTS = \
nsICSSDeclaration.h \
nsHTMLValue.h \
nsIHTMLCSSStyleSheet.h \
nsIHTMLStyleSheet.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -29,8 +29,9 @@ EXPORTS = \
nsCSSValue.h \
nsICSSStyleRule.h \
nsICSSDeclaration.h \
nsHTMLValue.h \
nsIHTMLCSSStyleSheet.h \
nsIHTMLStyleSheet.h \
nsHTMLValue.h \
nsDOMCSSDeclaration.h \
$(NULL)

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

@ -42,6 +42,7 @@
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsICSSParser.h"
#include "prlog.h"
//#define DEBUG_REFS
//#define DEBUG_RULES
@ -537,13 +538,14 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
CSSStyleSheetImpl(nsIURL* aURL);
CSSStyleSheetImpl();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
// basic style sheet data
NS_IMETHOD Init(nsIURL* aURL);
NS_IMETHOD GetURL(nsIURL*& aURL) const;
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD SetTitle(const nsString& aTitle);
@ -680,7 +682,7 @@ void CSSStyleSheetImpl::operator delete(void* ptr)
static PRInt32 gInstanceCount;
#endif
CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL)
CSSStyleSheetImpl::CSSStyleSheetImpl()
: nsICSSStyleSheet(),
mURL(nsnull), mTitle(), mMedia(nsnull),
mFirstChild(nsnull),
@ -689,7 +691,6 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL)
mRuleHash(nsnull)
{
NS_INIT_REFCNT();
mURL.SetAddRef(aURL);
mParent = nsnull;
mRuleCollection = nsnull;
mImportsCollection = nsnull;
@ -1151,6 +1152,21 @@ PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
return matchCount;
}
NS_IMETHODIMP
CSSStyleSheetImpl::Init(nsIURL* aURL)
{
NS_PRECONDITION(aURL, "null ptr");
if (! aURL)
return NS_ERROR_NULL_POINTER;
NS_ASSERTION(mURL == nsnull, "already initialized");
if (mURL)
return NS_ERROR_ALREADY_INITIALIZED;
mURL.SetAddRef(aURL);
return NS_OK;
}
NS_IMETHODIMP
CSSStyleSheetImpl::GetURL(nsIURL*& aURL) const
{
@ -1668,18 +1684,39 @@ CSSStyleSheetImpl::SetScriptObject(void* aScriptObject)
return NS_OK;
}
// XXX for backwards compatibility and convenience
NS_HTML nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult, nsIURL* aURL)
{
nsICSSStyleSheet* sheet;
nsresult rv;
if (NS_FAILED(rv = NS_NewCSSStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
CSSStyleSheetImpl *it = new CSSStyleSheetImpl(aURL);
CSSStyleSheetImpl *it = new CSSStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kICSSStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -43,13 +43,14 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
HTMLCSSStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument);
HTMLCSSStyleSheetImpl();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
// basic style sheet data
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument);
NS_IMETHOD GetURL(nsIURL*& aURL) const;
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD GetType(nsString& aType) const;
@ -132,13 +133,12 @@ void HTMLCSSStyleSheetImpl::operator delete(void* ptr)
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument)
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
: nsIHTMLCSSStyleSheet(),
mURL(aURL),
mDocument(aDocument)
mURL(nsnull),
mDocument(nsnull)
{
NS_INIT_REFCNT();
NS_ADDREF(mURL);
}
HTMLCSSStyleSheetImpl::~HTMLCSSStyleSheetImpl()
@ -223,6 +223,22 @@ PRInt32 HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
return 0;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::Init(nsIURL* aURL, nsIDocument* aDocument)
{
NS_PRECONDITION(aURL && aDocument, "null ptr");
if (! aURL || ! aDocument)
return NS_ERROR_NULL_POINTER;
if (mURL || mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
mDocument = aDocument; // not refcounted!
mURL = aURL;
NS_ADDREF(mURL);
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetURL(nsIURL*& aURL) const
{
@ -311,20 +327,40 @@ void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
}
// XXX For backwards compatibility and convenience
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument)
{
nsresult rv;
nsIHTMLCSSStyleSheet* sheet;
if (NS_FAILED(rv = NS_NewHTMLCSSStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl(aURL, aDocument);
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLCSSStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -212,7 +212,7 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
HTMLStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument);
HTMLStyleSheetImpl(void);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
@ -245,6 +245,7 @@ public:
nsIStyleContext* aParentContext,
nsISupportsArray* aResults);
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument);
NS_IMETHOD SetLinkColor(nscolor aColor);
NS_IMETHOD SetActiveLinkColor(nscolor aColor);
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
@ -440,17 +441,16 @@ void HTMLStyleSheetImpl::operator delete(void* ptr)
HTMLStyleSheetImpl::HTMLStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument)
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
: nsIHTMLStyleSheet(),
mURL(aURL),
mDocument(aDocument),
mURL(nsnull),
mDocument(nsnull),
mLinkRule(nsnull),
mVisitedRule(nsnull),
mActiveRule(nsnull),
mRecycledAttrs(nsnull)
{
NS_INIT_REFCNT();
NS_ADDREF(mURL);
}
HTMLStyleSheetImpl::~HTMLStyleSheetImpl()
@ -670,10 +670,24 @@ HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const
NS_IMETHODIMP
HTMLStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument)
{
mDocument = aDocument;
mDocument = aDocument; // not refcounted
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::Init(nsIURL* aURL, nsIDocument* aDocument)
{
NS_PRECONDITION(aURL && aDocument, "null ptr");
if (! aURL || ! aDocument)
return NS_ERROR_NULL_POINTER;
if (mURL || mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
mDocument = aDocument; // not refcounted!
mURL = aURL;
NS_ADDREF(mURL);
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
{
@ -2604,19 +2618,40 @@ void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
}
// XXX For convenience and backwards compatibility
NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument)
{
nsresult rv;
nsIHTMLStyleSheet* sheet;
if (NS_FAILED(rv = NS_NewHTMLStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl(aURL, aDocument);
HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -27,11 +27,15 @@
class nsIHTMLCSSStyleSheet : public nsIStyleSheet {
public:
// no methods for now
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument) = 0;
};
// XXX for convenience and backward compatibility
extern NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument);
extern NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult);
#endif /* nsIHTMLCSSStyleSheet_h___ */

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

@ -35,6 +35,7 @@ class nsIDocument;
class nsIHTMLStyleSheet : public nsIStyleSheet {
public:
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument) = 0;
NS_IMETHOD SetLinkColor(nscolor aColor) = 0;
NS_IMETHOD SetActiveLinkColor(nscolor aColor) = 0;
NS_IMETHOD SetVisitedLinkColor(nscolor aColor) = 0;
@ -57,8 +58,13 @@ public:
};
// XXX convenience method. Calls Initialize() automatically.
extern NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument);
extern NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult);
#endif /* nsIHTMLStyleSheet_h___ */

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

@ -42,6 +42,7 @@
#include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsICSSParser.h"
#include "prlog.h"
//#define DEBUG_REFS
//#define DEBUG_RULES
@ -537,13 +538,14 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
CSSStyleSheetImpl(nsIURL* aURL);
CSSStyleSheetImpl();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
// basic style sheet data
NS_IMETHOD Init(nsIURL* aURL);
NS_IMETHOD GetURL(nsIURL*& aURL) const;
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD SetTitle(const nsString& aTitle);
@ -680,7 +682,7 @@ void CSSStyleSheetImpl::operator delete(void* ptr)
static PRInt32 gInstanceCount;
#endif
CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL)
CSSStyleSheetImpl::CSSStyleSheetImpl()
: nsICSSStyleSheet(),
mURL(nsnull), mTitle(), mMedia(nsnull),
mFirstChild(nsnull),
@ -689,7 +691,6 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL)
mRuleHash(nsnull)
{
NS_INIT_REFCNT();
mURL.SetAddRef(aURL);
mParent = nsnull;
mRuleCollection = nsnull;
mImportsCollection = nsnull;
@ -1151,6 +1152,21 @@ PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
return matchCount;
}
NS_IMETHODIMP
CSSStyleSheetImpl::Init(nsIURL* aURL)
{
NS_PRECONDITION(aURL, "null ptr");
if (! aURL)
return NS_ERROR_NULL_POINTER;
NS_ASSERTION(mURL == nsnull, "already initialized");
if (mURL)
return NS_ERROR_ALREADY_INITIALIZED;
mURL.SetAddRef(aURL);
return NS_OK;
}
NS_IMETHODIMP
CSSStyleSheetImpl::GetURL(nsIURL*& aURL) const
{
@ -1668,18 +1684,39 @@ CSSStyleSheetImpl::SetScriptObject(void* aScriptObject)
return NS_OK;
}
// XXX for backwards compatibility and convenience
NS_HTML nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult, nsIURL* aURL)
{
nsICSSStyleSheet* sheet;
nsresult rv;
if (NS_FAILED(rv = NS_NewCSSStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
CSSStyleSheetImpl *it = new CSSStyleSheetImpl(aURL);
CSSStyleSheetImpl *it = new CSSStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kICSSStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -43,13 +43,14 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
HTMLCSSStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument);
HTMLCSSStyleSheetImpl();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
// basic style sheet data
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument);
NS_IMETHOD GetURL(nsIURL*& aURL) const;
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD GetType(nsString& aType) const;
@ -132,13 +133,12 @@ void HTMLCSSStyleSheetImpl::operator delete(void* ptr)
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument)
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
: nsIHTMLCSSStyleSheet(),
mURL(aURL),
mDocument(aDocument)
mURL(nsnull),
mDocument(nsnull)
{
NS_INIT_REFCNT();
NS_ADDREF(mURL);
}
HTMLCSSStyleSheetImpl::~HTMLCSSStyleSheetImpl()
@ -223,6 +223,22 @@ PRInt32 HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
return 0;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::Init(nsIURL* aURL, nsIDocument* aDocument)
{
NS_PRECONDITION(aURL && aDocument, "null ptr");
if (! aURL || ! aDocument)
return NS_ERROR_NULL_POINTER;
if (mURL || mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
mDocument = aDocument; // not refcounted!
mURL = aURL;
NS_ADDREF(mURL);
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetURL(nsIURL*& aURL) const
{
@ -311,20 +327,40 @@ void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
}
// XXX For backwards compatibility and convenience
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument)
{
nsresult rv;
nsIHTMLCSSStyleSheet* sheet;
if (NS_FAILED(rv = NS_NewHTMLCSSStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl(aURL, aDocument);
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLCSSStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -212,7 +212,7 @@ public:
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
HTMLStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument);
HTMLStyleSheetImpl(void);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
@ -245,6 +245,7 @@ public:
nsIStyleContext* aParentContext,
nsISupportsArray* aResults);
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument);
NS_IMETHOD SetLinkColor(nscolor aColor);
NS_IMETHOD SetActiveLinkColor(nscolor aColor);
NS_IMETHOD SetVisitedLinkColor(nscolor aColor);
@ -440,17 +441,16 @@ void HTMLStyleSheetImpl::operator delete(void* ptr)
HTMLStyleSheetImpl::HTMLStyleSheetImpl(nsIURL* aURL, nsIDocument* aDocument)
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
: nsIHTMLStyleSheet(),
mURL(aURL),
mDocument(aDocument),
mURL(nsnull),
mDocument(nsnull),
mLinkRule(nsnull),
mVisitedRule(nsnull),
mActiveRule(nsnull),
mRecycledAttrs(nsnull)
{
NS_INIT_REFCNT();
NS_ADDREF(mURL);
}
HTMLStyleSheetImpl::~HTMLStyleSheetImpl()
@ -670,10 +670,24 @@ HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const
NS_IMETHODIMP
HTMLStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument)
{
mDocument = aDocument;
mDocument = aDocument; // not refcounted
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::Init(nsIURL* aURL, nsIDocument* aDocument)
{
NS_PRECONDITION(aURL && aDocument, "null ptr");
if (! aURL || ! aDocument)
return NS_ERROR_NULL_POINTER;
if (mURL || mDocument)
return NS_ERROR_ALREADY_INITIALIZED;
mDocument = aDocument; // not refcounted!
mURL = aURL;
NS_ADDREF(mURL);
return NS_OK;
}
NS_IMETHODIMP HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
{
@ -2604,19 +2618,40 @@ void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
}
// XXX For convenience and backwards compatibility
NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument)
{
nsresult rv;
nsIHTMLStyleSheet* sheet;
if (NS_FAILED(rv = NS_NewHTMLStyleSheet(&sheet)))
return rv;
if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
NS_RELEASE(sheet);
return rv;
}
*aInstancePtrResult = sheet;
return NS_OK;
}
NS_HTML nsresult
NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult)
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl(aURL, aDocument);
HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIHTMLStyleSheetIID, (void **) aInstancePtrResult);
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
}

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

@ -27,11 +27,15 @@
class nsIHTMLCSSStyleSheet : public nsIStyleSheet {
public:
// no methods for now
NS_IMETHOD Init(nsIURL* aURL, nsIDocument* aDocument) = 0;
};
// XXX for convenience and backward compatibility
extern NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURL* aURL,
nsIDocument* aDocument);
extern NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult);
#endif /* nsIHTMLCSSStyleSheet_h___ */