parser/htmlparser/public/nsIContentSink.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/parser/htmlparser/public/nsIContentSink.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,132 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +#ifndef nsIContentSink_h___
     1.9 +#define nsIContentSink_h___
    1.10 +
    1.11 +/**
    1.12 + * MODULE NOTES:
    1.13 + * @update  gess 4/1/98
    1.14 + * 
    1.15 + * This pure virtual interface is used as the "glue" that connects the parsing 
    1.16 + * process to the content model construction process.
    1.17 + *
    1.18 + * The icontentsink interface is a very lightweight wrapper that represents the
    1.19 + * content-sink model building process. There is another one that you may care 
    1.20 + * about more, which is the IHTMLContentSink interface. (See that file for details).
    1.21 + */
    1.22 +#include "nsISupports.h"
    1.23 +#include "nsString.h"
    1.24 +#include "mozFlushType.h"
    1.25 +#include "nsIDTD.h"
    1.26 +
    1.27 +class nsParserBase;
    1.28 +
    1.29 +#define NS_ICONTENT_SINK_IID \
    1.30 +{ 0xcf9a7cbb, 0xfcbc, 0x4e13, \
    1.31 +  { 0x8e, 0xf5, 0x18, 0xef, 0x2d, 0x3d, 0x58, 0x29 } }
    1.32 +
    1.33 +class nsIContentSink : public nsISupports {
    1.34 +public:
    1.35 +
    1.36 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
    1.37 +
    1.38 +  /**
    1.39 +   * This method is called by the parser when it is entered from
    1.40 +   * the event loop. The content sink wants to know how long the
    1.41 +   * parser has been active since we last processed events on the
    1.42 +   * main event loop and this call calibrates that measurement.
    1.43 +   */
    1.44 +  NS_IMETHOD WillParse(void)=0;
    1.45 +
    1.46 +  /**
    1.47 +   * This method gets called when the parser begins the process
    1.48 +   * of building the content model via the content sink.
    1.49 +   *
    1.50 +   * Default implementation provided since the sink should have the option of
    1.51 +   * doing nothing in response to this call.
    1.52 +   *
    1.53 +   * @update 5/7/98 gess
    1.54 +   */
    1.55 +  NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) {
    1.56 +    return NS_OK;
    1.57 +  }
    1.58 +
    1.59 +  /**
    1.60 +   * This method gets called when the parser concludes the process
    1.61 +   * of building the content model via the content sink.
    1.62 +   *
    1.63 +   * Default implementation provided since the sink should have the option of
    1.64 +   * doing nothing in response to this call.
    1.65 +   *
    1.66 +   * @update 5/7/98 gess
    1.67 +   */
    1.68 +  NS_IMETHOD DidBuildModel(bool aTerminated) {
    1.69 +    return NS_OK;
    1.70 +  }
    1.71 +
    1.72 +  /**
    1.73 +   * This method gets called when the parser gets i/o blocked,
    1.74 +   * and wants to notify the sink that it may be a while before
    1.75 +   * more data is available.
    1.76 +   *
    1.77 +   * @update 5/7/98 gess
    1.78 +   */
    1.79 +  NS_IMETHOD WillInterrupt(void)=0;
    1.80 +
    1.81 +  /**
    1.82 +   * This method gets called when the parser i/o gets unblocked,
    1.83 +   * and we're about to start dumping content again to the sink.
    1.84 +   *
    1.85 +   * @update 5/7/98 gess
    1.86 +   */
    1.87 +  NS_IMETHOD WillResume(void)=0;
    1.88 +
    1.89 +  /**
    1.90 +   * This method gets called by the parser so that the content
    1.91 +   * sink can retain a reference to the parser. The expectation
    1.92 +   * is that the content sink will drop the reference when it
    1.93 +   * gets the DidBuildModel notification i.e. when parsing is done.
    1.94 +   */
    1.95 +  NS_IMETHOD SetParser(nsParserBase* aParser)=0;
    1.96 +
    1.97 +  /**
    1.98 +   * Flush content so that the content model is in sync with the state
    1.99 +   * of the sink.
   1.100 +   *
   1.101 +   * @param aType the type of flush to perform
   1.102 +   */
   1.103 +  virtual void FlushPendingNotifications(mozFlushType aType)=0;
   1.104 +
   1.105 +  /**
   1.106 +   * Set the document character set. This should be passed on to the
   1.107 +   * document itself.
   1.108 +   */
   1.109 +  NS_IMETHOD SetDocumentCharset(nsACString& aCharset)=0;
   1.110 +
   1.111 +  /**
   1.112 +   * Returns the target object (often a document object) into which
   1.113 +   * the content built by this content sink is being added, if any
   1.114 +   * (IOW, may return null).
   1.115 +   */
   1.116 +  virtual nsISupports *GetTarget()=0;
   1.117 +  
   1.118 +  /**
   1.119 +   * Returns true if there's currently script executing that we need to hold
   1.120 +   * parsing for.
   1.121 +   */
   1.122 +  virtual bool IsScriptExecuting()
   1.123 +  {
   1.124 +    return false;
   1.125 +  }
   1.126 +  
   1.127 +  /**
   1.128 +   * Posts a runnable that continues parsing.
   1.129 +   */
   1.130 +  virtual void ContinueInterruptedParsingAsync() {}
   1.131 +};
   1.132 +
   1.133 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID)
   1.134 +
   1.135 +#endif /* nsIContentSink_h___ */

mercurial