diff --git a/content/html/content/src/makefile.win b/content/html/content/src/makefile.win index c62efea35ec9..7186d245032a 100644 --- a/content/html/content/src/makefile.win +++ b/content/html/content/src/makefile.win @@ -24,7 +24,6 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ nsCommentNode.cpp \ - nsDOMStyleDeclaration.cpp \ nsGenericDOMDataNode.cpp \ nsGenericHTMLElement.cpp \ nsHTMLAnchorElement.cpp \ @@ -92,7 +91,6 @@ CPPSRCS= \ CPP_OBJS= \ .\$(OBJDIR)\nsCommentNode.obj \ - .\$(OBJDIR)\nsDOMStyleDeclaration.obj \ .\$(OBJDIR)\nsGenericDOMDataNode.obj \ .\$(OBJDIR)\nsGenericHTMLElement.obj \ .\$(OBJDIR)\nsHTMLAnchorElement.obj \ diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 7d27eb8b8018..6a26c81f021a 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -60,7 +60,7 @@ #include "nsIServiceManager.h" #include "nsIDOMScriptObjectFactory.h" #include "nsIDOMCSSStyleDeclaration.h" -#include "nsDOMStyleDeclaration.h" +#include "nsDOMCSSDeclaration.h" #include "prprf.h" #include "prmem.h" @@ -175,7 +175,7 @@ public: // nsIDOMNodeList interface NS_DECL_IDOMNODELIST - void DropContent(); + void DropReference(); private: nsGenericHTMLContainerElement *mContent; @@ -554,6 +554,113 @@ DOMAttributeMap::GetLength(PRUint32 *aLength) //---------------------------------------------------------------------- +class nsDOMCSSAttributeDeclaration : public nsDOMCSSDeclaration +{ +public: + nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent); + ~nsDOMCSSAttributeDeclaration(); + + virtual void DropReference(); + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate); + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint); + virtual nsresult GetParent(nsISupports **aParent); + +protected: + nsIHTMLContent *mContent; +}; + +nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent) +{ + // This reference is not reference-counted. The content + // object tells us when its about to go away. + mContent = aContent; +} + +nsDOMCSSAttributeDeclaration::~nsDOMCSSAttributeDeclaration() +{ +} + +void +nsDOMCSSAttributeDeclaration::DropReference() +{ + mContent = nsnull; +} + +nsresult +nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) +{ + nsHTMLValue val; + nsIStyleRule* rule; + nsICSSStyleRule* cssRule; + nsresult result = NS_OK; + + *aDecl = nsnull; + if (nsnull != mContent) { + mContent->GetAttribute(nsHTMLAtoms::style, val); + if (eHTMLUnit_ISupports == val.GetUnit()) { + rule = (nsIStyleRule*) val.GetISupportsValue(); + result = rule->QueryInterface(kICSSStyleRuleIID, (void**)&cssRule); + if (NS_OK == result) { + *aDecl = cssRule->GetDeclaration(); + NS_RELEASE(cssRule); + } + NS_RELEASE(rule); + } + else if (PR_TRUE == aAllocate) { + result = NS_NewCSSDeclaration(aDecl); + if (NS_OK == result) { + result = NS_NewCSSStyleRule(&cssRule, nsCSSSelector()); + if (NS_OK == result) { + cssRule->SetDeclaration(*aDecl); + cssRule->SetWeight(0x7fffffff); + rule = (nsIStyleRule *)cssRule; + result = mContent->SetAttribute(nsHTMLAtoms::style, + nsHTMLValue(cssRule), + PR_FALSE); + NS_RELEASE(cssRule); + } + else { + NS_RELEASE(*aDecl); + } + } + } + } + + return result; +} + +nsresult +nsDOMCSSAttributeDeclaration::StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) +{ + nsresult result = NS_OK; + if (nsnull != mContent) { + nsIDocument *doc; + result = mContent->GetDocument(doc); + if (NS_OK == result) { + result = doc->AttributeChanged(mContent, nsHTMLAtoms::style, aHint); + NS_RELEASE(doc); + } + } + + return result; +} + +nsresult +nsDOMCSSAttributeDeclaration::GetParent(nsISupports **aParent) +{ + if (nsnull != mContent) { + return mContent->QueryInterface(kISupportsIID, (void **)aParent); + } + + return NS_OK; +} + +//---------------------------------------------------------------------- + static nsresult EnsureWritableAttributes(nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes, PRBool aCreate) { @@ -641,11 +748,11 @@ nsGenericHTMLElement::~nsGenericHTMLElement() NS_IF_RELEASE(mListenerManager); if (nsnull != mDOMSlots) { if (nsnull != mDOMSlots->mChildNodes) { - mDOMSlots->mChildNodes->DropContent(); + mDOMSlots->mChildNodes->DropReference(); NS_RELEASE(mDOMSlots->mChildNodes); } if (nsnull != mDOMSlots->mStyle) { - mDOMSlots->mStyle->DropContent(); + mDOMSlots->mStyle->DropReference(); NS_RELEASE(mDOMSlots->mStyle); } // XXX Should really be arena managed @@ -954,7 +1061,7 @@ nsGenericHTMLElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) nsDOMSlots *slots = GetDOMSlots(); if (nsnull == slots->mStyle) { - slots->mStyle = new nsDOMStyleDeclaration(mContent); + slots->mStyle = new nsDOMCSSAttributeDeclaration(mContent); if (nsnull == slots->mStyle) { return NS_ERROR_OUT_OF_MEMORY; } @@ -2909,7 +3016,7 @@ nsChildContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) } void -nsChildContentList::DropContent() +nsChildContentList::DropReference() { mContent = nsnull; } diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 6492a86231a5..25ff051aef06 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -47,7 +47,7 @@ class nsIStyleRule; class nsISupportsArray; class nsIDOMScriptObjectFactory; class nsChildContentList; -class nsDOMStyleDeclaration; +class nsDOMCSSDeclaration; // There are a set of DOM- and scripting-specific instance variables @@ -59,7 +59,7 @@ class nsDOMStyleDeclaration; typedef struct { void *mScriptObject; nsChildContentList *mChildNodes; - nsDOMStyleDeclaration *mStyle; + nsDOMCSSDeclaration *mStyle; } nsDOMSlots; class nsGenericHTMLElement : public nsIJSScriptObject { diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 2dfb773d16aa..39a9926f2b6e 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -48,6 +48,9 @@ #include "nsIFormManager.h" #include "nsRepository.h" #include "nsParserCIID.h" +#include "nsIDOMStyleSheet.h" +#include "nsIDOMStyleSheetCollection.h" + // Find/Serach Includes #include "nsISelection.h" @@ -73,6 +76,239 @@ static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); static NS_DEFINE_IID(kIDOMNSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID); static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); +static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_IID); +static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID); + +class nsDOMStyleSheetCollection : public nsIDOMStyleSheetCollection, + public nsIScriptObjectOwner, + public nsIDocumentObserver +{ +public: + nsDOMStyleSheetCollection(nsIDocument *aDocument); + ~nsDOMStyleSheetCollection(); + + NS_DECL_ISUPPORTS + NS_DECL_IDOMSTYLESHEETCOLLECTION + + NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginReflow(nsIDocument *aDocument, + nsIPresShell* aShell) { return NS_OK; } + NS_IMETHOD EndReflow(nsIDocument *aDocument, + nsIPresShell* aShell) { return NS_OK; } + NS_IMETHOD ContentChanged(nsIDocument *aDocument, + nsIContent* aContent, + nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD AttributeChanged(nsIDocument *aDocument, + nsIContent* aContent, + nsIAtom* aAttribute, + PRInt32 aHint) { return NS_OK; } + NS_IMETHOD ContentAppended(nsIDocument *aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer) + { return NS_OK; } + NS_IMETHOD ContentInserted(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) { return NS_OK; } + NS_IMETHOD ContentReplaced(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer) { return NS_OK; } + NS_IMETHOD ContentRemoved(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) { return NS_OK; } + NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet); + NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + +protected: + PRInt32 mLength; + nsIDocument* mDocument; + void* mScriptObject; +}; + +nsDOMStyleSheetCollection::nsDOMStyleSheetCollection(nsIDocument *aDocument) +{ + NS_INIT_REFCNT(); + mLength = -1; + // Not reference counted to avoid circular references. + // The document will tell us when its going away. + mDocument = aDocument; + mDocument->AddObserver(this); + mScriptObject = nsnull; +} + +nsDOMStyleSheetCollection::~nsDOMStyleSheetCollection() +{ + if (nsnull != mDocument) { + mDocument->RemoveObserver(this); + } + mDocument = nsnull; +} + +NS_IMPL_ADDREF(nsDOMStyleSheetCollection) +NS_IMPL_RELEASE(nsDOMStyleSheetCollection) + +nsresult +nsDOMStyleSheetCollection::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMStyleSheetCollectionIID)) { + nsIDOMStyleSheetCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDocumentObserverIID)) { + nsIDocumentObserver *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMStyleSheetCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::GetLength(PRUint32* aLength) +{ + if (nsnull != mDocument) { + // XXX Find the number and then cache it. We'll use the + // observer notification to figure out if new ones have + // been added or removed. + if (-1 == mLength) { + PRUint32 count = 0; + PRInt32 i, imax = mDocument->GetNumberOfStyleSheets(); + + for (i = 0; i < imax; i++) { + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i); + nsIDOMStyleSheet *domss; + + if (NS_OK == sheet->QueryInterface(kIDOMStyleSheetIID, (void **)&domss)) { + count++; + NS_RELEASE(domss); + } + + NS_RELEASE(sheet); + } + mLength = count; + } + *aLength = mLength; + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn) +{ + *aReturn = nsnull; + if (nsnull != mDocument) { + PRUint32 count = 0; + PRInt32 i, imax = mDocument->GetNumberOfStyleSheets(); + + // XXX Not particularly efficient, but does anyone care? + for (i = 0; (i < imax) && (nsnull == *aReturn); i++) { + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i); + nsIDOMStyleSheet *domss; + + if (NS_OK == sheet->QueryInterface(kIDOMStyleSheetIID, (void **)&domss)) { + if (count++ == aIndex) { + *aReturn = domss; + NS_ADDREF(domss); + } + NS_RELEASE(domss); + } + + NS_RELEASE(sheet); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMStyleSheetCollection *)this; + nsISupports *parent = (nsISupports *)mDocument; + + // XXX Should be done through factory + res = NS_NewScriptStyleSheetCollection(aContext, + supports, + parent, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::StyleSheetAdded(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet) +{ + if (-1 != mLength) { + nsIDOMStyleSheet *domss; + if (NS_OK == aStyleSheet->QueryInterface(kIDOMStyleSheetIID, (void **)&domss)) { + mLength++; + NS_RELEASE(domss); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::DocumentWillBeDestroyed(nsIDocument *aDocument) +{ + if (nsnull != mDocument) { + aDocument->RemoveObserver(this); + mDocument = nsnull; + } + + return NS_OK; +} NS_LAYOUT nsresult NS_NewHTMLDocument(nsIDocument** aInstancePtrResult) @@ -93,6 +329,7 @@ nsHTMLDocument::nsHTMLDocument() mAnchors = nsnull; mNamedItems = nsnull; mParser = nsnull; + mDOMStyleSheets = nsnull; nsHTMLAtoms::AddrefAtoms(); mDTDMode = eDTDMode_NoQuirks; @@ -124,6 +361,7 @@ nsHTMLDocument::~nsHTMLDocument() NS_IF_RELEASE(mEmbeds); NS_IF_RELEASE(mLinks); NS_IF_RELEASE(mAnchors); + NS_IF_RELEASE(mDOMStyleSheets); NS_IF_RELEASE(mAttrStyleSheet); NS_IF_RELEASE(mStyleAttrStyleSheet); NS_IF_RELEASE(mParser); @@ -830,6 +1068,23 @@ nsHTMLDocument::GetLastModified(nsString& aLastModified) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsHTMLDocument::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets) +{ + if (nsnull == mDOMStyleSheets) { + mDOMStyleSheets = new nsDOMStyleSheetCollection(this); + if (nsnull == mDOMStyleSheets) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mDOMStyleSheets); + } + + *aStyleSheets = mDOMStyleSheets; + NS_ADDREF(mDOMStyleSheets); + + return NS_OK; +} + NS_IMETHODIMP nsHTMLDocument::GetEmbeds(nsIDOMHTMLCollection** aEmbeds) { diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index e112876e5ce5..091972938707 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -32,6 +32,7 @@ class nsContentList; class nsIContentViewerContainer; class nsIParser; class BlockText; +class nsDOMStyleSheetCollection; class nsHTMLDocument : public nsMarkupDocument, public nsIHTMLDocument, public nsIDOMHTMLDocument, public nsIDOMNSHTMLDocument { public: @@ -161,6 +162,7 @@ protected: nsContentList *mLinks; nsContentList *mAnchors; nsContentList *mForms; + nsDOMStyleSheetCollection *mDOMStyleSheets; PLHashTable *mNamedItems; diff --git a/content/html/style/public/nsICSSParser.h b/content/html/style/public/nsICSSParser.h index ca8a3422a4bc..957e5fef2bd7 100644 --- a/content/html/style/public/nsICSSParser.h +++ b/content/html/style/public/nsICSSParser.h @@ -43,7 +43,7 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aSheet) = 0; NS_IMETHOD Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult) = 0; // Parse declarations assuming that the outer curly braces have @@ -58,6 +58,7 @@ public: nsICSSDeclaration* aDeclaration, PRInt32* aHint) = 0; + NS_IMETHOD ProcessImport(const nsString& aURLSpec) = 0; }; // Values or'd in the GetInfoMask; other bits are reserved diff --git a/content/html/style/src/nsCSSParser.cpp b/content/html/style/src/nsCSSParser.cpp index f4d61344e30c..1d665f2d046d 100644 --- a/content/html/style/src/nsCSSParser.cpp +++ b/content/html/style/src/nsCSSParser.cpp @@ -197,7 +197,7 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aSheet); NS_IMETHOD Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult); NS_IMETHOD ParseDeclarations(const nsString& aDeclaration, @@ -209,6 +209,8 @@ public: nsICSSDeclaration* aDeclaration, PRInt32* aHint); + NS_IMETHOD ProcessImport(const nsString& aURLSpec); + protected: PRBool GetToken(PRInt32* aErrorCode, PRBool aSkipWS); void UngetToken(); @@ -281,8 +283,6 @@ protected: PRBool TranslateLength(nsICSSDeclaration* aDeclaration, const char* aName, float aNumber, const nsString& aDimension); - void ProcessImport(const nsString& aURLSpec); - // Current token. The value is valid after calling GetToken nsCSSToken mToken; @@ -364,7 +364,7 @@ CSSParserImpl::SetStyleSheet(nsIStyleSheet* aSheet) NS_METHOD CSSParserImpl::Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult) { if (nsnull == mSheet) { @@ -598,7 +598,7 @@ PRBool CSSParserImpl::ParseImportRule(PRInt32* aErrorCode) return PR_TRUE; } -void CSSParserImpl::ProcessImport(const nsString& aURLSpec) +NS_IMETHODIMP CSSParserImpl::ProcessImport(const nsString& aURLSpec) { // XXX probably need a way to encode unicode junk for the part of // the url that follows a "?" @@ -609,7 +609,7 @@ void CSSParserImpl::ProcessImport(const nsString& aURLSpec) if (NS_OK != rv) { // import url is bad // XXX log this somewhere for easier web page debugging - return; + return rv; } if (PR_FALSE == mSheet->ContainsStyleSheet(url)) { // don't allow circular references @@ -656,6 +656,8 @@ void CSSParserImpl::ProcessImport(const nsString& aURLSpec) } } NS_RELEASE(url); + + return rv; } void CSSParserImpl::SkipUntil(PRInt32* aErrorCode, PRUnichar aStopSymbol) diff --git a/content/html/style/src/nsCSSStyleRule.cpp b/content/html/style/src/nsCSSStyleRule.cpp index 513e3babb3f1..0c13a0041cfb 100644 --- a/content/html/style/src/nsCSSStyleRule.cpp +++ b/content/html/style/src/nsCSSStyleRule.cpp @@ -17,6 +17,7 @@ */ #include "nsICSSStyleRule.h" #include "nsICSSDeclaration.h" +#include "nsIStyleSheet.h" #include "nsIStyleContext.h" #include "nsIPresContext.h" #include "nsIDeviceContext.h" @@ -29,12 +30,25 @@ #include "nsUnitConversion.h" #include "nsStyleUtil.h" #include "nsIFontMetrics.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRule.h" +#include "nsIDOMCSSStyleRuleSimple.h" +#include "nsIDOMCSSStyleDeclaration.h" +#include "nsIScriptGlobalObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsDOMCSSDeclaration.h" //#define DEBUG_REFS +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); static NS_DEFINE_IID(kICSSDeclarationIID, NS_ICSS_DECLARATION_IID); static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleSheetIID, NS_IDOMCSSSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleIID, NS_IDOMCSSSTYLERULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleSimpleIID, NS_IDOMCSSSTYLERULESIMPLE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kCSSFontSID, NS_CSS_FONT_SID); static NS_DEFINE_IID(kCSSColorSID, NS_CSS_COLOR_SID); @@ -231,10 +245,79 @@ CSSImportantRule::List(FILE* out, PRInt32 aIndent) const return NS_OK; } +// -- nsDOMStyleRuleDeclaration ------------------------------- + +class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration +{ +public: + DOMCSSDeclarationImpl(nsICSSStyleRule *aRule); + ~DOMCSSDeclarationImpl(); + + virtual void DropReference(); + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate); + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint); + virtual nsresult GetParent(nsISupports **aParent); + +protected: + nsICSSStyleRule *mRule; +}; + +DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(nsICSSStyleRule *aRule) +{ + // This reference is not reference-counted. The rule + // object tells us when its about to go away. + mRule = aRule; +} + +DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl() +{ +} + +void +DOMCSSDeclarationImpl::DropReference() +{ + mRule = nsnull; +} + +nsresult +DOMCSSDeclarationImpl::GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) +{ + if (nsnull != mRule) { + *aDecl = mRule->GetDeclaration(); + } + else { + *aDecl = nsnull; + } + + return NS_OK; +} + +nsresult +DOMCSSDeclarationImpl::StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) +{ + // XXX TBI + return NS_OK; +} + +nsresult +DOMCSSDeclarationImpl::GetParent(nsISupports **aParent) +{ + if (nsnull != mRule) { + return mRule->QueryInterface(kISupportsIID, (void **)aParent); + } + + return NS_OK; +} // -- nsCSSStyleRule ------------------------------- -class CSSStyleRuleImpl : public nsICSSStyleRule { +class CSSStyleRuleImpl : public nsICSSStyleRule, + public nsIDOMCSSStyleRuleSimple, + public nsIScriptObjectOwner { public: void* operator new(size_t size); void* operator new(size_t size, nsIArena* aArena); @@ -263,10 +346,25 @@ public: virtual nsIStyleRule* GetImportantRule(void); + virtual nsIStyleSheet* GetStyleSheet(void); + virtual void SetStyleSheet(nsIStyleSheet *aSheet); + NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + // nsIDOMCSSStyleRule interface + NS_IMETHOD GetType(nsString& aType); + + // nsIDOMCSSStyleRuleSimple interface + NS_IMETHOD GetSelectorText(nsString& aSelectorText); + NS_IMETHOD SetSelectorText(const nsString& aSelectorText); + NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + private: // These are not supported and are not implemented! CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy); @@ -283,6 +381,9 @@ protected: nsICSSDeclaration* mDeclaration; PRInt32 mWeight; CSSImportantRule* mImportantRule; + nsIStyleSheet* mStyleSheet; + DOMCSSDeclarationImpl *mDOMDeclaration; + void* mScriptObject; #ifdef DEBUG_REFS PRInt32 mInstance; #endif @@ -334,6 +435,8 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(const nsCSSSelector& aSelector) mWeight(0), mImportantRule(nsnull) { NS_INIT_REFCNT(); + mDOMDeclaration = nsnull; + mScriptObject = nsnull; #ifdef DEBUG_REFS mInstance = gInstanceCount++; fprintf(stdout, "%d of %d + CSSStyleRule\n", mInstance, gInstanceCount); @@ -351,6 +454,9 @@ CSSStyleRuleImpl::~CSSStyleRuleImpl() } NS_IF_RELEASE(mDeclaration); NS_IF_RELEASE(mImportantRule); + if (nsnull != mDOMDeclaration) { + mDOMDeclaration->DropReference(); + } #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d of %d - CSSStyleRule\n", mInstance, gInstanceCount); @@ -389,7 +495,6 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID, if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); if (aIID.Equals(kICSSStyleRuleIID)) { *aInstancePtrResult = (void*) ((nsICSSStyleRule*)this); NS_ADDREF_THIS(); @@ -400,8 +505,28 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID, NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kIDOMCSSStyleRuleIID)) { + nsIDOMCSSStyleRule *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIDOMCSSStyleRuleSimpleIID)) { + nsIDOMCSSStyleRuleSimple *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)this); + nsICSSStyleRule *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; NS_ADDREF_THIS(); return NS_OK; } @@ -543,6 +668,21 @@ nsIStyleRule* CSSStyleRuleImpl::GetImportantRule(void) return mImportantRule; } +nsIStyleSheet* CSSStyleRuleImpl::GetStyleSheet(void) +{ + NS_IF_ADDREF(mStyleSheet); + + return mStyleSheet; +} + +void CSSStyleRuleImpl::SetStyleSheet(nsIStyleSheet *aSheet) +{ + // XXX We don't reference count this up reference. The style sheet + // will tell us when it's going away or when we're detached from + // it. + mStyleSheet = aSheet; +} + nscoord CalcLength(const nsCSSValue& aValue, const nsStyleFont* aFont, nsIPresContext* aPresContext) @@ -1236,6 +1376,105 @@ CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const return NS_OK; } +NS_IMETHODIMP +CSSStyleRuleImpl::GetType(nsString& aType) +{ + // XXX Need to define the different types + aType.SetString("simple"); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetSelectorText(nsString& aSelectorText) +{ + nsAutoString buffer; + nsAutoString thisSelector; + nsCSSSelector *selector = &mSelector; + + // XXX Ugh...they're in reverse order from the source. Sorry + // for the ugliness. + aSelectorText.SetLength(0); + while (nsnull != selector) { + thisSelector.SetLength(0); + if (nsnull != selector->mTag) { + selector->mTag->ToString(buffer); + thisSelector.Append(buffer); + } + if (nsnull != selector->mID) { + selector->mID->ToString(buffer); + thisSelector.Append("#"); + thisSelector.Append(buffer); + } + if (nsnull != selector->mClass) { + selector->mClass->ToString(buffer); + thisSelector.Append("."); + thisSelector.Append(buffer); + } + if (nsnull != selector->mPseudoClass) { + selector->mPseudoClass->ToString(buffer); + thisSelector.Append(":"); + thisSelector.Append(buffer); + } + aSelectorText.Insert(thisSelector, 0, thisSelector.Length()); + selector = selector->mNext; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::SetSelectorText(const nsString& aSelectorText) +{ + // XXX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) +{ + if (nsnull == mDOMDeclaration) { + mDOMDeclaration = new DOMCSSDeclarationImpl(this); + if (nsnull == mDOMDeclaration) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mDOMDeclaration); + } + + *aStyle = mDOMDeclaration; + NS_ADDREF(mDOMDeclaration); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsICSSStyleRule *)this; + // XXX Parent should be the style sheet + // XXX Should be done through factory + res = NS_NewScriptCSSStyleRuleSimple(aContext, + supports, + (nsISupports *)global, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return res; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + NS_HTML nsresult NS_NewCSSStyleRule(nsICSSStyleRule** aInstancePtrResult, const nsCSSSelector& aSelector) { diff --git a/content/html/style/src/nsCSSStyleSheet.cpp b/content/html/style/src/nsCSSStyleSheet.cpp index f8839f4d77e5..b74affeed84a 100644 --- a/content/html/style/src/nsCSSStyleSheet.cpp +++ b/content/html/style/src/nsCSSStyleSheet.cpp @@ -32,6 +32,13 @@ #include "nsString.h" #include "nsIPtr.h" #include "nsHTMLIIDs.h" +#include "nsIDOMStyleSheetCollection.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRule.h" +#include "nsIDOMCSSStyleRuleCollection.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsICSSParser.h" //#define DEBUG_REFS //#define DEBUG_RULES @@ -39,6 +46,12 @@ static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID); static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); +static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleSheetIID, NS_IDOMCSSSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleIID, NS_IDOMCSSSTYLERULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleCollectionIID, NS_IDOMCSSSTYLERULECOLLECTION_IID); +static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); NS_DEF_PTR(nsIHTMLContent); NS_DEF_PTR(nsIContent); @@ -129,6 +142,7 @@ public: RuleEnumFunc aFunc, void* aData); void EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData); + protected: void AppendRuleToTable(nsHashtable& aTable, nsIAtom* aAtom, nsICSSStyleRule* aRule); @@ -171,6 +185,7 @@ void RuleHash::AppendRuleToTable(nsHashtable& aTable, nsIAtom* aAtom, nsICSSStyl value = value->mNext; } value->mNext = new RuleValue(aRule, mRuleCount++); + value = value->mNext; } } @@ -242,11 +257,279 @@ void RuleHash::EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData) } } +// ------------------------------- +// Style Rule Collection for the DOM +// +class CSSStyleRuleCollectionImpl : public nsIDOMCSSStyleRuleCollection, + public nsIScriptObjectOwner +{ +public: + CSSStyleRuleCollectionImpl(nsICSSStyleSheet *aStyleSheet); + + NS_DECL_ISUPPORTS + + // nsIDOMCSSStyleRuleCollection interface + NS_IMETHOD GetLength(PRUint32* aLength); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMCSSStyleRule** aReturn); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + void DropReference() { mStyleSheet = nsnull; } + +protected: + virtual ~CSSStyleRuleCollectionImpl(); + + nsICSSStyleSheet* mStyleSheet; + void* mScriptObject; +}; + +CSSStyleRuleCollectionImpl::CSSStyleRuleCollectionImpl(nsICSSStyleSheet *aStyleSheet) +{ + NS_INIT_REFCNT(); + // Not reference counted to avoid circular references. + // The style sheet will tell us when its going away. + mStyleSheet = aStyleSheet; + mScriptObject = nsnull; +} + +CSSStyleRuleCollectionImpl::~CSSStyleRuleCollectionImpl() +{ +} + +NS_IMPL_ADDREF(CSSStyleRuleCollectionImpl); +NS_IMPL_RELEASE(CSSStyleRuleCollectionImpl); + +nsresult +CSSStyleRuleCollectionImpl::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMCSSStyleRuleCollectionIID)) { + nsIDOMCSSStyleRuleCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMCSSStyleRuleCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::GetLength(PRUint32* aLength) +{ + if (nsnull != mStyleSheet) { + *aLength = mStyleSheet->StyleRuleCount(); + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::Item(PRUint32 aIndex, nsIDOMCSSStyleRule** aReturn) +{ + nsresult result = NS_OK; + + *aReturn = nsnull; + if (nsnull != mStyleSheet) { + nsICSSStyleRule *rule; + + result = mStyleSheet->GetStyleRuleAt(aIndex, rule); + if (NS_OK == result) { + result = rule->QueryInterface(kIDOMCSSStyleRuleIID, (void **)aReturn); + } + NS_RELEASE(rule); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleRuleCollection *)this; + + // XXX Should be done through factory + res = NS_NewScriptCSSStyleRuleCollection(aContext, + supports, + (nsISupports *)mStyleSheet, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +// ------------------------------- +// Imports Collection for the DOM +// +class CSSImportsCollectionImpl : public nsIDOMStyleSheetCollection, + public nsIScriptObjectOwner +{ +public: + CSSImportsCollectionImpl(nsICSSStyleSheet *aStyleSheet); + + NS_DECL_ISUPPORTS + + // nsIDOMCSSStyleSheetCollection interface + NS_IMETHOD GetLength(PRUint32* aLength); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + void DropReference() { mStyleSheet = nsnull; } + +protected: + virtual ~CSSImportsCollectionImpl(); + + nsICSSStyleSheet* mStyleSheet; + void* mScriptObject; +}; + +CSSImportsCollectionImpl::CSSImportsCollectionImpl(nsICSSStyleSheet *aStyleSheet) +{ + NS_INIT_REFCNT(); + // Not reference counted to avoid circular references. + // The style sheet will tell us when its going away. + mStyleSheet = aStyleSheet; + mScriptObject = nsnull; +} + +CSSImportsCollectionImpl::~CSSImportsCollectionImpl() +{ +} + +NS_IMPL_ADDREF(CSSImportsCollectionImpl); +NS_IMPL_RELEASE(CSSImportsCollectionImpl); + +nsresult +CSSImportsCollectionImpl::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMStyleSheetCollectionIID)) { + nsIDOMStyleSheetCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMStyleSheetCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::GetLength(PRUint32* aLength) +{ + if (nsnull != mStyleSheet) { + *aLength = mStyleSheet->StyleSheetCount(); + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn) +{ + nsresult result = NS_OK; + + *aReturn = nsnull; + if (nsnull != mStyleSheet) { + nsICSSStyleSheet *sheet; + + result = mStyleSheet->GetStyleSheetAt(aIndex, sheet); + if (NS_OK == result) { + result = sheet->QueryInterface(kIDOMStyleSheetIID, (void **)aReturn); + } + NS_RELEASE(sheet); + } + + return result; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMStyleSheetCollection *)this; + + // XXX Should be done through factory + res = NS_NewScriptStyleSheetCollection(aContext, + supports, + (nsISupports *)mStyleSheet, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} // ------------------------------- // CSS Style Sheet // -class CSSStyleSheetImpl : public nsICSSStyleSheet { +class CSSStyleSheetImpl : public nsICSSStyleSheet, + public nsIDOMCSSStyleSheet, + public nsIScriptObjectOwner { public: void* operator new(size_t size); void* operator new(size_t size, nsIArena* aArena); @@ -281,8 +564,32 @@ public: virtual PRInt32 StyleRuleCount(void); virtual nsresult GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRule); + virtual PRInt32 StyleSheetCount(); + virtual nsresult GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet); + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + // nsIDOMStyleSheet interface + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetReadOnly(PRBool* aReadOnly); + + // nsIDOMCSSStyleSheet interface + NS_IMETHOD GetOwningElement(nsIDOMHTMLElement** aOwningElement); + NS_IMETHOD GetParentStyleSheet(nsIDOMCSSStyleSheet** aParentStyleSheet); + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD GetTitle(nsString& aTitle); + NS_IMETHOD GetImports(nsIDOMStyleSheetCollection** aImports); + NS_IMETHOD GetRules(nsIDOMCSSStyleRuleCollection** aRules); + NS_IMETHOD AddRule(const nsString& aSelector, const nsString& aDeclaration, PRUint32 aIndex, PRUint32* aReturn); + NS_IMETHOD AddImport(const nsString& aUrl, PRUint32 aIndex, PRUint32* aReturn); + NS_IMETHOD RemoveRule(PRUint32 aIndex); + NS_IMETHOD RemoveImport(PRUint32 aIndex); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + private: // These are not supported and are not implemented! CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy); @@ -303,7 +610,11 @@ protected: nsISupportsArrayPtr mOrderedRules; nsISupportsArrayPtr mWeightedRules; nsICSSStyleSheetPtr mNext; + nsICSSStyleSheet* mParent; RuleHash* mRuleHash; + CSSStyleRuleCollectionImpl* mRuleCollection; + CSSImportsCollectionImpl* mImportsCollection; + void * mScriptObject; }; @@ -354,18 +665,49 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL) { NS_INIT_REFCNT(); mURL.SetAddRef(aURL); + mParent = nsnull; + mRuleCollection = nsnull; + mImportsCollection = nsnull; + mScriptObject = nsnull; #ifdef DEBUG_REFS ++gInstanceCount; fprintf(stdout, "%d + CSSStyleSheet size: %d\n", gInstanceCount, sizeof(*this)); #endif } +static PRBool DropStyleSheetReference(nsISupports* aElement, void *aData) +{ + nsICSSStyleRule *rule = (nsICSSStyleRule *)aElement; + + if (nsnull != rule) { + rule->SetStyleSheet(nsnull); + } + + return PR_TRUE; +} + CSSStyleSheetImpl::~CSSStyleSheetImpl() { #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d - CSSStyleSheet\n", gInstanceCount); #endif + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while (nsnull != child) { + ((CSSStyleSheetImpl *)child)->mParent = nsnull; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + } + if (nsnull != mRuleCollection) { + mRuleCollection->DropReference(); + NS_RELEASE(mRuleCollection); + } + if (nsnull != mImportsCollection) { + mImportsCollection->DropReference(); + NS_RELEASE(mImportsCollection); + } + mOrderedRules->EnumerateForwards(DropStyleSheetReference, nsnull); ClearHash(); } @@ -390,8 +732,28 @@ nsresult CSSStyleSheetImpl::QueryInterface(const nsIID& aIID, NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kIDOMStyleSheetIID)) { + nsIDOMStyleSheet *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIDOMCSSStyleSheetIID)) { + nsIDOMCSSStyleSheet *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)this); + nsICSSStyleSheet *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; NS_ADDREF_THIS(); return NS_OK; } @@ -750,6 +1112,10 @@ void CSSStyleSheetImpl::AppendStyleSheet(nsICSSStyleSheet* aSheet) } ((CSSStyleSheetImpl*)child)->mNext.SetAddRef(aSheet); } + + // This is not reference counted. Our parent tells us when + // it's going away. + ((CSSStyleSheetImpl*)aSheet)->mParent = this; } void CSSStyleSheetImpl::PrependStyleRule(nsICSSStyleRule* aRule) @@ -778,6 +1144,7 @@ void CSSStyleSheetImpl::PrependStyleRule(nsICSSStyleRule* aRule) } mWeightedRules->InsertElementAt(aRule, index + 1); mOrderedRules->InsertElementAt(aRule, 0); + aRule->SetStyleSheet(this); } void CSSStyleSheetImpl::AppendStyleRule(nsICSSStyleRule* aRule) @@ -807,6 +1174,7 @@ void CSSStyleSheetImpl::AppendStyleRule(nsICSSStyleRule* aRule) } mWeightedRules->InsertElementAt(aRule, index); mOrderedRules->AppendElement(aRule); + aRule->SetStyleSheet(this); } PRInt32 CSSStyleSheetImpl::StyleRuleCount(void) @@ -833,6 +1201,43 @@ nsresult CSSStyleSheetImpl::GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRu return result; } +PRInt32 CSSStyleSheetImpl::StyleSheetCount() +{ + // XXX Far from an ideal way to do this, but the hope is that + // it won't be done too often. If it is, we might want to + // consider storing the children in an array. + PRInt32 count = 0; + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while (nsnull != child) { + count++; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + } + + return count; +} + +nsresult CSSStyleSheetImpl::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) +{ + // XXX Ughh...an O(n^2) method for doing iteration. Again, we hope + // that this isn't done too often. If it is, we need to change the + // underlying storage mechanism + aSheet = nsnull; + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while ((nsnull != child) && (0 != aIndex)) { + --aIndex; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + + aSheet = child; + NS_IF_ADDREF(child); + } + + return NS_OK; +} + void CSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { nsAutoString buffer; @@ -886,6 +1291,224 @@ void CSSStyleSheetImpl::BuildHash(void) } } +NS_IMETHODIMP +CSSStyleSheetImpl::GetDisabled(PRBool* aDisabled) +{ + // XXX TBI + *aDisabled = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::SetDisabled(PRBool aDisabled) +{ + // XXX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetReadOnly(PRBool* aReadOnly) +{ + // XXX TBI + *aReadOnly = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetOwningElement(nsIDOMHTMLElement** aOwningElement) +{ + // XXX TBI + *aOwningElement = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aParentStyleSheet) +{ + if (nsnull != mParent) { + return mParent->QueryInterface(kIDOMCSSStyleSheetIID, (void **)aParentStyleSheet); + } + else { + *aParentStyleSheet = nsnull; + return NS_OK; + } +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetHref(nsString& aHref) +{ + if (mURL.IsNotNull()) { + mURL->ToString(aHref); + } + else { + aHref.SetLength(0); + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetTitle(nsString& aTitle) +{ + // XX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetImports(nsIDOMStyleSheetCollection** aImports) +{ + if (nsnull == mImportsCollection) { + mImportsCollection = new CSSImportsCollectionImpl(this); + if (nsnull == mImportsCollection) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mImportsCollection); + } + + *aImports = mImportsCollection; + NS_ADDREF(mImportsCollection); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetRules(nsIDOMCSSStyleRuleCollection** aRules) +{ + if (nsnull == mRuleCollection) { + mRuleCollection = new CSSStyleRuleCollectionImpl(this); + if (nsnull == mRuleCollection) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mRuleCollection); + } + + *aRules = mRuleCollection; + NS_ADDREF(mRuleCollection); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::AddRule(const nsString& aSelector, + const nsString& aDeclaration, + PRUint32 aIndex, + PRUint32* aReturn) +{ + nsICSSParser* css; + nsresult result = NS_NewCSSParser(&css); + if (NS_OK == result) { + nsAutoString str; + str.SetString(aSelector); + // XXX Can we assume that the braces aren't there? + str.Append(" { "); + str.Append(aDeclaration); + str.Append(" } "); + + nsIUnicharInputStream* input = nsnull; + result = NS_NewStringUnicharInputStream(&input, &str); + if (NS_OK == result) { + nsIStyleSheet *tmp; + css->SetStyleSheet(this); + // XXX Currently, the parser will append the rule to the + // style sheet. We shouldn't ignore the index. + result = css->Parse(input, mURL, tmp); + NS_ASSERTION(tmp = this, "parser incorrectly created a new stylesheet"); + NS_RELEASE(input); + *aReturn = mOrderedRules->Count(); + } + + NS_RELEASE(css); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::AddImport(const nsString& aUrl, PRUint32 aIndex, PRUint32* aReturn) +{ + nsICSSParser* css; + nsresult result = NS_NewCSSParser(&css); + if (NS_OK == result) { + css->SetStyleSheet(this); + result = css->ProcessImport(aUrl); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::RemoveRule(PRUint32 aIndex) +{ + nsICSSStyleRule *rule; + + rule = (nsICSSStyleRule *)mOrderedRules->ElementAt(aIndex); + if (nsnull != rule) { + mOrderedRules->RemoveElementAt(aIndex); + mWeightedRules->RemoveElement(rule); + rule->SetStyleSheet(nsnull); + NS_RELEASE(rule); + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::RemoveImport(PRUint32 aIndex) +{ + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* prev = nsnull; + nsICSSStyleSheet* child = mFirstChild; + while ((nsnull != child) && (0 != aIndex)) { + prev = child; + child = ((CSSStyleSheetImpl*)child)->mNext; + --aIndex; + } + + if ((nsnull != child) && (0 == aIndex)) { + // Hold on to the child while we clean it up + NS_ADDREF(child); + if (nsnull == prev) { + mFirstChild.SetAddRef(((CSSStyleSheetImpl*)child)->mNext); + } + else { + ((CSSStyleSheetImpl*)prev)->mNext.SetAddRef(((CSSStyleSheetImpl*)child)->mNext); + } + ((CSSStyleSheetImpl*)child)->mNext.SetAddRef(nsnull); + ((CSSStyleSheetImpl*)child)->mParent = nsnull; + NS_RELEASE(child); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsICSSStyleSheet *)this; + // XXX Should be done through factory + res = NS_NewScriptCSSStyleSheet(aContext, + supports, + (nsISupports *)global, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return res; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + NS_HTML nsresult NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult, nsIURL* aURL) { diff --git a/layout/html/content/src/nsDOMStyleDeclaration.cpp b/content/html/style/src/nsDOMCSSDeclaration.cpp similarity index 54% rename from layout/html/content/src/nsDOMStyleDeclaration.cpp rename to content/html/style/src/nsDOMCSSDeclaration.cpp index 04944bb915d8..dedd6fff82ee 100644 --- a/layout/html/content/src/nsDOMStyleDeclaration.cpp +++ b/content/html/style/src/nsDOMCSSDeclaration.cpp @@ -17,38 +17,33 @@ * Netscape Communications Corporation. All Rights Reserved. */ -#include "nsDOMStyleDeclaration.h" -#include "nsGenericHTMLElement.h" +#include "nsDOMCSSDeclaration.h" #include "nsICSSStyleRule.h" #include "nsICSSParser.h" #include "nsIStyleRule.h" #include "nsICSSDeclaration.h" #include "nsCSSProps.h" -#include "nsHTMLAtoms.h" -#include "nsIHTMLContent.h" -#include "nsIDocument.h" -nsDOMStyleDeclaration::nsDOMStyleDeclaration(nsIHTMLContent *aContent) +nsDOMCSSDeclaration::nsDOMCSSDeclaration() { NS_INIT_REFCNT(); - // This reference is not reference-counted. The content - // object tells us when its about to go away. - mContent = aContent; mScriptObject = nsnull; } -nsDOMStyleDeclaration::~nsDOMStyleDeclaration() +nsDOMCSSDeclaration::~nsDOMCSSDeclaration() { } -NS_IMPL_ADDREF(nsDOMStyleDeclaration); -NS_IMPL_RELEASE(nsDOMStyleDeclaration); +NS_IMPL_ADDREF(nsDOMCSSDeclaration); +NS_IMPL_RELEASE(nsDOMCSSDeclaration); static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); NS_IMETHODIMP -nsDOMStyleDeclaration::QueryInterface(REFNSIID aIID, +nsDOMCSSDeclaration::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_PRECONDITION(nsnull != aInstancePtr, "null ptr"); @@ -78,26 +73,24 @@ nsDOMStyleDeclaration::QueryInterface(REFNSIID aIID, } NS_IMETHODIMP -nsDOMStyleDeclaration::GetScriptObject(nsIScriptContext* aContext, +nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject) { nsresult res = NS_OK; if (nsnull == mScriptObject) { nsISupports *parent = nsnull; - if (nsnull != mContent) { - res = mContent->QueryInterface(kISupportsIID, (void **)&parent); - if (NS_OK != res) { - return res; - } + + res = GetParent(&parent); + if (NS_OK == res) { + nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleDeclaration *)this; + // XXX Should be done through factory + res = NS_NewScriptCSSStyleDeclaration(aContext, + supports, + parent, + (void**)&mScriptObject); + NS_RELEASE(parent); } - nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleDeclaration *)this; - // XXX Should be done through factory - res = NS_NewScriptCSSStyleDeclaration(aContext, - supports, - parent, - (void**)&mScriptObject); - NS_RELEASE(parent); } *aScriptObject = mScriptObject; @@ -105,67 +98,17 @@ nsDOMStyleDeclaration::GetScriptObject(nsIScriptContext* aContext, } NS_IMETHODIMP -nsDOMStyleDeclaration::SetScriptObject(void* aScriptObject) +nsDOMCSSDeclaration::SetScriptObject(void* aScriptObject) { mScriptObject = aScriptObject; return NS_OK; } -void -nsDOMStyleDeclaration::DropContent() -{ - mContent = nsnull; -} - -nsresult -nsDOMStyleDeclaration::GetContentStyle(nsICSSDeclaration **aDecl, - PRBool aAllocate) -{ - nsHTMLValue val; - nsIStyleRule* rule; - nsICSSStyleRule* cssRule; - nsresult result = NS_OK; - - *aDecl = nsnull; - if (nsnull != mContent) { - mContent->GetAttribute(nsHTMLAtoms::style, val); - if (eHTMLUnit_ISupports == val.GetUnit()) { - rule = (nsIStyleRule*) val.GetISupportsValue(); - result = rule->QueryInterface(kICSSStyleRuleIID, (void**)&cssRule); - if (NS_OK == result) { - *aDecl = cssRule->GetDeclaration(); - NS_RELEASE(cssRule); - } - NS_RELEASE(rule); - } - else if (PR_TRUE == aAllocate) { - result = NS_NewCSSDeclaration(aDecl); - if (NS_OK == result) { - result = NS_NewCSSStyleRule(&cssRule, nsCSSSelector()); - if (NS_OK == result) { - cssRule->SetDeclaration(*aDecl); - cssRule->SetWeight(0x7fffffff); - rule = (nsIStyleRule *)cssRule; - result = mContent->SetAttribute(nsHTMLAtoms::style, - nsHTMLValue(cssRule), - PR_FALSE); - NS_RELEASE(cssRule); - } - else { - NS_RELEASE(*aDecl); - } - } - } - } - - return result; -} - NS_IMETHODIMP -nsDOMStyleDeclaration::GetLength(PRUint32* aLength) +nsDOMCSSDeclaration::GetLength(PRUint32* aLength) { nsICSSDeclaration *decl; - nsresult result = GetContentStyle(&decl, PR_FALSE); + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); *aLength = 0; if ((NS_OK == result) && (nsnull != decl)) { @@ -177,10 +120,10 @@ nsDOMStyleDeclaration::GetLength(PRUint32* aLength) } NS_IMETHODIMP -nsDOMStyleDeclaration::Item(PRUint32 aIndex, nsString& aReturn) +nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsString& aReturn) { nsICSSDeclaration *decl; - nsresult result = GetContentStyle(&decl, PR_FALSE); + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); aReturn.SetLength(0); if ((NS_OK == result) && (nsnull != decl)) { @@ -192,12 +135,12 @@ nsDOMStyleDeclaration::Item(PRUint32 aIndex, nsString& aReturn) } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPropertyValue(const nsString& aPropertyName, +nsDOMCSSDeclaration::GetPropertyValue(const nsString& aPropertyName, nsString& aReturn) { nsCSSValue val; nsICSSDeclaration *decl; - nsresult result = GetContentStyle(&decl, PR_FALSE); + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); aReturn.SetLength(0); if ((NS_OK == result) && (nsnull != decl)) { @@ -209,11 +152,11 @@ nsDOMStyleDeclaration::GetPropertyValue(const nsString& aPropertyName, } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPropertyPriority(const nsString& aPropertyName, +nsDOMCSSDeclaration::GetPropertyPriority(const nsString& aPropertyName, nsString& aReturn) { nsICSSDeclaration *decl; - nsresult result = GetContentStyle(&decl, PR_FALSE); + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); PRBool isImportant = PR_FALSE; if ((NS_OK == result) && (nsnull != decl)) { @@ -234,13 +177,13 @@ nsDOMStyleDeclaration::GetPropertyPriority(const nsString& aPropertyName, } NS_IMETHODIMP -nsDOMStyleDeclaration::SetProperty(const nsString& aPropertyName, - const nsString& aValue, - const nsString& aPriority) +nsDOMCSSDeclaration::SetProperty(const nsString& aPropertyName, + const nsString& aValue, + const nsString& aPriority) { nsAutoString declString; nsICSSDeclaration *decl; - nsresult result = GetContentStyle(&decl, PR_TRUE); + nsresult result = GetCSSDeclaration(&decl, PR_TRUE); if ((NS_OK == result) && (nsnull != decl)) { declString.SetString(aPropertyName); @@ -258,12 +201,7 @@ nsDOMStyleDeclaration::SetProperty(const nsString& aPropertyName, aPropertyName.ToCString(prop, sizeof(prop)); decl->SetValueImportant(prop); } - nsIDocument *doc; - result = mContent->GetDocument(doc); - if (NS_OK == result) { - doc->AttributeChanged(mContent, nsHTMLAtoms::style, hint); - NS_RELEASE(doc); - } + result = StylePropertyChanged(aPropertyName, hint); } NS_RELEASE(css); } @@ -274,1465 +212,1465 @@ nsDOMStyleDeclaration::SetProperty(const nsString& aPropertyName, } NS_IMETHODIMP -nsDOMStyleDeclaration::GetAzimuth(nsString& aAzimuth) +nsDOMCSSDeclaration::GetAzimuth(nsString& aAzimuth) { return GetPropertyValue("azimuth", aAzimuth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetAzimuth(const nsString& aAzimuth) +nsDOMCSSDeclaration::SetAzimuth(const nsString& aAzimuth) { return SetProperty("azimuth", aAzimuth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBackground(nsString& aBackground) +nsDOMCSSDeclaration::GetBackground(nsString& aBackground) { return GetPropertyValue("background", aBackground); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBackground(const nsString& aBackground) +nsDOMCSSDeclaration::SetBackground(const nsString& aBackground) { return SetProperty("background", aBackground, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBackgroundAttachment(nsString& aBackgroundAttachment) +nsDOMCSSDeclaration::GetBackgroundAttachment(nsString& aBackgroundAttachment) { return GetPropertyValue("background-attachment", aBackgroundAttachment); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBackgroundAttachment(const nsString& aBackgroundAttachment) +nsDOMCSSDeclaration::SetBackgroundAttachment(const nsString& aBackgroundAttachment) { return SetProperty("background-attachment", aBackgroundAttachment, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBackgroundColor(nsString& aBackgroundColor) +nsDOMCSSDeclaration::GetBackgroundColor(nsString& aBackgroundColor) { return GetPropertyValue("background-color", aBackgroundColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBackgroundColor(const nsString& aBackgroundColor) +nsDOMCSSDeclaration::SetBackgroundColor(const nsString& aBackgroundColor) { return SetProperty("background-color", aBackgroundColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBackgroundImage(nsString& aBackgroundImage) +nsDOMCSSDeclaration::GetBackgroundImage(nsString& aBackgroundImage) { return GetPropertyValue("background-image", aBackgroundImage); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBackgroundImage(const nsString& aBackgroundImage) +nsDOMCSSDeclaration::SetBackgroundImage(const nsString& aBackgroundImage) { return SetProperty("background-image", aBackgroundImage, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBackgroundPosition(nsString& aBackgroundPosition) +nsDOMCSSDeclaration::GetBackgroundPosition(nsString& aBackgroundPosition) { return GetPropertyValue("background-position", aBackgroundPosition); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBackgroundPosition(const nsString& aBackgroundPosition) +nsDOMCSSDeclaration::SetBackgroundPosition(const nsString& aBackgroundPosition) { return SetProperty("background-position", aBackgroundPosition, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBackgroundRepeat(nsString& aBackgroundRepeat) +nsDOMCSSDeclaration::GetBackgroundRepeat(nsString& aBackgroundRepeat) { return GetPropertyValue("background-repeat", aBackgroundRepeat); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBackgroundRepeat(const nsString& aBackgroundRepeat) +nsDOMCSSDeclaration::SetBackgroundRepeat(const nsString& aBackgroundRepeat) { return SetProperty("background-repeat", aBackgroundRepeat, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorder(nsString& aBorder) +nsDOMCSSDeclaration::GetBorder(nsString& aBorder) { return GetPropertyValue("border", aBorder); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorder(const nsString& aBorder) +nsDOMCSSDeclaration::SetBorder(const nsString& aBorder) { return SetProperty("border", aBorder, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderCollapse(nsString& aBorderCollapse) +nsDOMCSSDeclaration::GetBorderCollapse(nsString& aBorderCollapse) { return GetPropertyValue("border-collapse", aBorderCollapse); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderCollapse(const nsString& aBorderCollapse) +nsDOMCSSDeclaration::SetBorderCollapse(const nsString& aBorderCollapse) { return SetProperty("border-collapse", aBorderCollapse, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderColor(nsString& aBorderColor) +nsDOMCSSDeclaration::GetBorderColor(nsString& aBorderColor) { return GetPropertyValue("border-color", aBorderColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderColor(const nsString& aBorderColor) +nsDOMCSSDeclaration::SetBorderColor(const nsString& aBorderColor) { return SetProperty("border-color", aBorderColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderSpacing(nsString& aBorderSpacing) +nsDOMCSSDeclaration::GetBorderSpacing(nsString& aBorderSpacing) { return GetPropertyValue("border-spacing", aBorderSpacing); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderSpacing(const nsString& aBorderSpacing) +nsDOMCSSDeclaration::SetBorderSpacing(const nsString& aBorderSpacing) { return SetProperty("border-spacing", aBorderSpacing, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderStyle(nsString& aBorderStyle) +nsDOMCSSDeclaration::GetBorderStyle(nsString& aBorderStyle) { return GetPropertyValue("border-style", aBorderStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderStyle(const nsString& aBorderStyle) +nsDOMCSSDeclaration::SetBorderStyle(const nsString& aBorderStyle) { return SetProperty("border-style", aBorderStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderTop(nsString& aBorderTop) +nsDOMCSSDeclaration::GetBorderTop(nsString& aBorderTop) { return GetPropertyValue("border-top", aBorderTop); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderTop(const nsString& aBorderTop) +nsDOMCSSDeclaration::SetBorderTop(const nsString& aBorderTop) { return SetProperty("border-top", aBorderTop, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderRight(nsString& aBorderRight) +nsDOMCSSDeclaration::GetBorderRight(nsString& aBorderRight) { return GetPropertyValue("border-right", aBorderRight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderRight(const nsString& aBorderRight) +nsDOMCSSDeclaration::SetBorderRight(const nsString& aBorderRight) { return SetProperty("border-right", aBorderRight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderBottom(nsString& aBorderBottom) +nsDOMCSSDeclaration::GetBorderBottom(nsString& aBorderBottom) { return GetPropertyValue("border-bottom", aBorderBottom); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderBottom(const nsString& aBorderBottom) +nsDOMCSSDeclaration::SetBorderBottom(const nsString& aBorderBottom) { return SetProperty("border-bottom", aBorderBottom, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderLeft(nsString& aBorderLeft) +nsDOMCSSDeclaration::GetBorderLeft(nsString& aBorderLeft) { return GetPropertyValue("border-left", aBorderLeft); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderLeft(const nsString& aBorderLeft) +nsDOMCSSDeclaration::SetBorderLeft(const nsString& aBorderLeft) { return SetProperty("border-left", aBorderLeft, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderTopColor(nsString& aBorderTopColor) +nsDOMCSSDeclaration::GetBorderTopColor(nsString& aBorderTopColor) { return GetPropertyValue("border-top-color", aBorderTopColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderTopColor(const nsString& aBorderTopColor) +nsDOMCSSDeclaration::SetBorderTopColor(const nsString& aBorderTopColor) { return SetProperty("border-top-color", aBorderTopColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderRightColor(nsString& aBorderRightColor) +nsDOMCSSDeclaration::GetBorderRightColor(nsString& aBorderRightColor) { return GetPropertyValue("border-right-color", aBorderRightColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderRightColor(const nsString& aBorderRightColor) +nsDOMCSSDeclaration::SetBorderRightColor(const nsString& aBorderRightColor) { return SetProperty("border-right-color", aBorderRightColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderBottomColor(nsString& aBorderBottomColor) +nsDOMCSSDeclaration::GetBorderBottomColor(nsString& aBorderBottomColor) { return GetPropertyValue("border-bottom-color", aBorderBottomColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderBottomColor(const nsString& aBorderBottomColor) +nsDOMCSSDeclaration::SetBorderBottomColor(const nsString& aBorderBottomColor) { return SetProperty("border-bottom-color", aBorderBottomColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderLeftColor(nsString& aBorderLeftColor) +nsDOMCSSDeclaration::GetBorderLeftColor(nsString& aBorderLeftColor) { return GetPropertyValue("border-left-color", aBorderLeftColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderLeftColor(const nsString& aBorderLeftColor) +nsDOMCSSDeclaration::SetBorderLeftColor(const nsString& aBorderLeftColor) { return SetProperty("border-left-color", aBorderLeftColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderTopStyle(nsString& aBorderTopStyle) +nsDOMCSSDeclaration::GetBorderTopStyle(nsString& aBorderTopStyle) { return GetPropertyValue("border-top-style", aBorderTopStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderTopStyle(const nsString& aBorderTopStyle) +nsDOMCSSDeclaration::SetBorderTopStyle(const nsString& aBorderTopStyle) { return SetProperty("border-top-style", aBorderTopStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderRightStyle(nsString& aBorderRightStyle) +nsDOMCSSDeclaration::GetBorderRightStyle(nsString& aBorderRightStyle) { return GetPropertyValue("border-right-style", aBorderRightStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderRightStyle(const nsString& aBorderRightStyle) +nsDOMCSSDeclaration::SetBorderRightStyle(const nsString& aBorderRightStyle) { return SetProperty("border-right-style", aBorderRightStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderBottomStyle(nsString& aBorderBottomStyle) +nsDOMCSSDeclaration::GetBorderBottomStyle(nsString& aBorderBottomStyle) { return GetPropertyValue("border-bottom-style", aBorderBottomStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderBottomStyle(const nsString& aBorderBottomStyle) +nsDOMCSSDeclaration::SetBorderBottomStyle(const nsString& aBorderBottomStyle) { return SetProperty("border-bottom-style", aBorderBottomStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderLeftStyle(nsString& aBorderLeftStyle) +nsDOMCSSDeclaration::GetBorderLeftStyle(nsString& aBorderLeftStyle) { return GetPropertyValue("border-left-style", aBorderLeftStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderLeftStyle(const nsString& aBorderLeftStyle) +nsDOMCSSDeclaration::SetBorderLeftStyle(const nsString& aBorderLeftStyle) { return SetProperty("border-left-style", aBorderLeftStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderTopWidth(nsString& aBorderTopWidth) +nsDOMCSSDeclaration::GetBorderTopWidth(nsString& aBorderTopWidth) { return GetPropertyValue("border-top-width", aBorderTopWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderTopWidth(const nsString& aBorderTopWidth) +nsDOMCSSDeclaration::SetBorderTopWidth(const nsString& aBorderTopWidth) { return SetProperty("border-top-width", aBorderTopWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderRightWidth(nsString& aBorderRightWidth) +nsDOMCSSDeclaration::GetBorderRightWidth(nsString& aBorderRightWidth) { return GetPropertyValue("border-right-width", aBorderRightWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderRightWidth(const nsString& aBorderRightWidth) +nsDOMCSSDeclaration::SetBorderRightWidth(const nsString& aBorderRightWidth) { return SetProperty("border-right-width", aBorderRightWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderBottomWidth(nsString& aBorderBottomWidth) +nsDOMCSSDeclaration::GetBorderBottomWidth(nsString& aBorderBottomWidth) { return GetPropertyValue("border-bottom-width", aBorderBottomWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderBottomWidth(const nsString& aBorderBottomWidth) +nsDOMCSSDeclaration::SetBorderBottomWidth(const nsString& aBorderBottomWidth) { return SetProperty("border-bottom-width", aBorderBottomWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderLeftWidth(nsString& aBorderLeftWidth) +nsDOMCSSDeclaration::GetBorderLeftWidth(nsString& aBorderLeftWidth) { return GetPropertyValue("border-left-width", aBorderLeftWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderLeftWidth(const nsString& aBorderLeftWidth) +nsDOMCSSDeclaration::SetBorderLeftWidth(const nsString& aBorderLeftWidth) { return SetProperty("border-left-width", aBorderLeftWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBorderWidth(nsString& aBorderWidth) +nsDOMCSSDeclaration::GetBorderWidth(nsString& aBorderWidth) { return GetPropertyValue("border-width", aBorderWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBorderWidth(const nsString& aBorderWidth) +nsDOMCSSDeclaration::SetBorderWidth(const nsString& aBorderWidth) { return SetProperty("border-width", aBorderWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetBottom(nsString& aBottom) +nsDOMCSSDeclaration::GetBottom(nsString& aBottom) { return GetPropertyValue("bottom", aBottom); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetBottom(const nsString& aBottom) +nsDOMCSSDeclaration::SetBottom(const nsString& aBottom) { return SetProperty("bottom", aBottom, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCaptionSide(nsString& aCaptionSide) +nsDOMCSSDeclaration::GetCaptionSide(nsString& aCaptionSide) { return GetPropertyValue("caption-side", aCaptionSide); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCaptionSide(const nsString& aCaptionSide) +nsDOMCSSDeclaration::SetCaptionSide(const nsString& aCaptionSide) { return SetProperty("caption-side", aCaptionSide, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetClear(nsString& aClear) +nsDOMCSSDeclaration::GetClear(nsString& aClear) { return GetPropertyValue("clear", aClear); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetClear(const nsString& aClear) +nsDOMCSSDeclaration::SetClear(const nsString& aClear) { return SetProperty("clear", aClear, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetClip(nsString& aClip) +nsDOMCSSDeclaration::GetClip(nsString& aClip) { return GetPropertyValue("clip", aClip); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetClip(const nsString& aClip) +nsDOMCSSDeclaration::SetClip(const nsString& aClip) { return SetProperty("clip", aClip, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetColor(nsString& aColor) +nsDOMCSSDeclaration::GetColor(nsString& aColor) { return GetPropertyValue("color", aColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetColor(const nsString& aColor) +nsDOMCSSDeclaration::SetColor(const nsString& aColor) { return SetProperty("color", aColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetContent(nsString& aContent) +nsDOMCSSDeclaration::GetContent(nsString& aContent) { return GetPropertyValue("content", aContent); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetContent(const nsString& aContent) +nsDOMCSSDeclaration::SetContent(const nsString& aContent) { return SetProperty("content", aContent, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCounterIncrement(nsString& aCounterIncrement) +nsDOMCSSDeclaration::GetCounterIncrement(nsString& aCounterIncrement) { return GetPropertyValue("counter-increment", aCounterIncrement); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCounterIncrement(const nsString& aCounterIncrement) +nsDOMCSSDeclaration::SetCounterIncrement(const nsString& aCounterIncrement) { return SetProperty("counter-increment", aCounterIncrement, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCounterReset(nsString& aCounterReset) +nsDOMCSSDeclaration::GetCounterReset(nsString& aCounterReset) { return GetPropertyValue("counter-reset", aCounterReset); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCounterReset(const nsString& aCounterReset) +nsDOMCSSDeclaration::SetCounterReset(const nsString& aCounterReset) { return SetProperty("counter-reset", aCounterReset, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCue(nsString& aCue) +nsDOMCSSDeclaration::GetCue(nsString& aCue) { return GetPropertyValue("cue", aCue); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCue(const nsString& aCue) +nsDOMCSSDeclaration::SetCue(const nsString& aCue) { return SetProperty("cue", aCue, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCueAfter(nsString& aCueAfter) +nsDOMCSSDeclaration::GetCueAfter(nsString& aCueAfter) { return GetPropertyValue("cue-after", aCueAfter); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCueAfter(const nsString& aCueAfter) +nsDOMCSSDeclaration::SetCueAfter(const nsString& aCueAfter) { return SetProperty("cue-after", aCueAfter, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCueBefore(nsString& aCueBefore) +nsDOMCSSDeclaration::GetCueBefore(nsString& aCueBefore) { return GetPropertyValue("cue-before", aCueBefore); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCueBefore(const nsString& aCueBefore) +nsDOMCSSDeclaration::SetCueBefore(const nsString& aCueBefore) { return SetProperty("cue-before", aCueBefore, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetCursor(nsString& aCursor) +nsDOMCSSDeclaration::GetCursor(nsString& aCursor) { return GetPropertyValue("cursor", aCursor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetCursor(const nsString& aCursor) +nsDOMCSSDeclaration::SetCursor(const nsString& aCursor) { return SetProperty("cursor", aCursor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetDirection(nsString& aDirection) +nsDOMCSSDeclaration::GetDirection(nsString& aDirection) { return GetPropertyValue("direction", aDirection); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetDirection(const nsString& aDirection) +nsDOMCSSDeclaration::SetDirection(const nsString& aDirection) { return SetProperty("direction", aDirection, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetDisplay(nsString& aDisplay) +nsDOMCSSDeclaration::GetDisplay(nsString& aDisplay) { return GetPropertyValue("display", aDisplay); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetDisplay(const nsString& aDisplay) +nsDOMCSSDeclaration::SetDisplay(const nsString& aDisplay) { return SetProperty("display", aDisplay, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetElevation(nsString& aElevation) +nsDOMCSSDeclaration::GetElevation(nsString& aElevation) { return GetPropertyValue("elevation", aElevation); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetElevation(const nsString& aElevation) +nsDOMCSSDeclaration::SetElevation(const nsString& aElevation) { return SetProperty("elevation", aElevation, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetEmptyCells(nsString& aEmptyCells) +nsDOMCSSDeclaration::GetEmptyCells(nsString& aEmptyCells) { return GetPropertyValue("empty-cells", aEmptyCells); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetEmptyCells(const nsString& aEmptyCells) +nsDOMCSSDeclaration::SetEmptyCells(const nsString& aEmptyCells) { return SetProperty("empty-cells", aEmptyCells, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetStyleFloat(nsString& aStyleFloat) +nsDOMCSSDeclaration::GetStyleFloat(nsString& aStyleFloat) { return GetPropertyValue("style-float", aStyleFloat); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetStyleFloat(const nsString& aStyleFloat) +nsDOMCSSDeclaration::SetStyleFloat(const nsString& aStyleFloat) { return SetProperty("style-float", aStyleFloat, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFont(nsString& aFont) +nsDOMCSSDeclaration::GetFont(nsString& aFont) { return GetPropertyValue("font", aFont); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFont(const nsString& aFont) +nsDOMCSSDeclaration::SetFont(const nsString& aFont) { return SetProperty("font", aFont, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontFamily(nsString& aFontFamily) +nsDOMCSSDeclaration::GetFontFamily(nsString& aFontFamily) { return GetPropertyValue("font-family", aFontFamily); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontFamily(const nsString& aFontFamily) +nsDOMCSSDeclaration::SetFontFamily(const nsString& aFontFamily) { return SetProperty("font-family", aFontFamily, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontSize(nsString& aFontSize) +nsDOMCSSDeclaration::GetFontSize(nsString& aFontSize) { return GetPropertyValue("font-size", aFontSize); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontSize(const nsString& aFontSize) +nsDOMCSSDeclaration::SetFontSize(const nsString& aFontSize) { return SetProperty("font-size", aFontSize, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontSizeAdjust(nsString& aFontSizeAdjust) +nsDOMCSSDeclaration::GetFontSizeAdjust(nsString& aFontSizeAdjust) { return GetPropertyValue("font-size-adjust", aFontSizeAdjust); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontSizeAdjust(const nsString& aFontSizeAdjust) +nsDOMCSSDeclaration::SetFontSizeAdjust(const nsString& aFontSizeAdjust) { return SetProperty("font-size-adjust", aFontSizeAdjust, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontStretch(nsString& aFontStretch) +nsDOMCSSDeclaration::GetFontStretch(nsString& aFontStretch) { return GetPropertyValue("font-stretch", aFontStretch); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontStretch(const nsString& aFontStretch) +nsDOMCSSDeclaration::SetFontStretch(const nsString& aFontStretch) { return SetProperty("font-stretch", aFontStretch, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontStyle(nsString& aFontStyle) +nsDOMCSSDeclaration::GetFontStyle(nsString& aFontStyle) { return GetPropertyValue("font-style", aFontStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontStyle(const nsString& aFontStyle) +nsDOMCSSDeclaration::SetFontStyle(const nsString& aFontStyle) { return SetProperty("font-style", aFontStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontVariant(nsString& aFontVariant) +nsDOMCSSDeclaration::GetFontVariant(nsString& aFontVariant) { return GetPropertyValue("font-variant", aFontVariant); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontVariant(const nsString& aFontVariant) +nsDOMCSSDeclaration::SetFontVariant(const nsString& aFontVariant) { return SetProperty("font-variant", aFontVariant, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetFontWeight(nsString& aFontWeight) +nsDOMCSSDeclaration::GetFontWeight(nsString& aFontWeight) { return GetPropertyValue("font-weight", aFontWeight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetFontWeight(const nsString& aFontWeight) +nsDOMCSSDeclaration::SetFontWeight(const nsString& aFontWeight) { return SetProperty("font-weight", aFontWeight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetHeight(nsString& aHeight) +nsDOMCSSDeclaration::GetHeight(nsString& aHeight) { return GetPropertyValue("height", aHeight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetHeight(const nsString& aHeight) +nsDOMCSSDeclaration::SetHeight(const nsString& aHeight) { return SetProperty("height", aHeight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetLeft(nsString& aLeft) +nsDOMCSSDeclaration::GetLeft(nsString& aLeft) { return GetPropertyValue("left", aLeft); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetLeft(const nsString& aLeft) +nsDOMCSSDeclaration::SetLeft(const nsString& aLeft) { return SetProperty("left", aLeft, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetLetterSpacing(nsString& aLetterSpacing) +nsDOMCSSDeclaration::GetLetterSpacing(nsString& aLetterSpacing) { return GetPropertyValue("letter-spacing", aLetterSpacing); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetLetterSpacing(const nsString& aLetterSpacing) +nsDOMCSSDeclaration::SetLetterSpacing(const nsString& aLetterSpacing) { return SetProperty("letter-spacing", aLetterSpacing, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetLineHeight(nsString& aLineHeight) +nsDOMCSSDeclaration::GetLineHeight(nsString& aLineHeight) { return GetPropertyValue("line-height", aLineHeight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetLineHeight(const nsString& aLineHeight) +nsDOMCSSDeclaration::SetLineHeight(const nsString& aLineHeight) { return SetProperty("line-height", aLineHeight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetListStyle(nsString& aListStyle) +nsDOMCSSDeclaration::GetListStyle(nsString& aListStyle) { return GetPropertyValue("list-style", aListStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetListStyle(const nsString& aListStyle) +nsDOMCSSDeclaration::SetListStyle(const nsString& aListStyle) { return SetProperty("list-style", aListStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetListStyleImage(nsString& aListStyleImage) +nsDOMCSSDeclaration::GetListStyleImage(nsString& aListStyleImage) { return GetPropertyValue("list-style-image", aListStyleImage); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetListStyleImage(const nsString& aListStyleImage) +nsDOMCSSDeclaration::SetListStyleImage(const nsString& aListStyleImage) { return SetProperty("list-style-image", aListStyleImage, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetListStylePosition(nsString& aListStylePosition) +nsDOMCSSDeclaration::GetListStylePosition(nsString& aListStylePosition) { return GetPropertyValue("list-style-position", aListStylePosition); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetListStylePosition(const nsString& aListStylePosition) +nsDOMCSSDeclaration::SetListStylePosition(const nsString& aListStylePosition) { return SetProperty("list-style-position", aListStylePosition, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetListStyleType(nsString& aListStyleType) +nsDOMCSSDeclaration::GetListStyleType(nsString& aListStyleType) { return GetPropertyValue("list-style-type", aListStyleType); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetListStyleType(const nsString& aListStyleType) +nsDOMCSSDeclaration::SetListStyleType(const nsString& aListStyleType) { return SetProperty("list-style-type", aListStyleType, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMargin(nsString& aMargin) +nsDOMCSSDeclaration::GetMargin(nsString& aMargin) { return GetPropertyValue("margin", aMargin); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMargin(const nsString& aMargin) +nsDOMCSSDeclaration::SetMargin(const nsString& aMargin) { return SetProperty("margin", aMargin, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMarginTop(nsString& aMarginTop) +nsDOMCSSDeclaration::GetMarginTop(nsString& aMarginTop) { return GetPropertyValue("margin-top", aMarginTop); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMarginTop(const nsString& aMarginTop) +nsDOMCSSDeclaration::SetMarginTop(const nsString& aMarginTop) { return SetProperty("margin-top", aMarginTop, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMarginRight(nsString& aMarginRight) +nsDOMCSSDeclaration::GetMarginRight(nsString& aMarginRight) { return GetPropertyValue("margin-right", aMarginRight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMarginRight(const nsString& aMarginRight) +nsDOMCSSDeclaration::SetMarginRight(const nsString& aMarginRight) { return SetProperty("margin-right", aMarginRight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMarginBottom(nsString& aMarginBottom) +nsDOMCSSDeclaration::GetMarginBottom(nsString& aMarginBottom) { return GetPropertyValue("margin-bottom", aMarginBottom); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMarginBottom(const nsString& aMarginBottom) +nsDOMCSSDeclaration::SetMarginBottom(const nsString& aMarginBottom) { return SetProperty("margin-bottom", aMarginBottom, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMarginLeft(nsString& aMarginLeft) +nsDOMCSSDeclaration::GetMarginLeft(nsString& aMarginLeft) { return GetPropertyValue("margin-left", aMarginLeft); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMarginLeft(const nsString& aMarginLeft) +nsDOMCSSDeclaration::SetMarginLeft(const nsString& aMarginLeft) { return SetProperty("margin-left", aMarginLeft, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMarkerOffset(nsString& aMarkerOffset) +nsDOMCSSDeclaration::GetMarkerOffset(nsString& aMarkerOffset) { return GetPropertyValue("marker-offset", aMarkerOffset); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMarkerOffset(const nsString& aMarkerOffset) +nsDOMCSSDeclaration::SetMarkerOffset(const nsString& aMarkerOffset) { return SetProperty("marker-offset", aMarkerOffset, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMarks(nsString& aMarks) +nsDOMCSSDeclaration::GetMarks(nsString& aMarks) { return GetPropertyValue("marks", aMarks); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMarks(const nsString& aMarks) +nsDOMCSSDeclaration::SetMarks(const nsString& aMarks) { return SetProperty("marks", aMarks, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMaxHeight(nsString& aMaxHeight) +nsDOMCSSDeclaration::GetMaxHeight(nsString& aMaxHeight) { return GetPropertyValue("max-height", aMaxHeight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMaxHeight(const nsString& aMaxHeight) +nsDOMCSSDeclaration::SetMaxHeight(const nsString& aMaxHeight) { return SetProperty("max-height", aMaxHeight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMaxWidth(nsString& aMaxWidth) +nsDOMCSSDeclaration::GetMaxWidth(nsString& aMaxWidth) { return GetPropertyValue("max-width", aMaxWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMaxWidth(const nsString& aMaxWidth) +nsDOMCSSDeclaration::SetMaxWidth(const nsString& aMaxWidth) { return SetProperty("max-width", aMaxWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMinHeight(nsString& aMinHeight) +nsDOMCSSDeclaration::GetMinHeight(nsString& aMinHeight) { return GetPropertyValue("min-height", aMinHeight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMinHeight(const nsString& aMinHeight) +nsDOMCSSDeclaration::SetMinHeight(const nsString& aMinHeight) { return SetProperty("min-height", aMinHeight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetMinWidth(nsString& aMinWidth) +nsDOMCSSDeclaration::GetMinWidth(nsString& aMinWidth) { return GetPropertyValue("min-width", aMinWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetMinWidth(const nsString& aMinWidth) +nsDOMCSSDeclaration::SetMinWidth(const nsString& aMinWidth) { return SetProperty("min-width", aMinWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetOrphans(nsString& aOrphans) +nsDOMCSSDeclaration::GetOrphans(nsString& aOrphans) { return GetPropertyValue("orphans", aOrphans); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetOrphans(const nsString& aOrphans) +nsDOMCSSDeclaration::SetOrphans(const nsString& aOrphans) { return SetProperty("orphans", aOrphans, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetOutline(nsString& aOutline) +nsDOMCSSDeclaration::GetOutline(nsString& aOutline) { return GetPropertyValue("outline", aOutline); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetOutline(const nsString& aOutline) +nsDOMCSSDeclaration::SetOutline(const nsString& aOutline) { return SetProperty("outline", aOutline, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetOutlineColor(nsString& aOutlineColor) +nsDOMCSSDeclaration::GetOutlineColor(nsString& aOutlineColor) { return GetPropertyValue("outline-color", aOutlineColor); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetOutlineColor(const nsString& aOutlineColor) +nsDOMCSSDeclaration::SetOutlineColor(const nsString& aOutlineColor) { return SetProperty("outline-color", aOutlineColor, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetOutlineStyle(nsString& aOutlineStyle) +nsDOMCSSDeclaration::GetOutlineStyle(nsString& aOutlineStyle) { return GetPropertyValue("outline-style", aOutlineStyle); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetOutlineStyle(const nsString& aOutlineStyle) +nsDOMCSSDeclaration::SetOutlineStyle(const nsString& aOutlineStyle) { return SetProperty("outline-style", aOutlineStyle, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetOutlineWidth(nsString& aOutlineWidth) +nsDOMCSSDeclaration::GetOutlineWidth(nsString& aOutlineWidth) { return GetPropertyValue("outline-width", aOutlineWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetOutlineWidth(const nsString& aOutlineWidth) +nsDOMCSSDeclaration::SetOutlineWidth(const nsString& aOutlineWidth) { return SetProperty("outline-width", aOutlineWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetOverflow(nsString& aOverflow) +nsDOMCSSDeclaration::GetOverflow(nsString& aOverflow) { return GetPropertyValue("overflow", aOverflow); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetOverflow(const nsString& aOverflow) +nsDOMCSSDeclaration::SetOverflow(const nsString& aOverflow) { return SetProperty("overflow", aOverflow, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPadding(nsString& aPadding) +nsDOMCSSDeclaration::GetPadding(nsString& aPadding) { return GetPropertyValue("padding", aPadding); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPadding(const nsString& aPadding) +nsDOMCSSDeclaration::SetPadding(const nsString& aPadding) { return SetProperty("padding", aPadding, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPaddingTop(nsString& aPaddingTop) +nsDOMCSSDeclaration::GetPaddingTop(nsString& aPaddingTop) { return GetPropertyValue("padding-top", aPaddingTop); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPaddingTop(const nsString& aPaddingTop) +nsDOMCSSDeclaration::SetPaddingTop(const nsString& aPaddingTop) { return SetProperty("padding-top", aPaddingTop, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPaddingRight(nsString& aPaddingRight) +nsDOMCSSDeclaration::GetPaddingRight(nsString& aPaddingRight) { return GetPropertyValue("padding-right", aPaddingRight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPaddingRight(const nsString& aPaddingRight) +nsDOMCSSDeclaration::SetPaddingRight(const nsString& aPaddingRight) { return SetProperty("padding-right", aPaddingRight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPaddingBottom(nsString& aPaddingBottom) +nsDOMCSSDeclaration::GetPaddingBottom(nsString& aPaddingBottom) { return GetPropertyValue("padding-bottom", aPaddingBottom); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPaddingBottom(const nsString& aPaddingBottom) +nsDOMCSSDeclaration::SetPaddingBottom(const nsString& aPaddingBottom) { return SetProperty("padding-bottom", aPaddingBottom, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPaddingLeft(nsString& aPaddingLeft) +nsDOMCSSDeclaration::GetPaddingLeft(nsString& aPaddingLeft) { return GetPropertyValue("padding-left", aPaddingLeft); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPaddingLeft(const nsString& aPaddingLeft) +nsDOMCSSDeclaration::SetPaddingLeft(const nsString& aPaddingLeft) { return SetProperty("padding-left", aPaddingLeft, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPage(nsString& aPage) +nsDOMCSSDeclaration::GetPage(nsString& aPage) { return GetPropertyValue("page", aPage); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPage(const nsString& aPage) +nsDOMCSSDeclaration::SetPage(const nsString& aPage) { return SetProperty("page", aPage, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPageBreakAfter(nsString& aPageBreakAfter) +nsDOMCSSDeclaration::GetPageBreakAfter(nsString& aPageBreakAfter) { return GetPropertyValue("page-break-after", aPageBreakAfter); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPageBreakAfter(const nsString& aPageBreakAfter) +nsDOMCSSDeclaration::SetPageBreakAfter(const nsString& aPageBreakAfter) { return SetProperty("page-break-after", aPageBreakAfter, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPageBreakBefore(nsString& aPageBreakBefore) +nsDOMCSSDeclaration::GetPageBreakBefore(nsString& aPageBreakBefore) { return GetPropertyValue("page-break-before", aPageBreakBefore); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPageBreakBefore(const nsString& aPageBreakBefore) +nsDOMCSSDeclaration::SetPageBreakBefore(const nsString& aPageBreakBefore) { return SetProperty("page-break-before", aPageBreakBefore, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPageBreakInside(nsString& aPageBreakInside) +nsDOMCSSDeclaration::GetPageBreakInside(nsString& aPageBreakInside) { return GetPropertyValue("page-break-inside", aPageBreakInside); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPageBreakInside(const nsString& aPageBreakInside) +nsDOMCSSDeclaration::SetPageBreakInside(const nsString& aPageBreakInside) { return SetProperty("page-break-inside", aPageBreakInside, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPause(nsString& aPause) +nsDOMCSSDeclaration::GetPause(nsString& aPause) { return GetPropertyValue("pause", aPause); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPause(const nsString& aPause) +nsDOMCSSDeclaration::SetPause(const nsString& aPause) { return SetProperty("pause", aPause, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPauseAfter(nsString& aPauseAfter) +nsDOMCSSDeclaration::GetPauseAfter(nsString& aPauseAfter) { return GetPropertyValue("pause-after", aPauseAfter); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPauseAfter(const nsString& aPauseAfter) +nsDOMCSSDeclaration::SetPauseAfter(const nsString& aPauseAfter) { return SetProperty("pause-after", aPauseAfter, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPauseBefore(nsString& aPauseBefore) +nsDOMCSSDeclaration::GetPauseBefore(nsString& aPauseBefore) { return GetPropertyValue("pause-before", aPauseBefore); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPauseBefore(const nsString& aPauseBefore) +nsDOMCSSDeclaration::SetPauseBefore(const nsString& aPauseBefore) { return SetProperty("pause-before", aPauseBefore, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPitch(nsString& aPitch) +nsDOMCSSDeclaration::GetPitch(nsString& aPitch) { return GetPropertyValue("pitch", aPitch); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPitch(const nsString& aPitch) +nsDOMCSSDeclaration::SetPitch(const nsString& aPitch) { return SetProperty("pitch", aPitch, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPitchRange(nsString& aPitchRange) +nsDOMCSSDeclaration::GetPitchRange(nsString& aPitchRange) { return GetPropertyValue("pitch-range", aPitchRange); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPitchRange(const nsString& aPitchRange) +nsDOMCSSDeclaration::SetPitchRange(const nsString& aPitchRange) { return SetProperty("pitch-range", aPitchRange, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPlayDuring(nsString& aPlayDuring) +nsDOMCSSDeclaration::GetPlayDuring(nsString& aPlayDuring) { return GetPropertyValue("play-during", aPlayDuring); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPlayDuring(const nsString& aPlayDuring) +nsDOMCSSDeclaration::SetPlayDuring(const nsString& aPlayDuring) { return SetProperty("play-during", aPlayDuring, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetPosition(nsString& aPosition) +nsDOMCSSDeclaration::GetPosition(nsString& aPosition) { return GetPropertyValue("position", aPosition); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetPosition(const nsString& aPosition) +nsDOMCSSDeclaration::SetPosition(const nsString& aPosition) { return SetProperty("position", aPosition, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetQuotes(nsString& aQuotes) +nsDOMCSSDeclaration::GetQuotes(nsString& aQuotes) { return GetPropertyValue("quotes", aQuotes); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetQuotes(const nsString& aQuotes) +nsDOMCSSDeclaration::SetQuotes(const nsString& aQuotes) { return SetProperty("quotes", aQuotes, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetRichness(nsString& aRichness) +nsDOMCSSDeclaration::GetRichness(nsString& aRichness) { return GetPropertyValue("richness", aRichness); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetRichness(const nsString& aRichness) +nsDOMCSSDeclaration::SetRichness(const nsString& aRichness) { return SetProperty("richness", aRichness, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetRight(nsString& aRight) +nsDOMCSSDeclaration::GetRight(nsString& aRight) { return GetPropertyValue("right", aRight); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetRight(const nsString& aRight) +nsDOMCSSDeclaration::SetRight(const nsString& aRight) { return SetProperty("right", aRight, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetSize(nsString& aSize) +nsDOMCSSDeclaration::GetSize(nsString& aSize) { return GetPropertyValue("size", aSize); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetSize(const nsString& aSize) +nsDOMCSSDeclaration::SetSize(const nsString& aSize) { return SetProperty("size", aSize, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetSpeak(nsString& aSpeak) +nsDOMCSSDeclaration::GetSpeak(nsString& aSpeak) { return GetPropertyValue("speak", aSpeak); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetSpeak(const nsString& aSpeak) +nsDOMCSSDeclaration::SetSpeak(const nsString& aSpeak) { return SetProperty("speak", aSpeak, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetSpeakHeader(nsString& aSpeakHeader) +nsDOMCSSDeclaration::GetSpeakHeader(nsString& aSpeakHeader) { return GetPropertyValue("speak-header", aSpeakHeader); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetSpeakHeader(const nsString& aSpeakHeader) +nsDOMCSSDeclaration::SetSpeakHeader(const nsString& aSpeakHeader) { return SetProperty("speak-header", aSpeakHeader, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetSpeakNumeral(nsString& aSpeakNumeral) +nsDOMCSSDeclaration::GetSpeakNumeral(nsString& aSpeakNumeral) { return GetPropertyValue("speak-numeral", aSpeakNumeral); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetSpeakNumeral(const nsString& aSpeakNumeral) +nsDOMCSSDeclaration::SetSpeakNumeral(const nsString& aSpeakNumeral) { return SetProperty("speak-numeral", aSpeakNumeral, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetSpeakPunctuation(nsString& aSpeakPunctuation) +nsDOMCSSDeclaration::GetSpeakPunctuation(nsString& aSpeakPunctuation) { return GetPropertyValue("speak-punctuation", aSpeakPunctuation); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetSpeakPunctuation(const nsString& aSpeakPunctuation) +nsDOMCSSDeclaration::SetSpeakPunctuation(const nsString& aSpeakPunctuation) { return SetProperty("speak-punctuation", aSpeakPunctuation, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetSpeechRate(nsString& aSpeechRate) +nsDOMCSSDeclaration::GetSpeechRate(nsString& aSpeechRate) { return GetPropertyValue("speech-rate", aSpeechRate); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetSpeechRate(const nsString& aSpeechRate) +nsDOMCSSDeclaration::SetSpeechRate(const nsString& aSpeechRate) { return SetProperty("speech-rate", aSpeechRate, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetStress(nsString& aStress) +nsDOMCSSDeclaration::GetStress(nsString& aStress) { return GetPropertyValue("stress", aStress); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetStress(const nsString& aStress) +nsDOMCSSDeclaration::SetStress(const nsString& aStress) { return SetProperty("stress", aStress, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTableLayout(nsString& aTableLayout) +nsDOMCSSDeclaration::GetTableLayout(nsString& aTableLayout) { return GetPropertyValue("table-layout", aTableLayout); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTableLayout(const nsString& aTableLayout) +nsDOMCSSDeclaration::SetTableLayout(const nsString& aTableLayout) { return SetProperty("table-layout", aTableLayout, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTextAlign(nsString& aTextAlign) +nsDOMCSSDeclaration::GetTextAlign(nsString& aTextAlign) { return GetPropertyValue("text-align", aTextAlign); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTextAlign(const nsString& aTextAlign) +nsDOMCSSDeclaration::SetTextAlign(const nsString& aTextAlign) { return SetProperty("text-align", aTextAlign, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTextDecoration(nsString& aTextDecoration) +nsDOMCSSDeclaration::GetTextDecoration(nsString& aTextDecoration) { return GetPropertyValue("text-decoration", aTextDecoration); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTextDecoration(const nsString& aTextDecoration) +nsDOMCSSDeclaration::SetTextDecoration(const nsString& aTextDecoration) { return SetProperty("text-decoration", aTextDecoration, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTextIndent(nsString& aTextIndent) +nsDOMCSSDeclaration::GetTextIndent(nsString& aTextIndent) { return GetPropertyValue("text-indent", aTextIndent); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTextIndent(const nsString& aTextIndent) +nsDOMCSSDeclaration::SetTextIndent(const nsString& aTextIndent) { return SetProperty("text-indent", aTextIndent, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTextShadow(nsString& aTextShadow) +nsDOMCSSDeclaration::GetTextShadow(nsString& aTextShadow) { return GetPropertyValue("text-shadow", aTextShadow); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTextShadow(const nsString& aTextShadow) +nsDOMCSSDeclaration::SetTextShadow(const nsString& aTextShadow) { return SetProperty("text-shadow", aTextShadow, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTextTransform(nsString& aTextTransform) +nsDOMCSSDeclaration::GetTextTransform(nsString& aTextTransform) { return GetPropertyValue("text-transform", aTextTransform); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTextTransform(const nsString& aTextTransform) +nsDOMCSSDeclaration::SetTextTransform(const nsString& aTextTransform) { return SetProperty("text-transform", aTextTransform, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetTop(nsString& aTop) +nsDOMCSSDeclaration::GetTop(nsString& aTop) { return GetPropertyValue("top", aTop); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetTop(const nsString& aTop) +nsDOMCSSDeclaration::SetTop(const nsString& aTop) { return SetProperty("top", aTop, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetUnicodeBidi(nsString& aUnicodeBidi) +nsDOMCSSDeclaration::GetUnicodeBidi(nsString& aUnicodeBidi) { return GetPropertyValue("unicode-bidi", aUnicodeBidi); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetUnicodeBidi(const nsString& aUnicodeBidi) +nsDOMCSSDeclaration::SetUnicodeBidi(const nsString& aUnicodeBidi) { return SetProperty("unicode-bidi", aUnicodeBidi, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetVerticalAlign(nsString& aVerticalAlign) +nsDOMCSSDeclaration::GetVerticalAlign(nsString& aVerticalAlign) { return GetPropertyValue("vertical-align", aVerticalAlign); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetVerticalAlign(const nsString& aVerticalAlign) +nsDOMCSSDeclaration::SetVerticalAlign(const nsString& aVerticalAlign) { return SetProperty("vertical-align", aVerticalAlign, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetVisibility(nsString& aVisibility) +nsDOMCSSDeclaration::GetVisibility(nsString& aVisibility) { return GetPropertyValue("visibility", aVisibility); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetVisibility(const nsString& aVisibility) +nsDOMCSSDeclaration::SetVisibility(const nsString& aVisibility) { return SetProperty("visibility", aVisibility, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetVoiceFamily(nsString& aVoiceFamily) +nsDOMCSSDeclaration::GetVoiceFamily(nsString& aVoiceFamily) { return GetPropertyValue("voice-family", aVoiceFamily); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetVoiceFamily(const nsString& aVoiceFamily) +nsDOMCSSDeclaration::SetVoiceFamily(const nsString& aVoiceFamily) { return SetProperty("voice-family", aVoiceFamily, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetVolume(nsString& aVolume) +nsDOMCSSDeclaration::GetVolume(nsString& aVolume) { return GetPropertyValue("volume", aVolume); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetVolume(const nsString& aVolume) +nsDOMCSSDeclaration::SetVolume(const nsString& aVolume) { return SetProperty("volume", aVolume, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetWhiteSpace(nsString& aWhiteSpace) +nsDOMCSSDeclaration::GetWhiteSpace(nsString& aWhiteSpace) { return GetPropertyValue("white-space", aWhiteSpace); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetWhiteSpace(const nsString& aWhiteSpace) +nsDOMCSSDeclaration::SetWhiteSpace(const nsString& aWhiteSpace) { return SetProperty("white-space", aWhiteSpace, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetWidows(nsString& aWidows) +nsDOMCSSDeclaration::GetWidows(nsString& aWidows) { return GetPropertyValue("widows", aWidows); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetWidows(const nsString& aWidows) +nsDOMCSSDeclaration::SetWidows(const nsString& aWidows) { return SetProperty("widows", aWidows, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetWidth(nsString& aWidth) +nsDOMCSSDeclaration::GetWidth(nsString& aWidth) { return GetPropertyValue("width", aWidth); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetWidth(const nsString& aWidth) +nsDOMCSSDeclaration::SetWidth(const nsString& aWidth) { return SetProperty("width", aWidth, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetWordSpacing(nsString& aWordSpacing) +nsDOMCSSDeclaration::GetWordSpacing(nsString& aWordSpacing) { return GetPropertyValue("word-spacing", aWordSpacing); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetWordSpacing(const nsString& aWordSpacing) +nsDOMCSSDeclaration::SetWordSpacing(const nsString& aWordSpacing) { return SetProperty("word-spacing", aWordSpacing, ""); } NS_IMETHODIMP -nsDOMStyleDeclaration::GetZIndex(nsString& aZIndex) +nsDOMCSSDeclaration::GetZIndex(nsString& aZIndex) { return GetPropertyValue("z-index", aZIndex); } NS_IMETHODIMP -nsDOMStyleDeclaration::SetZIndex(const nsString& aZIndex) +nsDOMCSSDeclaration::SetZIndex(const nsString& aZIndex) { return SetProperty("z-index", aZIndex, ""); } diff --git a/layout/html/content/src/nsDOMStyleDeclaration.h b/content/html/style/src/nsDOMCSSDeclaration.h similarity index 66% rename from layout/html/content/src/nsDOMStyleDeclaration.h rename to content/html/style/src/nsDOMCSSDeclaration.h index bd9699a8cdda..acae956973a0 100644 --- a/layout/html/content/src/nsDOMStyleDeclaration.h +++ b/content/html/style/src/nsDOMCSSDeclaration.h @@ -16,22 +16,20 @@ * Corporation. Portions created by Netscape are Copyright (C) 1998 * Netscape Communications Corporation. All Rights Reserved. */ -#ifndef nsDOMStyleDeclaration_h___ -#define nsDOMStyleDeclaration_h___ +#ifndef nsDOMCSSDeclaration_h___ +#define nsDOMCSSSDeclaration_h___ #include "nsISupports.h" #include "nsIDOMCSSStyleDeclaration.h" #include "nsIScriptObjectOwner.h" -class nsIHTMLContent; class nsICSSDeclaration; -class nsDOMStyleDeclaration : public nsIDOMCSSStyleDeclaration, - public nsIScriptObjectOwner +class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration, + public nsIScriptObjectOwner { public: - nsDOMStyleDeclaration(nsIHTMLContent *aContent); - virtual ~nsDOMStyleDeclaration(); + nsDOMCSSDeclaration(); NS_DECL_ISUPPORTS @@ -41,13 +39,17 @@ public: NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); NS_IMETHOD SetScriptObject(void* aScriptObject); - void DropContent(); + virtual void DropReference() = 0; + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) = 0; + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) = 0; + virtual nsresult GetParent(nsISupports **aParent) = 0; protected: - nsresult GetContentStyle(nsICSSDeclaration **aDecl, PRBool aAllocate); + virtual ~nsDOMCSSDeclaration(); void *mScriptObject; - nsIHTMLContent *mContent; }; -#endif // nsDOMStyleDeclaration_h___ +#endif // nsDOMCSSDeclaration_h___ diff --git a/content/html/style/src/nsICSSStyleRule.h b/content/html/style/src/nsICSSStyleRule.h index d45b23b04cbc..dc68d7b04838 100644 --- a/content/html/style/src/nsICSSStyleRule.h +++ b/content/html/style/src/nsICSSStyleRule.h @@ -25,7 +25,7 @@ class nsIAtom; class nsIArena; class nsString; class nsICSSDeclaration; - +class nsIStyleSheet; struct nsCSSSelector { public: @@ -65,6 +65,9 @@ public: virtual void SetWeight(PRInt32 aWeight) = 0; virtual nsIStyleRule* GetImportantRule(void) = 0; + + virtual nsIStyleSheet* GetStyleSheet(void) = 0; + virtual void SetStyleSheet(nsIStyleSheet *aSheet) = 0; }; extern NS_HTML nsresult diff --git a/dom/public/css/nsIDOMCSSStyleRuleSimple.h b/dom/public/css/nsIDOMCSSStyleRuleSimple.h index a8d7d42405ff..5b58e7fcc3e8 100644 --- a/dom/public/css/nsIDOMCSSStyleRuleSimple.h +++ b/dom/public/css/nsIDOMCSSStyleRuleSimple.h @@ -38,7 +38,6 @@ public: NS_IMETHOD SetSelectorText(const nsString& aSelectorText)=0; NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle)=0; - NS_IMETHOD SetStyle(nsIDOMCSSStyleDeclaration* aStyle)=0; }; @@ -46,7 +45,6 @@ public: NS_IMETHOD GetSelectorText(nsString& aSelectorText); \ NS_IMETHOD SetSelectorText(const nsString& aSelectorText); \ NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle); \ - NS_IMETHOD SetStyle(nsIDOMCSSStyleDeclaration* aStyle); \ @@ -54,7 +52,6 @@ public: NS_IMETHOD GetSelectorText(nsString& aSelectorText) { return _to##GetSelectorText(aSelectorText); } \ NS_IMETHOD SetSelectorText(const nsString& aSelectorText) { return _to##SetSelectorText(aSelectorText); } \ NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle) { return _to##GetStyle(aStyle); } \ - NS_IMETHOD SetStyle(nsIDOMCSSStyleDeclaration* aStyle) { return _to##SetStyle(aStyle); } \ extern nsresult NS_InitCSSStyleRuleSimpleClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/dom/public/html/nsIDOMNSHTMLDocument.h b/dom/public/html/nsIDOMNSHTMLDocument.h index a18d94b99c52..d730c72ecb9a 100644 --- a/dom/public/html/nsIDOMNSHTMLDocument.h +++ b/dom/public/html/nsIDOMNSHTMLDocument.h @@ -25,6 +25,7 @@ #include "nsIScriptContext.h" class nsIDOMElement; +class nsIDOMStyleSheetCollection; class nsIDOMHTMLCollection; #define NS_IDOMNSHTMLDOCUMENT_IID \ @@ -49,6 +50,8 @@ public: NS_IMETHOD GetFgColor(nsString& aFgColor)=0; NS_IMETHOD SetFgColor(const nsString& aFgColor)=0; + NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)=0; + NS_IMETHOD GetLastModified(nsString& aLastModified)=0; NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds)=0; @@ -74,6 +77,7 @@ public: NS_IMETHOD SetBgColor(const nsString& aBgColor); \ NS_IMETHOD GetFgColor(nsString& aFgColor); \ NS_IMETHOD SetFgColor(const nsString& aFgColor); \ + NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets); \ NS_IMETHOD GetLastModified(nsString& aLastModified); \ NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds); \ NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers); \ @@ -94,6 +98,7 @@ public: NS_IMETHOD SetBgColor(const nsString& aBgColor) { return _to##SetBgColor(aBgColor); } \ NS_IMETHOD GetFgColor(nsString& aFgColor) { return _to##GetFgColor(aFgColor); } \ NS_IMETHOD SetFgColor(const nsString& aFgColor) { return _to##SetFgColor(aFgColor); } \ + NS_IMETHOD GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets) { return _to##GetStyleSheets(aStyleSheets); } \ NS_IMETHOD GetLastModified(nsString& aLastModified) { return _to##GetLastModified(aLastModified); } \ NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds) { return _to##GetEmbeds(aEmbeds); } \ NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers) { return _to##GetLayers(aLayers); } \ diff --git a/dom/public/idl/css/CSSStyleRuleSimple.idl b/dom/public/idl/css/CSSStyleRuleSimple.idl index 4c67d2c97a12..0182633582f3 100644 --- a/dom/public/idl/css/CSSStyleRuleSimple.idl +++ b/dom/public/idl/css/CSSStyleRuleSimple.idl @@ -1,5 +1,5 @@ interface CSSStyleRuleSimple : CSSStyleRule { attribute wstring selectorText; - attribute CSSStyleDeclaration style; + readonly attribute CSSStyleDeclaration style; }; diff --git a/dom/public/idl/html/HTMLDocument.idl b/dom/public/idl/html/HTMLDocument.idl index 4e5dfcd22910..deff175c7558 100644 --- a/dom/public/idl/html/HTMLDocument.idl +++ b/dom/public/idl/html/HTMLDocument.idl @@ -28,6 +28,7 @@ attribute wstring vlinkColor; attribute wstring bgColor; attribute wstring fgColor; + readonly attribute StyleSheetCollection styleSheets; readonly attribute wstring lastModified; readonly attribute HTMLCollection embeds; diff --git a/dom/src/build/dlldeps.cpp b/dom/src/build/dlldeps.cpp index 24a17c4584e1..9bf45652e069 100644 --- a/dom/src/build/dlldeps.cpp +++ b/dom/src/build/dlldeps.cpp @@ -25,6 +25,7 @@ #include "nsIDOMHTMLFormElement.h" #include "nsIDOMHTMLInputElement.h" #include "nsIScriptEventListener.h" +#include "nsIDOMCSSStyleSheet.h" #include "jsurl.h" // Force references to all of the symbols that we want exported from @@ -42,5 +43,6 @@ void XXXDomNeverCalled() NS_NewScriptHTMLImageElement(0, 0, 0, 0); NS_NewScriptHTMLFormElement(0, 0, 0, 0); NS_NewScriptHTMLInputElement(0, 0, 0, 0); + NS_NewScriptCSSStyleSheet(0, 0, 0, 0); NET_InitJavaScriptProtocol(); } diff --git a/dom/src/build/nsDOMFactory.cpp b/dom/src/build/nsDOMFactory.cpp index ca3f8f22f840..43b0e656f820 100644 --- a/dom/src/build/nsDOMFactory.cpp +++ b/dom/src/build/nsDOMFactory.cpp @@ -105,7 +105,11 @@ #include "nsIDOMNSHTMLFormElement.h" #include "nsIDOMNavigator.h" #include "nsIDOMLocation.h" +#include "nsIDOMStyleSheetCollection.h" #include "nsIDOMCSSStyleDeclaration.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRuleSimple.h" +#include "nsIDOMCSSStyleRuleCollection.h" #include "plhash.h" static NS_DEFINE_IID(kIDOMNativeObjectRegistry, NS_IDOM_NATIVE_OBJECT_REGISTRY_IID); @@ -673,5 +677,9 @@ void XXXDomNeverCalled() NS_NewScriptLocation(0, 0, 0, 0); NS_NewScriptEventListener(0, 0, 0); NS_NewScriptCSSStyleDeclaration(0, 0, 0, 0); + NS_NewScriptCSSStyleSheet(0, 0, 0, 0); + NS_NewScriptCSSStyleRuleSimple(0, 0, 0, 0); + NS_NewScriptStyleSheetCollection(0, 0, 0, 0); + NS_NewScriptCSSStyleRuleCollection(0, 0, 0, 0); NET_InitJavaScriptProtocol(); } diff --git a/dom/src/css/nsJSCSSStyleRuleSimple.cpp b/dom/src/css/nsJSCSSStyleRuleSimple.cpp index 216765e0eff7..07665b737b54 100644 --- a/dom/src/css/nsJSCSSStyleRuleSimple.cpp +++ b/dom/src/css/nsJSCSSStyleRuleSimple.cpp @@ -158,29 +158,6 @@ SetCSSStyleRuleSimpleProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) break; } - case CSSSTYLERULESIMPLE_STYLE: - { - nsIDOMCSSStyleDeclaration* prop; - if (JSVAL_IS_NULL(*vp)) { - prop = nsnull; - } - else if (JSVAL_IS_OBJECT(*vp)) { - JSObject *jsobj = JSVAL_TO_OBJECT(*vp); - nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj); - if (NS_OK != supports->QueryInterface(kICSSStyleDeclarationIID, (void **)&prop)) { - JS_ReportError(cx, "Parameter must be of type CSSStyleDeclaration"); - return JS_FALSE; - } - } - else { - JS_ReportError(cx, "Parameter must be an object"); - return JS_FALSE; - } - - a->SetStyle(prop); - if (prop) NS_RELEASE(prop); - break; - } default: { nsIJSScriptObject *object; @@ -292,7 +269,7 @@ JSClass CSSStyleRuleSimpleClass = { static JSPropertySpec CSSStyleRuleSimpleProperties[] = { {"selectorText", CSSSTYLERULESIMPLE_SELECTORTEXT, JSPROP_ENUMERATE}, - {"style", CSSSTYLERULESIMPLE_STYLE, JSPROP_ENUMERATE}, + {"style", CSSSTYLERULESIMPLE_STYLE, JSPROP_ENUMERATE | JSPROP_READONLY}, {0} }; diff --git a/dom/src/html/nsJSHTMLDocument.cpp b/dom/src/html/nsJSHTMLDocument.cpp index 3db407339ddd..c1a99005ece5 100644 --- a/dom/src/html/nsJSHTMLDocument.cpp +++ b/dom/src/html/nsJSHTMLDocument.cpp @@ -29,6 +29,7 @@ #include "nsIDOMHTMLElement.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMNSHTMLDocument.h" +#include "nsIDOMStyleSheetCollection.h" #include "nsIDOMHTMLCollection.h" #include "nsIDOMNodeList.h" @@ -40,6 +41,7 @@ static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIHTMLElementIID, NS_IDOMHTMLELEMENT_IID); static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); static NS_DEFINE_IID(kINSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID); +static NS_DEFINE_IID(kIStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_IID); static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID); static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID); @@ -47,6 +49,7 @@ NS_DEF_PTR(nsIDOMElement); NS_DEF_PTR(nsIDOMHTMLElement); NS_DEF_PTR(nsIDOMHTMLDocument); NS_DEF_PTR(nsIDOMNSHTMLDocument); +NS_DEF_PTR(nsIDOMStyleSheetCollection); NS_DEF_PTR(nsIDOMHTMLCollection); NS_DEF_PTR(nsIDOMNodeList); @@ -74,10 +77,11 @@ enum HTMLDocument_slots { NSHTMLDOCUMENT_VLINKCOLOR = -18, NSHTMLDOCUMENT_BGCOLOR = -19, NSHTMLDOCUMENT_FGCOLOR = -20, - NSHTMLDOCUMENT_LASTMODIFIED = -21, - NSHTMLDOCUMENT_EMBEDS = -22, - NSHTMLDOCUMENT_LAYERS = -23, - NSHTMLDOCUMENT_PLUGINS = -24 + NSHTMLDOCUMENT_STYLESHEETS = -21, + NSHTMLDOCUMENT_LASTMODIFIED = -22, + NSHTMLDOCUMENT_EMBEDS = -23, + NSHTMLDOCUMENT_LAYERS = -24, + NSHTMLDOCUMENT_PLUGINS = -25 }; /***********************************************************************/ @@ -485,6 +489,42 @@ GetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case NSHTMLDOCUMENT_STYLESHEETS: + { + nsIDOMStyleSheetCollection* prop; + nsIDOMNSHTMLDocument* b; + if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) { + if(NS_OK == b->GetStyleSheets(&prop)) { + // get the js object + if (prop != nsnull) { + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + JSObject *object = nsnull; + nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx); + if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) { + // set the return value + *vp = OBJECT_TO_JSVAL(object); + } + NS_RELEASE(owner); + } + NS_RELEASE(prop); + } + else { + *vp = JSVAL_NULL; + } + NS_RELEASE(b); + } + else { + NS_RELEASE(b); + return JS_FALSE; + } + } + else { + JS_ReportError(cx, "Object must be of type NSHTMLDocument"); + return JS_FALSE; + } + break; + } case NSHTMLDOCUMENT_LASTMODIFIED: { nsAutoString prop; @@ -1368,6 +1408,7 @@ static JSPropertySpec HTMLDocumentProperties[] = {"vlinkColor", NSHTMLDOCUMENT_VLINKCOLOR, JSPROP_ENUMERATE}, {"bgColor", NSHTMLDOCUMENT_BGCOLOR, JSPROP_ENUMERATE}, {"fgColor", NSHTMLDOCUMENT_FGCOLOR, JSPROP_ENUMERATE}, + {"styleSheets", NSHTMLDOCUMENT_STYLESHEETS, JSPROP_ENUMERATE | JSPROP_READONLY}, {"lastModified", NSHTMLDOCUMENT_LASTMODIFIED, JSPROP_ENUMERATE | JSPROP_READONLY}, {"embeds", NSHTMLDOCUMENT_EMBEDS, JSPROP_ENUMERATE | JSPROP_READONLY}, {"layers", NSHTMLDOCUMENT_LAYERS, JSPROP_ENUMERATE | JSPROP_READONLY}, diff --git a/dom/tests/js/ssheets.js b/dom/tests/js/ssheets.js new file mode 100644 index 000000000000..370b557e0033 --- /dev/null +++ b/dom/tests/js/ssheets.js @@ -0,0 +1,40 @@ +/* -*- Mode: js; 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.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +var s; +for (s = 0; s < document.styleSheets.length; s++) { + var sheet = document.styleSheets[s]; + dump("Style sheet #" + (s+1) + ": " + sheet.title + "\n"); + var i, r; + dump("\n"); + for (i = 0; i < sheet.imports.length; i++) { + dump("@import url(" + sheet.imports[i].href + ");\n"); + } + dump("\n"); + for (r = 0; r < sheet.rules.length; r++) { + var rule = sheet.rules[r]; + dump(rule.selectorText + " {" + "\n"); + var style = rule.style; + var p; + for (p = 0; p < style.length; p++) { + dump(" " + style[p] + ":" + style.getPropertyValue(style[p]) + ";\n"); + } + dump(" }\n"); + } + dump("\n"); +} \ No newline at end of file diff --git a/layout/html/content/src/Makefile b/layout/html/content/src/Makefile index ade044200630..9d7617df57af 100644 --- a/layout/html/content/src/Makefile +++ b/layout/html/content/src/Makefile @@ -22,7 +22,6 @@ LIBRARY_NAME = nglhtmlcon_s # Note the sophisticated alphabetical ordering :-| CPPSRCS= \ nsCommentNode.cpp \ - nsDOMStyleDeclaration.cpp \ nsGenericDOMDataNode.cpp \ nsGenericHTMLElement.cpp \ nsHTMLAnchorElement.cpp \ diff --git a/layout/html/content/src/makefile.win b/layout/html/content/src/makefile.win index c62efea35ec9..7186d245032a 100644 --- a/layout/html/content/src/makefile.win +++ b/layout/html/content/src/makefile.win @@ -24,7 +24,6 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN CPPSRCS= \ nsCommentNode.cpp \ - nsDOMStyleDeclaration.cpp \ nsGenericDOMDataNode.cpp \ nsGenericHTMLElement.cpp \ nsHTMLAnchorElement.cpp \ @@ -92,7 +91,6 @@ CPPSRCS= \ CPP_OBJS= \ .\$(OBJDIR)\nsCommentNode.obj \ - .\$(OBJDIR)\nsDOMStyleDeclaration.obj \ .\$(OBJDIR)\nsGenericDOMDataNode.obj \ .\$(OBJDIR)\nsGenericHTMLElement.obj \ .\$(OBJDIR)\nsHTMLAnchorElement.obj \ diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index 7d27eb8b8018..6a26c81f021a 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -60,7 +60,7 @@ #include "nsIServiceManager.h" #include "nsIDOMScriptObjectFactory.h" #include "nsIDOMCSSStyleDeclaration.h" -#include "nsDOMStyleDeclaration.h" +#include "nsDOMCSSDeclaration.h" #include "prprf.h" #include "prmem.h" @@ -175,7 +175,7 @@ public: // nsIDOMNodeList interface NS_DECL_IDOMNODELIST - void DropContent(); + void DropReference(); private: nsGenericHTMLContainerElement *mContent; @@ -554,6 +554,113 @@ DOMAttributeMap::GetLength(PRUint32 *aLength) //---------------------------------------------------------------------- +class nsDOMCSSAttributeDeclaration : public nsDOMCSSDeclaration +{ +public: + nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent); + ~nsDOMCSSAttributeDeclaration(); + + virtual void DropReference(); + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate); + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint); + virtual nsresult GetParent(nsISupports **aParent); + +protected: + nsIHTMLContent *mContent; +}; + +nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent) +{ + // This reference is not reference-counted. The content + // object tells us when its about to go away. + mContent = aContent; +} + +nsDOMCSSAttributeDeclaration::~nsDOMCSSAttributeDeclaration() +{ +} + +void +nsDOMCSSAttributeDeclaration::DropReference() +{ + mContent = nsnull; +} + +nsresult +nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) +{ + nsHTMLValue val; + nsIStyleRule* rule; + nsICSSStyleRule* cssRule; + nsresult result = NS_OK; + + *aDecl = nsnull; + if (nsnull != mContent) { + mContent->GetAttribute(nsHTMLAtoms::style, val); + if (eHTMLUnit_ISupports == val.GetUnit()) { + rule = (nsIStyleRule*) val.GetISupportsValue(); + result = rule->QueryInterface(kICSSStyleRuleIID, (void**)&cssRule); + if (NS_OK == result) { + *aDecl = cssRule->GetDeclaration(); + NS_RELEASE(cssRule); + } + NS_RELEASE(rule); + } + else if (PR_TRUE == aAllocate) { + result = NS_NewCSSDeclaration(aDecl); + if (NS_OK == result) { + result = NS_NewCSSStyleRule(&cssRule, nsCSSSelector()); + if (NS_OK == result) { + cssRule->SetDeclaration(*aDecl); + cssRule->SetWeight(0x7fffffff); + rule = (nsIStyleRule *)cssRule; + result = mContent->SetAttribute(nsHTMLAtoms::style, + nsHTMLValue(cssRule), + PR_FALSE); + NS_RELEASE(cssRule); + } + else { + NS_RELEASE(*aDecl); + } + } + } + } + + return result; +} + +nsresult +nsDOMCSSAttributeDeclaration::StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) +{ + nsresult result = NS_OK; + if (nsnull != mContent) { + nsIDocument *doc; + result = mContent->GetDocument(doc); + if (NS_OK == result) { + result = doc->AttributeChanged(mContent, nsHTMLAtoms::style, aHint); + NS_RELEASE(doc); + } + } + + return result; +} + +nsresult +nsDOMCSSAttributeDeclaration::GetParent(nsISupports **aParent) +{ + if (nsnull != mContent) { + return mContent->QueryInterface(kISupportsIID, (void **)aParent); + } + + return NS_OK; +} + +//---------------------------------------------------------------------- + static nsresult EnsureWritableAttributes(nsIHTMLContent* aContent, nsIHTMLAttributes*& aAttributes, PRBool aCreate) { @@ -641,11 +748,11 @@ nsGenericHTMLElement::~nsGenericHTMLElement() NS_IF_RELEASE(mListenerManager); if (nsnull != mDOMSlots) { if (nsnull != mDOMSlots->mChildNodes) { - mDOMSlots->mChildNodes->DropContent(); + mDOMSlots->mChildNodes->DropReference(); NS_RELEASE(mDOMSlots->mChildNodes); } if (nsnull != mDOMSlots->mStyle) { - mDOMSlots->mStyle->DropContent(); + mDOMSlots->mStyle->DropReference(); NS_RELEASE(mDOMSlots->mStyle); } // XXX Should really be arena managed @@ -954,7 +1061,7 @@ nsGenericHTMLElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) nsDOMSlots *slots = GetDOMSlots(); if (nsnull == slots->mStyle) { - slots->mStyle = new nsDOMStyleDeclaration(mContent); + slots->mStyle = new nsDOMCSSAttributeDeclaration(mContent); if (nsnull == slots->mStyle) { return NS_ERROR_OUT_OF_MEMORY; } @@ -2909,7 +3016,7 @@ nsChildContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn) } void -nsChildContentList::DropContent() +nsChildContentList::DropReference() { mContent = nsnull; } diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index 6492a86231a5..25ff051aef06 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -47,7 +47,7 @@ class nsIStyleRule; class nsISupportsArray; class nsIDOMScriptObjectFactory; class nsChildContentList; -class nsDOMStyleDeclaration; +class nsDOMCSSDeclaration; // There are a set of DOM- and scripting-specific instance variables @@ -59,7 +59,7 @@ class nsDOMStyleDeclaration; typedef struct { void *mScriptObject; nsChildContentList *mChildNodes; - nsDOMStyleDeclaration *mStyle; + nsDOMCSSDeclaration *mStyle; } nsDOMSlots; class nsGenericHTMLElement : public nsIJSScriptObject { diff --git a/layout/html/document/src/nsHTMLDocument.cpp b/layout/html/document/src/nsHTMLDocument.cpp index 2dfb773d16aa..39a9926f2b6e 100644 --- a/layout/html/document/src/nsHTMLDocument.cpp +++ b/layout/html/document/src/nsHTMLDocument.cpp @@ -48,6 +48,9 @@ #include "nsIFormManager.h" #include "nsRepository.h" #include "nsParserCIID.h" +#include "nsIDOMStyleSheet.h" +#include "nsIDOMStyleSheetCollection.h" + // Find/Serach Includes #include "nsISelection.h" @@ -73,6 +76,239 @@ static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); static NS_DEFINE_IID(kIDOMNSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID); static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID); static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID); +static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_IID); +static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID); + +class nsDOMStyleSheetCollection : public nsIDOMStyleSheetCollection, + public nsIScriptObjectOwner, + public nsIDocumentObserver +{ +public: + nsDOMStyleSheetCollection(nsIDocument *aDocument); + ~nsDOMStyleSheetCollection(); + + NS_DECL_ISUPPORTS + NS_DECL_IDOMSTYLESHEETCOLLECTION + + NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; } + NS_IMETHOD BeginReflow(nsIDocument *aDocument, + nsIPresShell* aShell) { return NS_OK; } + NS_IMETHOD EndReflow(nsIDocument *aDocument, + nsIPresShell* aShell) { return NS_OK; } + NS_IMETHOD ContentChanged(nsIDocument *aDocument, + nsIContent* aContent, + nsISupports* aSubContent) { return NS_OK; } + NS_IMETHOD AttributeChanged(nsIDocument *aDocument, + nsIContent* aContent, + nsIAtom* aAttribute, + PRInt32 aHint) { return NS_OK; } + NS_IMETHOD ContentAppended(nsIDocument *aDocument, + nsIContent* aContainer, + PRInt32 aNewIndexInContainer) + { return NS_OK; } + NS_IMETHOD ContentInserted(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) { return NS_OK; } + NS_IMETHOD ContentReplaced(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aOldChild, + nsIContent* aNewChild, + PRInt32 aIndexInContainer) { return NS_OK; } + NS_IMETHOD ContentRemoved(nsIDocument *aDocument, + nsIContent* aContainer, + nsIContent* aChild, + PRInt32 aIndexInContainer) { return NS_OK; } + NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet); + NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + +protected: + PRInt32 mLength; + nsIDocument* mDocument; + void* mScriptObject; +}; + +nsDOMStyleSheetCollection::nsDOMStyleSheetCollection(nsIDocument *aDocument) +{ + NS_INIT_REFCNT(); + mLength = -1; + // Not reference counted to avoid circular references. + // The document will tell us when its going away. + mDocument = aDocument; + mDocument->AddObserver(this); + mScriptObject = nsnull; +} + +nsDOMStyleSheetCollection::~nsDOMStyleSheetCollection() +{ + if (nsnull != mDocument) { + mDocument->RemoveObserver(this); + } + mDocument = nsnull; +} + +NS_IMPL_ADDREF(nsDOMStyleSheetCollection) +NS_IMPL_RELEASE(nsDOMStyleSheetCollection) + +nsresult +nsDOMStyleSheetCollection::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMStyleSheetCollectionIID)) { + nsIDOMStyleSheetCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIDocumentObserverIID)) { + nsIDocumentObserver *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMStyleSheetCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::GetLength(PRUint32* aLength) +{ + if (nsnull != mDocument) { + // XXX Find the number and then cache it. We'll use the + // observer notification to figure out if new ones have + // been added or removed. + if (-1 == mLength) { + PRUint32 count = 0; + PRInt32 i, imax = mDocument->GetNumberOfStyleSheets(); + + for (i = 0; i < imax; i++) { + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i); + nsIDOMStyleSheet *domss; + + if (NS_OK == sheet->QueryInterface(kIDOMStyleSheetIID, (void **)&domss)) { + count++; + NS_RELEASE(domss); + } + + NS_RELEASE(sheet); + } + mLength = count; + } + *aLength = mLength; + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn) +{ + *aReturn = nsnull; + if (nsnull != mDocument) { + PRUint32 count = 0; + PRInt32 i, imax = mDocument->GetNumberOfStyleSheets(); + + // XXX Not particularly efficient, but does anyone care? + for (i = 0; (i < imax) && (nsnull == *aReturn); i++) { + nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(i); + nsIDOMStyleSheet *domss; + + if (NS_OK == sheet->QueryInterface(kIDOMStyleSheetIID, (void **)&domss)) { + if (count++ == aIndex) { + *aReturn = domss; + NS_ADDREF(domss); + } + NS_RELEASE(domss); + } + + NS_RELEASE(sheet); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMStyleSheetCollection *)this; + nsISupports *parent = (nsISupports *)mDocument; + + // XXX Should be done through factory + res = NS_NewScriptStyleSheetCollection(aContext, + supports, + parent, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::StyleSheetAdded(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet) +{ + if (-1 != mLength) { + nsIDOMStyleSheet *domss; + if (NS_OK == aStyleSheet->QueryInterface(kIDOMStyleSheetIID, (void **)&domss)) { + mLength++; + NS_RELEASE(domss); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +nsDOMStyleSheetCollection::DocumentWillBeDestroyed(nsIDocument *aDocument) +{ + if (nsnull != mDocument) { + aDocument->RemoveObserver(this); + mDocument = nsnull; + } + + return NS_OK; +} NS_LAYOUT nsresult NS_NewHTMLDocument(nsIDocument** aInstancePtrResult) @@ -93,6 +329,7 @@ nsHTMLDocument::nsHTMLDocument() mAnchors = nsnull; mNamedItems = nsnull; mParser = nsnull; + mDOMStyleSheets = nsnull; nsHTMLAtoms::AddrefAtoms(); mDTDMode = eDTDMode_NoQuirks; @@ -124,6 +361,7 @@ nsHTMLDocument::~nsHTMLDocument() NS_IF_RELEASE(mEmbeds); NS_IF_RELEASE(mLinks); NS_IF_RELEASE(mAnchors); + NS_IF_RELEASE(mDOMStyleSheets); NS_IF_RELEASE(mAttrStyleSheet); NS_IF_RELEASE(mStyleAttrStyleSheet); NS_IF_RELEASE(mParser); @@ -830,6 +1068,23 @@ nsHTMLDocument::GetLastModified(nsString& aLastModified) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsHTMLDocument::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets) +{ + if (nsnull == mDOMStyleSheets) { + mDOMStyleSheets = new nsDOMStyleSheetCollection(this); + if (nsnull == mDOMStyleSheets) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mDOMStyleSheets); + } + + *aStyleSheets = mDOMStyleSheets; + NS_ADDREF(mDOMStyleSheets); + + return NS_OK; +} + NS_IMETHODIMP nsHTMLDocument::GetEmbeds(nsIDOMHTMLCollection** aEmbeds) { diff --git a/layout/html/document/src/nsHTMLDocument.h b/layout/html/document/src/nsHTMLDocument.h index e112876e5ce5..091972938707 100644 --- a/layout/html/document/src/nsHTMLDocument.h +++ b/layout/html/document/src/nsHTMLDocument.h @@ -32,6 +32,7 @@ class nsContentList; class nsIContentViewerContainer; class nsIParser; class BlockText; +class nsDOMStyleSheetCollection; class nsHTMLDocument : public nsMarkupDocument, public nsIHTMLDocument, public nsIDOMHTMLDocument, public nsIDOMNSHTMLDocument { public: @@ -161,6 +162,7 @@ protected: nsContentList *mLinks; nsContentList *mAnchors; nsContentList *mForms; + nsDOMStyleSheetCollection *mDOMStyleSheets; PLHashTable *mNamedItems; diff --git a/layout/html/style/public/nsICSSParser.h b/layout/html/style/public/nsICSSParser.h index ca8a3422a4bc..957e5fef2bd7 100644 --- a/layout/html/style/public/nsICSSParser.h +++ b/layout/html/style/public/nsICSSParser.h @@ -43,7 +43,7 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aSheet) = 0; NS_IMETHOD Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult) = 0; // Parse declarations assuming that the outer curly braces have @@ -58,6 +58,7 @@ public: nsICSSDeclaration* aDeclaration, PRInt32* aHint) = 0; + NS_IMETHOD ProcessImport(const nsString& aURLSpec) = 0; }; // Values or'd in the GetInfoMask; other bits are reserved diff --git a/layout/html/style/src/Makefile b/layout/html/style/src/Makefile index 891d1ea82ab5..4f160d777e1b 100644 --- a/layout/html/style/src/Makefile +++ b/layout/html/style/src/Makefile @@ -35,6 +35,7 @@ CPPSRCS = \ nsCSSScanner.cpp \ nsCSSStyleRule.cpp \ nsCSSStyleSheet.cpp \ + nsDOMCSSDeclaration.cpp \ nsHTMLAttributes.cpp \ nsHTMLStyleSheet.cpp \ nsHTMLCSSStyleSheet.cpp \ @@ -43,6 +44,7 @@ CPPSRCS = \ $(NULL) EXPORTS = \ + nsDOMCSSDeclaration.h \ nsCSSProps.h \ nsCSSPropIDs.h \ nsICSSStyleSheet.h \ diff --git a/layout/html/style/src/makefile.win b/layout/html/style/src/makefile.win index dc3c8cb8ff3f..b9c8fe1701e3 100644 --- a/layout/html/style/src/makefile.win +++ b/layout/html/style/src/makefile.win @@ -24,13 +24,14 @@ REQUIRES=xpcom raptor dom js DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN EXPORTS=nsCSSProps.h nsCSSPropIDs.h nsICSSStyleSheet.h nsICSSStyleRule.h \ - nsICSSDeclaration.h nsHTMLValue.h nsIHTMLCSSStyleSheet.h + nsICSSDeclaration.h nsHTMLValue.h nsIHTMLCSSStyleSheet.h \ + nsDOMCSSDeclaration.h CPPSRCS=nsCSSKeywords.cpp nsCSSLayout.cpp nsCSSDeclaration.cpp \ nsCSSParser.cpp nsCSSProps.cpp nsCSSProps2.cpp nsCSSRendering.cpp \ nsCSSScanner.cpp nsCSSStyleRule.cpp nsCSSStyleSheet.cpp nsHTMLAttributes.cpp \ nsHTMLStyleSheet.cpp nsHTMLCSSStyleSheet.cpp nsHTMLValue.cpp \ - nsStyleUtil.cpp + nsStyleUtil.cpp nsDOMCSSDeclaration.cpp CPP_OBJS=.\$(OBJDIR)\nsCSSKeywords.obj .\$(OBJDIR)\nsCSSLayout.obj \ .\$(OBJDIR)\nsCSSDeclaration.obj .\$(OBJDIR)\nsCSSParser.obj \ @@ -39,7 +40,8 @@ CPP_OBJS=.\$(OBJDIR)\nsCSSKeywords.obj .\$(OBJDIR)\nsCSSLayout.obj \ .\$(OBJDIR)\nsCSSScanner.obj .\$(OBJDIR)\nsCSSStyleRule.obj \ .\$(OBJDIR)\nsCSSStyleSheet.obj .\$(OBJDIR)\nsHTMLAttributes.obj \ .\$(OBJDIR)\nsHTMLStyleSheet.obj .\$(OBJDIR)\nsHTMLCSSStyleSheet.obj \ - .\$(OBJDIR)\nsHTMLValue.obj .\$(OBJDIR)\nsStyleUtil.obj + .\$(OBJDIR)\nsHTMLValue.obj .\$(OBJDIR)\nsStyleUtil.obj \ + .\$(OBJDIR)\nsDOMCSSDeclaration.obj LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\netlib \ -I..\..\..\base\src \ diff --git a/layout/html/style/src/nsCSSParser.cpp b/layout/html/style/src/nsCSSParser.cpp index f4d61344e30c..1d665f2d046d 100644 --- a/layout/html/style/src/nsCSSParser.cpp +++ b/layout/html/style/src/nsCSSParser.cpp @@ -197,7 +197,7 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aSheet); NS_IMETHOD Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult); NS_IMETHOD ParseDeclarations(const nsString& aDeclaration, @@ -209,6 +209,8 @@ public: nsICSSDeclaration* aDeclaration, PRInt32* aHint); + NS_IMETHOD ProcessImport(const nsString& aURLSpec); + protected: PRBool GetToken(PRInt32* aErrorCode, PRBool aSkipWS); void UngetToken(); @@ -281,8 +283,6 @@ protected: PRBool TranslateLength(nsICSSDeclaration* aDeclaration, const char* aName, float aNumber, const nsString& aDimension); - void ProcessImport(const nsString& aURLSpec); - // Current token. The value is valid after calling GetToken nsCSSToken mToken; @@ -364,7 +364,7 @@ CSSParserImpl::SetStyleSheet(nsIStyleSheet* aSheet) NS_METHOD CSSParserImpl::Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult) { if (nsnull == mSheet) { @@ -598,7 +598,7 @@ PRBool CSSParserImpl::ParseImportRule(PRInt32* aErrorCode) return PR_TRUE; } -void CSSParserImpl::ProcessImport(const nsString& aURLSpec) +NS_IMETHODIMP CSSParserImpl::ProcessImport(const nsString& aURLSpec) { // XXX probably need a way to encode unicode junk for the part of // the url that follows a "?" @@ -609,7 +609,7 @@ void CSSParserImpl::ProcessImport(const nsString& aURLSpec) if (NS_OK != rv) { // import url is bad // XXX log this somewhere for easier web page debugging - return; + return rv; } if (PR_FALSE == mSheet->ContainsStyleSheet(url)) { // don't allow circular references @@ -656,6 +656,8 @@ void CSSParserImpl::ProcessImport(const nsString& aURLSpec) } } NS_RELEASE(url); + + return rv; } void CSSParserImpl::SkipUntil(PRInt32* aErrorCode, PRUnichar aStopSymbol) diff --git a/layout/html/style/src/nsCSSStyleRule.cpp b/layout/html/style/src/nsCSSStyleRule.cpp index 513e3babb3f1..0c13a0041cfb 100644 --- a/layout/html/style/src/nsCSSStyleRule.cpp +++ b/layout/html/style/src/nsCSSStyleRule.cpp @@ -17,6 +17,7 @@ */ #include "nsICSSStyleRule.h" #include "nsICSSDeclaration.h" +#include "nsIStyleSheet.h" #include "nsIStyleContext.h" #include "nsIPresContext.h" #include "nsIDeviceContext.h" @@ -29,12 +30,25 @@ #include "nsUnitConversion.h" #include "nsStyleUtil.h" #include "nsIFontMetrics.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRule.h" +#include "nsIDOMCSSStyleRuleSimple.h" +#include "nsIDOMCSSStyleDeclaration.h" +#include "nsIScriptGlobalObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsDOMCSSDeclaration.h" //#define DEBUG_REFS +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); static NS_DEFINE_IID(kICSSDeclarationIID, NS_ICSS_DECLARATION_IID); static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleSheetIID, NS_IDOMCSSSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleIID, NS_IDOMCSSSTYLERULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleSimpleIID, NS_IDOMCSSSTYLERULESIMPLE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kCSSFontSID, NS_CSS_FONT_SID); static NS_DEFINE_IID(kCSSColorSID, NS_CSS_COLOR_SID); @@ -231,10 +245,79 @@ CSSImportantRule::List(FILE* out, PRInt32 aIndent) const return NS_OK; } +// -- nsDOMStyleRuleDeclaration ------------------------------- + +class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration +{ +public: + DOMCSSDeclarationImpl(nsICSSStyleRule *aRule); + ~DOMCSSDeclarationImpl(); + + virtual void DropReference(); + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate); + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint); + virtual nsresult GetParent(nsISupports **aParent); + +protected: + nsICSSStyleRule *mRule; +}; + +DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(nsICSSStyleRule *aRule) +{ + // This reference is not reference-counted. The rule + // object tells us when its about to go away. + mRule = aRule; +} + +DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl() +{ +} + +void +DOMCSSDeclarationImpl::DropReference() +{ + mRule = nsnull; +} + +nsresult +DOMCSSDeclarationImpl::GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) +{ + if (nsnull != mRule) { + *aDecl = mRule->GetDeclaration(); + } + else { + *aDecl = nsnull; + } + + return NS_OK; +} + +nsresult +DOMCSSDeclarationImpl::StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) +{ + // XXX TBI + return NS_OK; +} + +nsresult +DOMCSSDeclarationImpl::GetParent(nsISupports **aParent) +{ + if (nsnull != mRule) { + return mRule->QueryInterface(kISupportsIID, (void **)aParent); + } + + return NS_OK; +} // -- nsCSSStyleRule ------------------------------- -class CSSStyleRuleImpl : public nsICSSStyleRule { +class CSSStyleRuleImpl : public nsICSSStyleRule, + public nsIDOMCSSStyleRuleSimple, + public nsIScriptObjectOwner { public: void* operator new(size_t size); void* operator new(size_t size, nsIArena* aArena); @@ -263,10 +346,25 @@ public: virtual nsIStyleRule* GetImportantRule(void); + virtual nsIStyleSheet* GetStyleSheet(void); + virtual void SetStyleSheet(nsIStyleSheet *aSheet); + NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + // nsIDOMCSSStyleRule interface + NS_IMETHOD GetType(nsString& aType); + + // nsIDOMCSSStyleRuleSimple interface + NS_IMETHOD GetSelectorText(nsString& aSelectorText); + NS_IMETHOD SetSelectorText(const nsString& aSelectorText); + NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + private: // These are not supported and are not implemented! CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy); @@ -283,6 +381,9 @@ protected: nsICSSDeclaration* mDeclaration; PRInt32 mWeight; CSSImportantRule* mImportantRule; + nsIStyleSheet* mStyleSheet; + DOMCSSDeclarationImpl *mDOMDeclaration; + void* mScriptObject; #ifdef DEBUG_REFS PRInt32 mInstance; #endif @@ -334,6 +435,8 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(const nsCSSSelector& aSelector) mWeight(0), mImportantRule(nsnull) { NS_INIT_REFCNT(); + mDOMDeclaration = nsnull; + mScriptObject = nsnull; #ifdef DEBUG_REFS mInstance = gInstanceCount++; fprintf(stdout, "%d of %d + CSSStyleRule\n", mInstance, gInstanceCount); @@ -351,6 +454,9 @@ CSSStyleRuleImpl::~CSSStyleRuleImpl() } NS_IF_RELEASE(mDeclaration); NS_IF_RELEASE(mImportantRule); + if (nsnull != mDOMDeclaration) { + mDOMDeclaration->DropReference(); + } #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d of %d - CSSStyleRule\n", mInstance, gInstanceCount); @@ -389,7 +495,6 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID, if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); if (aIID.Equals(kICSSStyleRuleIID)) { *aInstancePtrResult = (void*) ((nsICSSStyleRule*)this); NS_ADDREF_THIS(); @@ -400,8 +505,28 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID, NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kIDOMCSSStyleRuleIID)) { + nsIDOMCSSStyleRule *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIDOMCSSStyleRuleSimpleIID)) { + nsIDOMCSSStyleRuleSimple *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)this); + nsICSSStyleRule *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; NS_ADDREF_THIS(); return NS_OK; } @@ -543,6 +668,21 @@ nsIStyleRule* CSSStyleRuleImpl::GetImportantRule(void) return mImportantRule; } +nsIStyleSheet* CSSStyleRuleImpl::GetStyleSheet(void) +{ + NS_IF_ADDREF(mStyleSheet); + + return mStyleSheet; +} + +void CSSStyleRuleImpl::SetStyleSheet(nsIStyleSheet *aSheet) +{ + // XXX We don't reference count this up reference. The style sheet + // will tell us when it's going away or when we're detached from + // it. + mStyleSheet = aSheet; +} + nscoord CalcLength(const nsCSSValue& aValue, const nsStyleFont* aFont, nsIPresContext* aPresContext) @@ -1236,6 +1376,105 @@ CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const return NS_OK; } +NS_IMETHODIMP +CSSStyleRuleImpl::GetType(nsString& aType) +{ + // XXX Need to define the different types + aType.SetString("simple"); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetSelectorText(nsString& aSelectorText) +{ + nsAutoString buffer; + nsAutoString thisSelector; + nsCSSSelector *selector = &mSelector; + + // XXX Ugh...they're in reverse order from the source. Sorry + // for the ugliness. + aSelectorText.SetLength(0); + while (nsnull != selector) { + thisSelector.SetLength(0); + if (nsnull != selector->mTag) { + selector->mTag->ToString(buffer); + thisSelector.Append(buffer); + } + if (nsnull != selector->mID) { + selector->mID->ToString(buffer); + thisSelector.Append("#"); + thisSelector.Append(buffer); + } + if (nsnull != selector->mClass) { + selector->mClass->ToString(buffer); + thisSelector.Append("."); + thisSelector.Append(buffer); + } + if (nsnull != selector->mPseudoClass) { + selector->mPseudoClass->ToString(buffer); + thisSelector.Append(":"); + thisSelector.Append(buffer); + } + aSelectorText.Insert(thisSelector, 0, thisSelector.Length()); + selector = selector->mNext; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::SetSelectorText(const nsString& aSelectorText) +{ + // XXX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) +{ + if (nsnull == mDOMDeclaration) { + mDOMDeclaration = new DOMCSSDeclarationImpl(this); + if (nsnull == mDOMDeclaration) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mDOMDeclaration); + } + + *aStyle = mDOMDeclaration; + NS_ADDREF(mDOMDeclaration); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsICSSStyleRule *)this; + // XXX Parent should be the style sheet + // XXX Should be done through factory + res = NS_NewScriptCSSStyleRuleSimple(aContext, + supports, + (nsISupports *)global, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return res; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + NS_HTML nsresult NS_NewCSSStyleRule(nsICSSStyleRule** aInstancePtrResult, const nsCSSSelector& aSelector) { diff --git a/layout/html/style/src/nsCSSStyleSheet.cpp b/layout/html/style/src/nsCSSStyleSheet.cpp index f8839f4d77e5..b74affeed84a 100644 --- a/layout/html/style/src/nsCSSStyleSheet.cpp +++ b/layout/html/style/src/nsCSSStyleSheet.cpp @@ -32,6 +32,13 @@ #include "nsString.h" #include "nsIPtr.h" #include "nsHTMLIIDs.h" +#include "nsIDOMStyleSheetCollection.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRule.h" +#include "nsIDOMCSSStyleRuleCollection.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsICSSParser.h" //#define DEBUG_REFS //#define DEBUG_RULES @@ -39,6 +46,12 @@ static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID); static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); +static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleSheetIID, NS_IDOMCSSSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleIID, NS_IDOMCSSSTYLERULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleCollectionIID, NS_IDOMCSSSTYLERULECOLLECTION_IID); +static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); NS_DEF_PTR(nsIHTMLContent); NS_DEF_PTR(nsIContent); @@ -129,6 +142,7 @@ public: RuleEnumFunc aFunc, void* aData); void EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData); + protected: void AppendRuleToTable(nsHashtable& aTable, nsIAtom* aAtom, nsICSSStyleRule* aRule); @@ -171,6 +185,7 @@ void RuleHash::AppendRuleToTable(nsHashtable& aTable, nsIAtom* aAtom, nsICSSStyl value = value->mNext; } value->mNext = new RuleValue(aRule, mRuleCount++); + value = value->mNext; } } @@ -242,11 +257,279 @@ void RuleHash::EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData) } } +// ------------------------------- +// Style Rule Collection for the DOM +// +class CSSStyleRuleCollectionImpl : public nsIDOMCSSStyleRuleCollection, + public nsIScriptObjectOwner +{ +public: + CSSStyleRuleCollectionImpl(nsICSSStyleSheet *aStyleSheet); + + NS_DECL_ISUPPORTS + + // nsIDOMCSSStyleRuleCollection interface + NS_IMETHOD GetLength(PRUint32* aLength); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMCSSStyleRule** aReturn); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + void DropReference() { mStyleSheet = nsnull; } + +protected: + virtual ~CSSStyleRuleCollectionImpl(); + + nsICSSStyleSheet* mStyleSheet; + void* mScriptObject; +}; + +CSSStyleRuleCollectionImpl::CSSStyleRuleCollectionImpl(nsICSSStyleSheet *aStyleSheet) +{ + NS_INIT_REFCNT(); + // Not reference counted to avoid circular references. + // The style sheet will tell us when its going away. + mStyleSheet = aStyleSheet; + mScriptObject = nsnull; +} + +CSSStyleRuleCollectionImpl::~CSSStyleRuleCollectionImpl() +{ +} + +NS_IMPL_ADDREF(CSSStyleRuleCollectionImpl); +NS_IMPL_RELEASE(CSSStyleRuleCollectionImpl); + +nsresult +CSSStyleRuleCollectionImpl::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMCSSStyleRuleCollectionIID)) { + nsIDOMCSSStyleRuleCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMCSSStyleRuleCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::GetLength(PRUint32* aLength) +{ + if (nsnull != mStyleSheet) { + *aLength = mStyleSheet->StyleRuleCount(); + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::Item(PRUint32 aIndex, nsIDOMCSSStyleRule** aReturn) +{ + nsresult result = NS_OK; + + *aReturn = nsnull; + if (nsnull != mStyleSheet) { + nsICSSStyleRule *rule; + + result = mStyleSheet->GetStyleRuleAt(aIndex, rule); + if (NS_OK == result) { + result = rule->QueryInterface(kIDOMCSSStyleRuleIID, (void **)aReturn); + } + NS_RELEASE(rule); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleRuleCollection *)this; + + // XXX Should be done through factory + res = NS_NewScriptCSSStyleRuleCollection(aContext, + supports, + (nsISupports *)mStyleSheet, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +// ------------------------------- +// Imports Collection for the DOM +// +class CSSImportsCollectionImpl : public nsIDOMStyleSheetCollection, + public nsIScriptObjectOwner +{ +public: + CSSImportsCollectionImpl(nsICSSStyleSheet *aStyleSheet); + + NS_DECL_ISUPPORTS + + // nsIDOMCSSStyleSheetCollection interface + NS_IMETHOD GetLength(PRUint32* aLength); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + void DropReference() { mStyleSheet = nsnull; } + +protected: + virtual ~CSSImportsCollectionImpl(); + + nsICSSStyleSheet* mStyleSheet; + void* mScriptObject; +}; + +CSSImportsCollectionImpl::CSSImportsCollectionImpl(nsICSSStyleSheet *aStyleSheet) +{ + NS_INIT_REFCNT(); + // Not reference counted to avoid circular references. + // The style sheet will tell us when its going away. + mStyleSheet = aStyleSheet; + mScriptObject = nsnull; +} + +CSSImportsCollectionImpl::~CSSImportsCollectionImpl() +{ +} + +NS_IMPL_ADDREF(CSSImportsCollectionImpl); +NS_IMPL_RELEASE(CSSImportsCollectionImpl); + +nsresult +CSSImportsCollectionImpl::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMStyleSheetCollectionIID)) { + nsIDOMStyleSheetCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMStyleSheetCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::GetLength(PRUint32* aLength) +{ + if (nsnull != mStyleSheet) { + *aLength = mStyleSheet->StyleSheetCount(); + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn) +{ + nsresult result = NS_OK; + + *aReturn = nsnull; + if (nsnull != mStyleSheet) { + nsICSSStyleSheet *sheet; + + result = mStyleSheet->GetStyleSheetAt(aIndex, sheet); + if (NS_OK == result) { + result = sheet->QueryInterface(kIDOMStyleSheetIID, (void **)aReturn); + } + NS_RELEASE(sheet); + } + + return result; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMStyleSheetCollection *)this; + + // XXX Should be done through factory + res = NS_NewScriptStyleSheetCollection(aContext, + supports, + (nsISupports *)mStyleSheet, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} // ------------------------------- // CSS Style Sheet // -class CSSStyleSheetImpl : public nsICSSStyleSheet { +class CSSStyleSheetImpl : public nsICSSStyleSheet, + public nsIDOMCSSStyleSheet, + public nsIScriptObjectOwner { public: void* operator new(size_t size); void* operator new(size_t size, nsIArena* aArena); @@ -281,8 +564,32 @@ public: virtual PRInt32 StyleRuleCount(void); virtual nsresult GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRule); + virtual PRInt32 StyleSheetCount(); + virtual nsresult GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet); + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + // nsIDOMStyleSheet interface + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetReadOnly(PRBool* aReadOnly); + + // nsIDOMCSSStyleSheet interface + NS_IMETHOD GetOwningElement(nsIDOMHTMLElement** aOwningElement); + NS_IMETHOD GetParentStyleSheet(nsIDOMCSSStyleSheet** aParentStyleSheet); + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD GetTitle(nsString& aTitle); + NS_IMETHOD GetImports(nsIDOMStyleSheetCollection** aImports); + NS_IMETHOD GetRules(nsIDOMCSSStyleRuleCollection** aRules); + NS_IMETHOD AddRule(const nsString& aSelector, const nsString& aDeclaration, PRUint32 aIndex, PRUint32* aReturn); + NS_IMETHOD AddImport(const nsString& aUrl, PRUint32 aIndex, PRUint32* aReturn); + NS_IMETHOD RemoveRule(PRUint32 aIndex); + NS_IMETHOD RemoveImport(PRUint32 aIndex); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + private: // These are not supported and are not implemented! CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy); @@ -303,7 +610,11 @@ protected: nsISupportsArrayPtr mOrderedRules; nsISupportsArrayPtr mWeightedRules; nsICSSStyleSheetPtr mNext; + nsICSSStyleSheet* mParent; RuleHash* mRuleHash; + CSSStyleRuleCollectionImpl* mRuleCollection; + CSSImportsCollectionImpl* mImportsCollection; + void * mScriptObject; }; @@ -354,18 +665,49 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL) { NS_INIT_REFCNT(); mURL.SetAddRef(aURL); + mParent = nsnull; + mRuleCollection = nsnull; + mImportsCollection = nsnull; + mScriptObject = nsnull; #ifdef DEBUG_REFS ++gInstanceCount; fprintf(stdout, "%d + CSSStyleSheet size: %d\n", gInstanceCount, sizeof(*this)); #endif } +static PRBool DropStyleSheetReference(nsISupports* aElement, void *aData) +{ + nsICSSStyleRule *rule = (nsICSSStyleRule *)aElement; + + if (nsnull != rule) { + rule->SetStyleSheet(nsnull); + } + + return PR_TRUE; +} + CSSStyleSheetImpl::~CSSStyleSheetImpl() { #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d - CSSStyleSheet\n", gInstanceCount); #endif + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while (nsnull != child) { + ((CSSStyleSheetImpl *)child)->mParent = nsnull; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + } + if (nsnull != mRuleCollection) { + mRuleCollection->DropReference(); + NS_RELEASE(mRuleCollection); + } + if (nsnull != mImportsCollection) { + mImportsCollection->DropReference(); + NS_RELEASE(mImportsCollection); + } + mOrderedRules->EnumerateForwards(DropStyleSheetReference, nsnull); ClearHash(); } @@ -390,8 +732,28 @@ nsresult CSSStyleSheetImpl::QueryInterface(const nsIID& aIID, NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kIDOMStyleSheetIID)) { + nsIDOMStyleSheet *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIDOMCSSStyleSheetIID)) { + nsIDOMCSSStyleSheet *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)this); + nsICSSStyleSheet *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; NS_ADDREF_THIS(); return NS_OK; } @@ -750,6 +1112,10 @@ void CSSStyleSheetImpl::AppendStyleSheet(nsICSSStyleSheet* aSheet) } ((CSSStyleSheetImpl*)child)->mNext.SetAddRef(aSheet); } + + // This is not reference counted. Our parent tells us when + // it's going away. + ((CSSStyleSheetImpl*)aSheet)->mParent = this; } void CSSStyleSheetImpl::PrependStyleRule(nsICSSStyleRule* aRule) @@ -778,6 +1144,7 @@ void CSSStyleSheetImpl::PrependStyleRule(nsICSSStyleRule* aRule) } mWeightedRules->InsertElementAt(aRule, index + 1); mOrderedRules->InsertElementAt(aRule, 0); + aRule->SetStyleSheet(this); } void CSSStyleSheetImpl::AppendStyleRule(nsICSSStyleRule* aRule) @@ -807,6 +1174,7 @@ void CSSStyleSheetImpl::AppendStyleRule(nsICSSStyleRule* aRule) } mWeightedRules->InsertElementAt(aRule, index); mOrderedRules->AppendElement(aRule); + aRule->SetStyleSheet(this); } PRInt32 CSSStyleSheetImpl::StyleRuleCount(void) @@ -833,6 +1201,43 @@ nsresult CSSStyleSheetImpl::GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRu return result; } +PRInt32 CSSStyleSheetImpl::StyleSheetCount() +{ + // XXX Far from an ideal way to do this, but the hope is that + // it won't be done too often. If it is, we might want to + // consider storing the children in an array. + PRInt32 count = 0; + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while (nsnull != child) { + count++; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + } + + return count; +} + +nsresult CSSStyleSheetImpl::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) +{ + // XXX Ughh...an O(n^2) method for doing iteration. Again, we hope + // that this isn't done too often. If it is, we need to change the + // underlying storage mechanism + aSheet = nsnull; + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while ((nsnull != child) && (0 != aIndex)) { + --aIndex; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + + aSheet = child; + NS_IF_ADDREF(child); + } + + return NS_OK; +} + void CSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { nsAutoString buffer; @@ -886,6 +1291,224 @@ void CSSStyleSheetImpl::BuildHash(void) } } +NS_IMETHODIMP +CSSStyleSheetImpl::GetDisabled(PRBool* aDisabled) +{ + // XXX TBI + *aDisabled = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::SetDisabled(PRBool aDisabled) +{ + // XXX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetReadOnly(PRBool* aReadOnly) +{ + // XXX TBI + *aReadOnly = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetOwningElement(nsIDOMHTMLElement** aOwningElement) +{ + // XXX TBI + *aOwningElement = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aParentStyleSheet) +{ + if (nsnull != mParent) { + return mParent->QueryInterface(kIDOMCSSStyleSheetIID, (void **)aParentStyleSheet); + } + else { + *aParentStyleSheet = nsnull; + return NS_OK; + } +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetHref(nsString& aHref) +{ + if (mURL.IsNotNull()) { + mURL->ToString(aHref); + } + else { + aHref.SetLength(0); + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetTitle(nsString& aTitle) +{ + // XX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetImports(nsIDOMStyleSheetCollection** aImports) +{ + if (nsnull == mImportsCollection) { + mImportsCollection = new CSSImportsCollectionImpl(this); + if (nsnull == mImportsCollection) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mImportsCollection); + } + + *aImports = mImportsCollection; + NS_ADDREF(mImportsCollection); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetRules(nsIDOMCSSStyleRuleCollection** aRules) +{ + if (nsnull == mRuleCollection) { + mRuleCollection = new CSSStyleRuleCollectionImpl(this); + if (nsnull == mRuleCollection) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mRuleCollection); + } + + *aRules = mRuleCollection; + NS_ADDREF(mRuleCollection); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::AddRule(const nsString& aSelector, + const nsString& aDeclaration, + PRUint32 aIndex, + PRUint32* aReturn) +{ + nsICSSParser* css; + nsresult result = NS_NewCSSParser(&css); + if (NS_OK == result) { + nsAutoString str; + str.SetString(aSelector); + // XXX Can we assume that the braces aren't there? + str.Append(" { "); + str.Append(aDeclaration); + str.Append(" } "); + + nsIUnicharInputStream* input = nsnull; + result = NS_NewStringUnicharInputStream(&input, &str); + if (NS_OK == result) { + nsIStyleSheet *tmp; + css->SetStyleSheet(this); + // XXX Currently, the parser will append the rule to the + // style sheet. We shouldn't ignore the index. + result = css->Parse(input, mURL, tmp); + NS_ASSERTION(tmp = this, "parser incorrectly created a new stylesheet"); + NS_RELEASE(input); + *aReturn = mOrderedRules->Count(); + } + + NS_RELEASE(css); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::AddImport(const nsString& aUrl, PRUint32 aIndex, PRUint32* aReturn) +{ + nsICSSParser* css; + nsresult result = NS_NewCSSParser(&css); + if (NS_OK == result) { + css->SetStyleSheet(this); + result = css->ProcessImport(aUrl); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::RemoveRule(PRUint32 aIndex) +{ + nsICSSStyleRule *rule; + + rule = (nsICSSStyleRule *)mOrderedRules->ElementAt(aIndex); + if (nsnull != rule) { + mOrderedRules->RemoveElementAt(aIndex); + mWeightedRules->RemoveElement(rule); + rule->SetStyleSheet(nsnull); + NS_RELEASE(rule); + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::RemoveImport(PRUint32 aIndex) +{ + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* prev = nsnull; + nsICSSStyleSheet* child = mFirstChild; + while ((nsnull != child) && (0 != aIndex)) { + prev = child; + child = ((CSSStyleSheetImpl*)child)->mNext; + --aIndex; + } + + if ((nsnull != child) && (0 == aIndex)) { + // Hold on to the child while we clean it up + NS_ADDREF(child); + if (nsnull == prev) { + mFirstChild.SetAddRef(((CSSStyleSheetImpl*)child)->mNext); + } + else { + ((CSSStyleSheetImpl*)prev)->mNext.SetAddRef(((CSSStyleSheetImpl*)child)->mNext); + } + ((CSSStyleSheetImpl*)child)->mNext.SetAddRef(nsnull); + ((CSSStyleSheetImpl*)child)->mParent = nsnull; + NS_RELEASE(child); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsICSSStyleSheet *)this; + // XXX Should be done through factory + res = NS_NewScriptCSSStyleSheet(aContext, + supports, + (nsISupports *)global, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return res; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + NS_HTML nsresult NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult, nsIURL* aURL) { diff --git a/layout/html/style/src/nsDOMCSSDeclaration.cpp b/layout/html/style/src/nsDOMCSSDeclaration.cpp new file mode 100644 index 000000000000..dedd6fff82ee --- /dev/null +++ b/layout/html/style/src/nsDOMCSSDeclaration.cpp @@ -0,0 +1,1677 @@ +/* -*- 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.0 (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/ + * + * 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. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsDOMCSSDeclaration.h" +#include "nsICSSStyleRule.h" +#include "nsICSSParser.h" +#include "nsIStyleRule.h" +#include "nsICSSDeclaration.h" +#include "nsCSSProps.h" + +nsDOMCSSDeclaration::nsDOMCSSDeclaration() +{ + NS_INIT_REFCNT(); + mScriptObject = nsnull; +} + +nsDOMCSSDeclaration::~nsDOMCSSDeclaration() +{ +} + +NS_IMPL_ADDREF(nsDOMCSSDeclaration); +NS_IMPL_RELEASE(nsDOMCSSDeclaration); + +static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); +static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + +NS_IMETHODIMP +nsDOMCSSDeclaration::QueryInterface(REFNSIID aIID, + void** aInstancePtr) +{ + NS_PRECONDITION(nsnull != aInstancePtr, "null ptr"); + if (nsnull == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIDOMCSSStyleDeclarationIID)) { + nsIDOMCSSStyleDeclaration *tmp = this; + AddRef(); + *aInstancePtr = (void*) tmp; + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + AddRef(); + *aInstancePtr = (void*) tmp; + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMCSSStyleDeclaration *tmp = this; + nsISupports *tmp2 = tmp; + AddRef(); + *aInstancePtr = (void*) tmp2; + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *parent = nsnull; + + res = GetParent(&parent); + if (NS_OK == res) { + nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleDeclaration *)this; + // XXX Should be done through factory + res = NS_NewScriptCSSStyleDeclaration(aContext, + supports, + parent, + (void**)&mScriptObject); + NS_RELEASE(parent); + } + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLength(PRUint32* aLength) +{ + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + + *aLength = 0; + if ((NS_OK == result) && (nsnull != decl)) { + result = decl->Count(aLength); + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsString& aReturn) +{ + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + + aReturn.SetLength(0); + if ((NS_OK == result) && (nsnull != decl)) { + result = decl->GetNthProperty(aIndex, aReturn); + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPropertyValue(const nsString& aPropertyName, + nsString& aReturn) +{ + nsCSSValue val; + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + + aReturn.SetLength(0); + if ((NS_OK == result) && (nsnull != decl)) { + result = decl->GetValue(aPropertyName, aReturn); + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPropertyPriority(const nsString& aPropertyName, + nsString& aReturn) +{ + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + PRBool isImportant = PR_FALSE; + + if ((NS_OK == result) && (nsnull != decl)) { + char prop[50]; + aPropertyName.ToCString(prop, sizeof(prop)); + result = decl->GetValueIsImportant(prop, isImportant); + NS_RELEASE(decl); + } + + if ((NS_OK == result) && isImportant) { + aReturn.SetString("!important"); + } + else { + aReturn.SetLength(0); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetProperty(const nsString& aPropertyName, + const nsString& aValue, + const nsString& aPriority) +{ + nsAutoString declString; + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_TRUE); + + if ((NS_OK == result) && (nsnull != decl)) { + declString.SetString(aPropertyName); + declString.Append(":"); + declString.Append(aValue); + + nsICSSParser* css; + result = NS_NewCSSParser(&css); + if (NS_OK == result) { + PRInt32 hint; + result = css->ParseAndAppendDeclaration(declString, nsnull, decl, &hint); + if (NS_OK == result) { + if (aPriority.Equals("!important")) { + char prop[50]; + aPropertyName.ToCString(prop, sizeof(prop)); + decl->SetValueImportant(prop); + } + result = StylePropertyChanged(aPropertyName, hint); + } + NS_RELEASE(css); + } + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetAzimuth(nsString& aAzimuth) +{ + return GetPropertyValue("azimuth", aAzimuth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetAzimuth(const nsString& aAzimuth) +{ + return SetProperty("azimuth", aAzimuth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackground(nsString& aBackground) +{ + return GetPropertyValue("background", aBackground); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackground(const nsString& aBackground) +{ + return SetProperty("background", aBackground, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundAttachment(nsString& aBackgroundAttachment) +{ + return GetPropertyValue("background-attachment", aBackgroundAttachment); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundAttachment(const nsString& aBackgroundAttachment) +{ + return SetProperty("background-attachment", aBackgroundAttachment, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundColor(nsString& aBackgroundColor) +{ + return GetPropertyValue("background-color", aBackgroundColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundColor(const nsString& aBackgroundColor) +{ + return SetProperty("background-color", aBackgroundColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundImage(nsString& aBackgroundImage) +{ + return GetPropertyValue("background-image", aBackgroundImage); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundImage(const nsString& aBackgroundImage) +{ + return SetProperty("background-image", aBackgroundImage, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundPosition(nsString& aBackgroundPosition) +{ + return GetPropertyValue("background-position", aBackgroundPosition); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundPosition(const nsString& aBackgroundPosition) +{ + return SetProperty("background-position", aBackgroundPosition, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundRepeat(nsString& aBackgroundRepeat) +{ + return GetPropertyValue("background-repeat", aBackgroundRepeat); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundRepeat(const nsString& aBackgroundRepeat) +{ + return SetProperty("background-repeat", aBackgroundRepeat, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorder(nsString& aBorder) +{ + return GetPropertyValue("border", aBorder); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorder(const nsString& aBorder) +{ + return SetProperty("border", aBorder, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderCollapse(nsString& aBorderCollapse) +{ + return GetPropertyValue("border-collapse", aBorderCollapse); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderCollapse(const nsString& aBorderCollapse) +{ + return SetProperty("border-collapse", aBorderCollapse, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderColor(nsString& aBorderColor) +{ + return GetPropertyValue("border-color", aBorderColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderColor(const nsString& aBorderColor) +{ + return SetProperty("border-color", aBorderColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderSpacing(nsString& aBorderSpacing) +{ + return GetPropertyValue("border-spacing", aBorderSpacing); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderSpacing(const nsString& aBorderSpacing) +{ + return SetProperty("border-spacing", aBorderSpacing, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderStyle(nsString& aBorderStyle) +{ + return GetPropertyValue("border-style", aBorderStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderStyle(const nsString& aBorderStyle) +{ + return SetProperty("border-style", aBorderStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTop(nsString& aBorderTop) +{ + return GetPropertyValue("border-top", aBorderTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTop(const nsString& aBorderTop) +{ + return SetProperty("border-top", aBorderTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRight(nsString& aBorderRight) +{ + return GetPropertyValue("border-right", aBorderRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRight(const nsString& aBorderRight) +{ + return SetProperty("border-right", aBorderRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottom(nsString& aBorderBottom) +{ + return GetPropertyValue("border-bottom", aBorderBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottom(const nsString& aBorderBottom) +{ + return SetProperty("border-bottom", aBorderBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeft(nsString& aBorderLeft) +{ + return GetPropertyValue("border-left", aBorderLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeft(const nsString& aBorderLeft) +{ + return SetProperty("border-left", aBorderLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTopColor(nsString& aBorderTopColor) +{ + return GetPropertyValue("border-top-color", aBorderTopColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTopColor(const nsString& aBorderTopColor) +{ + return SetProperty("border-top-color", aBorderTopColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRightColor(nsString& aBorderRightColor) +{ + return GetPropertyValue("border-right-color", aBorderRightColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRightColor(const nsString& aBorderRightColor) +{ + return SetProperty("border-right-color", aBorderRightColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottomColor(nsString& aBorderBottomColor) +{ + return GetPropertyValue("border-bottom-color", aBorderBottomColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottomColor(const nsString& aBorderBottomColor) +{ + return SetProperty("border-bottom-color", aBorderBottomColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeftColor(nsString& aBorderLeftColor) +{ + return GetPropertyValue("border-left-color", aBorderLeftColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeftColor(const nsString& aBorderLeftColor) +{ + return SetProperty("border-left-color", aBorderLeftColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTopStyle(nsString& aBorderTopStyle) +{ + return GetPropertyValue("border-top-style", aBorderTopStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTopStyle(const nsString& aBorderTopStyle) +{ + return SetProperty("border-top-style", aBorderTopStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRightStyle(nsString& aBorderRightStyle) +{ + return GetPropertyValue("border-right-style", aBorderRightStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRightStyle(const nsString& aBorderRightStyle) +{ + return SetProperty("border-right-style", aBorderRightStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottomStyle(nsString& aBorderBottomStyle) +{ + return GetPropertyValue("border-bottom-style", aBorderBottomStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottomStyle(const nsString& aBorderBottomStyle) +{ + return SetProperty("border-bottom-style", aBorderBottomStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeftStyle(nsString& aBorderLeftStyle) +{ + return GetPropertyValue("border-left-style", aBorderLeftStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeftStyle(const nsString& aBorderLeftStyle) +{ + return SetProperty("border-left-style", aBorderLeftStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTopWidth(nsString& aBorderTopWidth) +{ + return GetPropertyValue("border-top-width", aBorderTopWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTopWidth(const nsString& aBorderTopWidth) +{ + return SetProperty("border-top-width", aBorderTopWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRightWidth(nsString& aBorderRightWidth) +{ + return GetPropertyValue("border-right-width", aBorderRightWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRightWidth(const nsString& aBorderRightWidth) +{ + return SetProperty("border-right-width", aBorderRightWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottomWidth(nsString& aBorderBottomWidth) +{ + return GetPropertyValue("border-bottom-width", aBorderBottomWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottomWidth(const nsString& aBorderBottomWidth) +{ + return SetProperty("border-bottom-width", aBorderBottomWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeftWidth(nsString& aBorderLeftWidth) +{ + return GetPropertyValue("border-left-width", aBorderLeftWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeftWidth(const nsString& aBorderLeftWidth) +{ + return SetProperty("border-left-width", aBorderLeftWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderWidth(nsString& aBorderWidth) +{ + return GetPropertyValue("border-width", aBorderWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderWidth(const nsString& aBorderWidth) +{ + return SetProperty("border-width", aBorderWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBottom(nsString& aBottom) +{ + return GetPropertyValue("bottom", aBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBottom(const nsString& aBottom) +{ + return SetProperty("bottom", aBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCaptionSide(nsString& aCaptionSide) +{ + return GetPropertyValue("caption-side", aCaptionSide); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCaptionSide(const nsString& aCaptionSide) +{ + return SetProperty("caption-side", aCaptionSide, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetClear(nsString& aClear) +{ + return GetPropertyValue("clear", aClear); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetClear(const nsString& aClear) +{ + return SetProperty("clear", aClear, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetClip(nsString& aClip) +{ + return GetPropertyValue("clip", aClip); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetClip(const nsString& aClip) +{ + return SetProperty("clip", aClip, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetColor(nsString& aColor) +{ + return GetPropertyValue("color", aColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetColor(const nsString& aColor) +{ + return SetProperty("color", aColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetContent(nsString& aContent) +{ + return GetPropertyValue("content", aContent); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetContent(const nsString& aContent) +{ + return SetProperty("content", aContent, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCounterIncrement(nsString& aCounterIncrement) +{ + return GetPropertyValue("counter-increment", aCounterIncrement); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCounterIncrement(const nsString& aCounterIncrement) +{ + return SetProperty("counter-increment", aCounterIncrement, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCounterReset(nsString& aCounterReset) +{ + return GetPropertyValue("counter-reset", aCounterReset); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCounterReset(const nsString& aCounterReset) +{ + return SetProperty("counter-reset", aCounterReset, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCue(nsString& aCue) +{ + return GetPropertyValue("cue", aCue); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCue(const nsString& aCue) +{ + return SetProperty("cue", aCue, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCueAfter(nsString& aCueAfter) +{ + return GetPropertyValue("cue-after", aCueAfter); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCueAfter(const nsString& aCueAfter) +{ + return SetProperty("cue-after", aCueAfter, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCueBefore(nsString& aCueBefore) +{ + return GetPropertyValue("cue-before", aCueBefore); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCueBefore(const nsString& aCueBefore) +{ + return SetProperty("cue-before", aCueBefore, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCursor(nsString& aCursor) +{ + return GetPropertyValue("cursor", aCursor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCursor(const nsString& aCursor) +{ + return SetProperty("cursor", aCursor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetDirection(nsString& aDirection) +{ + return GetPropertyValue("direction", aDirection); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetDirection(const nsString& aDirection) +{ + return SetProperty("direction", aDirection, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetDisplay(nsString& aDisplay) +{ + return GetPropertyValue("display", aDisplay); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetDisplay(const nsString& aDisplay) +{ + return SetProperty("display", aDisplay, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetElevation(nsString& aElevation) +{ + return GetPropertyValue("elevation", aElevation); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetElevation(const nsString& aElevation) +{ + return SetProperty("elevation", aElevation, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetEmptyCells(nsString& aEmptyCells) +{ + return GetPropertyValue("empty-cells", aEmptyCells); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetEmptyCells(const nsString& aEmptyCells) +{ + return SetProperty("empty-cells", aEmptyCells, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetStyleFloat(nsString& aStyleFloat) +{ + return GetPropertyValue("style-float", aStyleFloat); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetStyleFloat(const nsString& aStyleFloat) +{ + return SetProperty("style-float", aStyleFloat, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFont(nsString& aFont) +{ + return GetPropertyValue("font", aFont); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFont(const nsString& aFont) +{ + return SetProperty("font", aFont, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontFamily(nsString& aFontFamily) +{ + return GetPropertyValue("font-family", aFontFamily); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontFamily(const nsString& aFontFamily) +{ + return SetProperty("font-family", aFontFamily, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontSize(nsString& aFontSize) +{ + return GetPropertyValue("font-size", aFontSize); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontSize(const nsString& aFontSize) +{ + return SetProperty("font-size", aFontSize, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontSizeAdjust(nsString& aFontSizeAdjust) +{ + return GetPropertyValue("font-size-adjust", aFontSizeAdjust); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontSizeAdjust(const nsString& aFontSizeAdjust) +{ + return SetProperty("font-size-adjust", aFontSizeAdjust, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontStretch(nsString& aFontStretch) +{ + return GetPropertyValue("font-stretch", aFontStretch); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontStretch(const nsString& aFontStretch) +{ + return SetProperty("font-stretch", aFontStretch, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontStyle(nsString& aFontStyle) +{ + return GetPropertyValue("font-style", aFontStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontStyle(const nsString& aFontStyle) +{ + return SetProperty("font-style", aFontStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontVariant(nsString& aFontVariant) +{ + return GetPropertyValue("font-variant", aFontVariant); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontVariant(const nsString& aFontVariant) +{ + return SetProperty("font-variant", aFontVariant, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontWeight(nsString& aFontWeight) +{ + return GetPropertyValue("font-weight", aFontWeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontWeight(const nsString& aFontWeight) +{ + return SetProperty("font-weight", aFontWeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetHeight(nsString& aHeight) +{ + return GetPropertyValue("height", aHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetHeight(const nsString& aHeight) +{ + return SetProperty("height", aHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLeft(nsString& aLeft) +{ + return GetPropertyValue("left", aLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetLeft(const nsString& aLeft) +{ + return SetProperty("left", aLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLetterSpacing(nsString& aLetterSpacing) +{ + return GetPropertyValue("letter-spacing", aLetterSpacing); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetLetterSpacing(const nsString& aLetterSpacing) +{ + return SetProperty("letter-spacing", aLetterSpacing, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLineHeight(nsString& aLineHeight) +{ + return GetPropertyValue("line-height", aLineHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetLineHeight(const nsString& aLineHeight) +{ + return SetProperty("line-height", aLineHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStyle(nsString& aListStyle) +{ + return GetPropertyValue("list-style", aListStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStyle(const nsString& aListStyle) +{ + return SetProperty("list-style", aListStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStyleImage(nsString& aListStyleImage) +{ + return GetPropertyValue("list-style-image", aListStyleImage); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStyleImage(const nsString& aListStyleImage) +{ + return SetProperty("list-style-image", aListStyleImage, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStylePosition(nsString& aListStylePosition) +{ + return GetPropertyValue("list-style-position", aListStylePosition); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStylePosition(const nsString& aListStylePosition) +{ + return SetProperty("list-style-position", aListStylePosition, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStyleType(nsString& aListStyleType) +{ + return GetPropertyValue("list-style-type", aListStyleType); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStyleType(const nsString& aListStyleType) +{ + return SetProperty("list-style-type", aListStyleType, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMargin(nsString& aMargin) +{ + return GetPropertyValue("margin", aMargin); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMargin(const nsString& aMargin) +{ + return SetProperty("margin", aMargin, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginTop(nsString& aMarginTop) +{ + return GetPropertyValue("margin-top", aMarginTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginTop(const nsString& aMarginTop) +{ + return SetProperty("margin-top", aMarginTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginRight(nsString& aMarginRight) +{ + return GetPropertyValue("margin-right", aMarginRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginRight(const nsString& aMarginRight) +{ + return SetProperty("margin-right", aMarginRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginBottom(nsString& aMarginBottom) +{ + return GetPropertyValue("margin-bottom", aMarginBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginBottom(const nsString& aMarginBottom) +{ + return SetProperty("margin-bottom", aMarginBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginLeft(nsString& aMarginLeft) +{ + return GetPropertyValue("margin-left", aMarginLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginLeft(const nsString& aMarginLeft) +{ + return SetProperty("margin-left", aMarginLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarkerOffset(nsString& aMarkerOffset) +{ + return GetPropertyValue("marker-offset", aMarkerOffset); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarkerOffset(const nsString& aMarkerOffset) +{ + return SetProperty("marker-offset", aMarkerOffset, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarks(nsString& aMarks) +{ + return GetPropertyValue("marks", aMarks); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarks(const nsString& aMarks) +{ + return SetProperty("marks", aMarks, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMaxHeight(nsString& aMaxHeight) +{ + return GetPropertyValue("max-height", aMaxHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMaxHeight(const nsString& aMaxHeight) +{ + return SetProperty("max-height", aMaxHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMaxWidth(nsString& aMaxWidth) +{ + return GetPropertyValue("max-width", aMaxWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMaxWidth(const nsString& aMaxWidth) +{ + return SetProperty("max-width", aMaxWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMinHeight(nsString& aMinHeight) +{ + return GetPropertyValue("min-height", aMinHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMinHeight(const nsString& aMinHeight) +{ + return SetProperty("min-height", aMinHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMinWidth(nsString& aMinWidth) +{ + return GetPropertyValue("min-width", aMinWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMinWidth(const nsString& aMinWidth) +{ + return SetProperty("min-width", aMinWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOrphans(nsString& aOrphans) +{ + return GetPropertyValue("orphans", aOrphans); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOrphans(const nsString& aOrphans) +{ + return SetProperty("orphans", aOrphans, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutline(nsString& aOutline) +{ + return GetPropertyValue("outline", aOutline); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutline(const nsString& aOutline) +{ + return SetProperty("outline", aOutline, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutlineColor(nsString& aOutlineColor) +{ + return GetPropertyValue("outline-color", aOutlineColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutlineColor(const nsString& aOutlineColor) +{ + return SetProperty("outline-color", aOutlineColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutlineStyle(nsString& aOutlineStyle) +{ + return GetPropertyValue("outline-style", aOutlineStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutlineStyle(const nsString& aOutlineStyle) +{ + return SetProperty("outline-style", aOutlineStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutlineWidth(nsString& aOutlineWidth) +{ + return GetPropertyValue("outline-width", aOutlineWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutlineWidth(const nsString& aOutlineWidth) +{ + return SetProperty("outline-width", aOutlineWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOverflow(nsString& aOverflow) +{ + return GetPropertyValue("overflow", aOverflow); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOverflow(const nsString& aOverflow) +{ + return SetProperty("overflow", aOverflow, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPadding(nsString& aPadding) +{ + return GetPropertyValue("padding", aPadding); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPadding(const nsString& aPadding) +{ + return SetProperty("padding", aPadding, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingTop(nsString& aPaddingTop) +{ + return GetPropertyValue("padding-top", aPaddingTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingTop(const nsString& aPaddingTop) +{ + return SetProperty("padding-top", aPaddingTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingRight(nsString& aPaddingRight) +{ + return GetPropertyValue("padding-right", aPaddingRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingRight(const nsString& aPaddingRight) +{ + return SetProperty("padding-right", aPaddingRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingBottom(nsString& aPaddingBottom) +{ + return GetPropertyValue("padding-bottom", aPaddingBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingBottom(const nsString& aPaddingBottom) +{ + return SetProperty("padding-bottom", aPaddingBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingLeft(nsString& aPaddingLeft) +{ + return GetPropertyValue("padding-left", aPaddingLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingLeft(const nsString& aPaddingLeft) +{ + return SetProperty("padding-left", aPaddingLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPage(nsString& aPage) +{ + return GetPropertyValue("page", aPage); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPage(const nsString& aPage) +{ + return SetProperty("page", aPage, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPageBreakAfter(nsString& aPageBreakAfter) +{ + return GetPropertyValue("page-break-after", aPageBreakAfter); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPageBreakAfter(const nsString& aPageBreakAfter) +{ + return SetProperty("page-break-after", aPageBreakAfter, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPageBreakBefore(nsString& aPageBreakBefore) +{ + return GetPropertyValue("page-break-before", aPageBreakBefore); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPageBreakBefore(const nsString& aPageBreakBefore) +{ + return SetProperty("page-break-before", aPageBreakBefore, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPageBreakInside(nsString& aPageBreakInside) +{ + return GetPropertyValue("page-break-inside", aPageBreakInside); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPageBreakInside(const nsString& aPageBreakInside) +{ + return SetProperty("page-break-inside", aPageBreakInside, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPause(nsString& aPause) +{ + return GetPropertyValue("pause", aPause); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPause(const nsString& aPause) +{ + return SetProperty("pause", aPause, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPauseAfter(nsString& aPauseAfter) +{ + return GetPropertyValue("pause-after", aPauseAfter); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPauseAfter(const nsString& aPauseAfter) +{ + return SetProperty("pause-after", aPauseAfter, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPauseBefore(nsString& aPauseBefore) +{ + return GetPropertyValue("pause-before", aPauseBefore); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPauseBefore(const nsString& aPauseBefore) +{ + return SetProperty("pause-before", aPauseBefore, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPitch(nsString& aPitch) +{ + return GetPropertyValue("pitch", aPitch); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPitch(const nsString& aPitch) +{ + return SetProperty("pitch", aPitch, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPitchRange(nsString& aPitchRange) +{ + return GetPropertyValue("pitch-range", aPitchRange); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPitchRange(const nsString& aPitchRange) +{ + return SetProperty("pitch-range", aPitchRange, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPlayDuring(nsString& aPlayDuring) +{ + return GetPropertyValue("play-during", aPlayDuring); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPlayDuring(const nsString& aPlayDuring) +{ + return SetProperty("play-during", aPlayDuring, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPosition(nsString& aPosition) +{ + return GetPropertyValue("position", aPosition); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPosition(const nsString& aPosition) +{ + return SetProperty("position", aPosition, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetQuotes(nsString& aQuotes) +{ + return GetPropertyValue("quotes", aQuotes); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetQuotes(const nsString& aQuotes) +{ + return SetProperty("quotes", aQuotes, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetRichness(nsString& aRichness) +{ + return GetPropertyValue("richness", aRichness); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetRichness(const nsString& aRichness) +{ + return SetProperty("richness", aRichness, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetRight(nsString& aRight) +{ + return GetPropertyValue("right", aRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetRight(const nsString& aRight) +{ + return SetProperty("right", aRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSize(nsString& aSize) +{ + return GetPropertyValue("size", aSize); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSize(const nsString& aSize) +{ + return SetProperty("size", aSize, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeak(nsString& aSpeak) +{ + return GetPropertyValue("speak", aSpeak); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeak(const nsString& aSpeak) +{ + return SetProperty("speak", aSpeak, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeakHeader(nsString& aSpeakHeader) +{ + return GetPropertyValue("speak-header", aSpeakHeader); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeakHeader(const nsString& aSpeakHeader) +{ + return SetProperty("speak-header", aSpeakHeader, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeakNumeral(nsString& aSpeakNumeral) +{ + return GetPropertyValue("speak-numeral", aSpeakNumeral); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeakNumeral(const nsString& aSpeakNumeral) +{ + return SetProperty("speak-numeral", aSpeakNumeral, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeakPunctuation(nsString& aSpeakPunctuation) +{ + return GetPropertyValue("speak-punctuation", aSpeakPunctuation); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeakPunctuation(const nsString& aSpeakPunctuation) +{ + return SetProperty("speak-punctuation", aSpeakPunctuation, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeechRate(nsString& aSpeechRate) +{ + return GetPropertyValue("speech-rate", aSpeechRate); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeechRate(const nsString& aSpeechRate) +{ + return SetProperty("speech-rate", aSpeechRate, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetStress(nsString& aStress) +{ + return GetPropertyValue("stress", aStress); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetStress(const nsString& aStress) +{ + return SetProperty("stress", aStress, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTableLayout(nsString& aTableLayout) +{ + return GetPropertyValue("table-layout", aTableLayout); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTableLayout(const nsString& aTableLayout) +{ + return SetProperty("table-layout", aTableLayout, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextAlign(nsString& aTextAlign) +{ + return GetPropertyValue("text-align", aTextAlign); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextAlign(const nsString& aTextAlign) +{ + return SetProperty("text-align", aTextAlign, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextDecoration(nsString& aTextDecoration) +{ + return GetPropertyValue("text-decoration", aTextDecoration); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextDecoration(const nsString& aTextDecoration) +{ + return SetProperty("text-decoration", aTextDecoration, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextIndent(nsString& aTextIndent) +{ + return GetPropertyValue("text-indent", aTextIndent); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextIndent(const nsString& aTextIndent) +{ + return SetProperty("text-indent", aTextIndent, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextShadow(nsString& aTextShadow) +{ + return GetPropertyValue("text-shadow", aTextShadow); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextShadow(const nsString& aTextShadow) +{ + return SetProperty("text-shadow", aTextShadow, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextTransform(nsString& aTextTransform) +{ + return GetPropertyValue("text-transform", aTextTransform); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextTransform(const nsString& aTextTransform) +{ + return SetProperty("text-transform", aTextTransform, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTop(nsString& aTop) +{ + return GetPropertyValue("top", aTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTop(const nsString& aTop) +{ + return SetProperty("top", aTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetUnicodeBidi(nsString& aUnicodeBidi) +{ + return GetPropertyValue("unicode-bidi", aUnicodeBidi); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetUnicodeBidi(const nsString& aUnicodeBidi) +{ + return SetProperty("unicode-bidi", aUnicodeBidi, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVerticalAlign(nsString& aVerticalAlign) +{ + return GetPropertyValue("vertical-align", aVerticalAlign); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVerticalAlign(const nsString& aVerticalAlign) +{ + return SetProperty("vertical-align", aVerticalAlign, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVisibility(nsString& aVisibility) +{ + return GetPropertyValue("visibility", aVisibility); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVisibility(const nsString& aVisibility) +{ + return SetProperty("visibility", aVisibility, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVoiceFamily(nsString& aVoiceFamily) +{ + return GetPropertyValue("voice-family", aVoiceFamily); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVoiceFamily(const nsString& aVoiceFamily) +{ + return SetProperty("voice-family", aVoiceFamily, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVolume(nsString& aVolume) +{ + return GetPropertyValue("volume", aVolume); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVolume(const nsString& aVolume) +{ + return SetProperty("volume", aVolume, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWhiteSpace(nsString& aWhiteSpace) +{ + return GetPropertyValue("white-space", aWhiteSpace); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWhiteSpace(const nsString& aWhiteSpace) +{ + return SetProperty("white-space", aWhiteSpace, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWidows(nsString& aWidows) +{ + return GetPropertyValue("widows", aWidows); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWidows(const nsString& aWidows) +{ + return SetProperty("widows", aWidows, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWidth(nsString& aWidth) +{ + return GetPropertyValue("width", aWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWidth(const nsString& aWidth) +{ + return SetProperty("width", aWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWordSpacing(nsString& aWordSpacing) +{ + return GetPropertyValue("word-spacing", aWordSpacing); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWordSpacing(const nsString& aWordSpacing) +{ + return SetProperty("word-spacing", aWordSpacing, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetZIndex(nsString& aZIndex) +{ + return GetPropertyValue("z-index", aZIndex); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetZIndex(const nsString& aZIndex) +{ + return SetProperty("z-index", aZIndex, ""); +} + diff --git a/layout/html/style/src/nsDOMCSSDeclaration.h b/layout/html/style/src/nsDOMCSSDeclaration.h new file mode 100644 index 000000000000..acae956973a0 --- /dev/null +++ b/layout/html/style/src/nsDOMCSSDeclaration.h @@ -0,0 +1,55 @@ +/* -*- 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.0 (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/ + * + * 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. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#ifndef nsDOMCSSDeclaration_h___ +#define nsDOMCSSSDeclaration_h___ + +#include "nsISupports.h" +#include "nsIDOMCSSStyleDeclaration.h" +#include "nsIScriptObjectOwner.h" + +class nsICSSDeclaration; + +class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration, + public nsIScriptObjectOwner +{ +public: + nsDOMCSSDeclaration(); + + NS_DECL_ISUPPORTS + + NS_DECL_IDOMCSSSTYLEDECLARATION + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + virtual void DropReference() = 0; + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) = 0; + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) = 0; + virtual nsresult GetParent(nsISupports **aParent) = 0; + +protected: + virtual ~nsDOMCSSDeclaration(); + + void *mScriptObject; +}; + +#endif // nsDOMCSSDeclaration_h___ diff --git a/layout/html/style/src/nsICSSStyleRule.h b/layout/html/style/src/nsICSSStyleRule.h index d45b23b04cbc..dc68d7b04838 100644 --- a/layout/html/style/src/nsICSSStyleRule.h +++ b/layout/html/style/src/nsICSSStyleRule.h @@ -25,7 +25,7 @@ class nsIAtom; class nsIArena; class nsString; class nsICSSDeclaration; - +class nsIStyleSheet; struct nsCSSSelector { public: @@ -65,6 +65,9 @@ public: virtual void SetWeight(PRInt32 aWeight) = 0; virtual nsIStyleRule* GetImportantRule(void) = 0; + + virtual nsIStyleSheet* GetStyleSheet(void) = 0; + virtual void SetStyleSheet(nsIStyleSheet *aSheet) = 0; }; extern NS_HTML nsresult diff --git a/layout/html/style/src/nsICSSStyleSheet.h b/layout/html/style/src/nsICSSStyleSheet.h index c3d6ae7e964f..2fb5e56341f7 100644 --- a/layout/html/style/src/nsICSSStyleSheet.h +++ b/layout/html/style/src/nsICSSStyleSheet.h @@ -39,6 +39,10 @@ public: virtual PRInt32 StyleRuleCount(void) = 0; virtual nsresult GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRule) = 0; + + virtual PRInt32 StyleSheetCount() = 0; + virtual nsresult GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) = 0; + }; extern NS_HTML nsresult diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index f4d61344e30c..1d665f2d046d 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -197,7 +197,7 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aSheet); NS_IMETHOD Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult); NS_IMETHOD ParseDeclarations(const nsString& aDeclaration, @@ -209,6 +209,8 @@ public: nsICSSDeclaration* aDeclaration, PRInt32* aHint); + NS_IMETHOD ProcessImport(const nsString& aURLSpec); + protected: PRBool GetToken(PRInt32* aErrorCode, PRBool aSkipWS); void UngetToken(); @@ -281,8 +283,6 @@ protected: PRBool TranslateLength(nsICSSDeclaration* aDeclaration, const char* aName, float aNumber, const nsString& aDimension); - void ProcessImport(const nsString& aURLSpec); - // Current token. The value is valid after calling GetToken nsCSSToken mToken; @@ -364,7 +364,7 @@ CSSParserImpl::SetStyleSheet(nsIStyleSheet* aSheet) NS_METHOD CSSParserImpl::Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult) { if (nsnull == mSheet) { @@ -598,7 +598,7 @@ PRBool CSSParserImpl::ParseImportRule(PRInt32* aErrorCode) return PR_TRUE; } -void CSSParserImpl::ProcessImport(const nsString& aURLSpec) +NS_IMETHODIMP CSSParserImpl::ProcessImport(const nsString& aURLSpec) { // XXX probably need a way to encode unicode junk for the part of // the url that follows a "?" @@ -609,7 +609,7 @@ void CSSParserImpl::ProcessImport(const nsString& aURLSpec) if (NS_OK != rv) { // import url is bad // XXX log this somewhere for easier web page debugging - return; + return rv; } if (PR_FALSE == mSheet->ContainsStyleSheet(url)) { // don't allow circular references @@ -656,6 +656,8 @@ void CSSParserImpl::ProcessImport(const nsString& aURLSpec) } } NS_RELEASE(url); + + return rv; } void CSSParserImpl::SkipUntil(PRInt32* aErrorCode, PRUnichar aStopSymbol) diff --git a/layout/style/nsCSSStyleRule.cpp b/layout/style/nsCSSStyleRule.cpp index 513e3babb3f1..0c13a0041cfb 100644 --- a/layout/style/nsCSSStyleRule.cpp +++ b/layout/style/nsCSSStyleRule.cpp @@ -17,6 +17,7 @@ */ #include "nsICSSStyleRule.h" #include "nsICSSDeclaration.h" +#include "nsIStyleSheet.h" #include "nsIStyleContext.h" #include "nsIPresContext.h" #include "nsIDeviceContext.h" @@ -29,12 +30,25 @@ #include "nsUnitConversion.h" #include "nsStyleUtil.h" #include "nsIFontMetrics.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRule.h" +#include "nsIDOMCSSStyleRuleSimple.h" +#include "nsIDOMCSSStyleDeclaration.h" +#include "nsIScriptGlobalObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsDOMCSSDeclaration.h" //#define DEBUG_REFS +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); static NS_DEFINE_IID(kICSSDeclarationIID, NS_ICSS_DECLARATION_IID); static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleSheetIID, NS_IDOMCSSSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleIID, NS_IDOMCSSSTYLERULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleSimpleIID, NS_IDOMCSSSTYLERULESIMPLE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kCSSFontSID, NS_CSS_FONT_SID); static NS_DEFINE_IID(kCSSColorSID, NS_CSS_COLOR_SID); @@ -231,10 +245,79 @@ CSSImportantRule::List(FILE* out, PRInt32 aIndent) const return NS_OK; } +// -- nsDOMStyleRuleDeclaration ------------------------------- + +class DOMCSSDeclarationImpl : public nsDOMCSSDeclaration +{ +public: + DOMCSSDeclarationImpl(nsICSSStyleRule *aRule); + ~DOMCSSDeclarationImpl(); + + virtual void DropReference(); + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate); + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint); + virtual nsresult GetParent(nsISupports **aParent); + +protected: + nsICSSStyleRule *mRule; +}; + +DOMCSSDeclarationImpl::DOMCSSDeclarationImpl(nsICSSStyleRule *aRule) +{ + // This reference is not reference-counted. The rule + // object tells us when its about to go away. + mRule = aRule; +} + +DOMCSSDeclarationImpl::~DOMCSSDeclarationImpl() +{ +} + +void +DOMCSSDeclarationImpl::DropReference() +{ + mRule = nsnull; +} + +nsresult +DOMCSSDeclarationImpl::GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) +{ + if (nsnull != mRule) { + *aDecl = mRule->GetDeclaration(); + } + else { + *aDecl = nsnull; + } + + return NS_OK; +} + +nsresult +DOMCSSDeclarationImpl::StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) +{ + // XXX TBI + return NS_OK; +} + +nsresult +DOMCSSDeclarationImpl::GetParent(nsISupports **aParent) +{ + if (nsnull != mRule) { + return mRule->QueryInterface(kISupportsIID, (void **)aParent); + } + + return NS_OK; +} // -- nsCSSStyleRule ------------------------------- -class CSSStyleRuleImpl : public nsICSSStyleRule { +class CSSStyleRuleImpl : public nsICSSStyleRule, + public nsIDOMCSSStyleRuleSimple, + public nsIScriptObjectOwner { public: void* operator new(size_t size); void* operator new(size_t size, nsIArena* aArena); @@ -263,10 +346,25 @@ public: virtual nsIStyleRule* GetImportantRule(void); + virtual nsIStyleSheet* GetStyleSheet(void); + virtual void SetStyleSheet(nsIStyleSheet *aSheet); + NS_IMETHOD MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + // nsIDOMCSSStyleRule interface + NS_IMETHOD GetType(nsString& aType); + + // nsIDOMCSSStyleRuleSimple interface + NS_IMETHOD GetSelectorText(nsString& aSelectorText); + NS_IMETHOD SetSelectorText(const nsString& aSelectorText); + NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + private: // These are not supported and are not implemented! CSSStyleRuleImpl(const CSSStyleRuleImpl& aCopy); @@ -283,6 +381,9 @@ protected: nsICSSDeclaration* mDeclaration; PRInt32 mWeight; CSSImportantRule* mImportantRule; + nsIStyleSheet* mStyleSheet; + DOMCSSDeclarationImpl *mDOMDeclaration; + void* mScriptObject; #ifdef DEBUG_REFS PRInt32 mInstance; #endif @@ -334,6 +435,8 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(const nsCSSSelector& aSelector) mWeight(0), mImportantRule(nsnull) { NS_INIT_REFCNT(); + mDOMDeclaration = nsnull; + mScriptObject = nsnull; #ifdef DEBUG_REFS mInstance = gInstanceCount++; fprintf(stdout, "%d of %d + CSSStyleRule\n", mInstance, gInstanceCount); @@ -351,6 +454,9 @@ CSSStyleRuleImpl::~CSSStyleRuleImpl() } NS_IF_RELEASE(mDeclaration); NS_IF_RELEASE(mImportantRule); + if (nsnull != mDOMDeclaration) { + mDOMDeclaration->DropReference(); + } #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d of %d - CSSStyleRule\n", mInstance, gInstanceCount); @@ -389,7 +495,6 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID, if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); if (aIID.Equals(kICSSStyleRuleIID)) { *aInstancePtrResult = (void*) ((nsICSSStyleRule*)this); NS_ADDREF_THIS(); @@ -400,8 +505,28 @@ nsresult CSSStyleRuleImpl::QueryInterface(const nsIID& aIID, NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kIDOMCSSStyleRuleIID)) { + nsIDOMCSSStyleRule *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIDOMCSSStyleRuleSimpleIID)) { + nsIDOMCSSStyleRuleSimple *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)this); + nsICSSStyleRule *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; NS_ADDREF_THIS(); return NS_OK; } @@ -543,6 +668,21 @@ nsIStyleRule* CSSStyleRuleImpl::GetImportantRule(void) return mImportantRule; } +nsIStyleSheet* CSSStyleRuleImpl::GetStyleSheet(void) +{ + NS_IF_ADDREF(mStyleSheet); + + return mStyleSheet; +} + +void CSSStyleRuleImpl::SetStyleSheet(nsIStyleSheet *aSheet) +{ + // XXX We don't reference count this up reference. The style sheet + // will tell us when it's going away or when we're detached from + // it. + mStyleSheet = aSheet; +} + nscoord CalcLength(const nsCSSValue& aValue, const nsStyleFont* aFont, nsIPresContext* aPresContext) @@ -1236,6 +1376,105 @@ CSSStyleRuleImpl::List(FILE* out, PRInt32 aIndent) const return NS_OK; } +NS_IMETHODIMP +CSSStyleRuleImpl::GetType(nsString& aType) +{ + // XXX Need to define the different types + aType.SetString("simple"); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetSelectorText(nsString& aSelectorText) +{ + nsAutoString buffer; + nsAutoString thisSelector; + nsCSSSelector *selector = &mSelector; + + // XXX Ugh...they're in reverse order from the source. Sorry + // for the ugliness. + aSelectorText.SetLength(0); + while (nsnull != selector) { + thisSelector.SetLength(0); + if (nsnull != selector->mTag) { + selector->mTag->ToString(buffer); + thisSelector.Append(buffer); + } + if (nsnull != selector->mID) { + selector->mID->ToString(buffer); + thisSelector.Append("#"); + thisSelector.Append(buffer); + } + if (nsnull != selector->mClass) { + selector->mClass->ToString(buffer); + thisSelector.Append("."); + thisSelector.Append(buffer); + } + if (nsnull != selector->mPseudoClass) { + selector->mPseudoClass->ToString(buffer); + thisSelector.Append(":"); + thisSelector.Append(buffer); + } + aSelectorText.Insert(thisSelector, 0, thisSelector.Length()); + selector = selector->mNext; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::SetSelectorText(const nsString& aSelectorText) +{ + // XXX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) +{ + if (nsnull == mDOMDeclaration) { + mDOMDeclaration = new DOMCSSDeclarationImpl(this); + if (nsnull == mDOMDeclaration) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mDOMDeclaration); + } + + *aStyle = mDOMDeclaration; + NS_ADDREF(mDOMDeclaration); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsICSSStyleRule *)this; + // XXX Parent should be the style sheet + // XXX Should be done through factory + res = NS_NewScriptCSSStyleRuleSimple(aContext, + supports, + (nsISupports *)global, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return res; +} + +NS_IMETHODIMP +CSSStyleRuleImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + NS_HTML nsresult NS_NewCSSStyleRule(nsICSSStyleRule** aInstancePtrResult, const nsCSSSelector& aSelector) { diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index f8839f4d77e5..b74affeed84a 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -32,6 +32,13 @@ #include "nsString.h" #include "nsIPtr.h" #include "nsHTMLIIDs.h" +#include "nsIDOMStyleSheetCollection.h" +#include "nsIDOMCSSStyleSheet.h" +#include "nsIDOMCSSStyleRule.h" +#include "nsIDOMCSSStyleRuleCollection.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsICSSParser.h" //#define DEBUG_REFS //#define DEBUG_RULES @@ -39,6 +46,12 @@ static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID); static NS_DEFINE_IID(kIStyleSheetIID, NS_ISTYLE_SHEET_IID); static NS_DEFINE_IID(kIStyleRuleIID, NS_ISTYLE_RULE_IID); +static NS_DEFINE_IID(kIDOMStyleSheetIID, NS_IDOMSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleSheetIID, NS_IDOMCSSSTYLESHEET_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleIID, NS_IDOMCSSSTYLERULE_IID); +static NS_DEFINE_IID(kIDOMCSSStyleRuleCollectionIID, NS_IDOMCSSSTYLERULECOLLECTION_IID); +static NS_DEFINE_IID(kIDOMStyleSheetCollectionIID, NS_IDOMSTYLESHEETCOLLECTION_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); NS_DEF_PTR(nsIHTMLContent); NS_DEF_PTR(nsIContent); @@ -129,6 +142,7 @@ public: RuleEnumFunc aFunc, void* aData); void EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData); + protected: void AppendRuleToTable(nsHashtable& aTable, nsIAtom* aAtom, nsICSSStyleRule* aRule); @@ -171,6 +185,7 @@ void RuleHash::AppendRuleToTable(nsHashtable& aTable, nsIAtom* aAtom, nsICSSStyl value = value->mNext; } value->mNext = new RuleValue(aRule, mRuleCount++); + value = value->mNext; } } @@ -242,11 +257,279 @@ void RuleHash::EnumerateTagRules(nsIAtom* aTag, RuleEnumFunc aFunc, void* aData) } } +// ------------------------------- +// Style Rule Collection for the DOM +// +class CSSStyleRuleCollectionImpl : public nsIDOMCSSStyleRuleCollection, + public nsIScriptObjectOwner +{ +public: + CSSStyleRuleCollectionImpl(nsICSSStyleSheet *aStyleSheet); + + NS_DECL_ISUPPORTS + + // nsIDOMCSSStyleRuleCollection interface + NS_IMETHOD GetLength(PRUint32* aLength); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMCSSStyleRule** aReturn); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + void DropReference() { mStyleSheet = nsnull; } + +protected: + virtual ~CSSStyleRuleCollectionImpl(); + + nsICSSStyleSheet* mStyleSheet; + void* mScriptObject; +}; + +CSSStyleRuleCollectionImpl::CSSStyleRuleCollectionImpl(nsICSSStyleSheet *aStyleSheet) +{ + NS_INIT_REFCNT(); + // Not reference counted to avoid circular references. + // The style sheet will tell us when its going away. + mStyleSheet = aStyleSheet; + mScriptObject = nsnull; +} + +CSSStyleRuleCollectionImpl::~CSSStyleRuleCollectionImpl() +{ +} + +NS_IMPL_ADDREF(CSSStyleRuleCollectionImpl); +NS_IMPL_RELEASE(CSSStyleRuleCollectionImpl); + +nsresult +CSSStyleRuleCollectionImpl::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMCSSStyleRuleCollectionIID)) { + nsIDOMCSSStyleRuleCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMCSSStyleRuleCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::GetLength(PRUint32* aLength) +{ + if (nsnull != mStyleSheet) { + *aLength = mStyleSheet->StyleRuleCount(); + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::Item(PRUint32 aIndex, nsIDOMCSSStyleRule** aReturn) +{ + nsresult result = NS_OK; + + *aReturn = nsnull; + if (nsnull != mStyleSheet) { + nsICSSStyleRule *rule; + + result = mStyleSheet->GetStyleRuleAt(aIndex, rule); + if (NS_OK == result) { + result = rule->QueryInterface(kIDOMCSSStyleRuleIID, (void **)aReturn); + } + NS_RELEASE(rule); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleRuleCollection *)this; + + // XXX Should be done through factory + res = NS_NewScriptCSSStyleRuleCollection(aContext, + supports, + (nsISupports *)mStyleSheet, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +CSSStyleRuleCollectionImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +// ------------------------------- +// Imports Collection for the DOM +// +class CSSImportsCollectionImpl : public nsIDOMStyleSheetCollection, + public nsIScriptObjectOwner +{ +public: + CSSImportsCollectionImpl(nsICSSStyleSheet *aStyleSheet); + + NS_DECL_ISUPPORTS + + // nsIDOMCSSStyleSheetCollection interface + NS_IMETHOD GetLength(PRUint32* aLength); + NS_IMETHOD Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + void DropReference() { mStyleSheet = nsnull; } + +protected: + virtual ~CSSImportsCollectionImpl(); + + nsICSSStyleSheet* mStyleSheet; + void* mScriptObject; +}; + +CSSImportsCollectionImpl::CSSImportsCollectionImpl(nsICSSStyleSheet *aStyleSheet) +{ + NS_INIT_REFCNT(); + // Not reference counted to avoid circular references. + // The style sheet will tell us when its going away. + mStyleSheet = aStyleSheet; + mScriptObject = nsnull; +} + +CSSImportsCollectionImpl::~CSSImportsCollectionImpl() +{ +} + +NS_IMPL_ADDREF(CSSImportsCollectionImpl); +NS_IMPL_RELEASE(CSSImportsCollectionImpl); + +nsresult +CSSImportsCollectionImpl::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) +{ + if (NULL == aInstancePtrResult) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + if (aIID.Equals(kIDOMStyleSheetCollectionIID)) { + nsIDOMStyleSheetCollection *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMStyleSheetCollection *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; + AddRef(); + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::GetLength(PRUint32* aLength) +{ + if (nsnull != mStyleSheet) { + *aLength = mStyleSheet->StyleSheetCount(); + } + else { + *aLength = 0; + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn) +{ + nsresult result = NS_OK; + + *aReturn = nsnull; + if (nsnull != mStyleSheet) { + nsICSSStyleSheet *sheet; + + result = mStyleSheet->GetStyleSheetAt(aIndex, sheet); + if (NS_OK == result) { + result = sheet->QueryInterface(kIDOMStyleSheetIID, (void **)aReturn); + } + NS_RELEASE(sheet); + } + + return result; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::GetScriptObject(nsIScriptContext *aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsIDOMStyleSheetCollection *)this; + + // XXX Should be done through factory + res = NS_NewScriptStyleSheetCollection(aContext, + supports, + (nsISupports *)mStyleSheet, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +CSSImportsCollectionImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} // ------------------------------- // CSS Style Sheet // -class CSSStyleSheetImpl : public nsICSSStyleSheet { +class CSSStyleSheetImpl : public nsICSSStyleSheet, + public nsIDOMCSSStyleSheet, + public nsIScriptObjectOwner { public: void* operator new(size_t size); void* operator new(size_t size, nsIArena* aArena); @@ -281,8 +564,32 @@ public: virtual PRInt32 StyleRuleCount(void); virtual nsresult GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRule); + virtual PRInt32 StyleSheetCount(); + virtual nsresult GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet); + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; + // nsIDOMStyleSheet interface + NS_IMETHOD GetDisabled(PRBool* aDisabled); + NS_IMETHOD SetDisabled(PRBool aDisabled); + NS_IMETHOD GetReadOnly(PRBool* aReadOnly); + + // nsIDOMCSSStyleSheet interface + NS_IMETHOD GetOwningElement(nsIDOMHTMLElement** aOwningElement); + NS_IMETHOD GetParentStyleSheet(nsIDOMCSSStyleSheet** aParentStyleSheet); + NS_IMETHOD GetHref(nsString& aHref); + NS_IMETHOD GetTitle(nsString& aTitle); + NS_IMETHOD GetImports(nsIDOMStyleSheetCollection** aImports); + NS_IMETHOD GetRules(nsIDOMCSSStyleRuleCollection** aRules); + NS_IMETHOD AddRule(const nsString& aSelector, const nsString& aDeclaration, PRUint32 aIndex, PRUint32* aReturn); + NS_IMETHOD AddImport(const nsString& aUrl, PRUint32 aIndex, PRUint32* aReturn); + NS_IMETHOD RemoveRule(PRUint32 aIndex); + NS_IMETHOD RemoveImport(PRUint32 aIndex); + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + private: // These are not supported and are not implemented! CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy); @@ -303,7 +610,11 @@ protected: nsISupportsArrayPtr mOrderedRules; nsISupportsArrayPtr mWeightedRules; nsICSSStyleSheetPtr mNext; + nsICSSStyleSheet* mParent; RuleHash* mRuleHash; + CSSStyleRuleCollectionImpl* mRuleCollection; + CSSImportsCollectionImpl* mImportsCollection; + void * mScriptObject; }; @@ -354,18 +665,49 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(nsIURL* aURL) { NS_INIT_REFCNT(); mURL.SetAddRef(aURL); + mParent = nsnull; + mRuleCollection = nsnull; + mImportsCollection = nsnull; + mScriptObject = nsnull; #ifdef DEBUG_REFS ++gInstanceCount; fprintf(stdout, "%d + CSSStyleSheet size: %d\n", gInstanceCount, sizeof(*this)); #endif } +static PRBool DropStyleSheetReference(nsISupports* aElement, void *aData) +{ + nsICSSStyleRule *rule = (nsICSSStyleRule *)aElement; + + if (nsnull != rule) { + rule->SetStyleSheet(nsnull); + } + + return PR_TRUE; +} + CSSStyleSheetImpl::~CSSStyleSheetImpl() { #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d - CSSStyleSheet\n", gInstanceCount); #endif + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while (nsnull != child) { + ((CSSStyleSheetImpl *)child)->mParent = nsnull; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + } + if (nsnull != mRuleCollection) { + mRuleCollection->DropReference(); + NS_RELEASE(mRuleCollection); + } + if (nsnull != mImportsCollection) { + mImportsCollection->DropReference(); + NS_RELEASE(mImportsCollection); + } + mOrderedRules->EnumerateForwards(DropStyleSheetReference, nsnull); ClearHash(); } @@ -390,8 +732,28 @@ nsresult CSSStyleSheetImpl::QueryInterface(const nsIID& aIID, NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kIDOMStyleSheetIID)) { + nsIDOMStyleSheet *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIDOMCSSStyleSheetIID)) { + nsIDOMCSSStyleSheet *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + *aInstancePtrResult = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } if (aIID.Equals(kISupportsIID)) { - *aInstancePtrResult = (void*) ((nsISupports*)this); + nsICSSStyleSheet *tmp = this; + nsISupports *tmp2 = tmp; + *aInstancePtrResult = (void*) tmp2; NS_ADDREF_THIS(); return NS_OK; } @@ -750,6 +1112,10 @@ void CSSStyleSheetImpl::AppendStyleSheet(nsICSSStyleSheet* aSheet) } ((CSSStyleSheetImpl*)child)->mNext.SetAddRef(aSheet); } + + // This is not reference counted. Our parent tells us when + // it's going away. + ((CSSStyleSheetImpl*)aSheet)->mParent = this; } void CSSStyleSheetImpl::PrependStyleRule(nsICSSStyleRule* aRule) @@ -778,6 +1144,7 @@ void CSSStyleSheetImpl::PrependStyleRule(nsICSSStyleRule* aRule) } mWeightedRules->InsertElementAt(aRule, index + 1); mOrderedRules->InsertElementAt(aRule, 0); + aRule->SetStyleSheet(this); } void CSSStyleSheetImpl::AppendStyleRule(nsICSSStyleRule* aRule) @@ -807,6 +1174,7 @@ void CSSStyleSheetImpl::AppendStyleRule(nsICSSStyleRule* aRule) } mWeightedRules->InsertElementAt(aRule, index); mOrderedRules->AppendElement(aRule); + aRule->SetStyleSheet(this); } PRInt32 CSSStyleSheetImpl::StyleRuleCount(void) @@ -833,6 +1201,43 @@ nsresult CSSStyleSheetImpl::GetStyleRuleAt(PRInt32 aIndex, nsICSSStyleRule*& aRu return result; } +PRInt32 CSSStyleSheetImpl::StyleSheetCount() +{ + // XXX Far from an ideal way to do this, but the hope is that + // it won't be done too often. If it is, we might want to + // consider storing the children in an array. + PRInt32 count = 0; + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while (nsnull != child) { + count++; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + } + + return count; +} + +nsresult CSSStyleSheetImpl::GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) +{ + // XXX Ughh...an O(n^2) method for doing iteration. Again, we hope + // that this isn't done too often. If it is, we need to change the + // underlying storage mechanism + aSheet = nsnull; + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* child = mFirstChild; + while ((nsnull != child) && (0 != aIndex)) { + --aIndex; + child = ((CSSStyleSheetImpl*)child)->mNext; + } + + aSheet = child; + NS_IF_ADDREF(child); + } + + return NS_OK; +} + void CSSStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const { nsAutoString buffer; @@ -886,6 +1291,224 @@ void CSSStyleSheetImpl::BuildHash(void) } } +NS_IMETHODIMP +CSSStyleSheetImpl::GetDisabled(PRBool* aDisabled) +{ + // XXX TBI + *aDisabled = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::SetDisabled(PRBool aDisabled) +{ + // XXX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetReadOnly(PRBool* aReadOnly) +{ + // XXX TBI + *aReadOnly = PR_FALSE; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetOwningElement(nsIDOMHTMLElement** aOwningElement) +{ + // XXX TBI + *aOwningElement = nsnull; + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetParentStyleSheet(nsIDOMCSSStyleSheet** aParentStyleSheet) +{ + if (nsnull != mParent) { + return mParent->QueryInterface(kIDOMCSSStyleSheetIID, (void **)aParentStyleSheet); + } + else { + *aParentStyleSheet = nsnull; + return NS_OK; + } +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetHref(nsString& aHref) +{ + if (mURL.IsNotNull()) { + mURL->ToString(aHref); + } + else { + aHref.SetLength(0); + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetTitle(nsString& aTitle) +{ + // XX TBI + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetImports(nsIDOMStyleSheetCollection** aImports) +{ + if (nsnull == mImportsCollection) { + mImportsCollection = new CSSImportsCollectionImpl(this); + if (nsnull == mImportsCollection) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mImportsCollection); + } + + *aImports = mImportsCollection; + NS_ADDREF(mImportsCollection); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetRules(nsIDOMCSSStyleRuleCollection** aRules) +{ + if (nsnull == mRuleCollection) { + mRuleCollection = new CSSStyleRuleCollectionImpl(this); + if (nsnull == mRuleCollection) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(mRuleCollection); + } + + *aRules = mRuleCollection; + NS_ADDREF(mRuleCollection); + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::AddRule(const nsString& aSelector, + const nsString& aDeclaration, + PRUint32 aIndex, + PRUint32* aReturn) +{ + nsICSSParser* css; + nsresult result = NS_NewCSSParser(&css); + if (NS_OK == result) { + nsAutoString str; + str.SetString(aSelector); + // XXX Can we assume that the braces aren't there? + str.Append(" { "); + str.Append(aDeclaration); + str.Append(" } "); + + nsIUnicharInputStream* input = nsnull; + result = NS_NewStringUnicharInputStream(&input, &str); + if (NS_OK == result) { + nsIStyleSheet *tmp; + css->SetStyleSheet(this); + // XXX Currently, the parser will append the rule to the + // style sheet. We shouldn't ignore the index. + result = css->Parse(input, mURL, tmp); + NS_ASSERTION(tmp = this, "parser incorrectly created a new stylesheet"); + NS_RELEASE(input); + *aReturn = mOrderedRules->Count(); + } + + NS_RELEASE(css); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::AddImport(const nsString& aUrl, PRUint32 aIndex, PRUint32* aReturn) +{ + nsICSSParser* css; + nsresult result = NS_NewCSSParser(&css); + if (NS_OK == result) { + css->SetStyleSheet(this); + result = css->ProcessImport(aUrl); + } + + return result; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::RemoveRule(PRUint32 aIndex) +{ + nsICSSStyleRule *rule; + + rule = (nsICSSStyleRule *)mOrderedRules->ElementAt(aIndex); + if (nsnull != rule) { + mOrderedRules->RemoveElementAt(aIndex); + mWeightedRules->RemoveElement(rule); + rule->SetStyleSheet(nsnull); + NS_RELEASE(rule); + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::RemoveImport(PRUint32 aIndex) +{ + if (mFirstChild.IsNotNull()) { + nsICSSStyleSheet* prev = nsnull; + nsICSSStyleSheet* child = mFirstChild; + while ((nsnull != child) && (0 != aIndex)) { + prev = child; + child = ((CSSStyleSheetImpl*)child)->mNext; + --aIndex; + } + + if ((nsnull != child) && (0 == aIndex)) { + // Hold on to the child while we clean it up + NS_ADDREF(child); + if (nsnull == prev) { + mFirstChild.SetAddRef(((CSSStyleSheetImpl*)child)->mNext); + } + else { + ((CSSStyleSheetImpl*)prev)->mNext.SetAddRef(((CSSStyleSheetImpl*)child)->mNext); + } + ((CSSStyleSheetImpl*)child)->mNext.SetAddRef(nsnull); + ((CSSStyleSheetImpl*)child)->mParent = nsnull; + NS_RELEASE(child); + } + } + + return NS_OK; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) +{ + nsresult res = NS_OK; + nsIScriptGlobalObject *global = aContext->GetGlobalObject(); + + if (nsnull == mScriptObject) { + nsISupports *supports = (nsISupports *)(nsICSSStyleSheet *)this; + // XXX Should be done through factory + res = NS_NewScriptCSSStyleSheet(aContext, + supports, + (nsISupports *)global, + (void**)&mScriptObject); + } + *aScriptObject = mScriptObject; + + NS_RELEASE(global); + return res; +} + +NS_IMETHODIMP +CSSStyleSheetImpl::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + NS_HTML nsresult NS_NewCSSStyleSheet(nsICSSStyleSheet** aInstancePtrResult, nsIURL* aURL) { diff --git a/layout/style/nsDOMCSSDeclaration.cpp b/layout/style/nsDOMCSSDeclaration.cpp new file mode 100644 index 000000000000..dedd6fff82ee --- /dev/null +++ b/layout/style/nsDOMCSSDeclaration.cpp @@ -0,0 +1,1677 @@ +/* -*- 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.0 (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/ + * + * 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. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +#include "nsDOMCSSDeclaration.h" +#include "nsICSSStyleRule.h" +#include "nsICSSParser.h" +#include "nsIStyleRule.h" +#include "nsICSSDeclaration.h" +#include "nsCSSProps.h" + +nsDOMCSSDeclaration::nsDOMCSSDeclaration() +{ + NS_INIT_REFCNT(); + mScriptObject = nsnull; +} + +nsDOMCSSDeclaration::~nsDOMCSSDeclaration() +{ +} + +NS_IMPL_ADDREF(nsDOMCSSDeclaration); +NS_IMPL_RELEASE(nsDOMCSSDeclaration); + +static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); +static NS_DEFINE_IID(kICSSStyleRuleIID, NS_ICSS_STYLE_RULE_IID); +static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + +NS_IMETHODIMP +nsDOMCSSDeclaration::QueryInterface(REFNSIID aIID, + void** aInstancePtr) +{ + NS_PRECONDITION(nsnull != aInstancePtr, "null ptr"); + if (nsnull == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + if (aIID.Equals(kIDOMCSSStyleDeclarationIID)) { + nsIDOMCSSStyleDeclaration *tmp = this; + AddRef(); + *aInstancePtr = (void*) tmp; + return NS_OK; + } + if (aIID.Equals(kIScriptObjectOwnerIID)) { + nsIScriptObjectOwner *tmp = this; + AddRef(); + *aInstancePtr = (void*) tmp; + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + nsIDOMCSSStyleDeclaration *tmp = this; + nsISupports *tmp2 = tmp; + AddRef(); + *aInstancePtr = (void*) tmp2; + return NS_OK; + } + return NS_NOINTERFACE; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetScriptObject(nsIScriptContext* aContext, + void** aScriptObject) +{ + nsresult res = NS_OK; + + if (nsnull == mScriptObject) { + nsISupports *parent = nsnull; + + res = GetParent(&parent); + if (NS_OK == res) { + nsISupports *supports = (nsISupports *)(nsIDOMCSSStyleDeclaration *)this; + // XXX Should be done through factory + res = NS_NewScriptCSSStyleDeclaration(aContext, + supports, + parent, + (void**)&mScriptObject); + NS_RELEASE(parent); + } + } + *aScriptObject = mScriptObject; + + return res; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetScriptObject(void* aScriptObject) +{ + mScriptObject = aScriptObject; + return NS_OK; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLength(PRUint32* aLength) +{ + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + + *aLength = 0; + if ((NS_OK == result) && (nsnull != decl)) { + result = decl->Count(aLength); + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsString& aReturn) +{ + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + + aReturn.SetLength(0); + if ((NS_OK == result) && (nsnull != decl)) { + result = decl->GetNthProperty(aIndex, aReturn); + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPropertyValue(const nsString& aPropertyName, + nsString& aReturn) +{ + nsCSSValue val; + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + + aReturn.SetLength(0); + if ((NS_OK == result) && (nsnull != decl)) { + result = decl->GetValue(aPropertyName, aReturn); + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPropertyPriority(const nsString& aPropertyName, + nsString& aReturn) +{ + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_FALSE); + PRBool isImportant = PR_FALSE; + + if ((NS_OK == result) && (nsnull != decl)) { + char prop[50]; + aPropertyName.ToCString(prop, sizeof(prop)); + result = decl->GetValueIsImportant(prop, isImportant); + NS_RELEASE(decl); + } + + if ((NS_OK == result) && isImportant) { + aReturn.SetString("!important"); + } + else { + aReturn.SetLength(0); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetProperty(const nsString& aPropertyName, + const nsString& aValue, + const nsString& aPriority) +{ + nsAutoString declString; + nsICSSDeclaration *decl; + nsresult result = GetCSSDeclaration(&decl, PR_TRUE); + + if ((NS_OK == result) && (nsnull != decl)) { + declString.SetString(aPropertyName); + declString.Append(":"); + declString.Append(aValue); + + nsICSSParser* css; + result = NS_NewCSSParser(&css); + if (NS_OK == result) { + PRInt32 hint; + result = css->ParseAndAppendDeclaration(declString, nsnull, decl, &hint); + if (NS_OK == result) { + if (aPriority.Equals("!important")) { + char prop[50]; + aPropertyName.ToCString(prop, sizeof(prop)); + decl->SetValueImportant(prop); + } + result = StylePropertyChanged(aPropertyName, hint); + } + NS_RELEASE(css); + } + NS_RELEASE(decl); + } + + return result; +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetAzimuth(nsString& aAzimuth) +{ + return GetPropertyValue("azimuth", aAzimuth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetAzimuth(const nsString& aAzimuth) +{ + return SetProperty("azimuth", aAzimuth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackground(nsString& aBackground) +{ + return GetPropertyValue("background", aBackground); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackground(const nsString& aBackground) +{ + return SetProperty("background", aBackground, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundAttachment(nsString& aBackgroundAttachment) +{ + return GetPropertyValue("background-attachment", aBackgroundAttachment); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundAttachment(const nsString& aBackgroundAttachment) +{ + return SetProperty("background-attachment", aBackgroundAttachment, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundColor(nsString& aBackgroundColor) +{ + return GetPropertyValue("background-color", aBackgroundColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundColor(const nsString& aBackgroundColor) +{ + return SetProperty("background-color", aBackgroundColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundImage(nsString& aBackgroundImage) +{ + return GetPropertyValue("background-image", aBackgroundImage); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundImage(const nsString& aBackgroundImage) +{ + return SetProperty("background-image", aBackgroundImage, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundPosition(nsString& aBackgroundPosition) +{ + return GetPropertyValue("background-position", aBackgroundPosition); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundPosition(const nsString& aBackgroundPosition) +{ + return SetProperty("background-position", aBackgroundPosition, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBackgroundRepeat(nsString& aBackgroundRepeat) +{ + return GetPropertyValue("background-repeat", aBackgroundRepeat); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBackgroundRepeat(const nsString& aBackgroundRepeat) +{ + return SetProperty("background-repeat", aBackgroundRepeat, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorder(nsString& aBorder) +{ + return GetPropertyValue("border", aBorder); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorder(const nsString& aBorder) +{ + return SetProperty("border", aBorder, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderCollapse(nsString& aBorderCollapse) +{ + return GetPropertyValue("border-collapse", aBorderCollapse); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderCollapse(const nsString& aBorderCollapse) +{ + return SetProperty("border-collapse", aBorderCollapse, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderColor(nsString& aBorderColor) +{ + return GetPropertyValue("border-color", aBorderColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderColor(const nsString& aBorderColor) +{ + return SetProperty("border-color", aBorderColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderSpacing(nsString& aBorderSpacing) +{ + return GetPropertyValue("border-spacing", aBorderSpacing); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderSpacing(const nsString& aBorderSpacing) +{ + return SetProperty("border-spacing", aBorderSpacing, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderStyle(nsString& aBorderStyle) +{ + return GetPropertyValue("border-style", aBorderStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderStyle(const nsString& aBorderStyle) +{ + return SetProperty("border-style", aBorderStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTop(nsString& aBorderTop) +{ + return GetPropertyValue("border-top", aBorderTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTop(const nsString& aBorderTop) +{ + return SetProperty("border-top", aBorderTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRight(nsString& aBorderRight) +{ + return GetPropertyValue("border-right", aBorderRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRight(const nsString& aBorderRight) +{ + return SetProperty("border-right", aBorderRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottom(nsString& aBorderBottom) +{ + return GetPropertyValue("border-bottom", aBorderBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottom(const nsString& aBorderBottom) +{ + return SetProperty("border-bottom", aBorderBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeft(nsString& aBorderLeft) +{ + return GetPropertyValue("border-left", aBorderLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeft(const nsString& aBorderLeft) +{ + return SetProperty("border-left", aBorderLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTopColor(nsString& aBorderTopColor) +{ + return GetPropertyValue("border-top-color", aBorderTopColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTopColor(const nsString& aBorderTopColor) +{ + return SetProperty("border-top-color", aBorderTopColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRightColor(nsString& aBorderRightColor) +{ + return GetPropertyValue("border-right-color", aBorderRightColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRightColor(const nsString& aBorderRightColor) +{ + return SetProperty("border-right-color", aBorderRightColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottomColor(nsString& aBorderBottomColor) +{ + return GetPropertyValue("border-bottom-color", aBorderBottomColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottomColor(const nsString& aBorderBottomColor) +{ + return SetProperty("border-bottom-color", aBorderBottomColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeftColor(nsString& aBorderLeftColor) +{ + return GetPropertyValue("border-left-color", aBorderLeftColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeftColor(const nsString& aBorderLeftColor) +{ + return SetProperty("border-left-color", aBorderLeftColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTopStyle(nsString& aBorderTopStyle) +{ + return GetPropertyValue("border-top-style", aBorderTopStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTopStyle(const nsString& aBorderTopStyle) +{ + return SetProperty("border-top-style", aBorderTopStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRightStyle(nsString& aBorderRightStyle) +{ + return GetPropertyValue("border-right-style", aBorderRightStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRightStyle(const nsString& aBorderRightStyle) +{ + return SetProperty("border-right-style", aBorderRightStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottomStyle(nsString& aBorderBottomStyle) +{ + return GetPropertyValue("border-bottom-style", aBorderBottomStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottomStyle(const nsString& aBorderBottomStyle) +{ + return SetProperty("border-bottom-style", aBorderBottomStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeftStyle(nsString& aBorderLeftStyle) +{ + return GetPropertyValue("border-left-style", aBorderLeftStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeftStyle(const nsString& aBorderLeftStyle) +{ + return SetProperty("border-left-style", aBorderLeftStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderTopWidth(nsString& aBorderTopWidth) +{ + return GetPropertyValue("border-top-width", aBorderTopWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderTopWidth(const nsString& aBorderTopWidth) +{ + return SetProperty("border-top-width", aBorderTopWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderRightWidth(nsString& aBorderRightWidth) +{ + return GetPropertyValue("border-right-width", aBorderRightWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderRightWidth(const nsString& aBorderRightWidth) +{ + return SetProperty("border-right-width", aBorderRightWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderBottomWidth(nsString& aBorderBottomWidth) +{ + return GetPropertyValue("border-bottom-width", aBorderBottomWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderBottomWidth(const nsString& aBorderBottomWidth) +{ + return SetProperty("border-bottom-width", aBorderBottomWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderLeftWidth(nsString& aBorderLeftWidth) +{ + return GetPropertyValue("border-left-width", aBorderLeftWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderLeftWidth(const nsString& aBorderLeftWidth) +{ + return SetProperty("border-left-width", aBorderLeftWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBorderWidth(nsString& aBorderWidth) +{ + return GetPropertyValue("border-width", aBorderWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBorderWidth(const nsString& aBorderWidth) +{ + return SetProperty("border-width", aBorderWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetBottom(nsString& aBottom) +{ + return GetPropertyValue("bottom", aBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetBottom(const nsString& aBottom) +{ + return SetProperty("bottom", aBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCaptionSide(nsString& aCaptionSide) +{ + return GetPropertyValue("caption-side", aCaptionSide); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCaptionSide(const nsString& aCaptionSide) +{ + return SetProperty("caption-side", aCaptionSide, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetClear(nsString& aClear) +{ + return GetPropertyValue("clear", aClear); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetClear(const nsString& aClear) +{ + return SetProperty("clear", aClear, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetClip(nsString& aClip) +{ + return GetPropertyValue("clip", aClip); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetClip(const nsString& aClip) +{ + return SetProperty("clip", aClip, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetColor(nsString& aColor) +{ + return GetPropertyValue("color", aColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetColor(const nsString& aColor) +{ + return SetProperty("color", aColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetContent(nsString& aContent) +{ + return GetPropertyValue("content", aContent); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetContent(const nsString& aContent) +{ + return SetProperty("content", aContent, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCounterIncrement(nsString& aCounterIncrement) +{ + return GetPropertyValue("counter-increment", aCounterIncrement); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCounterIncrement(const nsString& aCounterIncrement) +{ + return SetProperty("counter-increment", aCounterIncrement, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCounterReset(nsString& aCounterReset) +{ + return GetPropertyValue("counter-reset", aCounterReset); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCounterReset(const nsString& aCounterReset) +{ + return SetProperty("counter-reset", aCounterReset, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCue(nsString& aCue) +{ + return GetPropertyValue("cue", aCue); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCue(const nsString& aCue) +{ + return SetProperty("cue", aCue, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCueAfter(nsString& aCueAfter) +{ + return GetPropertyValue("cue-after", aCueAfter); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCueAfter(const nsString& aCueAfter) +{ + return SetProperty("cue-after", aCueAfter, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCueBefore(nsString& aCueBefore) +{ + return GetPropertyValue("cue-before", aCueBefore); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCueBefore(const nsString& aCueBefore) +{ + return SetProperty("cue-before", aCueBefore, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetCursor(nsString& aCursor) +{ + return GetPropertyValue("cursor", aCursor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetCursor(const nsString& aCursor) +{ + return SetProperty("cursor", aCursor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetDirection(nsString& aDirection) +{ + return GetPropertyValue("direction", aDirection); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetDirection(const nsString& aDirection) +{ + return SetProperty("direction", aDirection, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetDisplay(nsString& aDisplay) +{ + return GetPropertyValue("display", aDisplay); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetDisplay(const nsString& aDisplay) +{ + return SetProperty("display", aDisplay, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetElevation(nsString& aElevation) +{ + return GetPropertyValue("elevation", aElevation); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetElevation(const nsString& aElevation) +{ + return SetProperty("elevation", aElevation, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetEmptyCells(nsString& aEmptyCells) +{ + return GetPropertyValue("empty-cells", aEmptyCells); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetEmptyCells(const nsString& aEmptyCells) +{ + return SetProperty("empty-cells", aEmptyCells, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetStyleFloat(nsString& aStyleFloat) +{ + return GetPropertyValue("style-float", aStyleFloat); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetStyleFloat(const nsString& aStyleFloat) +{ + return SetProperty("style-float", aStyleFloat, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFont(nsString& aFont) +{ + return GetPropertyValue("font", aFont); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFont(const nsString& aFont) +{ + return SetProperty("font", aFont, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontFamily(nsString& aFontFamily) +{ + return GetPropertyValue("font-family", aFontFamily); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontFamily(const nsString& aFontFamily) +{ + return SetProperty("font-family", aFontFamily, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontSize(nsString& aFontSize) +{ + return GetPropertyValue("font-size", aFontSize); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontSize(const nsString& aFontSize) +{ + return SetProperty("font-size", aFontSize, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontSizeAdjust(nsString& aFontSizeAdjust) +{ + return GetPropertyValue("font-size-adjust", aFontSizeAdjust); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontSizeAdjust(const nsString& aFontSizeAdjust) +{ + return SetProperty("font-size-adjust", aFontSizeAdjust, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontStretch(nsString& aFontStretch) +{ + return GetPropertyValue("font-stretch", aFontStretch); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontStretch(const nsString& aFontStretch) +{ + return SetProperty("font-stretch", aFontStretch, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontStyle(nsString& aFontStyle) +{ + return GetPropertyValue("font-style", aFontStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontStyle(const nsString& aFontStyle) +{ + return SetProperty("font-style", aFontStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontVariant(nsString& aFontVariant) +{ + return GetPropertyValue("font-variant", aFontVariant); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontVariant(const nsString& aFontVariant) +{ + return SetProperty("font-variant", aFontVariant, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetFontWeight(nsString& aFontWeight) +{ + return GetPropertyValue("font-weight", aFontWeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetFontWeight(const nsString& aFontWeight) +{ + return SetProperty("font-weight", aFontWeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetHeight(nsString& aHeight) +{ + return GetPropertyValue("height", aHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetHeight(const nsString& aHeight) +{ + return SetProperty("height", aHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLeft(nsString& aLeft) +{ + return GetPropertyValue("left", aLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetLeft(const nsString& aLeft) +{ + return SetProperty("left", aLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLetterSpacing(nsString& aLetterSpacing) +{ + return GetPropertyValue("letter-spacing", aLetterSpacing); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetLetterSpacing(const nsString& aLetterSpacing) +{ + return SetProperty("letter-spacing", aLetterSpacing, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetLineHeight(nsString& aLineHeight) +{ + return GetPropertyValue("line-height", aLineHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetLineHeight(const nsString& aLineHeight) +{ + return SetProperty("line-height", aLineHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStyle(nsString& aListStyle) +{ + return GetPropertyValue("list-style", aListStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStyle(const nsString& aListStyle) +{ + return SetProperty("list-style", aListStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStyleImage(nsString& aListStyleImage) +{ + return GetPropertyValue("list-style-image", aListStyleImage); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStyleImage(const nsString& aListStyleImage) +{ + return SetProperty("list-style-image", aListStyleImage, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStylePosition(nsString& aListStylePosition) +{ + return GetPropertyValue("list-style-position", aListStylePosition); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStylePosition(const nsString& aListStylePosition) +{ + return SetProperty("list-style-position", aListStylePosition, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetListStyleType(nsString& aListStyleType) +{ + return GetPropertyValue("list-style-type", aListStyleType); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetListStyleType(const nsString& aListStyleType) +{ + return SetProperty("list-style-type", aListStyleType, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMargin(nsString& aMargin) +{ + return GetPropertyValue("margin", aMargin); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMargin(const nsString& aMargin) +{ + return SetProperty("margin", aMargin, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginTop(nsString& aMarginTop) +{ + return GetPropertyValue("margin-top", aMarginTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginTop(const nsString& aMarginTop) +{ + return SetProperty("margin-top", aMarginTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginRight(nsString& aMarginRight) +{ + return GetPropertyValue("margin-right", aMarginRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginRight(const nsString& aMarginRight) +{ + return SetProperty("margin-right", aMarginRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginBottom(nsString& aMarginBottom) +{ + return GetPropertyValue("margin-bottom", aMarginBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginBottom(const nsString& aMarginBottom) +{ + return SetProperty("margin-bottom", aMarginBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarginLeft(nsString& aMarginLeft) +{ + return GetPropertyValue("margin-left", aMarginLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarginLeft(const nsString& aMarginLeft) +{ + return SetProperty("margin-left", aMarginLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarkerOffset(nsString& aMarkerOffset) +{ + return GetPropertyValue("marker-offset", aMarkerOffset); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarkerOffset(const nsString& aMarkerOffset) +{ + return SetProperty("marker-offset", aMarkerOffset, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMarks(nsString& aMarks) +{ + return GetPropertyValue("marks", aMarks); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMarks(const nsString& aMarks) +{ + return SetProperty("marks", aMarks, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMaxHeight(nsString& aMaxHeight) +{ + return GetPropertyValue("max-height", aMaxHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMaxHeight(const nsString& aMaxHeight) +{ + return SetProperty("max-height", aMaxHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMaxWidth(nsString& aMaxWidth) +{ + return GetPropertyValue("max-width", aMaxWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMaxWidth(const nsString& aMaxWidth) +{ + return SetProperty("max-width", aMaxWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMinHeight(nsString& aMinHeight) +{ + return GetPropertyValue("min-height", aMinHeight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMinHeight(const nsString& aMinHeight) +{ + return SetProperty("min-height", aMinHeight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetMinWidth(nsString& aMinWidth) +{ + return GetPropertyValue("min-width", aMinWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetMinWidth(const nsString& aMinWidth) +{ + return SetProperty("min-width", aMinWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOrphans(nsString& aOrphans) +{ + return GetPropertyValue("orphans", aOrphans); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOrphans(const nsString& aOrphans) +{ + return SetProperty("orphans", aOrphans, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutline(nsString& aOutline) +{ + return GetPropertyValue("outline", aOutline); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutline(const nsString& aOutline) +{ + return SetProperty("outline", aOutline, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutlineColor(nsString& aOutlineColor) +{ + return GetPropertyValue("outline-color", aOutlineColor); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutlineColor(const nsString& aOutlineColor) +{ + return SetProperty("outline-color", aOutlineColor, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutlineStyle(nsString& aOutlineStyle) +{ + return GetPropertyValue("outline-style", aOutlineStyle); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutlineStyle(const nsString& aOutlineStyle) +{ + return SetProperty("outline-style", aOutlineStyle, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOutlineWidth(nsString& aOutlineWidth) +{ + return GetPropertyValue("outline-width", aOutlineWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOutlineWidth(const nsString& aOutlineWidth) +{ + return SetProperty("outline-width", aOutlineWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetOverflow(nsString& aOverflow) +{ + return GetPropertyValue("overflow", aOverflow); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetOverflow(const nsString& aOverflow) +{ + return SetProperty("overflow", aOverflow, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPadding(nsString& aPadding) +{ + return GetPropertyValue("padding", aPadding); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPadding(const nsString& aPadding) +{ + return SetProperty("padding", aPadding, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingTop(nsString& aPaddingTop) +{ + return GetPropertyValue("padding-top", aPaddingTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingTop(const nsString& aPaddingTop) +{ + return SetProperty("padding-top", aPaddingTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingRight(nsString& aPaddingRight) +{ + return GetPropertyValue("padding-right", aPaddingRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingRight(const nsString& aPaddingRight) +{ + return SetProperty("padding-right", aPaddingRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingBottom(nsString& aPaddingBottom) +{ + return GetPropertyValue("padding-bottom", aPaddingBottom); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingBottom(const nsString& aPaddingBottom) +{ + return SetProperty("padding-bottom", aPaddingBottom, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPaddingLeft(nsString& aPaddingLeft) +{ + return GetPropertyValue("padding-left", aPaddingLeft); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPaddingLeft(const nsString& aPaddingLeft) +{ + return SetProperty("padding-left", aPaddingLeft, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPage(nsString& aPage) +{ + return GetPropertyValue("page", aPage); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPage(const nsString& aPage) +{ + return SetProperty("page", aPage, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPageBreakAfter(nsString& aPageBreakAfter) +{ + return GetPropertyValue("page-break-after", aPageBreakAfter); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPageBreakAfter(const nsString& aPageBreakAfter) +{ + return SetProperty("page-break-after", aPageBreakAfter, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPageBreakBefore(nsString& aPageBreakBefore) +{ + return GetPropertyValue("page-break-before", aPageBreakBefore); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPageBreakBefore(const nsString& aPageBreakBefore) +{ + return SetProperty("page-break-before", aPageBreakBefore, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPageBreakInside(nsString& aPageBreakInside) +{ + return GetPropertyValue("page-break-inside", aPageBreakInside); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPageBreakInside(const nsString& aPageBreakInside) +{ + return SetProperty("page-break-inside", aPageBreakInside, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPause(nsString& aPause) +{ + return GetPropertyValue("pause", aPause); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPause(const nsString& aPause) +{ + return SetProperty("pause", aPause, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPauseAfter(nsString& aPauseAfter) +{ + return GetPropertyValue("pause-after", aPauseAfter); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPauseAfter(const nsString& aPauseAfter) +{ + return SetProperty("pause-after", aPauseAfter, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPauseBefore(nsString& aPauseBefore) +{ + return GetPropertyValue("pause-before", aPauseBefore); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPauseBefore(const nsString& aPauseBefore) +{ + return SetProperty("pause-before", aPauseBefore, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPitch(nsString& aPitch) +{ + return GetPropertyValue("pitch", aPitch); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPitch(const nsString& aPitch) +{ + return SetProperty("pitch", aPitch, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPitchRange(nsString& aPitchRange) +{ + return GetPropertyValue("pitch-range", aPitchRange); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPitchRange(const nsString& aPitchRange) +{ + return SetProperty("pitch-range", aPitchRange, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPlayDuring(nsString& aPlayDuring) +{ + return GetPropertyValue("play-during", aPlayDuring); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPlayDuring(const nsString& aPlayDuring) +{ + return SetProperty("play-during", aPlayDuring, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetPosition(nsString& aPosition) +{ + return GetPropertyValue("position", aPosition); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetPosition(const nsString& aPosition) +{ + return SetProperty("position", aPosition, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetQuotes(nsString& aQuotes) +{ + return GetPropertyValue("quotes", aQuotes); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetQuotes(const nsString& aQuotes) +{ + return SetProperty("quotes", aQuotes, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetRichness(nsString& aRichness) +{ + return GetPropertyValue("richness", aRichness); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetRichness(const nsString& aRichness) +{ + return SetProperty("richness", aRichness, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetRight(nsString& aRight) +{ + return GetPropertyValue("right", aRight); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetRight(const nsString& aRight) +{ + return SetProperty("right", aRight, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSize(nsString& aSize) +{ + return GetPropertyValue("size", aSize); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSize(const nsString& aSize) +{ + return SetProperty("size", aSize, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeak(nsString& aSpeak) +{ + return GetPropertyValue("speak", aSpeak); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeak(const nsString& aSpeak) +{ + return SetProperty("speak", aSpeak, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeakHeader(nsString& aSpeakHeader) +{ + return GetPropertyValue("speak-header", aSpeakHeader); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeakHeader(const nsString& aSpeakHeader) +{ + return SetProperty("speak-header", aSpeakHeader, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeakNumeral(nsString& aSpeakNumeral) +{ + return GetPropertyValue("speak-numeral", aSpeakNumeral); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeakNumeral(const nsString& aSpeakNumeral) +{ + return SetProperty("speak-numeral", aSpeakNumeral, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeakPunctuation(nsString& aSpeakPunctuation) +{ + return GetPropertyValue("speak-punctuation", aSpeakPunctuation); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeakPunctuation(const nsString& aSpeakPunctuation) +{ + return SetProperty("speak-punctuation", aSpeakPunctuation, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetSpeechRate(nsString& aSpeechRate) +{ + return GetPropertyValue("speech-rate", aSpeechRate); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetSpeechRate(const nsString& aSpeechRate) +{ + return SetProperty("speech-rate", aSpeechRate, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetStress(nsString& aStress) +{ + return GetPropertyValue("stress", aStress); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetStress(const nsString& aStress) +{ + return SetProperty("stress", aStress, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTableLayout(nsString& aTableLayout) +{ + return GetPropertyValue("table-layout", aTableLayout); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTableLayout(const nsString& aTableLayout) +{ + return SetProperty("table-layout", aTableLayout, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextAlign(nsString& aTextAlign) +{ + return GetPropertyValue("text-align", aTextAlign); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextAlign(const nsString& aTextAlign) +{ + return SetProperty("text-align", aTextAlign, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextDecoration(nsString& aTextDecoration) +{ + return GetPropertyValue("text-decoration", aTextDecoration); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextDecoration(const nsString& aTextDecoration) +{ + return SetProperty("text-decoration", aTextDecoration, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextIndent(nsString& aTextIndent) +{ + return GetPropertyValue("text-indent", aTextIndent); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextIndent(const nsString& aTextIndent) +{ + return SetProperty("text-indent", aTextIndent, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextShadow(nsString& aTextShadow) +{ + return GetPropertyValue("text-shadow", aTextShadow); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextShadow(const nsString& aTextShadow) +{ + return SetProperty("text-shadow", aTextShadow, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTextTransform(nsString& aTextTransform) +{ + return GetPropertyValue("text-transform", aTextTransform); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTextTransform(const nsString& aTextTransform) +{ + return SetProperty("text-transform", aTextTransform, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetTop(nsString& aTop) +{ + return GetPropertyValue("top", aTop); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetTop(const nsString& aTop) +{ + return SetProperty("top", aTop, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetUnicodeBidi(nsString& aUnicodeBidi) +{ + return GetPropertyValue("unicode-bidi", aUnicodeBidi); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetUnicodeBidi(const nsString& aUnicodeBidi) +{ + return SetProperty("unicode-bidi", aUnicodeBidi, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVerticalAlign(nsString& aVerticalAlign) +{ + return GetPropertyValue("vertical-align", aVerticalAlign); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVerticalAlign(const nsString& aVerticalAlign) +{ + return SetProperty("vertical-align", aVerticalAlign, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVisibility(nsString& aVisibility) +{ + return GetPropertyValue("visibility", aVisibility); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVisibility(const nsString& aVisibility) +{ + return SetProperty("visibility", aVisibility, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVoiceFamily(nsString& aVoiceFamily) +{ + return GetPropertyValue("voice-family", aVoiceFamily); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVoiceFamily(const nsString& aVoiceFamily) +{ + return SetProperty("voice-family", aVoiceFamily, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetVolume(nsString& aVolume) +{ + return GetPropertyValue("volume", aVolume); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetVolume(const nsString& aVolume) +{ + return SetProperty("volume", aVolume, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWhiteSpace(nsString& aWhiteSpace) +{ + return GetPropertyValue("white-space", aWhiteSpace); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWhiteSpace(const nsString& aWhiteSpace) +{ + return SetProperty("white-space", aWhiteSpace, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWidows(nsString& aWidows) +{ + return GetPropertyValue("widows", aWidows); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWidows(const nsString& aWidows) +{ + return SetProperty("widows", aWidows, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWidth(nsString& aWidth) +{ + return GetPropertyValue("width", aWidth); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWidth(const nsString& aWidth) +{ + return SetProperty("width", aWidth, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetWordSpacing(nsString& aWordSpacing) +{ + return GetPropertyValue("word-spacing", aWordSpacing); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetWordSpacing(const nsString& aWordSpacing) +{ + return SetProperty("word-spacing", aWordSpacing, ""); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::GetZIndex(nsString& aZIndex) +{ + return GetPropertyValue("z-index", aZIndex); +} + +NS_IMETHODIMP +nsDOMCSSDeclaration::SetZIndex(const nsString& aZIndex) +{ + return SetProperty("z-index", aZIndex, ""); +} + diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h new file mode 100644 index 000000000000..acae956973a0 --- /dev/null +++ b/layout/style/nsDOMCSSDeclaration.h @@ -0,0 +1,55 @@ +/* -*- 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.0 (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/ + * + * 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. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ +#ifndef nsDOMCSSDeclaration_h___ +#define nsDOMCSSSDeclaration_h___ + +#include "nsISupports.h" +#include "nsIDOMCSSStyleDeclaration.h" +#include "nsIScriptObjectOwner.h" + +class nsICSSDeclaration; + +class nsDOMCSSDeclaration : public nsIDOMCSSStyleDeclaration, + public nsIScriptObjectOwner +{ +public: + nsDOMCSSDeclaration(); + + NS_DECL_ISUPPORTS + + NS_DECL_IDOMCSSSTYLEDECLARATION + + // nsIScriptObjectOwner interface + NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); + NS_IMETHOD SetScriptObject(void* aScriptObject); + + virtual void DropReference() = 0; + virtual nsresult GetCSSDeclaration(nsICSSDeclaration **aDecl, + PRBool aAllocate) = 0; + virtual nsresult StylePropertyChanged(const nsString& aPropertyName, + PRInt32 aHint) = 0; + virtual nsresult GetParent(nsISupports **aParent) = 0; + +protected: + virtual ~nsDOMCSSDeclaration(); + + void *mScriptObject; +}; + +#endif // nsDOMCSSDeclaration_h___ diff --git a/layout/style/nsICSSParser.h b/layout/style/nsICSSParser.h index ca8a3422a4bc..957e5fef2bd7 100644 --- a/layout/style/nsICSSParser.h +++ b/layout/style/nsICSSParser.h @@ -43,7 +43,7 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aSheet) = 0; NS_IMETHOD Parse(nsIUnicharInputStream* aInput, - nsIURL* aInputURL, + nsIURL* aInputURL, nsIStyleSheet*& aResult) = 0; // Parse declarations assuming that the outer curly braces have @@ -58,6 +58,7 @@ public: nsICSSDeclaration* aDeclaration, PRInt32* aHint) = 0; + NS_IMETHOD ProcessImport(const nsString& aURLSpec) = 0; }; // Values or'd in the GetInfoMask; other bits are reserved diff --git a/layout/style/nsICSSStyleRule.h b/layout/style/nsICSSStyleRule.h index d45b23b04cbc..dc68d7b04838 100644 --- a/layout/style/nsICSSStyleRule.h +++ b/layout/style/nsICSSStyleRule.h @@ -25,7 +25,7 @@ class nsIAtom; class nsIArena; class nsString; class nsICSSDeclaration; - +class nsIStyleSheet; struct nsCSSSelector { public: @@ -65,6 +65,9 @@ public: virtual void SetWeight(PRInt32 aWeight) = 0; virtual nsIStyleRule* GetImportantRule(void) = 0; + + virtual nsIStyleSheet* GetStyleSheet(void) = 0; + virtual void SetStyleSheet(nsIStyleSheet *aSheet) = 0; }; extern NS_HTML nsresult