parser/htmlparser/public/nsIContentSink.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef nsIContentSink_h___
     6 #define nsIContentSink_h___
     8 /**
     9  * MODULE NOTES:
    10  * @update  gess 4/1/98
    11  * 
    12  * This pure virtual interface is used as the "glue" that connects the parsing 
    13  * process to the content model construction process.
    14  *
    15  * The icontentsink interface is a very lightweight wrapper that represents the
    16  * content-sink model building process. There is another one that you may care 
    17  * about more, which is the IHTMLContentSink interface. (See that file for details).
    18  */
    19 #include "nsISupports.h"
    20 #include "nsString.h"
    21 #include "mozFlushType.h"
    22 #include "nsIDTD.h"
    24 class nsParserBase;
    26 #define NS_ICONTENT_SINK_IID \
    27 { 0xcf9a7cbb, 0xfcbc, 0x4e13, \
    28   { 0x8e, 0xf5, 0x18, 0xef, 0x2d, 0x3d, 0x58, 0x29 } }
    30 class nsIContentSink : public nsISupports {
    31 public:
    33   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
    35   /**
    36    * This method is called by the parser when it is entered from
    37    * the event loop. The content sink wants to know how long the
    38    * parser has been active since we last processed events on the
    39    * main event loop and this call calibrates that measurement.
    40    */
    41   NS_IMETHOD WillParse(void)=0;
    43   /**
    44    * This method gets called when the parser begins the process
    45    * of building the content model via the content sink.
    46    *
    47    * Default implementation provided since the sink should have the option of
    48    * doing nothing in response to this call.
    49    *
    50    * @update 5/7/98 gess
    51    */
    52   NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) {
    53     return NS_OK;
    54   }
    56   /**
    57    * This method gets called when the parser concludes the process
    58    * of building the content model via the content sink.
    59    *
    60    * Default implementation provided since the sink should have the option of
    61    * doing nothing in response to this call.
    62    *
    63    * @update 5/7/98 gess
    64    */
    65   NS_IMETHOD DidBuildModel(bool aTerminated) {
    66     return NS_OK;
    67   }
    69   /**
    70    * This method gets called when the parser gets i/o blocked,
    71    * and wants to notify the sink that it may be a while before
    72    * more data is available.
    73    *
    74    * @update 5/7/98 gess
    75    */
    76   NS_IMETHOD WillInterrupt(void)=0;
    78   /**
    79    * This method gets called when the parser i/o gets unblocked,
    80    * and we're about to start dumping content again to the sink.
    81    *
    82    * @update 5/7/98 gess
    83    */
    84   NS_IMETHOD WillResume(void)=0;
    86   /**
    87    * This method gets called by the parser so that the content
    88    * sink can retain a reference to the parser. The expectation
    89    * is that the content sink will drop the reference when it
    90    * gets the DidBuildModel notification i.e. when parsing is done.
    91    */
    92   NS_IMETHOD SetParser(nsParserBase* aParser)=0;
    94   /**
    95    * Flush content so that the content model is in sync with the state
    96    * of the sink.
    97    *
    98    * @param aType the type of flush to perform
    99    */
   100   virtual void FlushPendingNotifications(mozFlushType aType)=0;
   102   /**
   103    * Set the document character set. This should be passed on to the
   104    * document itself.
   105    */
   106   NS_IMETHOD SetDocumentCharset(nsACString& aCharset)=0;
   108   /**
   109    * Returns the target object (often a document object) into which
   110    * the content built by this content sink is being added, if any
   111    * (IOW, may return null).
   112    */
   113   virtual nsISupports *GetTarget()=0;
   115   /**
   116    * Returns true if there's currently script executing that we need to hold
   117    * parsing for.
   118    */
   119   virtual bool IsScriptExecuting()
   120   {
   121     return false;
   122   }
   124   /**
   125    * Posts a runnable that continues parsing.
   126    */
   127   virtual void ContinueInterruptedParsingAsync() {}
   128 };
   130 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID)
   132 #endif /* nsIContentSink_h___ */

mercurial