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___
9 #include "mozilla/EventStates.h"
10 #include "mozilla/StyleSheet.h"
11 #include "nsISupports.h"
12 #include "nsIMutationObserver.h"
19 } // namespace mozilla
21 #define NS_IDOCUMENT_OBSERVER_IID \
23 0x71041fa3, 0x6dd7, 0x4cde, { \
24 0xbb, 0x76, 0xae, 0xcc, 0x69, 0xe1, 0x75, 0x78 \
28 // Document observer interface
29 class nsIDocumentObserver
: public nsIMutationObserver
{
31 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID
)
34 * Notify that a content model update is beginning. This call can be
37 virtual void BeginUpdate(mozilla::dom::Document
*) = 0;
40 * Notify that a content model update is finished. This call can be
43 virtual void EndUpdate(mozilla::dom::Document
*) = 0;
46 * Notify the observer that a document load is beginning.
48 virtual void BeginLoad(mozilla::dom::Document
*) = 0;
51 * Notify the observer that a document load has finished. Note that
52 * the associated reflow of the document will be done <b>before</b>
53 * EndLoad is invoked, not after.
55 virtual void EndLoad(mozilla::dom::Document
*) = 0;
58 * Notification that the state of a content node has changed.
59 * (ie: gained or lost focus, became active or hovered over)
60 * This method is called automatically by content objects
61 * when their state is changed (therefore there is normally
62 * no need to invoke this method directly). The notification
63 * is passed to any IDocumentObservers. The notification is
64 * passed on to all of the document observers. <p>
66 * This notification is not sent when a piece of content is
67 * added/removed from the document or the content itself changed
68 * (the other notifications are used for that).
70 * @param aDocument The document being observed
71 * @param aContent the piece of content that changed
73 virtual void ContentStateChanged(mozilla::dom::Document
*,
75 mozilla::EventStates aStateMask
) = 0;
78 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver
, NS_IDOCUMENT_OBSERVER_IID
)
80 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
81 virtual void BeginUpdate(mozilla::dom::Document*) override;
83 #define NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
84 virtual void EndUpdate(mozilla::dom::Document*) override;
86 #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
87 virtual void BeginLoad(mozilla::dom::Document*) override;
89 #define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
90 virtual void EndLoad(mozilla::dom::Document*) override;
92 #define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
93 virtual void ContentStateChanged(mozilla::dom::Document*, \
94 nsIContent* aContent, \
95 mozilla::EventStates aStateMask) override;
97 #define NS_DECL_NSIDOCUMENTOBSERVER \
98 NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
99 NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
100 NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
101 NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
102 NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
103 NS_DECL_NSIMUTATIONOBSERVER
105 #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \
106 void _class::BeginUpdate(mozilla::dom::Document*) {} \
107 void _class::EndUpdate(mozilla::dom::Document*) {} \
108 NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(_class)
110 #define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class) \
111 void _class::BeginLoad(mozilla::dom::Document*) {} \
112 void _class::EndLoad(mozilla::dom::Document*) {}
114 #define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
115 void _class::ContentStateChanged(mozilla::dom::Document*, \
116 nsIContent* aContent, \
117 mozilla::EventStates aStateMask) {}
119 #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \
120 NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
122 #endif /* nsIDocumentObserver_h___ */