michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsIContentSink_h___ michael@0: #define nsIContentSink_h___ michael@0: michael@0: /** michael@0: * MODULE NOTES: michael@0: * @update gess 4/1/98 michael@0: * michael@0: * This pure virtual interface is used as the "glue" that connects the parsing michael@0: * process to the content model construction process. michael@0: * michael@0: * The icontentsink interface is a very lightweight wrapper that represents the michael@0: * content-sink model building process. There is another one that you may care michael@0: * about more, which is the IHTMLContentSink interface. (See that file for details). michael@0: */ michael@0: #include "nsISupports.h" michael@0: #include "nsString.h" michael@0: #include "mozFlushType.h" michael@0: #include "nsIDTD.h" michael@0: michael@0: class nsParserBase; michael@0: michael@0: #define NS_ICONTENT_SINK_IID \ michael@0: { 0xcf9a7cbb, 0xfcbc, 0x4e13, \ michael@0: { 0x8e, 0xf5, 0x18, 0xef, 0x2d, 0x3d, 0x58, 0x29 } } michael@0: michael@0: class nsIContentSink : public nsISupports { michael@0: public: michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID) michael@0: michael@0: /** michael@0: * This method is called by the parser when it is entered from michael@0: * the event loop. The content sink wants to know how long the michael@0: * parser has been active since we last processed events on the michael@0: * main event loop and this call calibrates that measurement. michael@0: */ michael@0: NS_IMETHOD WillParse(void)=0; michael@0: michael@0: /** michael@0: * This method gets called when the parser begins the process michael@0: * of building the content model via the content sink. michael@0: * michael@0: * Default implementation provided since the sink should have the option of michael@0: * doing nothing in response to this call. michael@0: * michael@0: * @update 5/7/98 gess michael@0: */ michael@0: NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** michael@0: * This method gets called when the parser concludes the process michael@0: * of building the content model via the content sink. michael@0: * michael@0: * Default implementation provided since the sink should have the option of michael@0: * doing nothing in response to this call. michael@0: * michael@0: * @update 5/7/98 gess michael@0: */ michael@0: NS_IMETHOD DidBuildModel(bool aTerminated) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: /** michael@0: * This method gets called when the parser gets i/o blocked, michael@0: * and wants to notify the sink that it may be a while before michael@0: * more data is available. michael@0: * michael@0: * @update 5/7/98 gess michael@0: */ michael@0: NS_IMETHOD WillInterrupt(void)=0; michael@0: michael@0: /** michael@0: * This method gets called when the parser i/o gets unblocked, michael@0: * and we're about to start dumping content again to the sink. michael@0: * michael@0: * @update 5/7/98 gess michael@0: */ michael@0: NS_IMETHOD WillResume(void)=0; michael@0: michael@0: /** michael@0: * This method gets called by the parser so that the content michael@0: * sink can retain a reference to the parser. The expectation michael@0: * is that the content sink will drop the reference when it michael@0: * gets the DidBuildModel notification i.e. when parsing is done. michael@0: */ michael@0: NS_IMETHOD SetParser(nsParserBase* aParser)=0; michael@0: michael@0: /** michael@0: * Flush content so that the content model is in sync with the state michael@0: * of the sink. michael@0: * michael@0: * @param aType the type of flush to perform michael@0: */ michael@0: virtual void FlushPendingNotifications(mozFlushType aType)=0; michael@0: michael@0: /** michael@0: * Set the document character set. This should be passed on to the michael@0: * document itself. michael@0: */ michael@0: NS_IMETHOD SetDocumentCharset(nsACString& aCharset)=0; michael@0: michael@0: /** michael@0: * Returns the target object (often a document object) into which michael@0: * the content built by this content sink is being added, if any michael@0: * (IOW, may return null). michael@0: */ michael@0: virtual nsISupports *GetTarget()=0; michael@0: michael@0: /** michael@0: * Returns true if there's currently script executing that we need to hold michael@0: * parsing for. michael@0: */ michael@0: virtual bool IsScriptExecuting() michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: /** michael@0: * Posts a runnable that continues parsing. michael@0: */ michael@0: virtual void ContinueInterruptedParsingAsync() {} michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID) michael@0: michael@0: #endif /* nsIContentSink_h___ */