Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / layout / style / nsHTMLStyleSheet.h
blobd0727af34da649a0e53550876c98a26101f1e271
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
14 * License.
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.
23 * Contributor(s):
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
42 * HTML attributes
45 #ifndef nsHTMLStyleSheet_h_
46 #define nsHTMLStyleSheet_h_
48 #include "nsIStyleSheet.h"
49 #include "nsIStyleRuleProcessor.h"
50 #include "nsIStyleRule.h"
51 #include "pldhash.h"
52 #include "nsCOMPtr.h"
53 class nsMappedAttributes;
55 class nsHTMLStyleSheet : public nsIStyleSheet, public nsIStyleRuleProcessor {
56 public:
57 nsHTMLStyleSheet(void);
58 nsresult Init();
60 NS_DECL_ISUPPORTS
62 // nsIStyleSheet api
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);
75 #ifdef DEBUG
76 virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
77 #endif
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);
104 private:
105 // These are not supported and are not implemented!
106 nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy);
107 nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy);
109 ~nsHTMLStyleSheet();
111 class HTMLColorRule;
112 friend class HTMLColorRule;
113 class HTMLColorRule : public nsIStyleRule {
114 public:
115 HTMLColorRule() {}
117 NS_DECL_ISUPPORTS
119 // nsIStyleRule interface
120 NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
121 #ifdef DEBUG
122 NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
123 #endif
125 nscolor mColor;
129 class GenericTableRule;
130 friend class GenericTableRule;
131 class GenericTableRule: public nsIStyleRule {
132 public:
133 GenericTableRule() {}
135 NS_DECL_ISUPPORTS
137 // nsIStyleRule interface
138 NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
139 #ifdef DEBUG
140 NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
141 #endif
144 // this rule handles <th> inheritance
145 class TableTHRule;
146 friend class TableTHRule;
147 class TableTHRule: public GenericTableRule {
148 public:
149 TableTHRule() {}
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 {
159 public:
160 TableTbodyRule() {}
162 NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
165 // this rule handles borders on a <row> when rules is set on its <table>
166 class TableRowRule;
167 friend class TableRowRule;
168 class TableRowRule: public GenericTableRule {
169 public:
170 TableRowRule() {}
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 {
179 public:
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
187 // cols.
188 class TableColRule;
189 friend class TableColRule;
190 class TableColRule: public GenericTableRule {
191 public:
192 TableColRule() {}
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 {
202 public:
203 TableUngroupedColRule() {}
205 NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
208 nsIURI* mURL;
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.
225 nsresult
226 NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult, nsIURI* aURL,
227 nsIDocument* aDocument);
229 nsresult
230 NS_NewHTMLStyleSheet(nsHTMLStyleSheet** aInstancePtrResult);
232 #endif /* !defined(nsHTMLStyleSheet_h_) */