Bug 1855360 - Fix the skip-if syntax. a=bustage-fix
[gecko.git] / parser / htmlparser / nsIContentSink.h
blobaa77c192c79e75a5505afd18c5c158ee79cfd0ba
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
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
18 * details).
20 #include "nsISupports.h"
21 #include "nsString.h"
22 #include "mozilla/FlushType.h"
23 #include "mozilla/NotNull.h"
24 #include "nsIDTD.h"
26 class nsParserBase;
27 namespace mozilla {
28 class Encoding;
31 #define NS_ICONTENT_SINK_IID \
32 { \
33 0xcf9a7cbb, 0xfcbc, 0x4e13, { \
34 0x8e, 0xf5, 0x18, 0xef, 0x2d, 0x3d, 0x58, 0x29 \
35 } \
38 class nsIContentSink : public nsISupports {
39 protected:
40 using Encoding = mozilla::Encoding;
41 template <typename T>
42 using NotNull = mozilla::NotNull<T>;
44 public:
45 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
47 /**
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;
55 /**
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.
62 * @update 5/7/98 gess
64 NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) { return NS_OK; }
66 /**
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.
73 * @update 5/7/98 gess
75 NS_IMETHOD DidBuildModel(bool aTerminated) { return NS_OK; }
77 /**
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.
82 * @update 5/7/98 gess
84 NS_IMETHOD WillInterrupt(void) = 0;
86 /**
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.
90 virtual void WillResume() = 0;
92 /**
93 * This method returns nullptr unless `this` can
94 * be cast as nsHtml5TreeOpExecutor.
96 virtual nsIContentSink* AsExecutor() { return nullptr; }
98 /**
99 * This method gets called by the parser so that the content
100 * sink can retain a reference to the parser. The expectation
101 * is that the content sink will drop the reference when it
102 * gets the DidBuildModel notification i.e. when parsing is done.
104 NS_IMETHOD SetParser(nsParserBase* aParser) = 0;
107 * Flush content so that the content model is in sync with the state
108 * of the sink.
110 * @param aType the type of flush to perform
112 virtual void FlushPendingNotifications(mozilla::FlushType aType) = 0;
115 * Set the document character set. This should be passed on to the
116 * document itself.
118 virtual void SetDocumentCharset(NotNull<const Encoding*> aEncoding) = 0;
121 * Returns the target object (often a document object) into which
122 * the content built by this content sink is being added, if any
123 * (IOW, may return null).
125 virtual nsISupports* GetTarget() = 0;
128 * Returns true if there's currently script executing that we need to hold
129 * parsing for.
131 virtual bool IsScriptExecuting() { return false; }
134 * Posts a runnable that continues parsing.
136 virtual void ContinueInterruptedParsingAsync() {}
138 virtual void InitialTranslationCompleted() {}
141 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSink, NS_ICONTENT_SINK_IID)
143 #endif /* nsIContentSink_h___ */