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
4 : *
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/
9 : *
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.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
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.
21 : *
22 : * Contributor(s):
23 : * L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
24 : *
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.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : /*
40 : * internal abstract interface for containers (roughly origins within
41 : * the CSS cascade) that provide style rules matching an element or
42 : * pseudo-element
43 : */
44 :
45 : #ifndef nsIStyleRuleProcessor_h___
46 : #define nsIStyleRuleProcessor_h___
47 :
48 : #include "nsISupports.h"
49 : #include "nsChangeHint.h"
50 : #include "nsIContent.h"
51 :
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;
62 :
63 : // IID for the nsIStyleRuleProcessor interface
64 : // {c1d6001e-4fcb-4c40-bce1-5eba80bfd8f3}
65 : #define NS_ISTYLE_RULE_PROCESSOR_IID \
66 : { 0xc1d6001e, 0x4fcb, 0x4c40, \
67 : {0xbc, 0xe1, 0x5e, 0xba, 0x80, 0xbf, 0xd8, 0xf3} }
68 :
69 :
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)
75 : *
76 : * @see nsIStyleRule (for significantly more detailed comments)
77 : */
78 938 : class nsIStyleRuleProcessor : public nsISupports {
79 : public:
80 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
81 :
82 : // Shorthand for:
83 : // nsCOMArray<nsIStyleRuleProcessor>::nsCOMArrayEnumFunc
84 : typedef bool (* EnumFunc)(nsIStyleRuleProcessor*, void*);
85 :
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).
91 : */
92 : virtual void RulesMatching(ElementRuleProcessorData* aData) = 0;
93 :
94 : /**
95 : * Just like the previous |RulesMatching|, except for a given content
96 : * node <em>and pseudo-element</em>.
97 : */
98 : virtual void RulesMatching(PseudoElementRuleProcessorData* aData) = 0;
99 :
100 : /**
101 : * Just like the previous |RulesMatching|, except for a given anonymous box.
102 : */
103 : virtual void RulesMatching(AnonBoxRuleProcessorData* aData) = 0;
104 :
105 : #ifdef MOZ_XUL
106 : /**
107 : * Just like the previous |RulesMatching|, except for a given content
108 : * node <em>and tree pseudo</em>.
109 : */
110 : virtual void RulesMatching(XULTreeRuleProcessorData* aData) = 0;
111 : #endif
112 :
113 : /**
114 : * Return whether style can depend on a change of the given document state.
115 : *
116 : * Document states are defined in nsIDocument.h.
117 : */
118 : virtual bool
119 : HasDocumentStateDependentStyle(StateRuleProcessorData* aData) = 0;
120 :
121 : /**
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.
126 : *
127 : * Event states are defined in nsEventStates.h.
128 : */
129 : virtual nsRestyleHint
130 : HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
131 :
132 : /**
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.
147 : */
148 : virtual nsRestyleHint
149 : HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
150 :
151 : /**
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).
155 : */
156 : virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) = 0;
157 :
158 : /**
159 : * Report the size of this style rule processor to about:memory. A
160 : * processor may return 0.
161 : */
162 : virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0;
163 : virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0;
164 : };
165 :
166 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor,
167 : NS_ISTYLE_RULE_PROCESSOR_IID)
168 :
169 : #endif /* nsIStyleRuleProcessor_h___ */
|