content/base/public/nsIDocumentObserver.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial