Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
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/. */
6 #include "nsISupports.idl"
8 interface nsIInputStream;
9 interface nsIDOMDocument;
10 interface nsIURI;
11 interface nsIPrincipal;
12 interface nsIScriptGlobalObject;
14 /**
15 * The nsIDOMParser interface is a non-SAX interface that can be used
16 * to parse a string or byte stream containing XML or HTML content
17 * to a DOM document. Parsing is always synchronous - a document is always
18 * returned from the parsing methods. This is as opposed to loading and
19 * parsing with the XMLHttpRequest interface, which can be used for
20 * asynchronous (callback-based) loading.
21 */
22 [scriptable, uuid(5677f36e-1842-4c6f-a39c-2e5576ab8b40)]
23 interface nsIDOMParser : nsISupports
24 {
25 /**
26 * The string passed in is parsed into a DOM document.
27 *
28 * @param str The UTF16 string to be parsed
29 * @param contentType The content type of the string (see parseFromStream)
30 * @returns The DOM document created as a result of parsing the
31 * string
32 */
33 nsIDOMDocument parseFromString(in wstring str, in string contentType);
35 /**
36 * The buffer is parsed into a DOM document.
37 * The charset is determined from the xml entity decl.
38 *
39 * @param buf The octet array data to be parsed
40 * @param bufLen Length (in bytes) of the data
41 * @param contentType The content type of the data (see parseFromStream)
42 * @returns The DOM document created as a result of parsing the
43 * string
44 */
45 nsIDOMDocument parseFromBuffer([const,array,size_is(bufLen)] in octet buf,
46 in uint32_t bufLen, in string contentType);
48 /**
49 * The byte stream passed in is parsed into a DOM document.
50 *
51 * Not accessible from web content.
52 *
53 * @param stream The byte stream whose contents are parsed
54 * @param charset The character set that was used to encode the byte
55 * stream. NULL if not specified.
56 * @param contentLength The number of bytes in the input stream.
57 * @param contentType The content type of the string - either text/xml,
58 * application/xml, or application/xhtml+xml.
59 * Must not be NULL.
60 * @returns The DOM document created as a result of parsing the
61 * stream
62 */
63 nsIDOMDocument parseFromStream(in nsIInputStream stream,
64 in string charset,
65 in long contentLength,
66 in string contentType);
68 /**
69 * Initialize the principal and document and base URIs that the parser should
70 * use for documents it creates. If this is not called, then a null
71 * principal and its URI will be used. When creating a DOMParser via the JS
72 * constructor, this will be called automatically. This method may only be
73 * called once. If this method fails, all following parse attempts will
74 * fail.
75 *
76 * @param principal The principal to use for documents we create.
77 * If this is null, a codebase principal will be created
78 * based on documentURI; in that case the documentURI must
79 * be non-null.
80 * @param documentURI The documentURI to use for the documents we create.
81 * If null, the principal's URI will be used;
82 * in that case, the principal must be non-null and its
83 * URI must be non-null.
84 * @param baseURI The baseURI to use for the documents we create.
85 * If null, the documentURI will be used.
86 * @param scriptObject The object from which the context for event handling
87 * can be got.
88 */
89 [noscript] void init(in nsIPrincipal principal,
90 in nsIURI documentURI,
91 in nsIURI baseURI,
92 in nsIScriptGlobalObject scriptObject);
93 };
95 %{ C++
96 #define NS_DOMPARSER_CID \
97 { /* 3a8a3a50-512c-11d4-9a54-000064657374 */ \
98 0x3a8a3a50, 0x512c, 0x11d4, \
99 {0x9a, 0x54, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
100 #define NS_DOMPARSER_CONTRACTID \
101 "@mozilla.org/xmlextras/domparser;1"
102 %}