diff --git a/mozilla/content/base/public/nsContentCID.h b/mozilla/content/base/public/nsContentCID.h index 4ea4adc59ce..a0cc4004361 100644 --- a/mozilla/content/base/public/nsContentCID.h +++ b/mozilla/content/base/public/nsContentCID.h @@ -47,10 +47,6 @@ #define NS_STYLESET_CID \ { 0x1691e1f7, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } -// {96882B70-8A27-11d2-8EAF-00805F29F370} -#define NS_HTMLSTYLESHEET_CID \ -{ 0x96882b70, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } } - // {972D8D8F-F0DA-11d4-9885-00C04FA0CF4B} #define NS_DOCUMENT_VIEWER_CID \ { 0x972d8d8f, 0xf0da, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } diff --git a/mozilla/content/base/public/nsContentErrors.h b/mozilla/content/base/public/nsContentErrors.h index 8cf49e774d0..76a3080dbfe 100644 --- a/mozilla/content/base/public/nsContentErrors.h +++ b/mozilla/content/base/public/nsContentErrors.h @@ -52,7 +52,7 @@ NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 1) -/** Error codes for nsIHTMLStyleSheet */ +/** Error codes for nsHTMLStyleSheet */ // XXX this is not really used #define NS_HTML_STYLE_PROPERTY_NOT_THERE \ NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 2) diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 9d8abec4906..6dc762b3dcb 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -84,7 +84,7 @@ class nsIScriptLoader; class nsIContentSink; class nsIScriptEventManager; class nsICSSLoader; -class nsIHTMLStyleSheet; +class nsHTMLStyleSheet; class nsIHTMLCSSStyleSheet; // IID for the nsIDocument interface @@ -428,7 +428,7 @@ public: * Get this document's attribute stylesheet. May return null if * there isn't one. */ - virtual nsIHTMLStyleSheet* GetAttributeStyleSheet() const = 0; + virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const = 0; /** * Get this document's inline style sheet. May return null if there diff --git a/mozilla/content/base/src/nsAttrAndChildArray.cpp b/mozilla/content/base/src/nsAttrAndChildArray.cpp index 59ec6e6daa6..c52ac40ca55 100644 --- a/mozilla/content/base/src/nsAttrAndChildArray.cpp +++ b/mozilla/content/base/src/nsAttrAndChildArray.cpp @@ -41,7 +41,7 @@ #include "prmem.h" #include "prbit.h" #include "nsString.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsRuleWalker.h" #include "nsMappedAttributes.h" #include "nsUnicharUtils.h" @@ -434,7 +434,7 @@ nsresult nsAttrAndChildArray::SetAndTakeMappedAttr(nsIAtom* aLocalName, nsAttrValue& aValue, nsIHTMLContent* aContent, - nsIHTMLStyleSheet* aSheet) + nsHTMLStyleSheet* aSheet) { nsRefPtr mapped; nsresult rv = GetModifiableMapped(aContent, aSheet, PR_TRUE, @@ -448,7 +448,7 @@ nsAttrAndChildArray::SetAndTakeMappedAttr(nsIAtom* aLocalName, } nsresult -nsAttrAndChildArray::SetMappedAttrStyleSheet(nsIHTMLStyleSheet* aSheet) +nsAttrAndChildArray::SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet) { if (!mImpl || !mImpl->mMappedAttrs || aSheet == mImpl->mMappedAttrs->GetStyleSheet()) { @@ -555,7 +555,7 @@ nsAttrAndChildArray::MappedAttrCount() const nsresult nsAttrAndChildArray::GetModifiableMapped(nsIHTMLContent* aContent, - nsIHTMLStyleSheet* aSheet, + nsHTMLStyleSheet* aSheet, PRBool aWillAddAttr, nsMappedAttributes** aModifiable) { @@ -600,10 +600,9 @@ nsAttrAndChildArray::MakeMappedUnique(nsMappedAttributes* aAttributes) return NS_OK; } - nsRefPtr mapped; - nsresult rv = aAttributes->GetStyleSheet()-> - UniqueMappedAttributes(aAttributes, *getter_AddRefs(mapped)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr mapped = + aAttributes->GetStyleSheet()->UniqueMappedAttributes(aAttributes); + NS_ENSURE_TRUE(mapped, NS_ERROR_OUT_OF_MEMORY); if (mapped != aAttributes) { // Reset the stylesheet of aAttributes so that it doesn't spend time diff --git a/mozilla/content/base/src/nsAttrAndChildArray.h b/mozilla/content/base/src/nsAttrAndChildArray.h index b2c59b44b14..20fb7ae9c76 100644 --- a/mozilla/content/base/src/nsAttrAndChildArray.h +++ b/mozilla/content/base/src/nsAttrAndChildArray.h @@ -45,7 +45,7 @@ class nsIContent; class nsMappedAttributes; -class nsIHTMLStyleSheet; +class nsHTMLStyleSheet; class nsRuleWalker; class nsIHTMLContent; @@ -104,8 +104,8 @@ public: PRInt32 IndexOfAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID = kNameSpaceID_None) const; nsresult SetAndTakeMappedAttr(nsIAtom* aLocalName, nsAttrValue& aValue, - nsIHTMLContent* aContent, nsIHTMLStyleSheet* aSheet); - nsresult SetMappedAttrStyleSheet(nsIHTMLStyleSheet* aSheet); + nsIHTMLContent* aContent, nsHTMLStyleSheet* aSheet); + nsresult SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet); void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker); void Compact(); @@ -120,7 +120,7 @@ private: PRUint32 MappedAttrCount() const; nsresult GetModifiableMapped(nsIHTMLContent* aContent, - nsIHTMLStyleSheet* aSheet, + nsHTMLStyleSheet* aSheet, PRBool aWillAddAttr, nsMappedAttributes** aModifiable); nsresult MakeMappedUnique(nsMappedAttributes* aAttributes); diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index cfddd543c86..7f96a685d71 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -81,7 +81,7 @@ #include "nsIScriptEventManager.h" // Put these here so all document impls get them automatically -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "pldhash.h" @@ -323,7 +323,7 @@ public: * Get this document's attribute stylesheet. May return null if * there isn't one. */ - nsIHTMLStyleSheet* GetAttributeStyleSheet() const { + nsHTMLStyleSheet* GetAttributeStyleSheet() const { return mAttrStyleSheet; } @@ -564,7 +564,7 @@ protected: nsSupportsHashtable mContentWrapperHash; nsCOMPtr mCSSLoader; - nsCOMPtr mAttrStyleSheet; + nsRefPtr mAttrStyleSheet; nsCOMPtr mStyleAttrStyleSheet; nsCOMPtr mScriptEventManager; diff --git a/mozilla/content/base/src/nsMappedAttributes.cpp b/mozilla/content/base/src/nsMappedAttributes.cpp index 89f9a552302..5e7fa6cfa85 100644 --- a/mozilla/content/base/src/nsMappedAttributes.cpp +++ b/mozilla/content/base/src/nsMappedAttributes.cpp @@ -37,11 +37,11 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMappedAttributes.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsRuleWalker.h" #include "prmem.h" -nsMappedAttributes::nsMappedAttributes(nsIHTMLStyleSheet* aSheet, +nsMappedAttributes::nsMappedAttributes(nsHTMLStyleSheet* aSheet, nsMapRuleToAttributesFunc aMapRuleFunc) : mAttrCount(0), mSheet(aSheet), @@ -209,7 +209,7 @@ nsMappedAttributes::GetStyleSheet(nsIStyleSheet*& aSheet) const } void -nsMappedAttributes::SetStyleSheet(nsIHTMLStyleSheet* aSheet) +nsMappedAttributes::SetStyleSheet(nsHTMLStyleSheet* aSheet) { if (mSheet) { mSheet->DropMappedAttributes(this); diff --git a/mozilla/content/base/src/nsMappedAttributes.h b/mozilla/content/base/src/nsMappedAttributes.h index 266091db4b5..50144e624c5 100644 --- a/mozilla/content/base/src/nsMappedAttributes.h +++ b/mozilla/content/base/src/nsMappedAttributes.h @@ -44,13 +44,13 @@ #include "nsIStyleRule.h" class nsIAtom; -class nsIHTMLStyleSheet; +class nsHTMLStyleSheet; class nsRuleWalker; class nsMappedAttributes : public nsIStyleRule { public: - nsMappedAttributes(nsIHTMLStyleSheet* aSheet, + nsMappedAttributes(nsHTMLStyleSheet* aSheet, nsMapRuleToAttributesFunc aMapRuleFunc); void* operator new(size_t size, PRUint32 aAttrCount = 1) CPP_THROW_NEW; @@ -75,8 +75,8 @@ public: { mSheet = nsnull; } - void SetStyleSheet(nsIHTMLStyleSheet* aSheet); - nsIHTMLStyleSheet* GetStyleSheet() + void SetStyleSheet(nsHTMLStyleSheet* aSheet); + nsHTMLStyleSheet* GetStyleSheet() { return mSheet; } @@ -133,7 +133,7 @@ private: #ifdef DEBUG PRUint16 mBufferSize; #endif - nsIHTMLStyleSheet* mSheet; //weak + nsHTMLStyleSheet* mSheet; //weak nsMapRuleToAttributesFunc mRuleMapper; void* mAttrs[1]; }; diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 0fa7d0213c3..3d2e17ad2a7 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -59,7 +59,7 @@ #include "nsIEventListenerManager.h" #include "nsIFocusController.h" #include "nsMappedAttributes.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLDocument.h" #include "nsIHTMLContent.h" #include "nsILink.h" @@ -1278,7 +1278,7 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, ReparseStyleAttribute(); if (!doNothing && mDocument) { - nsIHTMLStyleSheet* sheet = mDocument->GetAttributeStyleSheet(); + nsHTMLStyleSheet* sheet = mDocument->GetAttributeStyleSheet(); if (sheet) { mAttrsAndChildren.SetMappedAttrStyleSheet(sheet); } @@ -1614,7 +1614,7 @@ nsGenericHTMLElement::SetAttrAndNotify(PRInt32 aNamespaceID, if (aNamespaceID == kNameSpaceID_None) { if (IsAttributeMapped(aAttribute)) { - nsIHTMLStyleSheet* sheet = mDocument ? + nsHTMLStyleSheet* sheet = mDocument ? mDocument->GetAttributeStyleSheet() : nsnull; rv = mAttrsAndChildren.SetAndTakeMappedAttr(aAttribute, aParsedValue, this, sheet); diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 630a6b1d1fa..af102a6026a 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -48,7 +48,7 @@ #include "nsIPresShell.h" #include "nsIDocument.h" #include "nsIHTMLDocument.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsICSSStyleRule.h" #include "nsIContentViewer.h" @@ -69,7 +69,7 @@ class nsHTMLBodyElement; class BodyRule: public nsIStyleRule { public: - BodyRule(nsHTMLBodyElement* aPart, nsIHTMLStyleSheet* aSheet); + BodyRule(nsHTMLBodyElement* aPart, nsHTMLStyleSheet* aSheet); virtual ~BodyRule(); NS_DECL_ISUPPORTS @@ -84,7 +84,7 @@ public: #endif nsHTMLBodyElement* mPart; // not ref-counted, cleared by content - nsIHTMLStyleSheet* mSheet; // not ref-counted, cleared by content + nsHTMLStyleSheet* mSheet; // not ref-counted, cleared by content }; //---------------------------------------------------------------------- @@ -126,7 +126,7 @@ protected: //---------------------------------------------------------------------- -BodyRule::BodyRule(nsHTMLBodyElement* aPart, nsIHTMLStyleSheet* aSheet) +BodyRule::BodyRule(nsHTMLBodyElement* aPart, nsHTMLStyleSheet* aSheet) { mPart = aPart; mSheet = aSheet; @@ -512,7 +512,7 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD nsCOMPtr doc; presShell->GetDocument(getter_AddRefs(doc)); if (doc) { - nsIHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet(); + nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet(); if (styleSheet) { nscolor color; if (aAttributes->GetAttribute(nsHTMLAtoms::link, value) != diff --git a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp index 306ad61eac2..3080f582e6d 100644 --- a/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLUnknownElement.cpp @@ -46,7 +46,7 @@ #include "nsIEventListenerManager.h" #include "nsIDOMEventReceiver.h" #include "nsIDocument.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIDOMMutationEvent.h" class nsHTMLUnknownElement : public nsGenericHTMLElement, diff --git a/mozilla/content/html/document/src/Makefile.in b/mozilla/content/html/document/src/Makefile.in index 8d292ef4cdb..7f369fdc547 100644 --- a/mozilla/content/html/document/src/Makefile.in +++ b/mozilla/content/html/document/src/Makefile.in @@ -80,9 +80,9 @@ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk INCLUDES += \ - -I$(srcdir)/../../base/src \ -I$(srcdir)/../../../base/src \ -I$(srcdir)/../../content/src \ + -I$(srcdir)/../../style/src \ $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 2b846dd3a0f..457aa7a6695 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -49,7 +49,7 @@ #include "nsIHTMLContentSink.h" #include "nsIXMLContentSink.h" #include "nsHTMLParts.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsHTMLAtoms.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index e0746e77b67..3b8a6d163f0 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -53,7 +53,7 @@ #include "pldhash.h" #include "nsIHttpChannel.h" #include "nsIHTMLCSSStyleSheet.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" // Document.Write() related #include "nsIWyciwygChannel.h" diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index b681a16f56d..a9ea875ace6 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -47,7 +47,7 @@ class nsIDOMNodeList; class nsIDOMHTMLCollection; class nsIDOMHTMLFormElement; class nsIDOMHTMLMapElement; -class nsIHTMLStyleSheet; +class nsHTMLStyleSheet; class nsIStyleSheet; class nsICSSLoader; class nsIContent; diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp index b65a7663520..1fdb693b058 100644 --- a/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.cpp @@ -27,68 +27,41 @@ * Date Modified by Description of modification * 04/20/2000 IBM Corp. OS/2 VisualAge build. */ + +#include "nsHTMLStyleSheet.h" #include "nsINameSpaceManager.h" -#include "nsIHTMLStyleSheet.h" -#include "nsCRT.h" #include "nsIAtom.h" #include "nsIURL.h" -#include "nsIServiceManager.h" #include "nsISupportsArray.h" -#include "pldhash.h" #include "nsMappedAttributes.h" #include "nsILink.h" -#include "nsIStyleRuleProcessor.h" -#include "nsIStyleRule.h" #include "nsIFrame.h" #include "nsStyleContext.h" #include "nsHTMLAtoms.h" #include "nsIPresContext.h" #include "nsIEventStateManager.h" #include "nsIDocument.h" -#include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsStyleConsts.h" -#include "nsLayoutAtoms.h" -#include "nsLayoutCID.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" #include "nsRuleWalker.h" -class HTMLColorRule : public nsIStyleRule { -public: - HTMLColorRule(nsIHTMLStyleSheet* aSheet); - virtual ~HTMLColorRule(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; - - // The new mapping function. - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); - -#ifdef DEBUG - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; -#endif - - nscolor mColor; - nsIHTMLStyleSheet* mSheet; -}; - -HTMLColorRule::HTMLColorRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::HTMLColorRule::HTMLColorRule(nsHTMLStyleSheet* aSheet) : mSheet(aSheet) { } -HTMLColorRule::~HTMLColorRule() +nsHTMLStyleSheet::HTMLColorRule::~HTMLColorRule() { } -NS_IMPL_ISUPPORTS1(HTMLColorRule, nsIStyleRule) +NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::HTMLColorRule, nsIStyleRule) NS_IMETHODIMP -HTMLColorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const +nsHTMLStyleSheet::HTMLColorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const { NS_IF_ADDREF(mSheet); aSheet = mSheet; @@ -96,7 +69,7 @@ HTMLColorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const } NS_IMETHODIMP -HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData->mSID == eStyleStruct_Color) { if (aRuleData->mColorData->mColor.GetUnit() == eCSSUnit_Null) @@ -107,51 +80,32 @@ HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) #ifdef DEBUG NS_IMETHODIMP -HTMLColorRule::List(FILE* out, PRInt32 aIndent) const +nsHTMLStyleSheet::HTMLColorRule::List(FILE* out, PRInt32 aIndent) const { return NS_OK; } #endif -class GenericTableRule: public nsIStyleRule { -public: - GenericTableRule(nsIHTMLStyleSheet* aSheet); - virtual ~GenericTableRule(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; - - // The new mapping function. - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); - -#ifdef DEBUG - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; -#endif - - nsIHTMLStyleSheet* mSheet; // not ref-counted, cleared by content -}; - -GenericTableRule::GenericTableRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::GenericTableRule::GenericTableRule(nsHTMLStyleSheet* aSheet) { mSheet = aSheet; } -GenericTableRule::~GenericTableRule() +nsHTMLStyleSheet::GenericTableRule::~GenericTableRule() { } -NS_IMPL_ISUPPORTS1(GenericTableRule, nsIStyleRule) +NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::GenericTableRule, nsIStyleRule) NS_IMETHODIMP -GenericTableRule::GetStyleSheet(nsIStyleSheet*& aSheet) const +nsHTMLStyleSheet::GenericTableRule::GetStyleSheet(nsIStyleSheet*& aSheet) const { aSheet = mSheet; return NS_OK; } NS_IMETHODIMP -GenericTableRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::GenericTableRule::MapRuleInfoInto(nsRuleData* aRuleData) { // Nothing to do. return NS_OK; @@ -159,29 +113,18 @@ GenericTableRule::MapRuleInfoInto(nsRuleData* aRuleData) #ifdef DEBUG NS_IMETHODIMP -GenericTableRule::List(FILE* out, PRInt32 aIndent) const +nsHTMLStyleSheet::GenericTableRule::List(FILE* out, PRInt32 aIndent) const { return NS_OK; } #endif -// ----------------------------------------------------------- -// this rule handles inheritance -// ----------------------------------------------------------- -class TableTHRule: public GenericTableRule { -public: - TableTHRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableTHRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableTHRule::TableTHRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableTHRule::TableTHRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableTHRule::~TableTHRule() +nsHTMLStyleSheet::TableTHRule::~TableTHRule() { } @@ -201,7 +144,7 @@ static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleDa } NS_IMETHODIMP -TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Text) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -295,23 +238,12 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct, } } -// ----------------------------------------------------------- -// this rule handles borders on a , , when rules is set on its -// ----------------------------------------------------------- -class TableTbodyRule: public GenericTableRule { -public: - TableTbodyRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableTbodyRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableTbodyRule::TableTbodyRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableTbodyRule::TableTbodyRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableTbodyRule::~TableTbodyRule() +nsHTMLStyleSheet::TableTbodyRule::~TableTbodyRule() { } @@ -324,7 +256,7 @@ static void TbodyPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aR } NS_IMETHODIMP -TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -334,23 +266,12 @@ TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData) } // ----------------------------------------------------------- -// ----------------------------------------------------------- -// this rule handles borders on a when rules is set on its
-// ----------------------------------------------------------- -class TableRowRule: public GenericTableRule { -public: - TableRowRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableRowRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableRowRule::TableRowRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableRowRule::TableRowRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableRowRule::~TableRowRule() +nsHTMLStyleSheet::TableRowRule::~TableRowRule() { } @@ -363,7 +284,7 @@ static void RowPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRul } NS_IMETHODIMP -TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -372,23 +293,12 @@ TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData) return NS_OK; } -// ----------------------------------------------------------- -// this rule handles borders on a when rules is set on its
-// ----------------------------------------------------------- -class TableColgroupRule: public GenericTableRule { -public: - TableColgroupRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableColgroupRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableColgroupRule::TableColgroupRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableColgroupRule::TableColgroupRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableColgroupRule::~TableColgroupRule() +nsHTMLStyleSheet::TableColgroupRule::~TableColgroupRule() { } @@ -401,7 +311,7 @@ static void ColgroupPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* } NS_IMETHODIMP -TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -410,23 +320,12 @@ TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData) return NS_OK; } -// ----------------------------------------------------------- -// this rule handles borders on a when rules is set on its
-// ----------------------------------------------------------- -class TableColRule: public GenericTableRule { -public: - TableColRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableColRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableColRule::TableColRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableColRule::TableColRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableColRule::~TableColRule() +nsHTMLStyleSheet::TableColRule::~TableColRule() { } @@ -439,7 +338,7 @@ static void ColPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRul } NS_IMETHODIMP -TableColRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableColRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -497,102 +396,8 @@ static PLDHashTableOps MappedAttrTable_Ops = { // ----------------------------------------------------------- -class HTMLStyleSheetImpl : public nsIHTMLStyleSheet, - public nsIStyleRuleProcessor { -public: - HTMLStyleSheetImpl(void); - nsresult Init(); - - NS_DECL_ISUPPORTS - - // nsIStyleSheet api - NS_IMETHOD GetURL(nsIURI*& aURL) const; - NS_IMETHOD GetTitle(nsString& aTitle) const; - NS_IMETHOD GetType(nsString& aType) const; - NS_IMETHOD GetMediumCount(PRInt32& aCount) const; - NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const; - NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const; - NS_IMETHOD_(PRBool) HasRules() const; - - NS_IMETHOD GetApplicable(PRBool& aApplicable) const; - - NS_IMETHOD SetEnabled(PRBool aEnabled); - - NS_IMETHOD GetComplete(PRBool& aComplete) const; - NS_IMETHOD SetComplete(); - - // style sheet owner info - NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null - NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const; - - NS_IMETHOD SetOwningDocument(nsIDocument* aDocumemt); - - NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, - nsIStyleRuleProcessor* aPrevProcessor); - - // nsIStyleRuleProcessor API - NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData, - nsIAtom* aMedium); - - NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData, - nsIAtom* aMedium); - - NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult); - - NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult); - - // nsIHTMLStyleSheet api - NS_IMETHOD Init(nsIURI* aURL, nsIDocument* aDocument); - NS_IMETHOD Reset(nsIURI* aURL); - NS_IMETHOD GetLinkColor(nscolor& aColor); - NS_IMETHOD GetActiveLinkColor(nscolor& aColor); - NS_IMETHOD GetVisitedLinkColor(nscolor& aColor); - NS_IMETHOD SetLinkColor(nscolor aColor); - NS_IMETHOD SetActiveLinkColor(nscolor aColor); - NS_IMETHOD SetVisitedLinkColor(nscolor aColor); - - // Mapped Attribute management methods - NS_IMETHOD UniqueMappedAttributes(nsMappedAttributes* aMapped, - nsMappedAttributes*& aUniqueMapped); - NS_IMETHOD DropMappedAttributes(nsMappedAttributes* aMapped); - -#ifdef DEBUG - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; -#endif - -private: - // These are not supported and are not implemented! - HTMLStyleSheetImpl(const HTMLStyleSheetImpl& aCopy); - HTMLStyleSheetImpl& operator=(const HTMLStyleSheetImpl& aCopy); - -protected: - virtual ~HTMLStyleSheetImpl(); - -protected: - nsIURI* mURL; - nsIDocument* mDocument; - HTMLColorRule* mLinkRule; - HTMLColorRule* mVisitedRule; - HTMLColorRule* mActiveRule; - HTMLColorRule* mDocumentColorRule; - TableTbodyRule* mTableTbodyRule; - TableRowRule* mTableRowRule; - TableColgroupRule* mTableColgroupRule; - TableColRule* mTableColRule; - TableTHRule* mTableTHRule; - - PLDHashTable mMappedAttrTable; -}; - - -HTMLStyleSheetImpl::HTMLStyleSheetImpl(void) - : nsIHTMLStyleSheet(), - mRefCnt(0), - mURL(nsnull), +nsHTMLStyleSheet::nsHTMLStyleSheet(void) + : mURL(nsnull), mDocument(nsnull), mLinkRule(nsnull), mVisitedRule(nsnull), @@ -603,7 +408,7 @@ HTMLStyleSheetImpl::HTMLStyleSheetImpl(void) } nsresult -HTMLStyleSheetImpl::Init() +nsHTMLStyleSheet::Init() { mTableTbodyRule = new TableTbodyRule(this); if (!mTableTbodyRule) @@ -633,7 +438,7 @@ HTMLStyleSheetImpl::Init() return NS_OK; } -HTMLStyleSheetImpl::~HTMLStyleSheetImpl() +nsHTMLStyleSheet::~nsHTMLStyleSheet() { NS_IF_RELEASE(mURL); if (nsnull != mLinkRule) { @@ -676,11 +481,11 @@ HTMLStyleSheetImpl::~HTMLStyleSheetImpl() PL_DHashTableFinish(&mMappedAttrTable); } -NS_IMPL_ISUPPORTS3(HTMLStyleSheetImpl, nsIHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor) +NS_IMPL_ISUPPORTS2(nsHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor) NS_IMETHODIMP -HTMLStyleSheetImpl::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, - nsIStyleRuleProcessor* /*aPrevProcessor*/) +nsHTMLStyleSheet::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, + nsIStyleRuleProcessor* /*aPrevProcessor*/) { aProcessor = this; NS_ADDREF(aProcessor); @@ -707,8 +512,8 @@ static nsresult GetBodyColor(nsIPresContext* aPresContext, nscolor* aColor) } NS_IMETHODIMP -HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData, - nsIAtom* aMedium) +nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData, + nsIAtom* aMedium) { nsIStyledContent *styledContent = aData->mStyledContent; @@ -789,9 +594,9 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData, // Test if style is dependent on content state NS_IMETHODIMP -HTMLStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult) +nsHTMLStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult) { if (mActiveRule && (aData->mStateMask & NS_EVENT_STATE_ACTIVE) && @@ -807,9 +612,9 @@ HTMLStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData, } NS_IMETHODIMP -HTMLStyleSheetImpl::HasAttributeDependentStyle(AttributeRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult) +nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult) { // Result is true for |href| changes on HTML links if we have link rules. nsIStyledContent *styledContent = aData->mStyledContent; @@ -837,8 +642,8 @@ HTMLStyleSheetImpl::HasAttributeDependentStyle(AttributeRuleProcessorData* aData NS_IMETHODIMP -HTMLStyleSheetImpl::RulesMatching(PseudoRuleProcessorData* aData, - nsIAtom* aMedium) +nsHTMLStyleSheet::RulesMatching(PseudoRuleProcessorData* aData, + nsIAtom* aMedium) { nsIAtom* pseudoTag = aData->mPseudoTag; if (pseudoTag == nsCSSAnonBoxes::tableCol) { @@ -853,7 +658,7 @@ HTMLStyleSheetImpl::RulesMatching(PseudoRuleProcessorData* aData, // nsIStyleSheet api NS_IMETHODIMP -HTMLStyleSheetImpl::GetURL(nsIURI*& aURL) const +nsHTMLStyleSheet::GetURL(nsIURI*& aURL) const { aURL = mURL; NS_IF_ADDREF(aURL); @@ -861,80 +666,80 @@ HTMLStyleSheetImpl::GetURL(nsIURI*& aURL) const } NS_IMETHODIMP -HTMLStyleSheetImpl::GetTitle(nsString& aTitle) const +nsHTMLStyleSheet::GetTitle(nsString& aTitle) const { aTitle.Truncate(); return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetType(nsString& aType) const +nsHTMLStyleSheet::GetType(nsString& aType) const { aType.Assign(NS_LITERAL_STRING("text/html")); return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetMediumCount(PRInt32& aCount) const +nsHTMLStyleSheet::GetMediumCount(PRInt32& aCount) const { aCount = 0; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const +nsHTMLStyleSheet::GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const { aMedium = nsnull; return NS_ERROR_INVALID_ARG; } NS_IMETHODIMP_(PRBool) -HTMLStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const +nsHTMLStyleSheet::UseForMedium(nsIAtom* aMedium) const { return PR_TRUE; // works for all media } NS_IMETHODIMP_(PRBool) -HTMLStyleSheetImpl::HasRules() const +nsHTMLStyleSheet::HasRules() const { return PR_TRUE; // We have rules at all reasonable times } NS_IMETHODIMP -HTMLStyleSheetImpl::GetApplicable(PRBool& aApplicable) const +nsHTMLStyleSheet::GetApplicable(PRBool& aApplicable) const { aApplicable = PR_TRUE; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::SetEnabled(PRBool aEnabled) +nsHTMLStyleSheet::SetEnabled(PRBool aEnabled) { // these can't be disabled return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetComplete(PRBool& aComplete) const +nsHTMLStyleSheet::GetComplete(PRBool& aComplete) const { aComplete = PR_TRUE; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::SetComplete() +nsHTMLStyleSheet::SetComplete() { return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const +nsHTMLStyleSheet::GetParentSheet(nsIStyleSheet*& aParent) const { aParent = nsnull; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const +nsHTMLStyleSheet::GetOwningDocument(nsIDocument*& aDocument) const { aDocument = mDocument; NS_IF_ADDREF(aDocument); @@ -942,14 +747,14 @@ HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const } NS_IMETHODIMP -HTMLStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument) +nsHTMLStyleSheet::SetOwningDocument(nsIDocument* aDocument) { mDocument = aDocument; // not refcounted return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::Init(nsIURI* aURL, nsIDocument* aDocument) +nsresult +nsHTMLStyleSheet::Init(nsIURI* aURL, nsIDocument* aDocument) { NS_PRECONDITION(aURL && aDocument, "null ptr"); if (! aURL || ! aDocument) @@ -964,8 +769,8 @@ HTMLStyleSheetImpl::Init(nsIURI* aURL, nsIDocument* aDocument) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::Reset(nsIURI* aURL) +nsresult +nsHTMLStyleSheet::Reset(nsIURI* aURL) { NS_IF_RELEASE(mURL); mURL = aURL; @@ -996,8 +801,8 @@ HTMLStyleSheetImpl::Reset(nsIURI* aURL) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::GetLinkColor(nscolor& aColor) +nsresult +nsHTMLStyleSheet::GetLinkColor(nscolor& aColor) { if (!mLinkRule) { return NS_HTML_STYLE_PROPERTY_NOT_THERE; @@ -1008,8 +813,8 @@ HTMLStyleSheetImpl::GetLinkColor(nscolor& aColor) } } -NS_IMETHODIMP -HTMLStyleSheetImpl::GetActiveLinkColor(nscolor& aColor) +nsresult +nsHTMLStyleSheet::GetActiveLinkColor(nscolor& aColor) { if (!mActiveRule) { return NS_HTML_STYLE_PROPERTY_NOT_THERE; @@ -1020,8 +825,8 @@ HTMLStyleSheetImpl::GetActiveLinkColor(nscolor& aColor) } } -NS_IMETHODIMP -HTMLStyleSheetImpl::GetVisitedLinkColor(nscolor& aColor) +nsresult +nsHTMLStyleSheet::GetVisitedLinkColor(nscolor& aColor) { if (!mVisitedRule) { return NS_HTML_STYLE_PROPERTY_NOT_THERE; @@ -1032,8 +837,8 @@ HTMLStyleSheetImpl::GetVisitedLinkColor(nscolor& aColor) } } -NS_IMETHODIMP -HTMLStyleSheetImpl::SetLinkColor(nscolor aColor) +nsresult +nsHTMLStyleSheet::SetLinkColor(nscolor aColor) { if (mLinkRule) { if (mLinkRule->mColor == aColor) @@ -1052,8 +857,8 @@ HTMLStyleSheetImpl::SetLinkColor(nscolor aColor) } -NS_IMETHODIMP -HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor) +nsresult +nsHTMLStyleSheet::SetActiveLinkColor(nscolor aColor) { if (mActiveRule) { if (mActiveRule->mColor == aColor) @@ -1071,8 +876,8 @@ HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor) +nsresult +nsHTMLStyleSheet::SetVisitedLinkColor(nscolor aColor) { if (mVisitedRule) { if (mVisitedRule->mColor == aColor) @@ -1090,37 +895,33 @@ HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::UniqueMappedAttributes(nsMappedAttributes* aMapped, - nsMappedAttributes*& aUniqueMapped) +already_AddRefed +nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped) { - aUniqueMapped = nsnull; if (!mMappedAttrTable.ops) { PRBool res = PL_DHashTableInit(&mMappedAttrTable, &MappedAttrTable_Ops, nsnull, sizeof(MappedAttrTableEntry), 16); if (!res) { mMappedAttrTable.ops = nsnull; - return NS_ERROR_OUT_OF_MEMORY; + return nsnull; } } MappedAttrTableEntry *entry = NS_STATIC_CAST(MappedAttrTableEntry*, PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_ADD)); if (!entry) - return NS_ERROR_OUT_OF_MEMORY; + return nsnull; if (!entry->mAttributes) { // We added a new entry to the hashtable, so we have a new unique set. entry->mAttributes = aMapped; } - aUniqueMapped = entry->mAttributes; - NS_ADDREF(aUniqueMapped); - - return NS_OK; + NS_ADDREF(entry->mAttributes); // for caller + return entry->mAttributes; } -NS_IMETHODIMP -HTMLStyleSheetImpl::DropMappedAttributes(nsMappedAttributes* aMapped) +void +nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped) { - NS_ENSURE_TRUE(aMapped, NS_OK); + NS_ENSURE_TRUE(aMapped, /**/); NS_ASSERTION(mMappedAttrTable.ops, "table uninitialized"); #ifdef DEBUG @@ -1130,12 +931,10 @@ HTMLStyleSheetImpl::DropMappedAttributes(nsMappedAttributes* aMapped) PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_REMOVE); NS_ASSERTION(entryCount == mMappedAttrTable.entryCount, "not removed"); - - return NS_OK; } #ifdef DEBUG -void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const +void nsHTMLStyleSheet::List(FILE* out, PRInt32 aIndent) const { // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); @@ -1152,11 +951,11 @@ void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const // XXX For convenience and backwards compatibility nsresult -NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, nsIDocument* aDocument) { nsresult rv; - nsIHTMLStyleSheet* sheet; + nsHTMLStyleSheet* sheet; if (NS_FAILED(rv = NS_NewHTMLStyleSheet(&sheet))) return rv; @@ -1171,11 +970,11 @@ NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, nsresult -NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult) +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult) { NS_ASSERTION(aInstancePtrResult, "null out param"); - HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl(); + nsHTMLStyleSheet *it = new nsHTMLStyleSheet(); if (!it) { *aInstancePtrResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/content/html/style/src/nsHTMLStyleSheet.h b/mozilla/content/html/style/src/nsHTMLStyleSheet.h new file mode 100644 index 00000000000..802c980f4bd --- /dev/null +++ b/mozilla/content/html/style/src/nsHTMLStyleSheet.h @@ -0,0 +1,214 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * 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.org 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 nsHTMLStyleSheet_h_ +#define nsHTMLStyleSheet_h_ + +#include "nsIStyleSheet.h" +#include "nsIStyleRuleProcessor.h" +#include "nsIStyleRule.h" +#include "pldhash.h" +#include "nsCOMPtr.h" +class nsMappedAttributes; + +class nsHTMLStyleSheet : public nsIStyleSheet, public nsIStyleRuleProcessor { +public: + nsHTMLStyleSheet(void); + nsresult Init(); + + NS_DECL_ISUPPORTS + + // nsIStyleSheet api + NS_IMETHOD GetURL(nsIURI*& aURL) const; + NS_IMETHOD GetTitle(nsString& aTitle) const; + NS_IMETHOD GetType(nsString& aType) const; + NS_IMETHOD GetMediumCount(PRInt32& aCount) const; + NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const; + NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const; + NS_IMETHOD_(PRBool) HasRules() const; + NS_IMETHOD GetApplicable(PRBool& aApplicable) const; + NS_IMETHOD SetEnabled(PRBool aEnabled); + NS_IMETHOD GetComplete(PRBool& aComplete) const; + NS_IMETHOD SetComplete(); + NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null + NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const; + NS_IMETHOD SetOwningDocument(nsIDocument* aDocumemt); + NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, + nsIStyleRuleProcessor* aPrevProcessor); +#ifdef DEBUG + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; +#endif + + // nsIStyleRuleProcessor API + NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData, + nsIAtom* aMedium); + NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData, + nsIAtom* aMedium); + NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult); + NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult); + + nsresult Init(nsIURI* aURL, nsIDocument* aDocument); + nsresult Reset(nsIURI* aURL); + nsresult GetLinkColor(nscolor& aColor); + nsresult GetActiveLinkColor(nscolor& aColor); + nsresult GetVisitedLinkColor(nscolor& aColor); + nsresult SetLinkColor(nscolor aColor); + nsresult SetActiveLinkColor(nscolor aColor); + nsresult SetVisitedLinkColor(nscolor aColor); + + // Mapped Attribute management methods + already_AddRefed + UniqueMappedAttributes(nsMappedAttributes* aMapped); + void DropMappedAttributes(nsMappedAttributes* aMapped); + + +private: + // These are not supported and are not implemented! + nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy); + nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy); + + ~nsHTMLStyleSheet(); + + class HTMLColorRule; + friend class HTMLColorRule; + class HTMLColorRule : public nsIStyleRule { + public: + HTMLColorRule(nsHTMLStyleSheet* aSheet); + virtual ~HTMLColorRule(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; + + // The new mapping function. + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + + #ifdef DEBUG + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + #endif + + nscolor mColor; + nsHTMLStyleSheet* mSheet; + }; + + class GenericTableRule; + friend class GenericTableRule; + class GenericTableRule: public nsIStyleRule { + public: + GenericTableRule(nsHTMLStyleSheet* aSheet); + virtual ~GenericTableRule(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; + + // The new mapping function. + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + + #ifdef DEBUG + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + #endif + + nsHTMLStyleSheet* mSheet; // not ref-counted, cleared by content + }; + + // this rule handles , , when rules + // is set on its
inheritance + class TableTHRule; + friend class TableTHRule; + class TableTHRule: public GenericTableRule { + public: + TableTHRule(nsHTMLStyleSheet* aSheet); + virtual ~TableTHRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a
+ class TableTbodyRule; + friend class TableTbodyRule; + class TableTbodyRule: public GenericTableRule { + public: + TableTbodyRule(nsHTMLStyleSheet* aSheet); + virtual ~TableTbodyRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a when rules is set on its
+ class TableRowRule; + friend class TableRowRule; + class TableRowRule: public GenericTableRule { + public: + TableRowRule(nsHTMLStyleSheet* aSheet); + virtual ~TableRowRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a when rules is set on its
+ class TableColgroupRule; + friend class TableColgroupRule; + class TableColgroupRule: public GenericTableRule { + public: + TableColgroupRule(nsHTMLStyleSheet* aSheet); + virtual ~TableColgroupRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a when rules is set on its
+ class TableColRule; + friend class TableColRule; + class TableColRule: public GenericTableRule { + public: + TableColRule(nsHTMLStyleSheet* aSheet); + virtual ~TableColRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + nsIURI* mURL; + nsIDocument* mDocument; + HTMLColorRule* mLinkRule; + HTMLColorRule* mVisitedRule; + HTMLColorRule* mActiveRule; + HTMLColorRule* mDocumentColorRule; + TableTbodyRule* mTableTbodyRule; + TableRowRule* mTableRowRule; + TableColgroupRule* mTableColgroupRule; + TableColRule* mTableColRule; + TableTHRule* mTableTHRule; + + PLDHashTable mMappedAttrTable; +}; + +// XXX convenience method. Calls Initialize() automatically. +nsresult +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, + nsIDocument* aDocument); + +nsresult +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult); + +#endif /* !defined(nsHTMLStyleSheet_h_) */ diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 6a2cc8141fe..8ae5fedd59f 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -71,7 +71,7 @@ #include "nsXBLInsertionPoint.h" #include "nsIStyleSheet.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsIStyleRuleProcessor.h" diff --git a/mozilla/content/xml/document/src/Makefile.in b/mozilla/content/xml/document/src/Makefile.in index e8a2c91232a..895ff2ee77e 100644 --- a/mozilla/content/xml/document/src/Makefile.in +++ b/mozilla/content/xml/document/src/Makefile.in @@ -67,8 +67,8 @@ include $(topsrcdir)/config/rules.mk LOCAL_INCLUDES = \ -I$(srcdir) \ -I$(srcdir)/../../../xsl/document/src \ - -I$(srcdir)/../../../html/base/src \ -I$(srcdir)/../../../html/document/src \ + -I$(srcdir)/../../../html/style/src \ -I$(srcdir)/../../../base/src \ -I$(srcdir)/../../../xul/content/src \ $(NULL) diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index d4ebbc76702..b3edfa9a6bb 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -52,7 +52,7 @@ #include "nsIMarkupDocumentViewer.h" #include "nsIDocumentLoader.h" #include "nsHTMLParts.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsIComponentManager.h" #include "nsIDOMComment.h" diff --git a/mozilla/content/xml/document/src/nsXMLDocument.h b/mozilla/content/xml/document/src/nsXMLDocument.h index 696c0fe0571..63296432a5c 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.h +++ b/mozilla/content/xml/document/src/nsXMLDocument.h @@ -45,7 +45,7 @@ #include "nsIHttpEventSink.h" #include "nsIDOMXMLDocument.h" #include "nsIScriptContext.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLCSSStyleSheet.h" #include "nsIEventQueueService.h" diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index de93cc0a07e..83ddc62cbf9 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -83,7 +83,7 @@ #include "nsIEventListenerManager.h" #include "nsIEventStateManager.h" #include "nsIFastLoadService.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsINameSpace.h" #include "nsINameSpaceManager.h" #include "nsIObjectInputStream.h" diff --git a/mozilla/content/xul/document/src/Makefile.in b/mozilla/content/xul/document/src/Makefile.in index b0acbe2267e..9e59e4426df 100644 --- a/mozilla/content/xul/document/src/Makefile.in +++ b/mozilla/content/xul/document/src/Makefile.in @@ -75,9 +75,10 @@ FORCE_STATIC_LIB = 1 include $(topsrcdir)/config/rules.mk LOCAL_INCLUDES = -I$(srcdir)/../../../base/src \ - -I$(srcdir)/../../content/src \ - -I$(srcdir)/../../templates/src \ - -I$(srcdir)/../../../xml/document/src \ - $(NULL) + -I$(srcdir)/../../content/src \ + -I$(srcdir)/../../templates/src \ + -I$(srcdir)/../../../html/style/src/ \ + -I$(srcdir)/../../../xml/document/src \ + $(NULL) DEFINES += -D_IMPL_NS_LAYOUT diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 8c78edfcbec..21dcd3c14ca 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -64,7 +64,7 @@ #include "nsIDocument.h" #include "nsIDocumentLoader.h" #include "nsIFormControl.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsINameSpace.h" #include "nsINameSpaceManager.h" #include "nsINodeInfo.h" diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index e7a8fc409b3..dd7c1436d58 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -84,7 +84,7 @@ #include "nsIHTMLCSSStyleSheet.h" #include "nsIHTMLContent.h" #include "nsIHTMLFragmentContentSink.h" -#include "nsIHTMLStyleSheet.h" +#include "nsHTMLStyleSheet.h" #include "nsIHTMLToTextSink.h" #include "nsILayoutDebugger.h" #include "nsINameSpaceManager.h" @@ -540,7 +540,6 @@ MAKE_CTOR(CreateNameSpaceManager, nsINameSpaceManager, NS_GetNam MAKE_CTOR(CreateEventListenerManager, nsIEventListenerManager, NS_NewEventListenerManager) MAKE_CTOR(CreateDOMEventGroup, nsIDOMEventGroup, NS_NewDOMEventGroup) MAKE_CTOR(CreateDocumentViewer, nsIDocumentViewer, NS_NewDocumentViewer) -MAKE_CTOR(CreateHTMLStyleSheet, nsIHTMLStyleSheet, NS_NewHTMLStyleSheet) MAKE_CTOR(CreateCSSStyleSheet, nsICSSStyleSheet, NS_NewCSSStyleSheet) MAKE_CTOR(CreateHTMLDocument, nsIDocument, NS_NewHTMLDocument) MAKE_CTOR(CreateHTMLCSSStyleSheet, nsIHTMLCSSStyleSheet, NS_NewHTMLCSSStyleSheet) @@ -935,11 +934,6 @@ static const nsModuleComponentInfo gComponents[] = { nsnull, CreateDocumentViewer }, - { "HTML Style Sheet", - NS_HTMLSTYLESHEET_CID, - nsnull, - CreateHTMLStyleSheet }, - { "CSS Style Sheet", NS_CSS_STYLESHEET_CID, nsnull, diff --git a/mozilla/layout/html/style/src/Makefile.in b/mozilla/layout/html/style/src/Makefile.in index 1d98968aff9..35bcf6d75a5 100644 --- a/mozilla/layout/html/style/src/Makefile.in +++ b/mozilla/layout/html/style/src/Makefile.in @@ -55,7 +55,6 @@ CPPSRCS = \ $(NULL) EXPORTS = \ - nsIHTMLStyleSheet.h \ nsCSSFrameConstructor.h \ $(NULL) diff --git a/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h b/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h deleted file mode 100644 index 870a2d1a9a5..00000000000 --- a/mozilla/layout/html/style/src/nsIHTMLStyleSheet.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * 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.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef nsIHTMLStyleSheet_h___ -#define nsIHTMLStyleSheet_h___ - -#include "nsIStyleSheet.h" -#include "nsColor.h" - -class nsIAtom; -class nsString; -class nsHTMLValue; -class nsMappedAttributes; -class nsIDocument; - -// IID for the nsIHTMLStyleSheet interface {bddbd1b0-c5cc-11d1-8031-006008159b5a} -#define NS_IHTML_STYLE_SHEET_IID \ -{0xbddbd1b0, 0xc5cc, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}} - -class nsIHTMLStyleSheet : public nsIStyleSheet { -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTML_STYLE_SHEET_IID) - - NS_IMETHOD Init(nsIURI* aURL, nsIDocument* aDocument) = 0; - NS_IMETHOD Reset(nsIURI* aURL) = 0; - NS_IMETHOD GetLinkColor(nscolor& aColor) = 0; - NS_IMETHOD SetLinkColor(nscolor aColor) = 0; - NS_IMETHOD GetActiveLinkColor(nscolor& aColor) = 0; - NS_IMETHOD SetActiveLinkColor(nscolor aColor) = 0; - NS_IMETHOD GetVisitedLinkColor(nscolor& aColor) = 0; - NS_IMETHOD SetVisitedLinkColor(nscolor aColor) = 0; - - // Mapped Attribute management methods - NS_IMETHOD UniqueMappedAttributes(nsMappedAttributes* aMapped, - nsMappedAttributes*& aUniqueMapped) = 0; - NS_IMETHOD DropMappedAttributes(nsMappedAttributes* aMapped) = 0; -}; - - -// XXX convenience method. Calls Initialize() automatically. -nsresult -NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, - nsIDocument* aDocument); - -nsresult -NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult); - -#endif /* nsIHTMLStyleSheet_h___ */ diff --git a/mozilla/layout/style/nsHTMLStyleSheet.cpp b/mozilla/layout/style/nsHTMLStyleSheet.cpp index b65a7663520..1fdb693b058 100644 --- a/mozilla/layout/style/nsHTMLStyleSheet.cpp +++ b/mozilla/layout/style/nsHTMLStyleSheet.cpp @@ -27,68 +27,41 @@ * Date Modified by Description of modification * 04/20/2000 IBM Corp. OS/2 VisualAge build. */ + +#include "nsHTMLStyleSheet.h" #include "nsINameSpaceManager.h" -#include "nsIHTMLStyleSheet.h" -#include "nsCRT.h" #include "nsIAtom.h" #include "nsIURL.h" -#include "nsIServiceManager.h" #include "nsISupportsArray.h" -#include "pldhash.h" #include "nsMappedAttributes.h" #include "nsILink.h" -#include "nsIStyleRuleProcessor.h" -#include "nsIStyleRule.h" #include "nsIFrame.h" #include "nsStyleContext.h" #include "nsHTMLAtoms.h" #include "nsIPresContext.h" #include "nsIEventStateManager.h" #include "nsIDocument.h" -#include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsStyleConsts.h" -#include "nsLayoutAtoms.h" -#include "nsLayoutCID.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" #include "nsRuleWalker.h" -class HTMLColorRule : public nsIStyleRule { -public: - HTMLColorRule(nsIHTMLStyleSheet* aSheet); - virtual ~HTMLColorRule(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; - - // The new mapping function. - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); - -#ifdef DEBUG - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; -#endif - - nscolor mColor; - nsIHTMLStyleSheet* mSheet; -}; - -HTMLColorRule::HTMLColorRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::HTMLColorRule::HTMLColorRule(nsHTMLStyleSheet* aSheet) : mSheet(aSheet) { } -HTMLColorRule::~HTMLColorRule() +nsHTMLStyleSheet::HTMLColorRule::~HTMLColorRule() { } -NS_IMPL_ISUPPORTS1(HTMLColorRule, nsIStyleRule) +NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::HTMLColorRule, nsIStyleRule) NS_IMETHODIMP -HTMLColorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const +nsHTMLStyleSheet::HTMLColorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const { NS_IF_ADDREF(mSheet); aSheet = mSheet; @@ -96,7 +69,7 @@ HTMLColorRule::GetStyleSheet(nsIStyleSheet*& aSheet) const } NS_IMETHODIMP -HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData->mSID == eStyleStruct_Color) { if (aRuleData->mColorData->mColor.GetUnit() == eCSSUnit_Null) @@ -107,51 +80,32 @@ HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData) #ifdef DEBUG NS_IMETHODIMP -HTMLColorRule::List(FILE* out, PRInt32 aIndent) const +nsHTMLStyleSheet::HTMLColorRule::List(FILE* out, PRInt32 aIndent) const { return NS_OK; } #endif -class GenericTableRule: public nsIStyleRule { -public: - GenericTableRule(nsIHTMLStyleSheet* aSheet); - virtual ~GenericTableRule(); - - NS_DECL_ISUPPORTS - - NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; - - // The new mapping function. - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); - -#ifdef DEBUG - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; -#endif - - nsIHTMLStyleSheet* mSheet; // not ref-counted, cleared by content -}; - -GenericTableRule::GenericTableRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::GenericTableRule::GenericTableRule(nsHTMLStyleSheet* aSheet) { mSheet = aSheet; } -GenericTableRule::~GenericTableRule() +nsHTMLStyleSheet::GenericTableRule::~GenericTableRule() { } -NS_IMPL_ISUPPORTS1(GenericTableRule, nsIStyleRule) +NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::GenericTableRule, nsIStyleRule) NS_IMETHODIMP -GenericTableRule::GetStyleSheet(nsIStyleSheet*& aSheet) const +nsHTMLStyleSheet::GenericTableRule::GetStyleSheet(nsIStyleSheet*& aSheet) const { aSheet = mSheet; return NS_OK; } NS_IMETHODIMP -GenericTableRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::GenericTableRule::MapRuleInfoInto(nsRuleData* aRuleData) { // Nothing to do. return NS_OK; @@ -159,29 +113,18 @@ GenericTableRule::MapRuleInfoInto(nsRuleData* aRuleData) #ifdef DEBUG NS_IMETHODIMP -GenericTableRule::List(FILE* out, PRInt32 aIndent) const +nsHTMLStyleSheet::GenericTableRule::List(FILE* out, PRInt32 aIndent) const { return NS_OK; } #endif -// ----------------------------------------------------------- -// this rule handles , , when rules is set on its
inheritance -// ----------------------------------------------------------- -class TableTHRule: public GenericTableRule { -public: - TableTHRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableTHRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableTHRule::TableTHRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableTHRule::TableTHRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableTHRule::~TableTHRule() +nsHTMLStyleSheet::TableTHRule::~TableTHRule() { } @@ -201,7 +144,7 @@ static void PostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRuleDa } NS_IMETHODIMP -TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Text) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -295,23 +238,12 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct, } } -// ----------------------------------------------------------- -// this rule handles borders on a
-// ----------------------------------------------------------- -class TableTbodyRule: public GenericTableRule { -public: - TableTbodyRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableTbodyRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableTbodyRule::TableTbodyRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableTbodyRule::TableTbodyRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableTbodyRule::~TableTbodyRule() +nsHTMLStyleSheet::TableTbodyRule::~TableTbodyRule() { } @@ -324,7 +256,7 @@ static void TbodyPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aR } NS_IMETHODIMP -TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -334,23 +266,12 @@ TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData) } // ----------------------------------------------------------- -// ----------------------------------------------------------- -// this rule handles borders on a when rules is set on its
-// ----------------------------------------------------------- -class TableRowRule: public GenericTableRule { -public: - TableRowRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableRowRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableRowRule::TableRowRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableRowRule::TableRowRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableRowRule::~TableRowRule() +nsHTMLStyleSheet::TableRowRule::~TableRowRule() { } @@ -363,7 +284,7 @@ static void RowPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRul } NS_IMETHODIMP -TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -372,23 +293,12 @@ TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData) return NS_OK; } -// ----------------------------------------------------------- -// this rule handles borders on a when rules is set on its
-// ----------------------------------------------------------- -class TableColgroupRule: public GenericTableRule { -public: - TableColgroupRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableColgroupRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableColgroupRule::TableColgroupRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableColgroupRule::TableColgroupRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableColgroupRule::~TableColgroupRule() +nsHTMLStyleSheet::TableColgroupRule::~TableColgroupRule() { } @@ -401,7 +311,7 @@ static void ColgroupPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* } NS_IMETHODIMP -TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -410,23 +320,12 @@ TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData) return NS_OK; } -// ----------------------------------------------------------- -// this rule handles borders on a when rules is set on its
-// ----------------------------------------------------------- -class TableColRule: public GenericTableRule { -public: - TableColRule(nsIHTMLStyleSheet* aSheet); - virtual ~TableColRule(); - - NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); -}; - -TableColRule::TableColRule(nsIHTMLStyleSheet* aSheet) +nsHTMLStyleSheet::TableColRule::TableColRule(nsHTMLStyleSheet* aSheet) : GenericTableRule(aSheet) { } -TableColRule::~TableColRule() +nsHTMLStyleSheet::TableColRule::~TableColRule() { } @@ -439,7 +338,7 @@ static void ColPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRul } NS_IMETHODIMP -TableColRule::MapRuleInfoInto(nsRuleData* aRuleData) +nsHTMLStyleSheet::TableColRule::MapRuleInfoInto(nsRuleData* aRuleData) { if (aRuleData && aRuleData->mSID == eStyleStruct_Border) { aRuleData->mCanStoreInRuleTree = PR_FALSE; @@ -497,102 +396,8 @@ static PLDHashTableOps MappedAttrTable_Ops = { // ----------------------------------------------------------- -class HTMLStyleSheetImpl : public nsIHTMLStyleSheet, - public nsIStyleRuleProcessor { -public: - HTMLStyleSheetImpl(void); - nsresult Init(); - - NS_DECL_ISUPPORTS - - // nsIStyleSheet api - NS_IMETHOD GetURL(nsIURI*& aURL) const; - NS_IMETHOD GetTitle(nsString& aTitle) const; - NS_IMETHOD GetType(nsString& aType) const; - NS_IMETHOD GetMediumCount(PRInt32& aCount) const; - NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const; - NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const; - NS_IMETHOD_(PRBool) HasRules() const; - - NS_IMETHOD GetApplicable(PRBool& aApplicable) const; - - NS_IMETHOD SetEnabled(PRBool aEnabled); - - NS_IMETHOD GetComplete(PRBool& aComplete) const; - NS_IMETHOD SetComplete(); - - // style sheet owner info - NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null - NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const; - - NS_IMETHOD SetOwningDocument(nsIDocument* aDocumemt); - - NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, - nsIStyleRuleProcessor* aPrevProcessor); - - // nsIStyleRuleProcessor API - NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData, - nsIAtom* aMedium); - - NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData, - nsIAtom* aMedium); - - NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult); - - NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult); - - // nsIHTMLStyleSheet api - NS_IMETHOD Init(nsIURI* aURL, nsIDocument* aDocument); - NS_IMETHOD Reset(nsIURI* aURL); - NS_IMETHOD GetLinkColor(nscolor& aColor); - NS_IMETHOD GetActiveLinkColor(nscolor& aColor); - NS_IMETHOD GetVisitedLinkColor(nscolor& aColor); - NS_IMETHOD SetLinkColor(nscolor aColor); - NS_IMETHOD SetActiveLinkColor(nscolor aColor); - NS_IMETHOD SetVisitedLinkColor(nscolor aColor); - - // Mapped Attribute management methods - NS_IMETHOD UniqueMappedAttributes(nsMappedAttributes* aMapped, - nsMappedAttributes*& aUniqueMapped); - NS_IMETHOD DropMappedAttributes(nsMappedAttributes* aMapped); - -#ifdef DEBUG - virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; -#endif - -private: - // These are not supported and are not implemented! - HTMLStyleSheetImpl(const HTMLStyleSheetImpl& aCopy); - HTMLStyleSheetImpl& operator=(const HTMLStyleSheetImpl& aCopy); - -protected: - virtual ~HTMLStyleSheetImpl(); - -protected: - nsIURI* mURL; - nsIDocument* mDocument; - HTMLColorRule* mLinkRule; - HTMLColorRule* mVisitedRule; - HTMLColorRule* mActiveRule; - HTMLColorRule* mDocumentColorRule; - TableTbodyRule* mTableTbodyRule; - TableRowRule* mTableRowRule; - TableColgroupRule* mTableColgroupRule; - TableColRule* mTableColRule; - TableTHRule* mTableTHRule; - - PLDHashTable mMappedAttrTable; -}; - - -HTMLStyleSheetImpl::HTMLStyleSheetImpl(void) - : nsIHTMLStyleSheet(), - mRefCnt(0), - mURL(nsnull), +nsHTMLStyleSheet::nsHTMLStyleSheet(void) + : mURL(nsnull), mDocument(nsnull), mLinkRule(nsnull), mVisitedRule(nsnull), @@ -603,7 +408,7 @@ HTMLStyleSheetImpl::HTMLStyleSheetImpl(void) } nsresult -HTMLStyleSheetImpl::Init() +nsHTMLStyleSheet::Init() { mTableTbodyRule = new TableTbodyRule(this); if (!mTableTbodyRule) @@ -633,7 +438,7 @@ HTMLStyleSheetImpl::Init() return NS_OK; } -HTMLStyleSheetImpl::~HTMLStyleSheetImpl() +nsHTMLStyleSheet::~nsHTMLStyleSheet() { NS_IF_RELEASE(mURL); if (nsnull != mLinkRule) { @@ -676,11 +481,11 @@ HTMLStyleSheetImpl::~HTMLStyleSheetImpl() PL_DHashTableFinish(&mMappedAttrTable); } -NS_IMPL_ISUPPORTS3(HTMLStyleSheetImpl, nsIHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor) +NS_IMPL_ISUPPORTS2(nsHTMLStyleSheet, nsIStyleSheet, nsIStyleRuleProcessor) NS_IMETHODIMP -HTMLStyleSheetImpl::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, - nsIStyleRuleProcessor* /*aPrevProcessor*/) +nsHTMLStyleSheet::GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, + nsIStyleRuleProcessor* /*aPrevProcessor*/) { aProcessor = this; NS_ADDREF(aProcessor); @@ -707,8 +512,8 @@ static nsresult GetBodyColor(nsIPresContext* aPresContext, nscolor* aColor) } NS_IMETHODIMP -HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData, - nsIAtom* aMedium) +nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData, + nsIAtom* aMedium) { nsIStyledContent *styledContent = aData->mStyledContent; @@ -789,9 +594,9 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData, // Test if style is dependent on content state NS_IMETHODIMP -HTMLStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult) +nsHTMLStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult) { if (mActiveRule && (aData->mStateMask & NS_EVENT_STATE_ACTIVE) && @@ -807,9 +612,9 @@ HTMLStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData, } NS_IMETHODIMP -HTMLStyleSheetImpl::HasAttributeDependentStyle(AttributeRuleProcessorData* aData, - nsIAtom* aMedium, - nsReStyleHint* aResult) +nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult) { // Result is true for |href| changes on HTML links if we have link rules. nsIStyledContent *styledContent = aData->mStyledContent; @@ -837,8 +642,8 @@ HTMLStyleSheetImpl::HasAttributeDependentStyle(AttributeRuleProcessorData* aData NS_IMETHODIMP -HTMLStyleSheetImpl::RulesMatching(PseudoRuleProcessorData* aData, - nsIAtom* aMedium) +nsHTMLStyleSheet::RulesMatching(PseudoRuleProcessorData* aData, + nsIAtom* aMedium) { nsIAtom* pseudoTag = aData->mPseudoTag; if (pseudoTag == nsCSSAnonBoxes::tableCol) { @@ -853,7 +658,7 @@ HTMLStyleSheetImpl::RulesMatching(PseudoRuleProcessorData* aData, // nsIStyleSheet api NS_IMETHODIMP -HTMLStyleSheetImpl::GetURL(nsIURI*& aURL) const +nsHTMLStyleSheet::GetURL(nsIURI*& aURL) const { aURL = mURL; NS_IF_ADDREF(aURL); @@ -861,80 +666,80 @@ HTMLStyleSheetImpl::GetURL(nsIURI*& aURL) const } NS_IMETHODIMP -HTMLStyleSheetImpl::GetTitle(nsString& aTitle) const +nsHTMLStyleSheet::GetTitle(nsString& aTitle) const { aTitle.Truncate(); return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetType(nsString& aType) const +nsHTMLStyleSheet::GetType(nsString& aType) const { aType.Assign(NS_LITERAL_STRING("text/html")); return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetMediumCount(PRInt32& aCount) const +nsHTMLStyleSheet::GetMediumCount(PRInt32& aCount) const { aCount = 0; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const +nsHTMLStyleSheet::GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const { aMedium = nsnull; return NS_ERROR_INVALID_ARG; } NS_IMETHODIMP_(PRBool) -HTMLStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const +nsHTMLStyleSheet::UseForMedium(nsIAtom* aMedium) const { return PR_TRUE; // works for all media } NS_IMETHODIMP_(PRBool) -HTMLStyleSheetImpl::HasRules() const +nsHTMLStyleSheet::HasRules() const { return PR_TRUE; // We have rules at all reasonable times } NS_IMETHODIMP -HTMLStyleSheetImpl::GetApplicable(PRBool& aApplicable) const +nsHTMLStyleSheet::GetApplicable(PRBool& aApplicable) const { aApplicable = PR_TRUE; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::SetEnabled(PRBool aEnabled) +nsHTMLStyleSheet::SetEnabled(PRBool aEnabled) { // these can't be disabled return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetComplete(PRBool& aComplete) const +nsHTMLStyleSheet::GetComplete(PRBool& aComplete) const { aComplete = PR_TRUE; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::SetComplete() +nsHTMLStyleSheet::SetComplete() { return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const +nsHTMLStyleSheet::GetParentSheet(nsIStyleSheet*& aParent) const { aParent = nsnull; return NS_OK; } NS_IMETHODIMP -HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const +nsHTMLStyleSheet::GetOwningDocument(nsIDocument*& aDocument) const { aDocument = mDocument; NS_IF_ADDREF(aDocument); @@ -942,14 +747,14 @@ HTMLStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const } NS_IMETHODIMP -HTMLStyleSheetImpl::SetOwningDocument(nsIDocument* aDocument) +nsHTMLStyleSheet::SetOwningDocument(nsIDocument* aDocument) { mDocument = aDocument; // not refcounted return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::Init(nsIURI* aURL, nsIDocument* aDocument) +nsresult +nsHTMLStyleSheet::Init(nsIURI* aURL, nsIDocument* aDocument) { NS_PRECONDITION(aURL && aDocument, "null ptr"); if (! aURL || ! aDocument) @@ -964,8 +769,8 @@ HTMLStyleSheetImpl::Init(nsIURI* aURL, nsIDocument* aDocument) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::Reset(nsIURI* aURL) +nsresult +nsHTMLStyleSheet::Reset(nsIURI* aURL) { NS_IF_RELEASE(mURL); mURL = aURL; @@ -996,8 +801,8 @@ HTMLStyleSheetImpl::Reset(nsIURI* aURL) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::GetLinkColor(nscolor& aColor) +nsresult +nsHTMLStyleSheet::GetLinkColor(nscolor& aColor) { if (!mLinkRule) { return NS_HTML_STYLE_PROPERTY_NOT_THERE; @@ -1008,8 +813,8 @@ HTMLStyleSheetImpl::GetLinkColor(nscolor& aColor) } } -NS_IMETHODIMP -HTMLStyleSheetImpl::GetActiveLinkColor(nscolor& aColor) +nsresult +nsHTMLStyleSheet::GetActiveLinkColor(nscolor& aColor) { if (!mActiveRule) { return NS_HTML_STYLE_PROPERTY_NOT_THERE; @@ -1020,8 +825,8 @@ HTMLStyleSheetImpl::GetActiveLinkColor(nscolor& aColor) } } -NS_IMETHODIMP -HTMLStyleSheetImpl::GetVisitedLinkColor(nscolor& aColor) +nsresult +nsHTMLStyleSheet::GetVisitedLinkColor(nscolor& aColor) { if (!mVisitedRule) { return NS_HTML_STYLE_PROPERTY_NOT_THERE; @@ -1032,8 +837,8 @@ HTMLStyleSheetImpl::GetVisitedLinkColor(nscolor& aColor) } } -NS_IMETHODIMP -HTMLStyleSheetImpl::SetLinkColor(nscolor aColor) +nsresult +nsHTMLStyleSheet::SetLinkColor(nscolor aColor) { if (mLinkRule) { if (mLinkRule->mColor == aColor) @@ -1052,8 +857,8 @@ HTMLStyleSheetImpl::SetLinkColor(nscolor aColor) } -NS_IMETHODIMP -HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor) +nsresult +nsHTMLStyleSheet::SetActiveLinkColor(nscolor aColor) { if (mActiveRule) { if (mActiveRule->mColor == aColor) @@ -1071,8 +876,8 @@ HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor) +nsresult +nsHTMLStyleSheet::SetVisitedLinkColor(nscolor aColor) { if (mVisitedRule) { if (mVisitedRule->mColor == aColor) @@ -1090,37 +895,33 @@ HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor) return NS_OK; } -NS_IMETHODIMP -HTMLStyleSheetImpl::UniqueMappedAttributes(nsMappedAttributes* aMapped, - nsMappedAttributes*& aUniqueMapped) +already_AddRefed +nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped) { - aUniqueMapped = nsnull; if (!mMappedAttrTable.ops) { PRBool res = PL_DHashTableInit(&mMappedAttrTable, &MappedAttrTable_Ops, nsnull, sizeof(MappedAttrTableEntry), 16); if (!res) { mMappedAttrTable.ops = nsnull; - return NS_ERROR_OUT_OF_MEMORY; + return nsnull; } } MappedAttrTableEntry *entry = NS_STATIC_CAST(MappedAttrTableEntry*, PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_ADD)); if (!entry) - return NS_ERROR_OUT_OF_MEMORY; + return nsnull; if (!entry->mAttributes) { // We added a new entry to the hashtable, so we have a new unique set. entry->mAttributes = aMapped; } - aUniqueMapped = entry->mAttributes; - NS_ADDREF(aUniqueMapped); - - return NS_OK; + NS_ADDREF(entry->mAttributes); // for caller + return entry->mAttributes; } -NS_IMETHODIMP -HTMLStyleSheetImpl::DropMappedAttributes(nsMappedAttributes* aMapped) +void +nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped) { - NS_ENSURE_TRUE(aMapped, NS_OK); + NS_ENSURE_TRUE(aMapped, /**/); NS_ASSERTION(mMappedAttrTable.ops, "table uninitialized"); #ifdef DEBUG @@ -1130,12 +931,10 @@ HTMLStyleSheetImpl::DropMappedAttributes(nsMappedAttributes* aMapped) PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_REMOVE); NS_ASSERTION(entryCount == mMappedAttrTable.entryCount, "not removed"); - - return NS_OK; } #ifdef DEBUG -void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const +void nsHTMLStyleSheet::List(FILE* out, PRInt32 aIndent) const { // Indent for (PRInt32 index = aIndent; --index >= 0; ) fputs(" ", out); @@ -1152,11 +951,11 @@ void HTMLStyleSheetImpl::List(FILE* out, PRInt32 aIndent) const // XXX For convenience and backwards compatibility nsresult -NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, nsIDocument* aDocument) { nsresult rv; - nsIHTMLStyleSheet* sheet; + nsHTMLStyleSheet* sheet; if (NS_FAILED(rv = NS_NewHTMLStyleSheet(&sheet))) return rv; @@ -1171,11 +970,11 @@ NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, nsresult -NS_NewHTMLStyleSheet(nsIHTMLStyleSheet** aInstancePtrResult) +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult) { NS_ASSERTION(aInstancePtrResult, "null out param"); - HTMLStyleSheetImpl *it = new HTMLStyleSheetImpl(); + nsHTMLStyleSheet *it = new nsHTMLStyleSheet(); if (!it) { *aInstancePtrResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/layout/style/nsHTMLStyleSheet.h b/mozilla/layout/style/nsHTMLStyleSheet.h new file mode 100644 index 00000000000..802c980f4bd --- /dev/null +++ b/mozilla/layout/style/nsHTMLStyleSheet.h @@ -0,0 +1,214 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * 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.org 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 nsHTMLStyleSheet_h_ +#define nsHTMLStyleSheet_h_ + +#include "nsIStyleSheet.h" +#include "nsIStyleRuleProcessor.h" +#include "nsIStyleRule.h" +#include "pldhash.h" +#include "nsCOMPtr.h" +class nsMappedAttributes; + +class nsHTMLStyleSheet : public nsIStyleSheet, public nsIStyleRuleProcessor { +public: + nsHTMLStyleSheet(void); + nsresult Init(); + + NS_DECL_ISUPPORTS + + // nsIStyleSheet api + NS_IMETHOD GetURL(nsIURI*& aURL) const; + NS_IMETHOD GetTitle(nsString& aTitle) const; + NS_IMETHOD GetType(nsString& aType) const; + NS_IMETHOD GetMediumCount(PRInt32& aCount) const; + NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const; + NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const; + NS_IMETHOD_(PRBool) HasRules() const; + NS_IMETHOD GetApplicable(PRBool& aApplicable) const; + NS_IMETHOD SetEnabled(PRBool aEnabled); + NS_IMETHOD GetComplete(PRBool& aComplete) const; + NS_IMETHOD SetComplete(); + NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null + NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const; + NS_IMETHOD SetOwningDocument(nsIDocument* aDocumemt); + NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor, + nsIStyleRuleProcessor* aPrevProcessor); +#ifdef DEBUG + virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const; +#endif + + // nsIStyleRuleProcessor API + NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData, + nsIAtom* aMedium); + NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData, + nsIAtom* aMedium); + NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult); + NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData, + nsIAtom* aMedium, + nsReStyleHint* aResult); + + nsresult Init(nsIURI* aURL, nsIDocument* aDocument); + nsresult Reset(nsIURI* aURL); + nsresult GetLinkColor(nscolor& aColor); + nsresult GetActiveLinkColor(nscolor& aColor); + nsresult GetVisitedLinkColor(nscolor& aColor); + nsresult SetLinkColor(nscolor aColor); + nsresult SetActiveLinkColor(nscolor aColor); + nsresult SetVisitedLinkColor(nscolor aColor); + + // Mapped Attribute management methods + already_AddRefed + UniqueMappedAttributes(nsMappedAttributes* aMapped); + void DropMappedAttributes(nsMappedAttributes* aMapped); + + +private: + // These are not supported and are not implemented! + nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy); + nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy); + + ~nsHTMLStyleSheet(); + + class HTMLColorRule; + friend class HTMLColorRule; + class HTMLColorRule : public nsIStyleRule { + public: + HTMLColorRule(nsHTMLStyleSheet* aSheet); + virtual ~HTMLColorRule(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; + + // The new mapping function. + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + + #ifdef DEBUG + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + #endif + + nscolor mColor; + nsHTMLStyleSheet* mSheet; + }; + + class GenericTableRule; + friend class GenericTableRule; + class GenericTableRule: public nsIStyleRule { + public: + GenericTableRule(nsHTMLStyleSheet* aSheet); + virtual ~GenericTableRule(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const; + + // The new mapping function. + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + + #ifdef DEBUG + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; + #endif + + nsHTMLStyleSheet* mSheet; // not ref-counted, cleared by content + }; + + // this rule handles , , when rules + // is set on its
inheritance + class TableTHRule; + friend class TableTHRule; + class TableTHRule: public GenericTableRule { + public: + TableTHRule(nsHTMLStyleSheet* aSheet); + virtual ~TableTHRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a
+ class TableTbodyRule; + friend class TableTbodyRule; + class TableTbodyRule: public GenericTableRule { + public: + TableTbodyRule(nsHTMLStyleSheet* aSheet); + virtual ~TableTbodyRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a when rules is set on its
+ class TableRowRule; + friend class TableRowRule; + class TableRowRule: public GenericTableRule { + public: + TableRowRule(nsHTMLStyleSheet* aSheet); + virtual ~TableRowRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a when rules is set on its
+ class TableColgroupRule; + friend class TableColgroupRule; + class TableColgroupRule: public GenericTableRule { + public: + TableColgroupRule(nsHTMLStyleSheet* aSheet); + virtual ~TableColgroupRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + // this rule handles borders on a when rules is set on its
+ class TableColRule; + friend class TableColRule; + class TableColRule: public GenericTableRule { + public: + TableColRule(nsHTMLStyleSheet* aSheet); + virtual ~TableColRule(); + + NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData); + }; + + nsIURI* mURL; + nsIDocument* mDocument; + HTMLColorRule* mLinkRule; + HTMLColorRule* mVisitedRule; + HTMLColorRule* mActiveRule; + HTMLColorRule* mDocumentColorRule; + TableTbodyRule* mTableTbodyRule; + TableRowRule* mTableRowRule; + TableColgroupRule* mTableColgroupRule; + TableColRule* mTableColRule; + TableTHRule* mTableTHRule; + + PLDHashTable mMappedAttrTable; +}; + +// XXX convenience method. Calls Initialize() automatically. +nsresult +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL, + nsIDocument* aDocument); + +nsresult +NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult); + +#endif /* !defined(nsHTMLStyleSheet_h_) */