nsIDOMDocument.idl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /* -*- Mode: IDL; 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. #include "nsIDOMNode.idl"
  6. %{ C++
  7. #include "jspubtd.h"
  8. // windows.h #defines CreateEvent
  9. #ifdef CreateEvent
  10. #undef CreateEvent
  11. #endif
  12. %}
  13. interface mozIDOMWindowProxy;
  14. interface nsIDOMNodeIterator;
  15. interface nsIDOMNodeFilter;
  16. interface nsIDOMTreeWalker;
  17. interface nsIDOMLocation;
  18. /**
  19. * The nsIDOMDocument interface represents the entire HTML or XML document.
  20. * Conceptually, it is the root of the document tree, and provides the
  21. * primary access to the document's data.
  22. * Since elements, text nodes, comments, processing instructions, etc.
  23. * cannot exist outside the context of a Document, the nsIDOMDocument
  24. * interface also contains the factory methods needed to create these
  25. * objects.
  26. *
  27. * For more information on this interface please see
  28. * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  29. */
  30. [uuid(b15fa0f4-97c1-4388-af62-2ceff7a89bdf)]
  31. interface nsIDOMDocument : nsIDOMNode
  32. {
  33. readonly attribute nsIDOMDocumentType doctype;
  34. readonly attribute nsIDOMDOMImplementation implementation;
  35. readonly attribute nsIDOMElement documentElement;
  36. nsIDOMElement createElement([Null(Stringify)] in DOMString tagName)
  37. raises(DOMException);
  38. nsIDOMDocumentFragment createDocumentFragment();
  39. nsIDOMText createTextNode(in DOMString data);
  40. nsIDOMComment createComment(in DOMString data);
  41. nsIDOMCDATASection createCDATASection(in DOMString data)
  42. raises(DOMException);
  43. nsIDOMProcessingInstruction createProcessingInstruction(in DOMString target,
  44. in DOMString data)
  45. raises(DOMException);
  46. nsIDOMAttr createAttribute(in DOMString name)
  47. raises(DOMException);
  48. nsIDOMNodeList getElementsByTagName(in DOMString tagname);
  49. // Introduced in DOM Level 2:
  50. [optional_argc] nsIDOMNode importNode(in nsIDOMNode importedNode,
  51. [optional] in boolean deep)
  52. raises(DOMException);
  53. // Introduced in DOM Level 2:
  54. nsIDOMElement createElementNS(in DOMString namespaceURI,
  55. [Null(Stringify)] in DOMString qualifiedName)
  56. raises(DOMException);
  57. // Introduced in DOM Level 2:
  58. nsIDOMAttr createAttributeNS(in DOMString namespaceURI,
  59. in DOMString qualifiedName)
  60. raises(DOMException);
  61. // Introduced in DOM Level 2:
  62. nsIDOMNodeList getElementsByTagNameNS(in DOMString namespaceURI,
  63. in DOMString localName);
  64. // Introduced in DOM Level 2:
  65. nsIDOMElement getElementById(in DOMString elementId);
  66. // Introduced in DOM Level 3:
  67. readonly attribute DOMString inputEncoding;
  68. // Introduced in DOM Level 3:
  69. readonly attribute DOMString documentURI;
  70. // Alias introduced for all documents in recent DOM standards
  71. readonly attribute DOMString URL;
  72. // Introduced in DOM Level 3:
  73. nsIDOMNode adoptNode(in nsIDOMNode source)
  74. raises(DOMException);
  75. /**
  76. * Create a range
  77. *
  78. * @see http://html5.org/specs/dom-range.html#dom-document-createrange
  79. */
  80. nsIDOMRange createRange();
  81. [optional_argc] nsIDOMNodeIterator createNodeIterator(in nsIDOMNode root,
  82. [optional] in unsigned long whatToShow,
  83. [optional] in nsIDOMNodeFilter filter)
  84. raises(DOMException);
  85. [optional_argc] nsIDOMTreeWalker createTreeWalker(in nsIDOMNode root,
  86. [optional] in unsigned long whatToShow,
  87. [optional] in nsIDOMNodeFilter filter)
  88. raises(DOMException);
  89. nsIDOMEvent createEvent(in DOMString eventType)
  90. raises(DOMException);
  91. // HTML
  92. /**
  93. * The window associated with this document.
  94. *
  95. * @see <http://www.whatwg.org/html/#dom-document-defaultview>
  96. */
  97. readonly attribute mozIDOMWindowProxy defaultView;
  98. /**
  99. * @see <http://www.whatwg.org/html/#dom-document-characterset>
  100. */
  101. readonly attribute DOMString characterSet;
  102. /**
  103. * @see <http://www.whatwg.org/html/#dom-document-dir>
  104. */
  105. attribute DOMString dir;
  106. /**
  107. * @see <http://www.whatwg.org/html/#dom-document-location>
  108. */
  109. readonly attribute nsIDOMLocation location;
  110. /**
  111. * @see <http://www.whatwg.org/html/#document.title>
  112. */
  113. attribute DOMString title;
  114. /**
  115. * @see <http://www.whatwg.org/html/#dom-document-readystate>
  116. */
  117. readonly attribute DOMString readyState;
  118. /**
  119. * @see <http://www.whatwg.org/html/#dom-document-lastmodified>
  120. */
  121. readonly attribute DOMString lastModified;
  122. /**
  123. * @see <http://www.whatwg.org/html/#dom-document-referrer>
  124. */
  125. readonly attribute DOMString referrer;
  126. /**
  127. * @see <http://www.whatwg.org/html/#dom-document-hasfocus>
  128. */
  129. boolean hasFocus();
  130. /**
  131. * @see <http://www.whatwg.org/html/#dom-document-activeelement>
  132. */
  133. readonly attribute nsIDOMElement activeElement;
  134. /**
  135. * Retrieve elements matching all classes listed in a
  136. * space-separated string.
  137. *
  138. * @see <http://www.whatwg.org/html/#dom-document-getelementsbyclassname>
  139. */
  140. nsIDOMNodeList getElementsByClassName(in DOMString classes);
  141. // CSSOM
  142. /**
  143. * @see <http://dev.w3.org/csswg/cssom/#dom-document-stylesheets>
  144. */
  145. readonly attribute nsIDOMStyleSheetList styleSheets;
  146. /**
  147. * This attribute must return the preferred style sheet set as set by the
  148. * author. It is determined from the order of style sheet declarations and
  149. * the Default-Style HTTP headers, as eventually defined elsewhere in the Web
  150. * Apps 1.0 specification. If there is no preferred style sheet set, this
  151. * attribute must return the empty string. The case of this attribute must
  152. * exactly match the case given by the author where the preferred style sheet
  153. * is specified or implied. This attribute must never return null.
  154. *
  155. * @see <http://dev.w3.org/csswg/cssom/#dom-document-preferredStyleSheetSet>
  156. */
  157. readonly attribute DOMString preferredStyleSheetSet;
  158. /**
  159. * This attribute indicates which style sheet set is in use. This attribute
  160. * is live; changing the disabled attribute on style sheets directly will
  161. * change the value of this attribute.
  162. *
  163. * If all the sheets that are enabled and have a title have the same title
  164. * (by case-sensitive comparisons) then the value of this attribute must be
  165. * exactly equal to the title of the first enabled style sheet with a title
  166. * in the styleSheets list. Otherwise, if style sheets from different sets
  167. * are enabled, then the return value must be null (there is no way to
  168. * determine what the currently selected style sheet set is in those
  169. * conditions). Otherwise, either all style sheets that have a title are
  170. * disabled, or there are no alternate style sheets, and
  171. * selectedStyleSheetSet must return the empty string.
  172. *
  173. * Setting this attribute to the null value must have no effect.
  174. *
  175. * Setting this attribute to a non-null value must call
  176. * enableStyleSheetsForSet() with that value as the function's argument, and
  177. * set lastStyleSheetSet to that value.
  178. *
  179. * From the DOM's perspective, all views have the same
  180. * selectedStyleSheetSet. If a UA supports multiple views with different
  181. * selected alternate style sheets, then this attribute (and the StyleSheet
  182. * interface's disabled attribute) must return and set the value for the
  183. * default view.
  184. *
  185. * @see <http://dev.w3.org/csswg/cssom/#dom-document-selectedStyleSheetSet>
  186. */
  187. [binaryname(MozSelectedStyleSheetSet)]
  188. attribute DOMString selectedStyleSheetSet;
  189. /*
  190. * This property must initially have the value null. Its value changes when
  191. * the selectedStyleSheetSet attribute is set.
  192. *
  193. * @see <http://dev.w3.org/csswg/cssom/#dom-document-lastStyleSheetSet>
  194. */
  195. readonly attribute DOMString lastStyleSheetSet;
  196. /**
  197. * This must return the live list of the currently available style sheet
  198. * sets. This list is constructed by enumerating all the style sheets for
  199. * this document available to the implementation, in the order they are
  200. * listed in the styleSheets attribute, adding the title of each style sheet
  201. * with a title to the list, avoiding duplicates by dropping titles that
  202. * match (case-sensitively) titles that have already been added to the
  203. * list.
  204. *
  205. * @see <http://dev.w3.org/csswg/cssom/#dom-document-styleSheetSets>
  206. */
  207. readonly attribute nsISupports styleSheetSets;
  208. /**
  209. * Calling this method must change the disabled attribute on each StyleSheet
  210. * object with a title attribute with a length greater than 0 in the
  211. * styleSheets attribute, so that all those whose title matches the name
  212. * argument are enabled, and all others are disabled. Title matches must be
  213. * case-sensitive. Calling this method with the empty string disables all
  214. * alternate and preferred style sheets (but does not change the state of
  215. * persistent style sheets, that is those with no title attribute).
  216. *
  217. * Calling this method with a null value must have no effect.
  218. *
  219. * Style sheets that do not have a title are never affected by this
  220. * method. This method does not change the values of the lastStyleSheetSet or
  221. * preferredStyleSheetSet attributes.
  222. *
  223. * @see <http://dev.w3.org/csswg/cssom/#dom-document-enableStyleSheetsForSet>
  224. */
  225. [binaryname(MozEnableStyleSheetsForSet)]
  226. void enableStyleSheetsForSet(in DOMString name);
  227. // CSSOM-View
  228. /**
  229. * Returns the element from the caller's document at the given point,
  230. * relative to the upper-left-most point in the (possibly scrolled)
  231. * window or frame.
  232. *
  233. * If the element at the given point belongs to another document (such as
  234. * an iframe's subdocument), the element in the calling document's DOM
  235. * (e.g. the iframe) is returned. If the element at the given point is
  236. * anonymous or XBL generated content, such as a textbox's scrollbars, then
  237. * the first non-anonymous parent element (that is, the textbox) is returned.
  238. *
  239. * This method returns null if either coordinate is negative, or if the
  240. * specified point lies outside the visible bounds of the document.
  241. *
  242. * Callers from XUL documents should wait until the onload event has fired
  243. * before calling this method.
  244. *
  245. * @see <http://dev.w3.org/csswg/cssom-view/#dom-document-elementfrompoint>
  246. */
  247. nsIDOMElement elementFromPoint(in float x, in float y);
  248. // Mozilla extensions
  249. /**
  250. * @see <https://developer.mozilla.org/en/DOM/document.contentType>
  251. */
  252. readonly attribute DOMString contentType;
  253. /**
  254. * True if this document is synthetic : stand alone image, video, audio file,
  255. * etc.
  256. */
  257. readonly attribute boolean mozSyntheticDocument;
  258. /**
  259. * Returns the script element whose script is currently being processed.
  260. *
  261. * @see <https://developer.mozilla.org/en/DOM/document.currentScript>
  262. */
  263. readonly attribute nsIDOMElement currentScript;
  264. /**
  265. * Release the current mouse capture if it is on an element within this
  266. * document.
  267. *
  268. * @see <https://developer.mozilla.org/en/DOM/document.releaseCapture>
  269. */
  270. void releaseCapture();
  271. /**
  272. * Use the given DOM element as the source image of target |-moz-element()|.
  273. *
  274. * This function introduces a new special ID (called "image element ID"),
  275. * which is only used by |-moz-element()|, and associates it with the given
  276. * DOM element. Image elements ID's have the higher precedence than general
  277. * HTML id's, so if |document.mozSetImageElement(<id>, <element>)| is called,
  278. * |-moz-element(#<id>)| uses |<element>| as the source image even if there
  279. * is another element with id attribute = |<id>|. To unregister an image
  280. * element ID |<id>|, call |document.mozSetImageElement(<id>, null)|.
  281. *
  282. * Example:
  283. * <script>
  284. * canvas = document.createElement("canvas");
  285. * canvas.setAttribute("width", 100);
  286. * canvas.setAttribute("height", 100);
  287. * // draw to canvas
  288. * document.mozSetImageElement("canvasbg", canvas);
  289. * </script>
  290. * <div style="background-image: -moz-element(#canvasbg);"></div>
  291. *
  292. * @param aImageElementId an image element ID to associate with
  293. * |aImageElement|
  294. * @param aImageElement a DOM element to be used as the source image of
  295. * |-moz-element(#aImageElementId)|. If this is null, the function will
  296. * unregister the image element ID |aImageElementId|.
  297. *
  298. * @see <https://developer.mozilla.org/en/DOM/document.mozSetImageElement>
  299. */
  300. void mozSetImageElement(in DOMString aImageElementId,
  301. in nsIDOMElement aImageElement);
  302. /**
  303. * Element which is currently the full-screen element as per the DOM
  304. * full-screen api.
  305. *
  306. * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
  307. */
  308. readonly attribute nsIDOMElement mozFullScreenElement;
  309. /**
  310. * Causes the document to leave DOM full-screen mode, if it's in
  311. * full-screen mode, as per the DOM full-screen api.
  312. *
  313. * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
  314. */
  315. void mozCancelFullScreen();
  316. /**
  317. * Denotes whether this document is in DOM full-screen mode, as per the DOM
  318. * full-screen api.
  319. *
  320. * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
  321. */
  322. readonly attribute boolean mozFullScreen;
  323. /**
  324. * Denotes whether the full-screen-api.enabled is true, no windowed
  325. * plugins are present, and all ancestor documents have the
  326. * allowfullscreen attribute set.
  327. *
  328. * @see <https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI>
  329. */
  330. readonly attribute boolean mozFullScreenEnabled;
  331. /**
  332. * The element to which the mouse pointer is locked, if any, as per the
  333. * DOM pointer lock api.
  334. *
  335. * @see <http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html>
  336. */
  337. readonly attribute nsIDOMElement mozPointerLockElement;
  338. /**
  339. * Retrieve the location of the caret position (DOM node and character
  340. * offset within that node), given a point.
  341. *
  342. * @param x Horizontal point at which to determine the caret position, in
  343. * page coordinates.
  344. * @param y Vertical point at which to determine the caret position, in
  345. * page coordinates.
  346. */
  347. nsISupports /* CaretPosition */ caretPositionFromPoint(in float x, in float y);
  348. /**
  349. * Exit pointer is lock if locked, as per the DOM pointer lock api.
  350. *
  351. * @see <http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html>
  352. */
  353. void mozExitPointerLock();
  354. /**
  355. * Visibility API implementation.
  356. */
  357. readonly attribute boolean hidden;
  358. readonly attribute DOMString visibilityState;
  359. /**
  360. * Returns "BackCompat" if we're in quirks mode or "CSS1Compat" if we're in
  361. * strict mode. (XML documents are always in strict mode.)
  362. */
  363. readonly attribute DOMString compatMode;
  364. /**
  365. * Return nodes that match a given CSS selector.
  366. *
  367. * @see <http://dev.w3.org/2006/webapi/selectors-api/>
  368. */
  369. nsIDOMElement querySelector([Null(Stringify)] in DOMString selectors);
  370. nsIDOMNodeList querySelectorAll([Null(Stringify)] in DOMString selectors);
  371. };