Line data Source 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___
7 :
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 "mozilla/FlushType.h"
22 : #include "mozilla/NotNull.h"
23 : #include "nsIDTD.h"
24 :
25 : class nsParserBase;
26 : namespace mozilla {
27 : class Encoding;
28 : }
29 :
30 : #define NS_ICONTENT_SINK_IID \
31 : { 0xcf9a7cbb, 0xfcbc, 0x4e13, \
32 : { 0x8e, 0xf5, 0x18, 0xef, 0x2d, 0x3d, 0x58, 0x29 } }
33 :
34 25 : class nsIContentSink : public nsISupports {
35 : protected:
36 : using Encoding = mozilla::Encoding;
37 : template <typename T> using NotNull = mozilla::NotNull<T>;
38 : public:
39 :
40 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
41 :
42 : /**
43 : * This method is called by the parser when it is entered from
44 : * the event loop. The content sink wants to know how long the
45 : * parser has been active since we last processed events on the
46 : * main event loop and this call calibrates that measurement.
47 : */
48 : NS_IMETHOD WillParse(void)=0;
49 :
50 : /**
51 : * This method gets called when the parser begins the process
52 : * of building the content model via the content sink.
53 : *
54 : * Default implementation provided since the sink should have the option of
55 : * doing nothing in response to this call.
56 : *
57 : * @update 5/7/98 gess
58 : */
59 0 : NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) {
60 0 : return NS_OK;
61 : }
62 :
63 : /**
64 : * This method gets called when the parser concludes the process
65 : * of building the content model via the content sink.
66 : *
67 : * Default implementation provided since the sink should have the option of
68 : * doing nothing in response to this call.
69 : *
70 : * @update 5/7/98 gess
71 : */
72 0 : NS_IMETHOD DidBuildModel(bool aTerminated) {
73 0 : return NS_OK;
74 : }
75 :
76 : /**
77 : * This method gets called when the parser gets i/o blocked,
78 : * and wants to notify the sink that it may be a while before
79 : * more data is available.
80 : *
81 : * @update 5/7/98 gess
82 : */
83 : NS_IMETHOD WillInterrupt(void)=0;
84 :
85 : /**
86 : * This method gets called when the parser i/o gets unblocked,
87 : * and we're about to start dumping content again to the sink.
88 : *
89 : * @update 5/7/98 gess
90 : */
91 : NS_IMETHOD WillResume(void)=0;
92 :
93 : /**
94 : * This method gets called by the parser so that the content
95 : * sink can retain a reference to the parser. The expectation
96 : * is that the content sink will drop the reference when it
97 : * gets the DidBuildModel notification i.e. when parsing is done.
98 : */
99 : NS_IMETHOD SetParser(nsParserBase* aParser)=0;
100 :
101 : /**
102 : * Flush content so that the content model is in sync with the state
103 : * of the sink.
104 : *
105 : * @param aType the type of flush to perform
106 : */
107 : virtual void FlushPendingNotifications(mozilla::FlushType aType)=0;
108 :
109 : /**
110 : * Set the document character set. This should be passed on to the
111 : * document itself.
112 : */
113 : virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) = 0;
114 :
115 : /**
116 : * Returns the target object (often a document object) into which
117 : * the content built by this content sink is being added, if any
118 : * (IOW, may return null).
119 : */
120 : virtual nsISupports *GetTarget()=0;
121 :
122 : /**
123 : * Returns true if there's currently script executing that we need to hold
124 : * parsing for.
125 : */
126 0 : virtual bool IsScriptExecuting()
127 : {
128 0 : return false;
129 : }
130 :
131 : /**
132 : * Posts a runnable that continues parsing.
133 : */
134 0 : virtual void ContinueInterruptedParsingAsync() {}
135 : };
136 :
137 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID)
138 :
139 : #endif /* nsIContentSink_h___ */
|