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 nsIFragmentContentSink_h___ 6 #define nsIFragmentContentSink_h___ 7 8 #include "nsISupports.h" 9 10 namespace mozilla { 11 namespace dom { 12 class Document; 13 class DocumentFragment; 14 } // namespace dom 15 } // namespace mozilla 16 17 #define NS_I_FRAGMENT_CONTENT_SINK_IID \ 18 { \ 19 0x1a8ce30b, 0x63fc, 0x441a, { \ 20 0xa3, 0xaa, 0xf7, 0x16, 0xc0, 0xfe, 0x96, 0x69 \ 21 } \ 22 } 23 24 /** 25 * The fragment sink allows a client to parse a fragment of sink, possibly 26 * surrounded in context. Also see nsIParser::ParseFragment(). 27 * Note: once you've parsed a fragment, the fragment sink must be re-set on 28 * the parser in order to parse another fragment. 29 */ 30 class nsIFragmentContentSink : public nsISupports { 31 public: 32 NS_DECLARE_STATIC_IID_ACCESSOR(NS_I_FRAGMENT_CONTENT_SINK_IID) 33 /** 34 * This method is used to obtain the fragment created by 35 * a fragment content sink and to release resources held by the parser. 36 * 37 * The sink drops its reference to the fragment. 38 */ 39 NS_IMETHOD FinishFragmentParsing(mozilla::dom::DocumentFragment** aFragment) = 40 0; 41 42 /** 43 * This method is used to set the target document for this fragment 44 * sink. This document's nodeinfo manager will be used to create 45 * the content objects. This MUST be called before the sink is used. 46 * 47 * @param aDocument the document the new nodes will belong to 48 * (should not be null) 49 */ 50 NS_IMETHOD SetTargetDocument(mozilla::dom::Document*) = 0; 51 52 /** 53 * This method is used to indicate to the sink that we're done building 54 * the context and should start paying attention to the incoming content 55 */ 56 NS_IMETHOD WillBuildContent() = 0; 57 58 /** 59 * This method is used to indicate to the sink that we're done building 60 * The real content. This is useful if you want to parse additional context 61 * (such as an end context). 62 */ 63 NS_IMETHOD DidBuildContent() = 0; 64 65 /** 66 * This method is a total hack to help with parsing fragments. It is called to 67 * tell the fragment sink that a container from the context will be delivered 68 * after the call to WillBuildContent(). This is only relevent for HTML 69 * fragments that use nsHTMLTokenizer/CNavDTD. 70 */ 71 NS_IMETHOD IgnoreFirstContainer() = 0; 72 73 /** 74 * Sets whether scripts elements are marked as unexecutable. 75 */ 76 NS_IMETHOD SetPreventScriptExecution(bool aPreventScriptExecution) = 0; 77 }; 78 79 NS_DEFINE_STATIC_IID_ACCESSOR(nsIFragmentContentSink, 80 NS_I_FRAGMENT_CONTENT_SINK_IID) 81 82 nsresult NS_NewXMLFragmentContentSink( 83 nsIFragmentContentSink** aInstancePtrResult); 84 85 #endif 86