gecko-dev/layout/style/nsHTMLCSSStyleSheet.cpp

675 строки
18 KiB
C++
Исходник Обычный вид История

1998-05-14 03:42:18 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
1998-05-14 03:42:18 +04:00
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
1998-05-14 03:42:18 +04:00
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
1998-05-14 03:42:18 +04:00
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
1998-05-14 03:42:18 +04:00
*/
1998-05-14 03:42:18 +04:00
#include "nsIHTMLCSSStyleSheet.h"
#include "nsIArena.h"
#include "nsCRT.h"
#include "nsIAtom.h"
#include "nsIURL.h"
#include "nsISupportsArray.h"
#include "nsHTMLAtoms.h"
#include "nsIHTMLContent.h"
#include "nsIStyleRule.h"
1998-05-19 01:11:08 +04:00
#include "nsIFrame.h"
#include "nsHTMLIIDs.h"
1998-09-12 06:46:59 +04:00
#include "nsICSSStyleRule.h"
#include "nsIStyleRuleProcessor.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
1998-11-26 04:34:53 +03:00
#include "nsIDocument.h"
#include "nsCOMPtr.h"
#include "nsIStyleSet.h"
#include "nsIRuleWalker.h"
#include "nsISizeOfHandler.h"
1998-05-14 03:42:18 +04:00
1999-04-20 04:28:40 +04:00
class CSSFirstLineRule : public nsIStyleRule {
public:
CSSFirstLineRule(nsIHTMLCSSStyleSheet* aSheet);
virtual ~CSSFirstLineRule();
NS_DECL_ISUPPORTS
NS_IMETHOD Equals(const nsIStyleRule* aRule, PRBool& aValue) const;
NS_IMETHOD HashValue(PRUint32& aValue) const;
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
NS_IMETHOD GetStrength(PRInt32& aStrength) const;
// The new mapping function.
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
1999-04-20 04:28:40 +04:00
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
virtual void SizeOf(nsISizeOfHandler *aSizeofHandler, PRUint32 &aSize);
1999-04-20 04:28:40 +04:00
nsIHTMLCSSStyleSheet* mSheet;
};
CSSFirstLineRule::CSSFirstLineRule(nsIHTMLCSSStyleSheet* aSheet)
: mSheet(aSheet)
{
NS_INIT_REFCNT();
}
CSSFirstLineRule::~CSSFirstLineRule()
{
}
NS_IMPL_ISUPPORTS1(CSSFirstLineRule, nsIStyleRule)
1999-04-20 04:28:40 +04:00
NS_IMETHODIMP
CSSFirstLineRule::Equals(const nsIStyleRule* aRule, PRBool& aResult) const
{
aResult = PRBool(this == aRule);
return NS_OK;
}
NS_IMETHODIMP
CSSFirstLineRule::HashValue(PRUint32& aValue) const
{
aValue = (PRUint32)7; // XXX got a better suggestion?
return NS_OK;
}
NS_IMETHODIMP
CSSFirstLineRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
{
NS_IF_ADDREF(mSheet);
aSheet = mSheet;
return NS_OK;
}
// Strength is an out-of-band weighting, always 0 here
NS_IMETHODIMP
CSSFirstLineRule::GetStrength(PRInt32& aStrength) const
{
aStrength = 0;
return NS_OK;
}
NS_IMETHODIMP
CSSFirstLineRule::MapRuleInfoInto(nsRuleData* aData)
1999-04-20 04:28:40 +04:00
{
if (!aData)
return NS_OK;
1999-04-20 04:28:40 +04:00
if (aData->mSID == eStyleStruct_Border && aData->mMarginData) {
// Disable the border.
nsCSSValue styleVal(NS_STYLE_BORDER_STYLE_NONE, eCSSUnit_Enumerated);
if (aData->mMarginData->mBorderStyle->mLeft.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderStyle->mLeft = styleVal;
if (aData->mMarginData->mBorderStyle->mRight.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderStyle->mRight = styleVal;
if (aData->mMarginData->mBorderStyle->mTop.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderStyle->mTop = styleVal;
if (aData->mMarginData->mBorderStyle->mBottom.GetUnit() == eCSSUnit_Null)
aData->mMarginData->mBorderStyle->mBottom = styleVal;
1999-04-20 04:28:40 +04:00
}
return NS_OK;
}
NS_IMETHODIMP
CSSFirstLineRule::List(FILE* out, PRInt32 aIndent) const
{
return NS_OK;
}
/******************************************************************************
* SizeOf method:
*
* Self (reported as CSSFirstLineRule's size):
* 1) sizeof(*this)
*
* Contained / Aggregated data (not reported as CSSFirstLineRule's size):
* 1) Delegate to mSheet if it exists
*
* Children / siblings / parents:
* none
*
******************************************************************************/
void CSSFirstLineRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
{
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
// first get the unique items collection
UNIQUE_STYLE_ITEMS(uniqueItems);
if(! uniqueItems->AddItem((void*)this) ){
// object has already been accounted for
return;
}
// get or create a tag for this instance
nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("CSSFirstLine-LetterRule"));
// get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize);
if(mSheet){
PRUint32 localSize=0;
mSheet->SizeOf(aSizeOfHandler, localSize);
}
}
1999-04-20 04:28:40 +04:00
// -----------------------------------------------------------
class CSSFirstLetterRule : public CSSFirstLineRule {
public:
CSSFirstLetterRule(nsIHTMLCSSStyleSheet* aSheet);
};
CSSFirstLetterRule::CSSFirstLetterRule(nsIHTMLCSSStyleSheet* aSheet)
: CSSFirstLineRule(aSheet)
{
}
// -----------------------------------------------------------
1998-05-14 03:42:18 +04:00
class HTMLCSSStyleSheetImpl : public nsIHTMLCSSStyleSheet,
public nsIStyleRuleProcessor {
1998-05-14 03:42:18 +04:00
public:
void* operator new(size_t size);
void* operator new(size_t size, nsIArena* aArena);
void operator delete(void* ptr);
1998-05-14 03:42:18 +04:00
HTMLCSSStyleSheetImpl();
1998-05-14 03:42:18 +04:00
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
1998-11-26 04:34:53 +03:00
// basic style sheet data
NS_IMETHOD Init(nsIURI* aURL, nsIDocument* aDocument);
NS_IMETHOD Reset(nsIURI* aURL);
NS_IMETHOD GetURL(nsIURI*& aURL) const;
1998-11-26 04:34:53 +03:00
NS_IMETHOD GetTitle(nsString& aTitle) const;
NS_IMETHOD GetType(nsString& aType) const;
NS_IMETHOD GetMediumCount(PRInt32& aCount) const;
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const;
1998-11-26 04:34:53 +03:00
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
NS_IMETHOD SetEnabled(PRBool aEnabled);
// style sheet owner info
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
NS_IMETHOD SetOwningDocument(nsIDocument* aDocument);
NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor,
nsIStyleRuleProcessor* aPrevProcessor);
1998-05-14 03:42:18 +04:00
// nsIStyleRuleProcessor api
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
1998-05-19 01:11:08 +04:00
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aParentContent,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent);
1999-04-20 04:05:54 +04:00
1998-05-14 03:42:18 +04:00
// XXX style rule enumerations
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
virtual void SizeOf(nsISizeOfHandler *aSizeofHandler, PRUint32 &aSize);
// If changing the given attribute cannot affect style context, aAffects
// will be PR_FALSE on return.
NS_IMETHOD AttributeAffectsStyle(nsIAtom *aAttribute, nsIContent *aContent,
PRBool &aAffects);
1998-05-14 03:42:18 +04:00
private:
// These are not supported and are not implemented!
HTMLCSSStyleSheetImpl(const HTMLCSSStyleSheetImpl& aCopy);
HTMLCSSStyleSheetImpl& operator=(const HTMLCSSStyleSheetImpl& aCopy);
protected:
virtual ~HTMLCSSStyleSheetImpl();
protected:
PRUint32 mInHeap : 1;
PRUint32 mRefCnt : 31;
NS_DECL_OWNINGTHREAD // for thread-safety checking
1998-05-14 03:42:18 +04:00
nsIURI* mURL;
1998-11-26 04:34:53 +03:00
nsIDocument* mDocument;
1999-04-20 04:28:40 +04:00
CSSFirstLineRule* mFirstLineRule;
CSSFirstLetterRule* mFirstLetterRule;
1998-05-14 03:42:18 +04:00
};
void* HTMLCSSStyleSheetImpl::operator new(size_t size)
{
HTMLCSSStyleSheetImpl* rv = (HTMLCSSStyleSheetImpl*) ::operator new(size);
#ifdef NS_DEBUG
if (nsnull != rv) {
nsCRT::memset(rv, 0xEE, size);
}
#endif
rv->mInHeap = 1;
return (void*) rv;
}
void* HTMLCSSStyleSheetImpl::operator new(size_t size, nsIArena* aArena)
{
HTMLCSSStyleSheetImpl* rv = (HTMLCSSStyleSheetImpl*) aArena->Alloc(PRInt32(size));
#ifdef NS_DEBUG
if (nsnull != rv) {
nsCRT::memset(rv, 0xEE, size);
}
#endif
rv->mInHeap = 0;
return (void*) rv;
}
void HTMLCSSStyleSheetImpl::operator delete(void* ptr)
1998-05-14 03:42:18 +04:00
{
HTMLCSSStyleSheetImpl* sheet = (HTMLCSSStyleSheetImpl*) ptr;
if (nsnull != sheet) {
if (sheet->mInHeap) {
1999-02-26 20:13:10 +03:00
::operator delete(ptr);
1998-05-14 03:42:18 +04:00
}
}
}
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
1998-05-14 03:42:18 +04:00
: nsIHTMLCSSStyleSheet(),
mURL(nsnull),
1999-04-20 04:28:40 +04:00
mDocument(nsnull),
mFirstLineRule(nsnull),
mFirstLetterRule(nsnull)
1998-05-14 03:42:18 +04:00
{
NS_INIT_REFCNT();
}
HTMLCSSStyleSheetImpl::~HTMLCSSStyleSheetImpl()
{
NS_RELEASE(mURL);
1999-04-20 04:28:40 +04:00
if (nsnull != mFirstLineRule) {
mFirstLineRule->mSheet = nsnull;
NS_RELEASE(mFirstLineRule);
}
if (nsnull != mFirstLetterRule) {
mFirstLetterRule->mSheet = nsnull;
NS_RELEASE(mFirstLetterRule);
}
1998-05-14 03:42:18 +04:00
}
NS_IMPL_ADDREF(HTMLCSSStyleSheetImpl)
NS_IMPL_RELEASE(HTMLCSSStyleSheetImpl)
nsresult HTMLCSSStyleSheetImpl::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(NS_GET_IID(nsIHTMLCSSStyleSheet))) {
1998-05-14 03:42:18 +04:00
*aInstancePtrResult = (void*) ((nsIHTMLCSSStyleSheet*)this);
NS_ADDREF_THIS();
1998-05-14 03:42:18 +04:00
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStyleSheet))) {
1998-05-14 03:42:18 +04:00
*aInstancePtrResult = (void*) ((nsIStyleSheet*)this);
NS_ADDREF_THIS();
1998-05-14 03:42:18 +04:00
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStyleRuleProcessor))) {
*aInstancePtrResult = (void*) ((nsIStyleRuleProcessor*)this);
NS_ADDREF_THIS();
return NS_OK;
}
1998-05-14 03:42:18 +04:00
if (aIID.Equals(kISupportsIID)) {
*aInstancePtrResult = (void*) ((nsISupports*)(nsIStyleSheet*)this);
NS_ADDREF_THIS();
1998-05-14 03:42:18 +04:00
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor,
nsIStyleRuleProcessor* /*aPrevProcessor*/)
{
aProcessor = this;
NS_ADDREF(aProcessor);
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
1998-05-14 03:42:18 +04:00
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
NS_PRECONDITION(nsnull != aRuleWalker, "null arg");
nsCOMPtr<nsIStyledContent> styledContent(do_QueryInterface(aContent));
if (styledContent)
// just get the one and only style rule from the content's STYLE attribute
styledContent->WalkInlineStyleRules(aRuleWalker);
1998-05-14 03:42:18 +04:00
return NS_OK;
1998-05-14 03:42:18 +04:00
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aParentContent,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
1998-05-19 01:11:08 +04:00
{
1999-04-20 04:28:40 +04:00
if (aPseudoTag == nsHTMLAtoms::firstLinePseudo) {
PRBool atRoot = PR_FALSE;
aRuleWalker->AtRoot(&atRoot);
if (!atRoot) {
1999-04-20 04:28:40 +04:00
if (nsnull == mFirstLineRule) {
mFirstLineRule = new CSSFirstLineRule(this);
if (mFirstLineRule) {
NS_ADDREF(mFirstLineRule);
}
}
if (mFirstLineRule) {
aRuleWalker->Forward(mFirstLineRule);
return NS_OK;
1999-04-20 04:28:40 +04:00
}
}
}
if (aPseudoTag == nsHTMLAtoms::firstLetterPseudo) {
PRBool atRoot = PR_FALSE;
aRuleWalker->AtRoot(&atRoot);
if (!atRoot) {
if (nsnull == mFirstLetterRule) {
mFirstLetterRule = new CSSFirstLetterRule(this);
if (mFirstLetterRule) {
NS_ADDREF(mFirstLetterRule);
}
}
if (mFirstLetterRule) {
aRuleWalker->Forward(mFirstLetterRule);
return NS_OK;
}
}
}
1999-04-20 04:28:40 +04:00
// else no pseudo frame style...
return NS_OK;
1998-05-19 01:11:08 +04:00
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::Init(nsIURI* 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;
}
1999-04-20 04:05:54 +04:00
// Test if style is dependent on content state
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
1999-04-20 04:05:54 +04:00
nsIContent* aContent)
{
return NS_COMFALSE;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::Reset(nsIURI* aURL)
{
NS_IF_RELEASE(mURL);
mURL = aURL;
NS_ADDREF(mURL);
1999-04-20 04:28:40 +04:00
if (nsnull != mFirstLineRule) {
mFirstLineRule->mSheet = nsnull;
NS_RELEASE(mFirstLineRule);
}
if (nsnull != mFirstLetterRule) {
mFirstLetterRule->mSheet = nsnull;
NS_RELEASE(mFirstLetterRule);
}
return NS_OK;
}
1998-11-26 04:34:53 +03:00
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetURL(nsIURI*& aURL) const
1998-05-14 03:42:18 +04:00
{
1998-11-26 04:34:53 +03:00
NS_IF_ADDREF(mURL);
aURL = mURL;
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetTitle(nsString& aTitle) const
{
2000-04-16 00:15:37 +04:00
aTitle.AssignWithConversion("Internal HTML/CSS Style Sheet");
1998-11-26 04:34:53 +03:00
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetType(nsString& aType) const
{
2000-04-16 00:15:37 +04:00
aType.AssignWithConversion("text/html");
1998-11-26 04:34:53 +03:00
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetMediumCount(PRInt32& aCount) const
{
aCount = 0;
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const
1998-11-26 04:34:53 +03:00
{
aMedium = nsnull;
1998-11-26 04:34:53 +03:00
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP_(PRBool)
1999-06-15 10:21:47 +04:00
HTMLCSSStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const
{
return PR_TRUE; // works for all media
1999-06-15 10:21:47 +04:00
}
1998-11-26 04:34:53 +03:00
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
{
aEnabled = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::SetEnabled(PRBool aEnabled)
{ // these can't be disabled
return NS_OK;
}
// style sheet owner info
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
{
aParent = nsnull;
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const
{
NS_IF_ADDREF(mDocument);
aDocument = mDocument;
return NS_OK;
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument)
{
mDocument = aDocument;
return NS_OK;
1998-05-14 03:42:18 +04:00
}
void HTMLCSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const
{
// Indent
for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out);
fputs("HTML CSS Style Sheet: ", out);
char* urlSpec = nsnull;
mURL->GetSpec(&urlSpec);
if (urlSpec) {
fputs(urlSpec, out);
nsCRT::free(urlSpec);
}
1998-05-14 03:42:18 +04:00
fputs("\n", out);
}
/******************************************************************************
* SizeOf method:
*
* Self (reported as HTMLCSSStyleSheetImpl's size):
* 1) sizeof(*this)
*
* Contained / Aggregated data (not reported as HTMLCSSStyleSheetImpl's size):
* 1) We don't really delegate but count seperately the FirstLineRule and
* the FirstLetterRule if the exist and are unique instances
*
* Children / siblings / parents:
* none
*
******************************************************************************/
void HTMLCSSStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
{
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
// first get the unique items collection
UNIQUE_STYLE_ITEMS(uniqueItems);
if(! uniqueItems->AddItem((void*)this)){
// this style sheet is lared accounted for
return;
}
PRUint32 localSize=0;
// create a tag for this instance
nsCOMPtr<nsIAtom> tag;
tag = getter_AddRefs(NS_NewAtom("HTMLCSSStyleSheet"));
// get the size of an empty instance and add to the sizeof handler
aSize = sizeof(HTMLCSSStyleSheetImpl);
aSizeOfHandler->AddSize(tag,aSize);
// Now the associated rules (if they exist)
// - mFirstLineRule
// - mFirstLetterRule
if(mFirstLineRule && uniqueItems->AddItem((void*)mFirstLineRule)){
localSize = sizeof(*mFirstLineRule);
aSize += localSize;
tag = getter_AddRefs(NS_NewAtom("FirstLineRule"));
aSizeOfHandler->AddSize(tag,localSize);
}
if(mFirstLetterRule && uniqueItems->AddItem((void*)mFirstLetterRule)){
localSize = sizeof(*mFirstLetterRule);
aSize += localSize;
tag = getter_AddRefs(NS_NewAtom("FirstLetterRule"));
aSizeOfHandler->AddSize(tag,localSize);
}
}
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::AttributeAffectsStyle(nsIAtom *aAttribute,
nsIContent *aContent,
PRBool &aAffects)
{
// XXX can attributes affect rules in these?
aAffects = PR_FALSE;
return NS_OK;
}
// XXX For backwards compatibility and convenience
1998-05-14 03:42:18 +04:00
NS_HTML nsresult
NS_NewHTMLCSSStyleSheet(nsIHTMLCSSStyleSheet** aInstancePtrResult, nsIURI* aURL,
1998-11-26 04:34:53 +03:00
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)
1998-05-14 03:42:18 +04:00
{
if (aInstancePtrResult == nsnull) {
return NS_ERROR_NULL_POINTER;
}
HTMLCSSStyleSheetImpl* it = new HTMLCSSStyleSheetImpl();
1998-05-14 03:42:18 +04:00
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(it);
*aInstancePtrResult = it;
return NS_OK;
1998-05-14 03:42:18 +04:00
}