michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef nsIFragmentContentSink_h___ michael@0: #define nsIFragmentContentSink_h___ michael@0: michael@0: #include "nsISupports.h" michael@0: michael@0: class nsIDOMDocumentFragment; michael@0: class nsIDocument; michael@0: michael@0: #define NS_I_FRAGMENT_CONTENT_SINK_IID \ michael@0: { 0x1a8ce30b, 0x63fc, 0x441a, \ michael@0: { 0xa3, 0xaa, 0xf7, 0x16, 0xc0, 0xfe, 0x96, 0x69 } } michael@0: michael@0: /** michael@0: * The fragment sink allows a client to parse a fragment of sink, possibly michael@0: * surrounded in context. Also see nsIParser::ParseFragment(). michael@0: * Note: once you've parsed a fragment, the fragment sink must be re-set on michael@0: * the parser in order to parse another fragment. michael@0: */ michael@0: class nsIFragmentContentSink : public nsISupports { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_I_FRAGMENT_CONTENT_SINK_IID) michael@0: /** michael@0: * This method is used to obtain the fragment created by michael@0: * a fragment content sink and to release resources held by the parser. michael@0: * michael@0: * The sink drops its reference to the fragment. michael@0: */ michael@0: NS_IMETHOD FinishFragmentParsing(nsIDOMDocumentFragment** aFragment) = 0; michael@0: michael@0: /** michael@0: * This method is used to set the target document for this fragment michael@0: * sink. This document's nodeinfo manager will be used to create michael@0: * the content objects. This MUST be called before the sink is used. michael@0: * michael@0: * @param aDocument the document the new nodes will belong to michael@0: * (should not be null) michael@0: */ michael@0: NS_IMETHOD SetTargetDocument(nsIDocument* aDocument) = 0; michael@0: michael@0: /** michael@0: * This method is used to indicate to the sink that we're done building michael@0: * the context and should start paying attention to the incoming content michael@0: */ michael@0: NS_IMETHOD WillBuildContent() = 0; michael@0: michael@0: /** michael@0: * This method is used to indicate to the sink that we're done building michael@0: * The real content. This is useful if you want to parse additional context michael@0: * (such as an end context). michael@0: */ michael@0: NS_IMETHOD DidBuildContent() = 0; michael@0: michael@0: /** michael@0: * This method is a total hack to help with parsing fragments. It is called to michael@0: * tell the fragment sink that a container from the context will be delivered michael@0: * after the call to WillBuildContent(). This is only relevent for HTML michael@0: * fragments that use nsHTMLTokenizer/CNavDTD. michael@0: */ michael@0: NS_IMETHOD IgnoreFirstContainer() = 0; michael@0: michael@0: /** michael@0: * Sets whether scripts elements are marked as unexecutable. michael@0: */ michael@0: NS_IMETHOD SetPreventScriptExecution(bool aPreventScriptExecution) = 0; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIFragmentContentSink, michael@0: NS_I_FRAGMENT_CONTENT_SINK_IID) michael@0: michael@0: nsresult michael@0: NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aInstancePtrResult); michael@0: michael@0: #endif