content/base/public/nsIDOMParser.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/public/nsIDOMParser.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +interface nsIInputStream;
    1.12 +interface nsIDOMDocument;
    1.13 +interface nsIURI;
    1.14 +interface nsIPrincipal;
    1.15 +interface nsIScriptGlobalObject;
    1.16 +
    1.17 +/**
    1.18 + * The nsIDOMParser interface is a non-SAX interface that can be used
    1.19 + * to parse a string or byte stream containing XML or HTML content
    1.20 + * to a DOM document. Parsing is always synchronous - a document is always
    1.21 + * returned from the parsing methods. This is as opposed to loading and
    1.22 + * parsing with the XMLHttpRequest interface, which can be used for
    1.23 + * asynchronous (callback-based) loading.
    1.24 + */
    1.25 +[scriptable, uuid(5677f36e-1842-4c6f-a39c-2e5576ab8b40)]
    1.26 +interface nsIDOMParser : nsISupports
    1.27 +{
    1.28 +  /**
    1.29 +   * The string passed in is parsed into a DOM document.
    1.30 +   *
    1.31 +   * @param str The UTF16 string to be parsed
    1.32 +   * @param contentType The content type of the string (see parseFromStream)
    1.33 +   * @returns The DOM document created as a result of parsing the 
    1.34 +   *          string
    1.35 +   */
    1.36 +  nsIDOMDocument parseFromString(in wstring str, in string contentType);
    1.37 +
    1.38 +  /**
    1.39 +   * The buffer is parsed into a DOM document.
    1.40 +   * The charset is determined from the xml entity decl.
    1.41 +   *
    1.42 +   * @param buf The octet array data to be parsed
    1.43 +   * @param bufLen Length (in bytes) of the data
    1.44 +   * @param contentType The content type of the data (see parseFromStream)
    1.45 +   * @returns The DOM document created as a result of parsing the 
    1.46 +   *          string
    1.47 +   */
    1.48 +  nsIDOMDocument parseFromBuffer([const,array,size_is(bufLen)] in octet buf,
    1.49 +                                 in uint32_t bufLen, in string contentType);
    1.50 +
    1.51 +  /**
    1.52 +   * The byte stream passed in is parsed into a DOM document.
    1.53 +   *
    1.54 +   * Not accessible from web content.
    1.55 +   *
    1.56 +   * @param stream The byte stream whose contents are parsed
    1.57 +   * @param charset The character set that was used to encode the byte
    1.58 +   *                stream. NULL if not specified.
    1.59 +   * @param contentLength The number of bytes in the input stream.
    1.60 +   * @param contentType The content type of the string - either text/xml,
    1.61 +   *                    application/xml, or application/xhtml+xml.
    1.62 +   *                    Must not be NULL.
    1.63 +   * @returns The DOM document created as a result of parsing the 
    1.64 +   *          stream
    1.65 +   */
    1.66 +  nsIDOMDocument parseFromStream(in nsIInputStream stream, 
    1.67 +                                 in string charset,
    1.68 +                                 in long contentLength,
    1.69 +                                 in string contentType);
    1.70 +
    1.71 +  /**
    1.72 +   * Initialize the principal and document and base URIs that the parser should
    1.73 +   * use for documents it creates.  If this is not called, then a null
    1.74 +   * principal and its URI will be used.  When creating a DOMParser via the JS
    1.75 +   * constructor, this will be called automatically.  This method may only be
    1.76 +   * called once.  If this method fails, all following parse attempts will
    1.77 +   * fail.
    1.78 +   *
    1.79 +   * @param principal The principal to use for documents we create.
    1.80 +   *                  If this is null, a codebase principal will be created
    1.81 +   *                  based on documentURI; in that case the documentURI must
    1.82 +   *                  be non-null.
    1.83 +   * @param documentURI The documentURI to use for the documents we create.
    1.84 +   *                    If null, the principal's URI will be used;
    1.85 +   *                    in that case, the principal must be non-null and its
    1.86 +   *                    URI must be non-null.
    1.87 +   * @param baseURI The baseURI to use for the documents we create.
    1.88 +   *                If null, the documentURI will be used.
    1.89 +   * @param scriptObject The object from which the context for event handling
    1.90 +   *                     can be got.
    1.91 +   */
    1.92 +  [noscript] void init(in nsIPrincipal principal,
    1.93 +                       in nsIURI documentURI,
    1.94 +                       in nsIURI baseURI,
    1.95 +                       in nsIScriptGlobalObject scriptObject);
    1.96 +};
    1.97 +
    1.98 +%{ C++
    1.99 +#define NS_DOMPARSER_CID                            \
   1.100 + { /* 3a8a3a50-512c-11d4-9a54-000064657374 */       \
   1.101 +   0x3a8a3a50, 0x512c, 0x11d4,                      \
   1.102 +  {0x9a, 0x54, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
   1.103 +#define NS_DOMPARSER_CONTRACTID \
   1.104 +"@mozilla.org/xmlextras/domparser;1"
   1.105 +%}

mercurial