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___
12 * This pure virtual interface is used as the "glue" that connects the parsing
13 * process to the content model construction process.
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
20 #include "nsISupports.h"
22 #include "mozilla/FlushType.h"
23 #include "mozilla/NotNull.h"
31 #define NS_ICONTENT_SINK_IID \
33 0xcf9a7cbb, 0xfcbc, 0x4e13, { \
34 0x8e, 0xf5, 0x18, 0xef, 0x2d, 0x3d, 0x58, 0x29 \
38 class nsIContentSink
: public nsISupports
{
40 using Encoding
= mozilla::Encoding
;
42 using NotNull
= mozilla::NotNull
<T
>;
45 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID
)
48 * This method is called by the parser when it is entered from
49 * the event loop. The content sink wants to know how long the
50 * parser has been active since we last processed events on the
51 * main event loop and this call calibrates that measurement.
53 NS_IMETHOD
WillParse(void) = 0;
56 * This method gets called when the parser begins the process
57 * of building the content model via the content sink.
59 * Default implementation provided since the sink should have the option of
60 * doing nothing in response to this call.
64 NS_IMETHOD
WillBuildModel(nsDTDMode aDTDMode
) { return NS_OK
; }
67 * This method gets called when the parser concludes the process
68 * of building the content model via the content sink.
70 * Default implementation provided since the sink should have the option of
71 * doing nothing in response to this call.
75 NS_IMETHOD
DidBuildModel(bool aTerminated
) { return NS_OK
; }
78 * This method gets called when the parser gets i/o blocked,
79 * and wants to notify the sink that it may be a while before
80 * more data is available.
84 NS_IMETHOD
WillInterrupt(void) = 0;
87 * This method gets called when the parser i/o gets unblocked,
88 * and we're about to start dumping content again to the sink.
92 NS_IMETHOD
WillResume(void) = 0;
95 * This method gets called by the parser so that the content
96 * sink can retain a reference to the parser. The expectation
97 * is that the content sink will drop the reference when it
98 * gets the DidBuildModel notification i.e. when parsing is done.
100 NS_IMETHOD
SetParser(nsParserBase
* aParser
) = 0;
103 * Flush content so that the content model is in sync with the state
106 * @param aType the type of flush to perform
108 virtual void FlushPendingNotifications(mozilla::FlushType aType
) = 0;
111 * Set the document character set. This should be passed on to the
114 virtual void SetDocumentCharset(NotNull
<const Encoding
*> aEncoding
) = 0;
117 * Returns the target object (often a document object) into which
118 * the content built by this content sink is being added, if any
119 * (IOW, may return null).
121 virtual nsISupports
* GetTarget() = 0;
124 * Returns true if there's currently script executing that we need to hold
127 virtual bool IsScriptExecuting() { return false; }
130 * Posts a runnable that continues parsing.
132 virtual void ContinueInterruptedParsingAsync() {}
134 virtual void InitialTranslationCompleted() {}
137 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink
, NS_ICONTENT_SINK_IID
)
139 #endif /* nsIContentSink_h___ */