parser/htmlparser/public/nsIFragmentContentSink.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

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

mercurial