Back to index

lightning-sunbird  0.9+nobinonly
nsIDocumentObserver.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsIDocumentObserver_h___
00038 #define nsIDocumentObserver_h___
00039 
00040 #include "nsISupports.h"
00041 
00042 class nsIAtom;
00043 class nsIContent;
00044 class nsIPresShell;
00045 class nsIStyleSheet;
00046 class nsIStyleRule;
00047 class nsString;
00048 class nsIDocument;
00049 
00050 #define NS_IDOCUMENT_OBSERVER_IID \
00051 { 0xb3f92460, 0x944c, 0x11d1, {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
00052 
00053 typedef PRUint32 nsUpdateType;
00054 
00055 #define UPDATE_CONTENT_MODEL 0x00000001
00056 #define UPDATE_STYLE         0x00000002
00057 #define UPDATE_CONTENT_STATE 0x00000004
00058 #define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE | UPDATE_CONTENT_STATE)
00059 
00060 // Document observer interface
00061 class nsIDocumentObserver : public nsISupports
00062 {
00063 public:
00064   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
00065 
00066   
00070   virtual void BeginUpdate(nsIDocument *aDocument,
00071                            nsUpdateType aUpdateType) = 0;
00072 
00077   virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
00078 
00082   virtual void BeginLoad(nsIDocument *aDocument) = 0;
00083 
00089   virtual void EndLoad(nsIDocument *aDocument) = 0;
00090 
00095   virtual void BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
00096 
00101   virtual void EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
00102 
00119   virtual void CharacterDataChanged(nsIDocument *aDocument,
00120                                     nsIContent* aContent,
00121                                     PRBool aAppend) = 0;
00122 
00146   virtual void ContentStatesChanged(nsIDocument* aDocument,
00147                                     nsIContent* aContent1,
00148                                     nsIContent* aContent2,
00149                                     PRInt32 aStateMask) = 0;
00150 
00163   virtual void AttributeChanged(nsIDocument *aDocument,
00164                                 nsIContent*  aContent,
00165                                 PRInt32      aNameSpaceID,
00166                                 nsIAtom*     aAttribute,
00167                                 PRInt32      aModType) = 0;
00168 
00182   virtual void ContentAppended(nsIDocument *aDocument,
00183                                nsIContent* aContainer,
00184                                PRInt32     aNewIndexInContainer) = 0;
00185 
00198   virtual void ContentInserted(nsIDocument *aDocument,
00199                                nsIContent* aContainer,
00200                                nsIContent* aChild,
00201                                PRInt32 aIndexInContainer) = 0;
00202 
00216   virtual void ContentRemoved(nsIDocument *aDocument,
00217                               nsIContent* aContainer,
00218                               nsIContent* aChild,
00219                               PRInt32 aIndexInContainer) = 0;
00220 
00232   virtual void StyleSheetAdded(nsIDocument *aDocument,
00233                                nsIStyleSheet* aStyleSheet,
00234                                PRBool aDocumentSheet) = 0;
00235 
00247   virtual void StyleSheetRemoved(nsIDocument *aDocument,
00248                                  nsIStyleSheet* aStyleSheet,
00249                                  PRBool aDocumentSheet) = 0;
00250   
00263   virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
00264                                                 nsIStyleSheet* aStyleSheet,
00265                                                 PRBool aApplicable) = 0;
00266 
00290   virtual void StyleRuleChanged(nsIDocument *aDocument,
00291                                 nsIStyleSheet* aStyleSheet,
00292                                 nsIStyleRule* aOldStyleRule,
00293                                 nsIStyleRule* aNewStyleRule) = 0;
00294 
00306   virtual void StyleRuleAdded(nsIDocument *aDocument,
00307                               nsIStyleSheet* aStyleSheet,
00308                               nsIStyleRule* aStyleRule) = 0;
00309 
00321   virtual void StyleRuleRemoved(nsIDocument *aDocument,
00322                                 nsIStyleSheet* aStyleSheet,
00323                                 nsIStyleRule* aStyleRule) = 0;
00324 
00332   virtual void DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
00333 };
00334 
00335 #define NS_DECL_NSIDOCUMENTOBSERVER                                          \
00336     virtual void BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
00337     virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
00338     virtual void BeginLoad(nsIDocument* aDocument);                          \
00339     virtual void EndLoad(nsIDocument* aDocument);                            \
00340     virtual void BeginReflow(nsIDocument* aDocument,                         \
00341                              nsIPresShell* aShell);                          \
00342     virtual void EndReflow(nsIDocument* aDocument,                           \
00343                            nsIPresShell* aShell);                            \
00344     virtual void CharacterDataChanged(nsIDocument* aDocument,                \
00345                                       nsIContent* aContent,                  \
00346                                       PRBool aAppend);                       \
00347     virtual void ContentStatesChanged(nsIDocument* aDocument,                \
00348                                       nsIContent* aContent1,                 \
00349                                       nsIContent* aContent2,                 \
00350                                       PRInt32 aStateMask);                   \
00351     virtual void AttributeChanged(nsIDocument* aDocument,                    \
00352                                   nsIContent* aContent,                      \
00353                                   PRInt32 aNameSpaceID,                      \
00354                                   nsIAtom* aAttribute,                       \
00355                                   PRInt32 aModType);                         \
00356     virtual void ContentAppended(nsIDocument* aDocument,                     \
00357                                  nsIContent* aContainer,                     \
00358                                  PRInt32 aNewIndexInContainer);              \
00359     virtual void ContentInserted(nsIDocument* aDocument,                     \
00360                                  nsIContent* aContainer,                     \
00361                                  nsIContent* aChild,                         \
00362                                  PRInt32 aIndexInContainer);                 \
00363     virtual void ContentRemoved(nsIDocument* aDocument,                      \
00364                                 nsIContent* aContainer,                      \
00365                                 nsIContent* aChild,                          \
00366                                 PRInt32 aIndexInContainer);                  \
00367     virtual void StyleSheetAdded(nsIDocument* aDocument,                     \
00368                                  nsIStyleSheet* aStyleSheet,                 \
00369                                  PRBool aDocumentSheet);                     \
00370     virtual void StyleSheetRemoved(nsIDocument* aDocument,                   \
00371                                    nsIStyleSheet* aStyleSheet,               \
00372                                    PRBool aDocumentSheet);                   \
00373     virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument,    \
00374                                                   nsIStyleSheet* aStyleSheet,\
00375                                                   PRBool aApplicable);       \
00376     virtual void StyleRuleChanged(nsIDocument* aDocument,                    \
00377                                   nsIStyleSheet* aStyleSheet,                \
00378                                   nsIStyleRule* aOldStyleRule,               \
00379                                   nsIStyleRule* aNewStyleRule);              \
00380     virtual void StyleRuleAdded(nsIDocument* aDocument,                      \
00381                                 nsIStyleSheet* aStyleSheet,                  \
00382                                 nsIStyleRule* aStyleRule);                   \
00383     virtual void StyleRuleRemoved(nsIDocument* aDocument,                    \
00384                                   nsIStyleSheet* aStyleSheet,                \
00385                                   nsIStyleRule* aStyleRule);                 \
00386     virtual void DocumentWillBeDestroyed(nsIDocument* aDocument);            \
00387 
00388 
00389 #define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class)                     \
00390 void                                                                      \
00391 _class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)     \
00392 {                                                                         \
00393 }                                                                         \
00394 void                                                                      \
00395 _class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)       \
00396 {                                                                         \
00397 }                                                                         \
00398 void                                                                      \
00399 _class::DocumentWillBeDestroyed(nsIDocument* aDocument)                   \
00400 {                                                                         \
00401 }
00402 
00403 #define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class)                     \
00404 void                                                                      \
00405 _class::BeginLoad(nsIDocument* aDocument)                                 \
00406 {                                                                         \
00407 }                                                                         \
00408 void                                                                      \
00409 _class::EndLoad(nsIDocument* aDocument)                                   \
00410 {                                                                         \
00411 }
00412 
00413 #define NS_IMPL_NSIDOCUMENTOBSERVER_REFLOW_STUB(_class)                   \
00414 void                                                                      \
00415 _class::BeginReflow(nsIDocument* aDocument,                               \
00416                     nsIPresShell* aShell)                                 \
00417 {                                                                         \
00418 }                                                                         \
00419 void                                                                      \
00420 _class::EndReflow(nsIDocument* aDocument,                                 \
00421                   nsIPresShell* aShell)                                   \
00422 {                                                                         \
00423 }
00424 
00425 #define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class)                    \
00426 void                                                                      \
00427 _class::ContentStatesChanged(nsIDocument* aDocument,                      \
00428                              nsIContent* aContent1,                       \
00429                              nsIContent* aContent2,                       \
00430                              PRInt32 aStateMask)                          \
00431 {                                                                         \
00432 }
00433 
00434 #define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class)                       \
00435 void                                                                      \
00436 _class::CharacterDataChanged(nsIDocument* aDocument,                      \
00437                              nsIContent* aContent,                        \
00438                              PRBool aAppend)                              \
00439 {                                                                         \
00440 }                                                                         \
00441 void                                                                      \
00442 _class::AttributeChanged(nsIDocument* aDocument,                          \
00443                          nsIContent* aContent,                            \
00444                          PRInt32 aNameSpaceID,                            \
00445                          nsIAtom* aAttribute,                             \
00446                          PRInt32 aModType)                                \
00447 {                                                                         \
00448 }                                                                         \
00449 void                                                                      \
00450 _class::ContentAppended(nsIDocument* aDocument,                           \
00451                         nsIContent* aContainer,                           \
00452                         PRInt32 aNewIndexInContainer)                     \
00453 {                                                                         \
00454 }                                                                         \
00455 void                                                                      \
00456 _class::ContentInserted(nsIDocument* aDocument,                           \
00457                         nsIContent* aContainer,                           \
00458                         nsIContent* aChild,                               \
00459                         PRInt32 aIndexInContainer)                        \
00460 {                                                                         \
00461 }                                                                         \
00462 void                                                                      \
00463 _class::ContentRemoved(nsIDocument* aDocument,                            \
00464                        nsIContent* aContainer,                            \
00465                        nsIContent* aChild,                                \
00466                        PRInt32 aIndexInContainer)                         \
00467 {                                                                         \
00468 }
00469 
00470 #define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class)                    \
00471 void                                                                      \
00472 _class::StyleSheetAdded(nsIDocument* aDocument,                           \
00473                         nsIStyleSheet* aStyleSheet,                       \
00474                         PRBool aDocumentSheet)                            \
00475 {                                                                         \
00476 }                                                                         \
00477 void                                                                      \
00478 _class::StyleSheetRemoved(nsIDocument* aDocument,                         \
00479                           nsIStyleSheet* aStyleSheet,                     \
00480                           PRBool aDocumentSheet)                          \
00481 {                                                                         \
00482 }                                                                         \
00483 void                                                                      \
00484 _class::StyleSheetApplicableStateChanged(nsIDocument* aDocument,          \
00485                                          nsIStyleSheet* aStyleSheet,      \
00486                                          PRBool aApplicable)              \
00487 {                                                                         \
00488 }                                                                         \
00489 void                                                                      \
00490 _class::StyleRuleChanged(nsIDocument* aDocument,                          \
00491                          nsIStyleSheet* aStyleSheet,                      \
00492                          nsIStyleRule* aOldStyleRule,                     \
00493                          nsIStyleRule* aNewStyleRule)                     \
00494 {                                                                         \
00495 }                                                                         \
00496 void                                                                      \
00497 _class::StyleRuleAdded(nsIDocument* aDocument,                            \
00498                        nsIStyleSheet* aStyleSheet,                        \
00499                        nsIStyleRule* aStyleRule)                          \
00500 {                                                                         \
00501 }                                                                         \
00502 void                                                                      \
00503 _class::StyleRuleRemoved(nsIDocument* aDocument,                          \
00504                          nsIStyleSheet* aStyleSheet,                      \
00505                          nsIStyleRule* aStyleRule)                        \
00506 {                                                                         \
00507 }
00508 
00509 #endif /* nsIDocumentObserver_h___ */