2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#ifndef nsIDocumentObserver_h___
|
|
|
|
#define nsIDocumentObserver_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIMutationObserver.h"
|
2010-10-20 04:26:32 -07:00
|
|
|
#include "nsEventStates.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIAtom;
|
|
|
|
class nsIContent;
|
|
|
|
class nsIStyleSheet;
|
|
|
|
class nsIStyleRule;
|
|
|
|
class nsString;
|
|
|
|
class nsIDocument;
|
|
|
|
|
|
|
|
#define NS_IDOCUMENT_OBSERVER_IID \
|
2011-03-28 20:32:11 -07:00
|
|
|
{ 0x900bc4bc, 0x8b6c, 0x4cba, \
|
|
|
|
{ 0x82, 0xfa, 0x56, 0x8a, 0x80, 0xff, 0xfd, 0x3e } }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
typedef PRUint32 nsUpdateType;
|
|
|
|
|
|
|
|
#define UPDATE_CONTENT_MODEL 0x00000001
|
|
|
|
#define UPDATE_STYLE 0x00000002
|
2011-05-31 14:38:25 -07:00
|
|
|
#define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Document observer interface
|
|
|
|
class nsIDocumentObserver : public nsIMutationObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify that a content model update is beginning. This call can be
|
|
|
|
* nested.
|
|
|
|
*/
|
|
|
|
virtual void BeginUpdate(nsIDocument *aDocument,
|
|
|
|
nsUpdateType aUpdateType) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify that a content model update is finished. This call can be
|
|
|
|
* nested.
|
|
|
|
*/
|
|
|
|
virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify the observer that a document load is beginning.
|
|
|
|
*/
|
|
|
|
virtual void BeginLoad(nsIDocument *aDocument) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify the observer that a document load has finished. Note that
|
|
|
|
* the associated reflow of the document will be done <b>before</b>
|
|
|
|
* EndLoad is invoked, not after.
|
|
|
|
*/
|
|
|
|
virtual void EndLoad(nsIDocument *aDocument) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification that the state of a content node has changed.
|
|
|
|
* (ie: gained or lost focus, became active or hovered over)
|
|
|
|
* This method is called automatically by content objects
|
|
|
|
* when their state is changed (therefore there is normally
|
|
|
|
* no need to invoke this method directly). The notification
|
|
|
|
* is passed to any IDocumentObservers. The notification is
|
|
|
|
* passed on to all of the document observers. <p>
|
|
|
|
*
|
|
|
|
* This notification is not sent when a piece of content is
|
|
|
|
* added/removed from the document or the content itself changed
|
|
|
|
* (the other notifications are used for that).
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
2011-03-28 20:32:11 -07:00
|
|
|
* @param aContent the piece of content that changed
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-03-28 20:32:11 -07:00
|
|
|
virtual void ContentStateChanged(nsIDocument* aDocument,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsEventStates aStateMask) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-17 10:10:57 -07:00
|
|
|
/**
|
|
|
|
* Notification that the state of the document has changed.
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStateMask the state that changed
|
|
|
|
*/
|
|
|
|
virtual void DocumentStatesChanged(nsIDocument* aDocument,
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask) = 0;
|
2010-03-17 10:10:57 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* A StyleSheet has just been added to the document. This method is
|
|
|
|
* called automatically when a StyleSheet gets added to the
|
|
|
|
* document, even if the stylesheet is not applicable. The
|
|
|
|
* notification is passed on to all of the document observers.
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStyleSheet the StyleSheet that has been added
|
|
|
|
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
|
|
|
* false if sheet is not (i.e., UA or user sheet)
|
|
|
|
*/
|
|
|
|
virtual void StyleSheetAdded(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDocumentSheet) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A StyleSheet has just been removed from the document. This
|
|
|
|
* method is called automatically when a StyleSheet gets removed
|
|
|
|
* from the document, even if the stylesheet is not applicable. The
|
|
|
|
* notification is passed on to all of the document observers.
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStyleSheet the StyleSheet that has been removed
|
|
|
|
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
|
|
|
* false if sheet is not (i.e., UA or user sheet)
|
|
|
|
*/
|
|
|
|
virtual void StyleSheetRemoved(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDocumentSheet) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A StyleSheet has just changed its applicable state.
|
|
|
|
* This method is called automatically when the applicable state
|
|
|
|
* of a StyleSheet gets changed. The style sheet passes this
|
|
|
|
* notification to the document. The notification is passed on
|
|
|
|
* to all of the document observers.
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStyleSheet the StyleSheet that has changed state
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aApplicable true if the sheet is applicable, false if
|
2007-03-22 10:30:00 -07:00
|
|
|
* it is not applicable
|
|
|
|
*/
|
|
|
|
virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aApplicable) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A StyleRule has just been modified within a style sheet.
|
|
|
|
* This method is called automatically when the rule gets
|
|
|
|
* modified. The style sheet passes this notification to
|
|
|
|
* the document. The notification is passed on to all of
|
|
|
|
* the document observers.
|
|
|
|
*
|
|
|
|
* Since nsIStyleRule objects are immutable, there is a new object
|
|
|
|
* replacing the old one. However, the use of this method (rather
|
|
|
|
* than StyleRuleAdded and StyleRuleRemoved) implies that the new rule
|
|
|
|
* matches the same elements and has the same priority (weight,
|
|
|
|
* origin, specificity) as the old one. (However, if it is a CSS
|
|
|
|
* style rule, there may be a change in whether it has an important
|
|
|
|
* rule.)
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStyleSheet the StyleSheet that contians the rule
|
|
|
|
* @param aOldStyleRule The rule being removed. This rule may not be
|
|
|
|
* fully valid anymore -- however, it can still
|
|
|
|
* be used for pointer comparison and
|
|
|
|
* |QueryInterface|.
|
|
|
|
* @param aNewStyleRule The rule being added.
|
|
|
|
*/
|
|
|
|
virtual void StyleRuleChanged(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aOldStyleRule,
|
|
|
|
nsIStyleRule* aNewStyleRule) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A StyleRule has just been added to a style sheet.
|
|
|
|
* This method is called automatically when the rule gets
|
|
|
|
* added to the sheet. The style sheet passes this
|
|
|
|
* notification to the document. The notification is passed on
|
|
|
|
* to all of the document observers.
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStyleSheet the StyleSheet that has been modified
|
|
|
|
* @param aStyleRule the rule that was added
|
|
|
|
*/
|
|
|
|
virtual void StyleRuleAdded(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A StyleRule has just been removed from a style sheet.
|
|
|
|
* This method is called automatically when the rule gets
|
|
|
|
* removed from the sheet. The style sheet passes this
|
|
|
|
* notification to the document. The notification is passed on
|
|
|
|
* to all of the document observers.
|
|
|
|
*
|
|
|
|
* @param aDocument The document being observed
|
|
|
|
* @param aStyleSheet the StyleSheet that has been modified
|
|
|
|
* @param aStyleRule the rule that was removed
|
|
|
|
*/
|
|
|
|
virtual void StyleRuleRemoved(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
|
|
|
|
2010-10-20 00:41:05 -07:00
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
|
|
|
|
virtual void BeginUpdate(nsIDocument* aDocument, \
|
|
|
|
nsUpdateType aUpdateType);
|
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
|
|
|
|
virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);
|
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
|
|
|
|
virtual void BeginLoad(nsIDocument* aDocument);
|
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
|
|
|
|
virtual void EndLoad(nsIDocument* aDocument);
|
|
|
|
|
2011-03-28 20:32:11 -07:00
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
|
|
|
|
virtual void ContentStateChanged(nsIDocument* aDocument, \
|
|
|
|
nsIContent* aContent, \
|
|
|
|
nsEventStates aStateMask);
|
2010-10-20 00:41:05 -07:00
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
|
2010-03-17 10:10:57 -07:00
|
|
|
virtual void DocumentStatesChanged(nsIDocument* aDocument, \
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask);
|
2010-10-20 00:41:05 -07:00
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void StyleSheetAdded(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDocumentSheet);
|
2010-10-20 00:41:05 -07:00
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void StyleSheetRemoved(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDocumentSheet);
|
2010-10-20 00:41:05 -07:00
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet,\
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aApplicable);
|
2010-10-20 00:41:05 -07:00
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void StyleRuleChanged(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
|
|
|
nsIStyleRule* aOldStyleRule, \
|
2010-10-20 00:41:05 -07:00
|
|
|
nsIStyleRule* aNewStyleRule);
|
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void StyleRuleAdded(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2010-10-20 00:41:05 -07:00
|
|
|
nsIStyleRule* aStyleRule);
|
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void StyleRuleRemoved(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2010-10-20 00:41:05 -07:00
|
|
|
nsIStyleRule* aStyleRule);
|
|
|
|
|
|
|
|
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_BEGINLOAD \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_ENDLOAD \
|
2011-03-28 20:32:11 -07:00
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_CONTENTSTATECHANGED \
|
2010-10-20 00:41:05 -07:00
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_DOCUMENTSTATESCHANGED \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETADDED \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETREMOVED \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLESHEETAPPLICABLESTATECHANGED \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLERULECHANGED \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEADDED \
|
|
|
|
NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED \
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER
|
|
|
|
|
|
|
|
|
|
|
|
#define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \
|
|
|
|
void \
|
|
|
|
_class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
NS_IMPL_NSIMUTATIONOBSERVER_CORE_STUB(_class)
|
|
|
|
|
|
|
|
#define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class) \
|
|
|
|
void \
|
|
|
|
_class::BeginLoad(nsIDocument* aDocument) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::EndLoad(nsIDocument* aDocument) \
|
|
|
|
{ \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
|
|
|
|
void \
|
2011-03-28 20:32:11 -07:00
|
|
|
_class::ContentStateChanged(nsIDocument* aDocument, \
|
|
|
|
nsIContent* aContent, \
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask) \
|
2010-03-17 10:10:57 -07:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
|
|
|
_class::DocumentStatesChanged(nsIDocument* aDocument, \
|
2010-10-20 04:26:32 -07:00
|
|
|
nsEventStates aStateMask) \
|
2007-03-22 10:30:00 -07:00
|
|
|
{ \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \
|
|
|
|
NS_IMPL_NSIMUTATIONOBSERVER_CONTENT(_class)
|
|
|
|
|
|
|
|
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
|
|
|
|
void \
|
|
|
|
_class::StyleSheetAdded(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDocumentSheet) \
|
2007-03-22 10:30:00 -07:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::StyleSheetRemoved(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aDocumentSheet) \
|
2007-03-22 10:30:00 -07:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aApplicable) \
|
2007-03-22 10:30:00 -07:00
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::StyleRuleChanged(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
|
|
|
nsIStyleRule* aOldStyleRule, \
|
|
|
|
nsIStyleRule* aNewStyleRule) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::StyleRuleAdded(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
|
|
|
nsIStyleRule* aStyleRule) \
|
|
|
|
{ \
|
|
|
|
} \
|
|
|
|
void \
|
|
|
|
_class::StyleRuleRemoved(nsIDocument* aDocument, \
|
|
|
|
nsIStyleSheet* aStyleSheet, \
|
|
|
|
nsIStyleRule* aStyleRule) \
|
|
|
|
{ \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* nsIDocumentObserver_h___ */
|