Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / layout / style / nsIStyleRuleProcessor.h
blobf64897b3c8d317a3617413aefd883a4113036baa
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * internal abstract interface for containers (roughly origins within
41 * the CSS cascade) that provide style rules matching an element or
42 * pseudo-element
45 #ifndef nsIStyleRuleProcessor_h___
46 #define nsIStyleRuleProcessor_h___
48 #include "nsISupports.h"
49 #include "nsChangeHint.h"
50 #include "nsIContent.h"
52 struct RuleProcessorData;
53 struct ElementRuleProcessorData;
54 struct PseudoElementRuleProcessorData;
55 struct AnonBoxRuleProcessorData;
56 #ifdef MOZ_XUL
57 struct XULTreeRuleProcessorData;
58 #endif
59 struct StateRuleProcessorData;
60 struct AttributeRuleProcessorData;
61 class nsPresContext;
63 // IID for the nsIStyleRuleProcessor interface
64 // {b8e44bbe-aaac-4125-8ab2-0f42802e14ad}
65 #define NS_ISTYLE_RULE_PROCESSOR_IID \
66 { 0xb8e44bbe, 0xaaac, 0x4125, \
67 { 0x8a, 0xb2, 0x0f, 0x42, 0x80, 0x2e, 0x14, 0xad } }
70 /* The style rule processor interface is a mechanism to separate the matching
71 * of style rules from style sheet instances.
72 * Simple style sheets can and will act as their own processor.
73 * Sheets where rule ordering interlaces between multiple sheets, will need to
74 * share a single rule processor between them (CSS sheets do this for cascading order)
76 * @see nsIStyleRule (for significantly more detailed comments)
78 class nsIStyleRuleProcessor : public nsISupports {
79 public:
80 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
82 // Shorthand for:
83 // nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
84 typedef PRBool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
86 /**
87 * Find the |nsIStyleRule|s matching the given content node and
88 * position the given |nsRuleWalker| at the |nsRuleNode| in the rule
89 * tree representing that ordered list of rules (with higher
90 * precedence being farther from the root of the lexicographic tree).
92 virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
94 /**
95 * Just like the previous |RulesMatching|, except for a given content
96 * node <em>and pseudo-element</em>.
98 virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
101 * Just like the previous |RulesMatching|, except for a given anonymous box.
103 virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
105 #ifdef MOZ_XUL
107 * Just like the previous |RulesMatching|, except for a given content
108 * node <em>and tree pseudo</em>.
110 virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
111 #endif
114 * Return whether style can depend on a change of the given document state.
116 * Document states are defined in nsIDocument.h.
118 virtual PRBool
119 HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
122 * Return how (as described by nsRestyleHint) style can depend on a
123 * change of the given content state on the given content node. This
124 * test is used for optimization only, and may err on the side of
125 * reporting more dependencies than really exist.
127 * Event states are defined in nsIEventStateManager.h.
129 virtual nsRestyleHint
130 HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
133 * This method will be called twice for every attribute change.
134 * During the first call, aData->mAttrHasChanged will be false and
135 * the attribute change will not have happened yet. During the
136 * second call, aData->mAttrHasChanged will be true and the
137 * change will have already happened. The bitwise OR of the two
138 * return values must describe the style changes that are needed due
139 * to the attribute change. It's up to the rule processor
140 * implementation to decide how to split the bits up amongst the two
141 * return values. For example, it could return the bits needed by
142 * rules that might stop matching the node from the first call and
143 * the bits needed by rules that might have started matching the
144 * node from the second call. This test is used for optimization
145 * only, and may err on the side of reporting more dependencies than
146 * really exist.
148 virtual nsRestyleHint
149 HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
152 * Do any processing that needs to happen as a result of a change in
153 * the characteristics of the medium, and return whether this rule
154 * processor's rules have changed (e.g., because of media queries).
156 virtual PRBool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
159 NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
160 NS_ISTYLE_RULE_PROCESSOR_IID)
162 #endif /* nsIStyleRuleProcessor_h___ */