Bug 1807268 - Fix verifyOpenAllInNewTabsOptionTest UI test r=ohorvath
[gecko.git] / docshell / base / nsIDocumentViewer.idl
blob27510dc87905a41e1f222449810e3a2a71e6243c
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/. */
5 #include "nsISupports.idl"
7 interface nsIDocShell;
8 interface nsISHEntry;
9 interface nsIPrintSettings;
10 webidl Document;
11 webidl Node;
13 %{ C++
14 #include "mozilla/Maybe.h"
15 #include "nsTArray.h"
16 #include "nsRect.h"
17 #include "Units.h"
19 class nsIWidget;
20 class nsPresContext;
21 class nsView;
22 class nsDOMNavigationTiming;
23 namespace mozilla {
24 class Encoding;
25 class PresShell;
26 namespace dom {
27 class WindowGlobalChild;
28 } // namespace dom
29 namespace layout {
30 class RemotePrintJobChild;
31 } // namespace layout
32 } // namespace mozilla
35 [ptr] native nsIWidgetPtr(nsIWidget);
36 [ref] native nsIntRectRef(nsIntRect);
37 [ptr] native nsPresContextPtr(nsPresContext);
38 [ptr] native nsViewPtr(nsView);
39 [ptr] native nsDOMNavigationTimingPtr(nsDOMNavigationTiming);
40 [ptr] native Encoding(const mozilla::Encoding);
41 [ptr] native PresShellPtr(mozilla::PresShell);
42 [ptr] native RemotePrintJobChildPtr(mozilla::layout::RemotePrintJobChild);
43 [ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild);
45 [scriptable, builtinclass, uuid(48118355-e9a5-4452-ab18-59cc426fb817)]
46 interface nsIDocumentViewer : nsISupports
48 [noscript] void init(in nsIWidgetPtr aParentWidget,
49 [const] in nsIntRectRef aBounds,
50 in WindowGlobalChildPtr aWindowActor);
52 attribute nsIDocShell container;
54 [noscript,notxpcom,nostdcall] void loadStart(in Document aDoc);
55 [can_run_script] void loadComplete(in nsresult aStatus);
56 [notxpcom,nostdcall] readonly attribute boolean loadCompleted;
58 [notxpcom,nostdcall] readonly attribute boolean isStopped;
60 /**
61 * aAction is passed to PermitUnload to indicate what action to take
62 * if a beforeunload handler wants to prompt the user.
64 * ePrompt: Prompt and return the user's choice (default).
65 * eDontPromptAndDontUnload: Don't prompt and return false (unload not permitted)
66 * if the document (or its children) asks us to prompt.
67 * eDontPromptAndUnload: Don't prompt and return true (unload permitted) no matter what.
69 * NOTE: Keep this in sync with PermitUnloadAction in WindowGlobalActors.webidl.
71 cenum PermitUnloadAction : 8 {
72 ePrompt = 0,
73 eDontPromptAndDontUnload = 1,
74 eDontPromptAndUnload = 2
77 /**
78 * The result of dispatching a "beforeunload" event. If `eAllowNavigation`,
79 * no "beforeunload" listener requested to prevent the navigation, or its
80 * request was ignored. If `eRequestBlockNavigation`, a listener did request
81 * to block the navigation, and the user should be prompted.
83 cenum PermitUnloadResult : 8 {
84 eAllowNavigation = 0,
85 eRequestBlockNavigation = 1,
88 /**
89 * Overload PermitUnload method for C++ consumers with no aPermitUnloadFlags
90 * argument.
92 %{C++
93 nsresult PermitUnload(bool* canUnload) {
94 return PermitUnload(ePrompt, canUnload);
98 /**
99 * Checks if the document wants to prevent unloading by firing beforeunload on
100 * the document.
101 * The result is returned.
103 boolean permitUnload([optional] in nsIDocumentViewer_PermitUnloadAction aAction);
106 * Exposes whether we're blocked in a call to permitUnload.
108 readonly attribute boolean inPermitUnload;
111 * Dispatches the "beforeunload" event and returns the result, as documented
112 * in the `PermitUnloadResult` enum.
114 [noscript,nostdcall,notxpcom] nsIDocumentViewer_PermitUnloadResult dispatchBeforeUnload();
117 * Exposes whether we're in the process of firing the beforeunload event.
118 * In this case, the corresponding docshell will not allow navigation.
120 readonly attribute boolean beforeUnloadFiring;
122 [can_run_script] void pageHide(in boolean isUnload);
125 * All users of a content viewer are responsible for calling both
126 * close() and destroy(), in that order.
128 * close() should be called when the load of a new page for the next
129 * content viewer begins, and destroy() should be called when the next
130 * content viewer replaces this one.
132 * |historyEntry| sets the session history entry for the content viewer. If
133 * this is null, then Destroy() will be called on the document by close().
134 * If it is non-null, the document will not be destroyed, and the following
135 * actions will happen when destroy() is called (*):
136 * - Sanitize() will be called on the viewer's document
137 * - The content viewer will set the contentViewer property on the
138 * history entry, and release its reference (ownership reversal).
139 * - hide() will be called, and no further destruction will happen.
141 * (*) unless the document is currently being printed, in which case
142 * it will never be saved in session history.
145 void close(in nsISHEntry historyEntry);
146 void destroy();
148 void stop();
151 * Returns the same thing as getDocument(), but for use from script
152 * only. C++ consumers should use getDocument().
154 readonly attribute Document DOMDocument;
157 * Returns DOMDocument without addrefing.
159 [noscript,notxpcom,nostdcall] Document getDocument();
162 * Allows setting the document.
164 [noscript,nostdcall] void setDocument(in Document aDocument);
166 [noscript] void getBounds(in nsIntRectRef aBounds);
167 [noscript] void setBounds([const] in nsIntRectRef aBounds);
169 * The 'aFlags' argument to setBoundsWithFlags is a set of these bits.
171 const unsigned long eDelayResize = 1;
172 [noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds,
173 in unsigned long aFlags);
176 * The previous content viewer, which has been |close|d but not
177 * |destroy|ed.
179 [notxpcom,nostdcall] attribute nsIDocumentViewer previousViewer;
181 void move(in long aX, in long aY);
183 void show();
184 void hide();
186 attribute boolean sticky;
189 * Attach the content viewer to its DOM window and docshell.
190 * @param aState A state object that might be useful in attaching the DOM
191 * window.
192 * @param aSHEntry The history entry that the content viewer was stored in.
193 * The entry must have the docshells for all of the child
194 * documents stored in its child shell list.
196 void open(in nsISupports aState, in nsISHEntry aSHEntry);
199 * Clears the current history entry. This is used if we need to clear out
200 * the saved presentation state.
202 void clearHistoryEntry();
205 * Change the layout to view the document with page layout (like print preview), but
206 * dynamic and editable (like Galley layout).
208 void setPageModeForTesting(in boolean aPageMode,
209 in nsIPrintSettings aPrintSettings);
212 * Sets the print settings for print / print-previewing a subdocument.
214 [can_run_script, noscript]
215 void setPrintSettingsForSubdocument(in nsIPrintSettings aPrintSettings,
216 in RemotePrintJobChildPtr aRemotePrintJob);
219 * Get the history entry that this viewer will save itself into when
220 * destroyed. Can return null
222 readonly attribute nsISHEntry historyEntry;
225 * Indicates when we're in a state where content shouldn't be allowed to
226 * trigger a tab-modal prompt (as opposed to a window-modal prompt) because
227 * we're part way through some operation (eg beforeunload) that shouldn't be
228 * rentrant if the user closes the tab while the prompt is showing.
229 * See bug 613800.
231 readonly attribute boolean isTabModalPromptAllowed;
234 * Returns whether this content viewer is in a hidden state.
236 * @note Only Gecko internal code should set the attribute!
238 attribute boolean isHidden;
240 // presShell can be null.
241 [notxpcom,nostdcall] readonly attribute PresShellPtr presShell;
242 // presContext can be null.
243 [notxpcom,nostdcall] readonly attribute nsPresContextPtr presContext;
244 // aDocument must not be null.
245 [noscript] void setDocumentInternal(in Document aDocument,
246 in boolean aForceReuseInnerWindow);
248 * Find the view to use as the container view for MakeWindow. Returns
249 * null if this will be the root of a view manager hierarchy. In that
250 * case, if mParentWidget is null then this document should not even
251 * be displayed.
253 [noscript,notxpcom,nostdcall] nsViewPtr findContainerView();
255 * Set collector for navigation timing data (load, unload events).
257 [noscript,notxpcom,nostdcall] void setNavigationTiming(in nsDOMNavigationTimingPtr aTiming);
260 * The actual full zoom in effect, as modified by the device context.
261 * For a requested full zoom, the device context may choose a slightly
262 * different effectiveFullZoom to accomodate integer rounding of app units
263 * per dev pixel. This property returns the actual zoom amount in use,
264 * though it may not be good user experience to report that a requested zoom
265 * of 90% is actually 89.1%, for example. This value is provided primarily to
266 * support media queries of dppx values, because those queries are matched
267 * against the actual native device pixel ratio and the actual full zoom.
269 * You should only need this for testing.
271 readonly attribute float deviceFullZoomForTest;
274 * Disable entire author style level (including HTML presentation hints),
275 * for this viewer but not any child viewers.
277 attribute boolean authorStyleDisabled;
280 * Returns the preferred width and height of the content, constrained to the
281 * given maximum values. If either maxWidth or maxHeight is less than or
282 * equal to zero, that dimension is not constrained.
284 * If a pref width is provided, it is max'd with the min-content size.
286 * All input and output values are in CSS pixels.
288 void getContentSize(in long maxWidth,
289 in long maxHeight,
290 in long prefWidth,
291 out long width,
292 out long height);
294 %{C++
295 mozilla::Maybe<mozilla::CSSIntSize> GetContentSize(int32_t aMaxWidth = 0, int32_t aMaxHeight = 0, int32_t aPrefWidth = 0) {
296 int32_t w = 0;
297 int32_t h = 0;
298 if (NS_SUCCEEDED(GetContentSize(aMaxWidth, aMaxHeight, aPrefWidth, &w, &h))) {
299 return mozilla::Some(mozilla::CSSIntSize(w, h));
301 return mozilla::Nothing();
305 [noscript, notxpcom] Encoding getReloadEncodingAndSource(out int32_t aSource);
306 [noscript, notxpcom] void setReloadEncodingAndSource(in Encoding aEncoding, in int32_t aSource);
307 [noscript, notxpcom] void forgetReloadEncoding();
310 %{C++
311 namespace mozilla {
312 namespace dom {
314 using XPCOMPermitUnloadAction = nsIDocumentViewer::PermitUnloadAction;
315 using PermitUnloadResult = nsIDocumentViewer::PermitUnloadResult;
317 } // namespace dom
318 } // namespace mozilla