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