nsIDocumentObserver.h (4153B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #ifndef nsIDocumentObserver_h___ 7 #define nsIDocumentObserver_h___ 8 9 #include "mozilla/dom/RustTypes.h" 10 #include "nsIMutationObserver.h" 11 #include "nsISupports.h" 12 13 namespace mozilla { 14 15 namespace dom { 16 class Document; 17 class Element; 18 } // namespace dom 19 } // namespace mozilla 20 21 #define NS_IDOCUMENT_OBSERVER_IID \ 22 {0x71041fa3, 0x6dd7, 0x4cde, {0xbb, 0x76, 0xae, 0xcc, 0x69, 0xe1, 0x75, 0x78}} 23 24 // Document observer interface 25 class nsIDocumentObserver : public nsIMutationObserver { 26 public: 27 NS_INLINE_DECL_STATIC_IID(NS_IDOCUMENT_OBSERVER_IID) 28 29 /** 30 * Notify that a content model update is beginning. This call can be 31 * nested. 32 */ 33 virtual void BeginUpdate(mozilla::dom::Document*) = 0; 34 35 /** 36 * Notify that a content model update is finished. This call can be 37 * nested. 38 */ 39 virtual void EndUpdate(mozilla::dom::Document*) = 0; 40 41 /** 42 * Notify the observer that a document load is beginning. 43 */ 44 virtual void BeginLoad(mozilla::dom::Document*) = 0; 45 46 /** 47 * Notify the observer that a document load has finished. Note that 48 * the associated reflow of the document will be done <b>before</b> 49 * EndLoad is invoked, not after. 50 */ 51 virtual void EndLoad(mozilla::dom::Document*) = 0; 52 53 /** 54 * Notification that the state of an element has changed. (ie: gained or lost 55 * focus, became active or hovered over) 56 * 57 * This method is called automatically by elements when their state is changed 58 * (therefore there is normally no need to invoke this method directly). 59 * 60 * This notification is not sent when elements are added/removed from the 61 * document (the other notifications are used for that). 62 * 63 * @param Document The document being observed 64 * @param Element the piece of content that changed 65 * @param ElementState the element states that changed 66 */ 67 virtual void ElementStateChanged(mozilla::dom::Document*, 68 mozilla::dom::Element*, 69 mozilla::dom::ElementState) = 0; 70 }; 71 72 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \ 73 virtual void BeginUpdate(mozilla::dom::Document*) override; 74 75 #define NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \ 76 virtual void EndUpdate(mozilla::dom::Document*) override; 77 78 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \ 79 virtual void BeginLoad(mozilla::dom::Document*) override; 80 81 #define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \ 82 virtual void EndLoad(mozilla::dom::Document*) override; 83 84 #define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \ 85 virtual void ElementStateChanged(mozilla::dom::Document*, \ 86 mozilla::dom::Element*, \ 87 mozilla::dom::ElementState) override; 88 89 #define NS_DECL_NSIDOCUMENTOBSERVER \ 90 NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \ 91 NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \ 92 NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \ 93 NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \ 94 NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \ 95 NS_DECL_NSIMUTATIONOBSERVER 96 97 #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \ 98 void _class::BeginUpdate(mozilla::dom::Document*) {} \ 99 void _class::EndUpdate(mozilla::dom::Document*) {} \ 100 NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(_class) 101 102 #define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class) \ 103 void _class::BeginLoad(mozilla::dom::Document*) {} \ 104 void _class::EndLoad(mozilla::dom::Document*) {} 105 106 #define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \ 107 void _class::ElementStateChanged(mozilla::dom::Document*, \ 108 mozilla::dom::Element*, \ 109 mozilla::dom::ElementState) {} 110 111 #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \ 112 NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class) 113 114 #endif /* nsIDocumentObserver_h___ */