LCOV - code coverage report
Current view: top level - dom/base - nsIDocumentObserver.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/EventStates.h"
      10             : #include "mozilla/StyleSheet.h"
      11             : #include "nsISupports.h"
      12             : #include "nsIMutationObserver.h"
      13             : 
      14             : class nsIContent;
      15             : class nsIDocument;
      16             : 
      17             : namespace mozilla {
      18             : namespace css {
      19             : class Rule;
      20             : } // namespace css
      21             : } // namespace mozilla
      22             : 
      23             : #define NS_IDOCUMENT_OBSERVER_IID \
      24             : { 0x71041fa3, 0x6dd7, 0x4cde, \
      25             :   { 0xbb, 0x76, 0xae, 0xcc, 0x69, 0xe1, 0x75, 0x78 } }
      26             : 
      27             : typedef uint32_t nsUpdateType;
      28             : 
      29             : #define UPDATE_CONTENT_MODEL 0x00000001
      30             : #define UPDATE_STYLE         0x00000002
      31             : #define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE)
      32             : 
      33             : // Document observer interface
      34          76 : class nsIDocumentObserver : public nsIMutationObserver
      35             : {
      36             : public:
      37             :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
      38             : 
      39             :   /**
      40             :    * Notify that a content model update is beginning. This call can be
      41             :    * nested.
      42             :    */
      43             :   virtual void BeginUpdate(nsIDocument *aDocument,
      44             :                            nsUpdateType aUpdateType) = 0;
      45             : 
      46             :   /**
      47             :    * Notify that a content model update is finished. This call can be
      48             :    * nested.
      49             :    */
      50             :   virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
      51             : 
      52             :   /**
      53             :    * Notify the observer that a document load is beginning.
      54             :    */
      55             :   virtual void BeginLoad(nsIDocument *aDocument) = 0;
      56             : 
      57             :   /**
      58             :    * Notify the observer that a document load has finished. Note that
      59             :    * the associated reflow of the document will be done <b>before</b>
      60             :    * EndLoad is invoked, not after.
      61             :    */
      62             :   virtual void EndLoad(nsIDocument *aDocument) = 0;
      63             : 
      64             :   /**
      65             :    * Notification that the state of a content node has changed.
      66             :    * (ie: gained or lost focus, became active or hovered over)
      67             :    * This method is called automatically by content objects
      68             :    * when their state is changed (therefore there is normally
      69             :    * no need to invoke this method directly).  The notification
      70             :    * is passed to any IDocumentObservers. The notification is
      71             :    * passed on to all of the document observers. <p>
      72             :    *
      73             :    * This notification is not sent when a piece of content is
      74             :    * added/removed from the document or the content itself changed
      75             :    * (the other notifications are used for that).
      76             :    *
      77             :    * @param aDocument The document being observed
      78             :    * @param aContent the piece of content that changed
      79             :    */
      80             :   virtual void ContentStateChanged(nsIDocument* aDocument,
      81             :                                    nsIContent* aContent,
      82             :                                    mozilla::EventStates aStateMask) = 0;
      83             : 
      84             :   /**
      85             :    * Notification that the state of the document has changed.
      86             :    *
      87             :    * @param aDocument The document being observed
      88             :    * @param aStateMask the state that changed
      89             :    */
      90             :   virtual void DocumentStatesChanged(nsIDocument* aDocument,
      91             :                                      mozilla::EventStates aStateMask) = 0;
      92             : 
      93             :   /**
      94             :    * A StyleSheet has just been added to the document.  This method is
      95             :    * called automatically when a StyleSheet gets added to the
      96             :    * document, even if the stylesheet is not applicable. The
      97             :    * notification is passed on to all of the document observers.
      98             :    *
      99             :    * @param aStyleSheet the StyleSheet that has been added
     100             :    * @param aDocumentSheet True if sheet is in document's style sheet list,
     101             :    *                       false if sheet is not (i.e., UA or user sheet)
     102             :    */
     103             :   virtual void StyleSheetAdded(mozilla::StyleSheet* aStyleSheet,
     104             :                                bool aDocumentSheet) = 0;
     105             : 
     106             :   /**
     107             :    * A StyleSheet has just been removed from the document.  This
     108             :    * method is called automatically when a StyleSheet gets removed
     109             :    * from the document, even if the stylesheet is not applicable. The
     110             :    * notification is passed on to all of the document observers.
     111             :    *
     112             :    * @param aStyleSheet the StyleSheet that has been removed
     113             :    * @param aDocumentSheet True if sheet is in document's style sheet list,
     114             :    *                       false if sheet is not (i.e., UA or user sheet)
     115             :    */
     116             :   virtual void StyleSheetRemoved(mozilla::StyleSheet* aStyleSheet,
     117             :                                  bool aDocumentSheet) = 0;
     118             : 
     119             :   /**
     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.
     125             :    *
     126             :    * @param aStyleSheet the StyleSheet that has changed state
     127             :    */
     128             :   virtual void StyleSheetApplicableStateChanged(mozilla::StyleSheet* aStyleSheet) = 0;
     129             : 
     130             :   /**
     131             :    * A StyleRule has just been modified within a style sheet.
     132             :    * This method is called automatically when the rule gets
     133             :    * modified. The style sheet passes this notification to
     134             :    * the document. The notification is passed on to all of
     135             :    * the document observers.
     136             :    *
     137             :    * @param aStyleSheet the StyleSheet that contians the rule
     138             :    * @param aStyleRule the changed rule
     139             :    */
     140             :   virtual void StyleRuleChanged(mozilla::StyleSheet* aStyleSheet,
     141             :                                 mozilla::css::Rule* aStyleRule) = 0;
     142             : 
     143             :   /**
     144             :    * A StyleRule has just been added to a style sheet.
     145             :    * This method is called automatically when the rule gets
     146             :    * added to the sheet. The style sheet passes this
     147             :    * notification to the document. The notification is passed on
     148             :    * to all of the document observers.
     149             :    *
     150             :    * @param aStyleSheet the StyleSheet that has been modified
     151             :    * @param aStyleRule the added rule
     152             :    */
     153             :   virtual void StyleRuleAdded(mozilla::StyleSheet* aStyleSheet,
     154             :                               mozilla::css::Rule* aStyleRule) = 0;
     155             : 
     156             :   /**
     157             :    * A StyleRule has just been removed from a style sheet.
     158             :    * This method is called automatically when the rule gets
     159             :    * removed from the sheet. The style sheet passes this
     160             :    * notification to the document. The notification is passed on
     161             :    * to all of the document observers.
     162             :    *
     163             :    * @param aStyleSheet the StyleSheet that has been modified
     164             :    * @param aStyleRule the removed rule
     165             :    */
     166             :   virtual void StyleRuleRemoved(mozilla::StyleSheet* aStyleSheet,
     167             :                                 mozilla::css::Rule* aStyleRule) = 0;
     168             : };
     169             : 
     170             : NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
     171             : 
     172             : #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE                              \
     173             :     virtual void BeginUpdate(nsIDocument* aDocument,                         \
     174             :                              nsUpdateType aUpdateType) override;
     175             : 
     176             : #define NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE                                \
     177             :     virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) override;
     178             : 
     179             : #define NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD                                \
     180             :     virtual void BeginLoad(nsIDocument* aDocument) override;
     181             : 
     182             : #define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD                                  \
     183             :     virtual void EndLoad(nsIDocument* aDocument) override;
     184             : 
     185             : #define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED                      \
     186             :     virtual void ContentStateChanged(nsIDocument* aDocument,                 \
     187             :                                      nsIContent* aContent,                   \
     188             :                                      mozilla::EventStates aStateMask) override;
     189             : 
     190             : #define NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED                    \
     191             :     virtual void DocumentStatesChanged(nsIDocument* aDocument,               \
     192             :                                        mozilla::EventStates aStateMask) override;
     193             : 
     194             : #define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED                          \
     195             :     virtual void StyleSheetAdded(mozilla::StyleSheet* aStyleSheet,           \
     196             :                                  bool aDocumentSheet) override;
     197             : 
     198             : #define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED                        \
     199             :     virtual void StyleSheetRemoved(mozilla::StyleSheet* aStyleSheet,         \
     200             :                                    bool aDocumentSheet) override;
     201             : 
     202             : #define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED         \
     203             :     virtual void StyleSheetApplicableStateChanged(                           \
     204             :         mozilla::StyleSheet* aStyleSheet) override;
     205             : 
     206             : #define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED                         \
     207             :     virtual void StyleRuleChanged(mozilla::StyleSheet* aStyleSheet,          \
     208             :                                   mozilla::css::Rule* aStyleRule) override;
     209             : 
     210             : #define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED                           \
     211             :     virtual void StyleRuleAdded(mozilla::StyleSheet* aStyleSheet,            \
     212             :                                 mozilla::css::Rule* aStyleRule) override;
     213             : 
     214             : #define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED                         \
     215             :     virtual void StyleRuleRemoved(mozilla::StyleSheet* aStyleSheet,          \
     216             :                                   mozilla::css::Rule* aStyleRule) override;
     217             : 
     218             : #define NS_DECL_NSIDOCUMENTOBSERVER                                          \
     219             :     NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE                                  \
     220             :     NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE                                    \
     221             :     NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD                                    \
     222             :     NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD                                      \
     223             :     NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED                          \
     224             :     NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED                        \
     225             :     NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED                              \
     226             :     NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED                            \
     227             :     NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED             \
     228             :     NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED                             \
     229             :     NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED                               \
     230             :     NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED                             \
     231             :     NS_DECL_NSIMUTATIONOBSERVER
     232             : 
     233             : 
     234             : #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class)                     \
     235             : void                                                                      \
     236             : _class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)     \
     237             : {                                                                         \
     238             : }                                                                         \
     239             : void                                                                      \
     240             : _class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)       \
     241             : {                                                                         \
     242             : }                                                                         \
     243             : NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(_class)
     244             : 
     245             : #define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class)                     \
     246             : void                                                                      \
     247             : _class::BeginLoad(nsIDocument* aDocument)                                 \
     248             : {                                                                         \
     249             : }                                                                         \
     250             : void                                                                      \
     251             : _class::EndLoad(nsIDocument* aDocument)                                   \
     252             : {                                                                         \
     253             : }
     254             : 
     255             : #define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class)                    \
     256             : void                                                                      \
     257             : _class::ContentStateChanged(nsIDocument* aDocument,                       \
     258             :                             nsIContent* aContent,                         \
     259             :                             mozilla::EventStates aStateMask)              \
     260             : {                                                                         \
     261             : }                                                                         \
     262             :                                                                           \
     263             : void                                                                      \
     264             : _class::DocumentStatesChanged(nsIDocument* aDocument,                     \
     265             :                               mozilla::EventStates aStateMask)            \
     266             : {                                                                         \
     267             : }
     268             : 
     269             : #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class)                       \
     270             : NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
     271             : 
     272             : #define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class)                    \
     273             : void                                                                      \
     274             : _class::StyleSheetAdded(mozilla::StyleSheet* aStyleSheet,                 \
     275             :                         bool aDocumentSheet)                              \
     276             : {                                                                         \
     277             : }                                                                         \
     278             : void                                                                      \
     279             : _class::StyleSheetRemoved(mozilla::StyleSheet* aStyleSheet,               \
     280             :                           bool aDocumentSheet)                            \
     281             : {                                                                         \
     282             : }                                                                         \
     283             : void                                                                      \
     284             : _class::StyleSheetApplicableStateChanged(mozilla::StyleSheet* aStyleSheet)\
     285             : {                                                                         \
     286             : }                                                                         \
     287             : void                                                                      \
     288             : _class::StyleRuleChanged(mozilla::StyleSheet* aStyleSheet,                \
     289             :                          mozilla::css::Rule* aStyleRule)                  \
     290             : {                                                                         \
     291             : }                                                                         \
     292             : void                                                                      \
     293             : _class::StyleRuleAdded(mozilla::StyleSheet* aStyleSheet,                  \
     294             :                        mozilla::css::Rule* aStyleRule)                    \
     295             : {                                                                         \
     296             : }                                                                         \
     297             : void                                                                      \
     298             : _class::StyleRuleRemoved(mozilla::StyleSheet* aStyleSheet,                \
     299             :                          mozilla::css::Rule* aStyleRule)                  \
     300             : {                                                                         \
     301             : }
     302             : 
     303             : #endif /* nsIDocumentObserver_h___ */

Generated by: LCOV version 1.13