Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / nsIDocumentObserver.h
blobe30a61639d9b9633bd9fc1c5c46a180f8f8a4890
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsIDocumentObserver_h___
6 #define nsIDocumentObserver_h___
8 #include "mozilla/EventStates.h"
9 #include "nsISupports.h"
10 #include "nsIMutationObserver.h"
12 class nsIAtom;
13 class nsIContent;
14 class nsIStyleSheet;
15 class nsIStyleRule;
16 class nsString;
17 class nsIDocument;
19 #define NS_IDOCUMENT_OBSERVER_IID \
20 { 0x900bc4bc, 0x8b6c, 0x4cba, \
21 { 0x82, 0xfa, 0x56, 0x8a, 0x80, 0xff, 0xfd, 0x3e } }
23 typedef uint32_t nsUpdateType;
25 #define UPDATE_CONTENT_MODEL 0x00000001
26 #define UPDATE_STYLE 0x00000002
27 #define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE)
29 // Document observer interface
30 class nsIDocumentObserver : public nsIMutationObserver
32 public:
33 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
35 /**
36 * Notify that a content model update is beginning. This call can be
37 * nested.
39 virtual void BeginUpdate(nsIDocument *aDocument,
40 nsUpdateType aUpdateType) = 0;
42 /**
43 * Notify that a content model update is finished. This call can be
44 * nested.
46 virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
48 /**
49 * Notify the observer that a document load is beginning.
51 virtual void BeginLoad(nsIDocument *aDocument) = 0;
53 /**
54 * Notify the observer that a document load has finished. Note that
55 * the associated reflow of the document will be done <b>before</b>
56 * EndLoad is invoked, not after.
58 virtual void EndLoad(nsIDocument *aDocument) = 0;
60 /**
61 * Notification that the state of a content node has changed.
62 * (ie: gained or lost focus, became active or hovered over)
63 * This method is called automatically by content objects
64 * when their state is changed (therefore there is normally
65 * no need to invoke this method directly). The notification
66 * is passed to any IDocumentObservers. The notification is
67 * passed on to all of the document observers. <p>
69 * This notification is not sent when a piece of content is
70 * added/removed from the document or the content itself changed
71 * (the other notifications are used for that).
73 * @param aDocument The document being observed
74 * @param aContent the piece of content that changed
76 virtual void ContentStateChanged(nsIDocument* aDocument,
77 nsIContent* aContent,
78 mozilla::EventStates aStateMask) = 0;
80 /**
81 * Notification that the state of the document has changed.
83 * @param aDocument The document being observed
84 * @param aStateMask the state that changed
86 virtual void DocumentStatesChanged(nsIDocument* aDocument,
87 mozilla::EventStates aStateMask) = 0;
89 /**
90 * A StyleSheet has just been added to the document. This method is
91 * called automatically when a StyleSheet gets added to the
92 * document, even if the stylesheet is not applicable. The
93 * notification is passed on to all of the document observers.
95 * @param aDocument The document being observed
96 * @param aStyleSheet the StyleSheet that has been added
97 * @param aDocumentSheet True if sheet is in document's style sheet list,
98 * false if sheet is not (i.e., UA or user sheet)
100 virtual void StyleSheetAdded(nsIDocument *aDocument,
101 nsIStyleSheet* aStyleSheet,
102 bool aDocumentSheet) = 0;
105 * A StyleSheet has just been removed from the document. This
106 * method is called automatically when a StyleSheet gets removed
107 * from the document, even if the stylesheet is not applicable. The
108 * notification is passed on to all of the document observers.
110 * @param aDocument The document being observed
111 * @param aStyleSheet the StyleSheet that has been removed
112 * @param aDocumentSheet True if sheet is in document's style sheet list,
113 * false if sheet is not (i.e., UA or user sheet)
115 virtual void StyleSheetRemoved(nsIDocument *aDocument,
116 nsIStyleSheet* aStyleSheet,
117 bool aDocumentSheet) = 0;
120 * A StyleSheet has just changed its applicable state.
121 * This method is called automatically when the applicable state
122 * of a StyleSheet gets changed. The style sheet passes this
123 * notification to the document. The notification is passed on
124 * to all of the document observers.
126 * @param aDocument The document being observed
127 * @param aStyleSheet the StyleSheet that has changed state
128 * @param aApplicable true if the sheet is applicable, false if
129 * it is not applicable
131 virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
132 nsIStyleSheet* aStyleSheet,
133 bool aApplicable) = 0;
136 * A StyleRule has just been modified within a style sheet.
137 * This method is called automatically when the rule gets
138 * modified. The style sheet passes this notification to
139 * the document. The notification is passed on to all of
140 * the document observers.
142 * Since nsIStyleRule objects are immutable, there is a new object
143 * replacing the old one. However, the use of this method (rather
144 * than StyleRuleAdded and StyleRuleRemoved) implies that the new rule
145 * matches the same elements and has the same priority (weight,
146 * origin, specificity) as the old one. (However, if it is a CSS
147 * style rule, there may be a change in whether it has an important
148 * rule.)
150 * @param aDocument The document being observed
151 * @param aStyleSheet the StyleSheet that contians the rule
152 * @param aOldStyleRule The rule being removed. This rule may not be
153 * fully valid anymore -- however, it can still
154 * be used for pointer comparison and
155 * |QueryInterface|.
156 * @param aNewStyleRule The rule being added.
158 virtual void StyleRuleChanged(nsIDocument *aDocument,
159 nsIStyleSheet* aStyleSheet,
160 nsIStyleRule* aOldStyleRule,
161 nsIStyleRule* aNewStyleRule) = 0;
164 * A StyleRule has just been added to a style sheet.
165 * This method is called automatically when the rule gets
166 * added to the sheet. The style sheet passes this
167 * notification to the document. The notification is passed on
168 * to all of the document observers.
170 * @param aDocument The document being observed
171 * @param aStyleSheet the StyleSheet that has been modified
172 * @param aStyleRule the rule that was added
174 virtual void StyleRuleAdded(nsIDocument *aDocument,
175 nsIStyleSheet* aStyleSheet,
176 nsIStyleRule* aStyleRule) = 0;
179 * A StyleRule has just been removed from a style sheet.
180 * This method is called automatically when the rule gets
181 * removed from the sheet. The style sheet passes this
182 * notification to the document. The notification is passed on
183 * to all of the document observers.
185 * @param aDocument The document being observed
186 * @param aStyleSheet the StyleSheet that has been modified
187 * @param aStyleRule the rule that was removed
189 virtual void StyleRuleRemoved(nsIDocument *aDocument,
190 nsIStyleSheet* aStyleSheet,
191 nsIStyleRule* aStyleRule) = 0;
194 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
196 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
197 virtual void BeginUpdate(nsIDocument* aDocument, \
198 nsUpdateType aUpdateType) MOZ_OVERRIDE;
200 #define NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
201 virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) MOZ_OVERRIDE;
203 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
204 virtual void BeginLoad(nsIDocument* aDocument) MOZ_OVERRIDE;
206 #define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
207 virtual void EndLoad(nsIDocument* aDocument) MOZ_OVERRIDE;
209 #define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
210 virtual void ContentStateChanged(nsIDocument* aDocument, \
211 nsIContent* aContent, \
212 mozilla::EventStates aStateMask) MOZ_OVERRIDE;
214 #define NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
215 virtual void DocumentStatesChanged(nsIDocument* aDocument, \
216 mozilla::EventStates aStateMask) MOZ_OVERRIDE;
218 #define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
219 virtual void StyleSheetAdded(nsIDocument* aDocument, \
220 nsIStyleSheet* aStyleSheet, \
221 bool aDocumentSheet) MOZ_OVERRIDE;
223 #define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
224 virtual void StyleSheetRemoved(nsIDocument* aDocument, \
225 nsIStyleSheet* aStyleSheet, \
226 bool aDocumentSheet) MOZ_OVERRIDE;
228 #define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
229 virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
230 nsIStyleSheet* aStyleSheet,\
231 bool aApplicable) MOZ_OVERRIDE;
233 #define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
234 virtual void StyleRuleChanged(nsIDocument* aDocument, \
235 nsIStyleSheet* aStyleSheet, \
236 nsIStyleRule* aOldStyleRule, \
237 nsIStyleRule* aNewStyleRule) MOZ_OVERRIDE;
239 #define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
240 virtual void StyleRuleAdded(nsIDocument* aDocument, \
241 nsIStyleSheet* aStyleSheet, \
242 nsIStyleRule* aStyleRule) MOZ_OVERRIDE;
244 #define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
245 virtual void StyleRuleRemoved(nsIDocument* aDocument, \
246 nsIStyleSheet* aStyleSheet, \
247 nsIStyleRule* aStyleRule) MOZ_OVERRIDE;
249 #define NS_DECL_NSIDOCUMENTOBSERVER \
250 NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
251 NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
252 NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
253 NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
254 NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
255 NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
256 NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
257 NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
258 NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
259 NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
260 NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
261 NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
262 NS_DECL_NSIMUTATIONOBSERVER
265 #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \
266 void \
267 _class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
270 void \
271 _class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
274 NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(_class)
276 #define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class) \
277 void \
278 _class::BeginLoad(nsIDocument* aDocument) \
281 void \
282 _class::EndLoad(nsIDocument* aDocument) \
286 #define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
287 void \
288 _class::ContentStateChanged(nsIDocument* aDocument, \
289 nsIContent* aContent, \
290 mozilla::EventStates aStateMask) \
294 void \
295 _class::DocumentStatesChanged(nsIDocument* aDocument, \
296 mozilla::EventStates aStateMask) \
300 #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \
301 NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
303 #define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
304 void \
305 _class::StyleSheetAdded(nsIDocument* aDocument, \
306 nsIStyleSheet* aStyleSheet, \
307 bool aDocumentSheet) \
310 void \
311 _class::StyleSheetRemoved(nsIDocument* aDocument, \
312 nsIStyleSheet* aStyleSheet, \
313 bool aDocumentSheet) \
316 void \
317 _class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
318 nsIStyleSheet* aStyleSheet, \
319 bool aApplicable) \
322 void \
323 _class::StyleRuleChanged(nsIDocument* aDocument, \
324 nsIStyleSheet* aStyleSheet, \
325 nsIStyleRule* aOldStyleRule, \
326 nsIStyleRule* aNewStyleRule) \
329 void \
330 _class::StyleRuleAdded(nsIDocument* aDocument, \
331 nsIStyleSheet* aStyleSheet, \
332 nsIStyleRule* aStyleRule) \
335 void \
336 _class::StyleRuleRemoved(nsIDocument* aDocument, \
337 nsIStyleSheet* aStyleSheet, \
338 nsIStyleRule* aStyleRule) \
342 #endif /* nsIDocumentObserver_h___ */