nsIContentViewer.idl 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. interface nsIDocShell;
  6. interface nsIDocument;
  7. interface nsIDOMDocument;
  8. interface nsIDOMNode;
  9. interface nsISHEntry;
  10. interface nsIPrintSettings;
  11. %{ C++
  12. #include "nsTArray.h"
  13. #include "nsRect.h"
  14. class nsIWidget;
  15. class nsIPresShell;
  16. class nsPresContext;
  17. class nsView;
  18. class nsDOMNavigationTiming;
  19. %}
  20. [ptr] native nsIWidgetPtr(nsIWidget);
  21. [ref] native nsIntRectRef(nsIntRect);
  22. [ptr] native nsIPresShellPtr(nsIPresShell);
  23. [ptr] native nsPresContextPtr(nsPresContext);
  24. [ptr] native nsViewPtr(nsView);
  25. [ptr] native nsDOMNavigationTimingPtr(nsDOMNavigationTiming);
  26. [ref] native nsIContentViewerTArray(nsTArray<nsCOMPtr<nsIContentViewer> >);
  27. [scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
  28. interface nsIContentViewer : nsISupports
  29. {
  30. [noscript] void init(in nsIWidgetPtr aParentWidget,
  31. [const] in nsIntRectRef aBounds);
  32. attribute nsIDocShell container;
  33. [noscript,notxpcom,nostdcall] void loadStart(in nsIDocument aDoc);
  34. void loadComplete(in nsresult aStatus);
  35. [noscript] readonly attribute boolean loadCompleted;
  36. /**
  37. * Checks if the document wants to prevent unloading by firing beforeunload on
  38. * the document, and if it does, prompts the user. The result is returned.
  39. */
  40. boolean permitUnload();
  41. /**
  42. * Exposes whether we're blocked in a call to permitUnload.
  43. */
  44. readonly attribute boolean inPermitUnload;
  45. /**
  46. * As above, but this passes around the aShouldPrompt argument to keep
  47. * track of whether the user has responded to a prompt.
  48. * Used internally by the scriptable version to ensure we only prompt once.
  49. */
  50. [noscript,nostdcall] boolean permitUnloadInternal(inout boolean aShouldPrompt);
  51. /**
  52. * Exposes whether we're in the process of firing the beforeunload event.
  53. * In this case, the corresponding docshell will not allow navigation.
  54. */
  55. readonly attribute boolean beforeUnloadFiring;
  56. void pageHide(in boolean isUnload);
  57. /**
  58. * All users of a content viewer are responsible for calling both
  59. * close() and destroy(), in that order.
  60. *
  61. * close() should be called when the load of a new page for the next
  62. * content viewer begins, and destroy() should be called when the next
  63. * content viewer replaces this one.
  64. *
  65. * |historyEntry| sets the session history entry for the content viewer. If
  66. * this is null, then Destroy() will be called on the document by close().
  67. * If it is non-null, the document will not be destroyed, and the following
  68. * actions will happen when destroy() is called (*):
  69. * - Sanitize() will be called on the viewer's document
  70. * - The content viewer will set the contentViewer property on the
  71. * history entry, and release its reference (ownership reversal).
  72. * - hide() will be called, and no further destruction will happen.
  73. *
  74. * (*) unless the document is currently being printed, in which case
  75. * it will never be saved in session history.
  76. *
  77. */
  78. void close(in nsISHEntry historyEntry);
  79. void destroy();
  80. void stop();
  81. attribute nsIDOMDocument DOMDocument;
  82. /**
  83. * Returns DOMDocument as nsIDocument and without addrefing.
  84. */
  85. [noscript,notxpcom] nsIDocument getDocument();
  86. [noscript] void getBounds(in nsIntRectRef aBounds);
  87. [noscript] void setBounds([const] in nsIntRectRef aBounds);
  88. /**
  89. * The 'aFlags' argument to setBoundsWithFlags is a set of these bits.
  90. */
  91. const unsigned long eDelayResize = 1;
  92. [noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds,
  93. in unsigned long aFlags);
  94. /**
  95. * The previous content viewer, which has been |close|d but not
  96. * |destroy|ed.
  97. */
  98. [noscript] attribute nsIContentViewer previousViewer;
  99. void move(in long aX, in long aY);
  100. void show();
  101. void hide();
  102. attribute boolean sticky;
  103. /*
  104. * This is called when the DOM window wants to be closed. Returns true
  105. * if the window can close immediately. Otherwise, returns false and will
  106. * close the DOM window as soon as practical.
  107. */
  108. boolean requestWindowClose();
  109. /**
  110. * Attach the content viewer to its DOM window and docshell.
  111. * @param aState A state object that might be useful in attaching the DOM
  112. * window.
  113. * @param aSHEntry The history entry that the content viewer was stored in.
  114. * The entry must have the docshells for all of the child
  115. * documents stored in its child shell list.
  116. */
  117. void open(in nsISupports aState, in nsISHEntry aSHEntry);
  118. /**
  119. * Clears the current history entry. This is used if we need to clear out
  120. * the saved presentation state.
  121. */
  122. void clearHistoryEntry();
  123. /**
  124. * Change the layout to view the document with page layout (like print preview), but
  125. * dynamic and editable (like Galley layout).
  126. */
  127. void setPageMode(in boolean aPageMode, in nsIPrintSettings aPrintSettings);
  128. /**
  129. * Get the history entry that this viewer will save itself into when
  130. * destroyed. Can return null
  131. */
  132. readonly attribute nsISHEntry historyEntry;
  133. /**
  134. * Indicates when we're in a state where content shouldn't be allowed to
  135. * trigger a tab-modal prompt (as opposed to a window-modal prompt) because
  136. * we're part way through some operation (eg beforeunload) that shouldn't be
  137. * rentrant if the user closes the tab while the prompt is showing.
  138. * See bug 613800.
  139. */
  140. readonly attribute boolean isTabModalPromptAllowed;
  141. /**
  142. * Returns whether this content viewer is in a hidden state.
  143. *
  144. * @note Only Gecko internal code should set the attribute!
  145. */
  146. attribute boolean isHidden;
  147. [noscript] readonly attribute nsIPresShellPtr presShell;
  148. [noscript] readonly attribute nsPresContextPtr presContext;
  149. // aDocument must not be null.
  150. [noscript] void setDocumentInternal(in nsIDocument aDocument,
  151. in boolean aForceReuseInnerWindow);
  152. /**
  153. * Find the view to use as the container view for MakeWindow. Returns
  154. * null if this will be the root of a view manager hierarchy. In that
  155. * case, if mParentWidget is null then this document should not even
  156. * be displayed.
  157. */
  158. [noscript,notxpcom,nostdcall] nsViewPtr findContainerView();
  159. /**
  160. * Set collector for navigation timing data (load, unload events).
  161. */
  162. [noscript,notxpcom,nostdcall] void setNavigationTiming(in nsDOMNavigationTimingPtr aTiming);
  163. /*
  164. Scrolls to a given DOM content node.
  165. */
  166. void scrollToNode(in nsIDOMNode node);
  167. /** The amount by which to scale all text. Default is 1.0. */
  168. attribute float textZoom;
  169. /** The amount by which to scale all lengths. Default is 1.0. */
  170. attribute float fullZoom;
  171. /**
  172. * The value used to override devicePixelRatio and media queries dppx.
  173. * Default is 0.0, that means no overriding is done (only a positive value
  174. * is applied).
  175. */
  176. attribute float overrideDPPX;
  177. /** Disable entire author style level (including HTML presentation hints) */
  178. attribute boolean authorStyleDisabled;
  179. /**
  180. * XXX comm-central only: bug 829543. Not the Character Encoding menu in
  181. * browser!
  182. */
  183. attribute ACString forceCharacterSet;
  184. /**
  185. * XXX comm-central only: bug 829543.
  186. */
  187. attribute ACString hintCharacterSet;
  188. /**
  189. * XXX comm-central only: bug 829543.
  190. */
  191. attribute int32_t hintCharacterSetSource;
  192. /**
  193. * Requests the size of the content to the container.
  194. */
  195. void getContentSize(out long width, out long height);
  196. /**
  197. * Returns the preferred width and height of the content, constrained to the
  198. * given maximum values. If either maxWidth or maxHeight is less than zero,
  199. * that dimension is not constrained.
  200. *
  201. * All input and output values are in device pixels, rather than CSS pixels.
  202. */
  203. void getContentSizeConstrained(in long maxWidth, in long maxHeight,
  204. out long width, out long height);
  205. /** The minimum font size */
  206. attribute long minFontSize;
  207. /**
  208. * Append |this| and all of its descendants to the given array,
  209. * in depth-first pre-order traversal.
  210. */
  211. [noscript] void appendSubtree(in nsIContentViewerTArray array);
  212. /**
  213. * Instruct the refresh driver to discontinue painting until further
  214. * notice.
  215. */
  216. void pausePainting();
  217. /**
  218. * Instruct the refresh driver to resume painting after a previous call to
  219. * pausePainting().
  220. */
  221. void resumePainting();
  222. /*
  223. * Render the document as if being viewed on a device with the specified
  224. * media type. This will cause a reflow.
  225. *
  226. * @param mediaType The media type to be emulated
  227. */
  228. void emulateMedium(in AString aMediaType);
  229. /*
  230. * Restore the viewer's natural media type
  231. */
  232. void stopEmulatingMedium();
  233. };