1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
24 * Pierre Phaneuf <pp@ludusdesign.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
41 * style sheet and style rule processor representing data from presentational
45 #ifndef nsHTMLStyleSheet_h_
46 #define nsHTMLStyleSheet_h_
48 #include "nsIStyleSheet.h"
49 #include "nsIStyleRuleProcessor.h"
50 #include "nsIStyleRule.h"
53 class nsMappedAttributes
;
55 class nsHTMLStyleSheet
: public nsIStyleSheet
, public nsIStyleRuleProcessor
{
57 nsHTMLStyleSheet(void);
63 NS_IMETHOD
GetSheetURI(nsIURI
** aSheetURL
) const;
64 NS_IMETHOD
GetBaseURI(nsIURI
** aBaseURL
) const;
65 NS_IMETHOD
GetTitle(nsString
& aTitle
) const;
66 NS_IMETHOD
GetType(nsString
& aType
) const;
67 NS_IMETHOD_(PRBool
) HasRules() const;
68 NS_IMETHOD
GetApplicable(PRBool
& aApplicable
) const;
69 NS_IMETHOD
SetEnabled(PRBool aEnabled
);
70 NS_IMETHOD
GetComplete(PRBool
& aComplete
) const;
71 NS_IMETHOD
SetComplete();
72 NS_IMETHOD
GetParentSheet(nsIStyleSheet
*& aParent
) const; // will be null
73 NS_IMETHOD
GetOwningDocument(nsIDocument
*& aDocument
) const;
74 NS_IMETHOD
SetOwningDocument(nsIDocument
* aDocumemt
);
76 virtual void List(FILE* out
= stdout
, PRInt32 aIndent
= 0) const;
79 // nsIStyleRuleProcessor API
80 NS_IMETHOD
RulesMatching(ElementRuleProcessorData
* aData
);
81 NS_IMETHOD
RulesMatching(PseudoRuleProcessorData
* aData
);
82 NS_IMETHOD
HasStateDependentStyle(StateRuleProcessorData
* aData
,
83 nsReStyleHint
* aResult
);
84 NS_IMETHOD
HasAttributeDependentStyle(AttributeRuleProcessorData
* aData
,
85 nsReStyleHint
* aResult
);
86 NS_IMETHOD
MediumFeaturesChanged(nsPresContext
* aPresContext
,
87 PRBool
* aRulesChanged
);
89 nsresult
Init(nsIURI
* aURL
, nsIDocument
* aDocument
);
90 nsresult
Reset(nsIURI
* aURL
);
91 nsresult
GetLinkColor(nscolor
& aColor
);
92 nsresult
GetActiveLinkColor(nscolor
& aColor
);
93 nsresult
GetVisitedLinkColor(nscolor
& aColor
);
94 nsresult
SetLinkColor(nscolor aColor
);
95 nsresult
SetActiveLinkColor(nscolor aColor
);
96 nsresult
SetVisitedLinkColor(nscolor aColor
);
98 // Mapped Attribute management methods
99 already_AddRefed
<nsMappedAttributes
>
100 UniqueMappedAttributes(nsMappedAttributes
* aMapped
);
101 void DropMappedAttributes(nsMappedAttributes
* aMapped
);
105 // These are not supported and are not implemented!
106 nsHTMLStyleSheet(const nsHTMLStyleSheet
& aCopy
);
107 nsHTMLStyleSheet
& operator=(const nsHTMLStyleSheet
& aCopy
);
112 friend class HTMLColorRule
;
113 class HTMLColorRule
: public nsIStyleRule
{
119 // nsIStyleRule interface
120 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
122 NS_IMETHOD
List(FILE* out
= stdout
, PRInt32 aIndent
= 0) const;
129 class GenericTableRule
;
130 friend class GenericTableRule
;
131 class GenericTableRule
: public nsIStyleRule
{
133 GenericTableRule() {}
137 // nsIStyleRule interface
138 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
140 NS_IMETHOD
List(FILE* out
= stdout
, PRInt32 aIndent
= 0) const;
144 // this rule handles <th> inheritance
146 friend class TableTHRule
;
147 class TableTHRule
: public GenericTableRule
{
151 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
154 // this rule handles borders on a <thead>, <tbody>, <tfoot> when rules
155 // is set on its <table>
156 class TableTbodyRule
;
157 friend class TableTbodyRule
;
158 class TableTbodyRule
: public GenericTableRule
{
162 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
165 // this rule handles borders on a <row> when rules is set on its <table>
167 friend class TableRowRule
;
168 class TableRowRule
: public GenericTableRule
{
172 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
175 // this rule handles borders on a <colgroup> when rules is set on its <table>
176 class TableColgroupRule
;
177 friend class TableColgroupRule
;
178 class TableColgroupRule
: public GenericTableRule
{
180 TableColgroupRule() {}
182 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
185 // this rule handles borders on a <col> when rules is set on its <table>.
186 // This should only be used for <col>s which are in a colgroup or anonymous
189 friend class TableColRule
;
190 class TableColRule
: public GenericTableRule
{
194 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
197 // this rule handles borders on a <col> when rules is set on its <table>.
198 // This should only be used for <col>s which are not in a colgroup.
199 class TableUngroupedColRule
;
200 friend class TableUngroupedColRule
;
201 class TableUngroupedColRule
: public GenericTableRule
{
203 TableUngroupedColRule() {}
205 NS_IMETHOD
MapRuleInfoInto(nsRuleData
* aRuleData
);
209 nsIDocument
* mDocument
;
210 HTMLColorRule
* mLinkRule
;
211 HTMLColorRule
* mVisitedRule
;
212 HTMLColorRule
* mActiveRule
;
213 HTMLColorRule
* mDocumentColorRule
;
214 TableTbodyRule
* mTableTbodyRule
;
215 TableRowRule
* mTableRowRule
;
216 TableColgroupRule
* mTableColgroupRule
;
217 TableColRule
* mTableColRule
;
218 TableUngroupedColRule
* mTableUngroupedColRule
;
219 TableTHRule
* mTableTHRule
;
221 PLDHashTable mMappedAttrTable
;
224 // XXX convenience method. Calls Initialize() automatically.
226 NS_NewHTMLStyleSheet(nsHTMLStyleSheet
** aInstancePtrResult
, nsIURI
* aURL
,
227 nsIDocument
* aDocument
);
230 NS_NewHTMLStyleSheet(nsHTMLStyleSheet
** aInstancePtrResult
);
232 #endif /* !defined(nsHTMLStyleSheet_h_) */