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"
9 interface nsIPrintSettings
;
14 #include
"mozilla/Maybe.h"
22 class nsDOMNavigationTiming
;
27 class WindowGlobalChild
;
30 class RemotePrintJobChild
;
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
;
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 {
73 eDontPromptAndDontUnload
= 1,
74 eDontPromptAndUnload
= 2
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 {
85 eRequestBlockNavigation
= 1,
89 * Overload PermitUnload method for C++ consumers with no aPermitUnloadFlags
93 nsresult PermitUnload
(bool
* canUnload
) {
94 return PermitUnload
(ePrompt
, canUnload
);
99 * Checks if the document wants to prevent unloading by firing beforeunload on
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
);
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
179 [notxpcom
,nostdcall
] attribute nsIDocumentViewer previousViewer
;
181 void move
(in long aX
, in long aY
);
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
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
] void setPrintSettingsForSubdocument
(in nsIPrintSettings aPrintSettings
,
215 in RemotePrintJobChildPtr aRemotePrintJob
);
218 * Get the history entry that this viewer will save itself into when
219 * destroyed. Can return null
221 readonly attribute nsISHEntry historyEntry
;
224 * Indicates when we're in a state where content shouldn't be allowed to
225 * trigger a tab-modal prompt (as opposed to a window-modal prompt) because
226 * we're part way through some operation (eg beforeunload) that shouldn't be
227 * rentrant if the user closes the tab while the prompt is showing.
230 readonly attribute
boolean isTabModalPromptAllowed
;
233 * Returns whether this content viewer is in a hidden state.
235 * @note Only Gecko internal code should set the attribute!
237 attribute
boolean isHidden
;
239 // presShell can be null.
240 [notxpcom
,nostdcall
] readonly attribute PresShellPtr presShell
;
241 // presContext can be null.
242 [notxpcom
,nostdcall
] readonly attribute nsPresContextPtr presContext
;
243 // aDocument must not be null.
244 [noscript
] void setDocumentInternal
(in Document aDocument
,
245 in boolean aForceReuseInnerWindow
);
247 * Find the view to use as the container view for MakeWindow. Returns
248 * null if this will be the root of a view manager hierarchy. In that
249 * case, if mParentWidget is null then this document should not even
252 [noscript
,notxpcom
,nostdcall
] nsViewPtr findContainerView
();
254 * Set collector for navigation timing data (load, unload events).
256 [noscript
,notxpcom
,nostdcall
] void setNavigationTiming
(in nsDOMNavigationTimingPtr aTiming
);
259 * The actual full zoom in effect, as modified by the device context.
260 * For a requested full zoom, the device context may choose a slightly
261 * different effectiveFullZoom to accomodate integer rounding of app units
262 * per dev pixel. This property returns the actual zoom amount in use,
263 * though it may not be good user experience to report that a requested zoom
264 * of 90% is actually 89.1%, for example. This value is provided primarily to
265 * support media queries of dppx values, because those queries are matched
266 * against the actual native device pixel ratio and the actual full zoom.
268 * You should only need this for testing.
270 readonly attribute
float deviceFullZoomForTest
;
273 * Disable entire author style level (including HTML presentation hints),
274 * for this viewer but not any child viewers.
276 attribute
boolean authorStyleDisabled
;
279 * Returns the preferred width and height of the content, constrained to the
280 * given maximum values. If either maxWidth or maxHeight is less than or
281 * equal to zero, that dimension is not constrained.
283 * If a pref width is provided, it is max'd with the min-content size.
285 * All input and output values are in CSS pixels.
287 void getContentSize
(in long maxWidth
,
294 mozilla
::Maybe<mozilla
::CSSIntSize
> GetContentSize
(int32_t aMaxWidth
= 0, int32_t aMaxHeight
= 0, int32_t aPrefWidth
= 0) {
297 if
(NS_SUCCEEDED
(GetContentSize
(aMaxWidth
, aMaxHeight
, aPrefWidth
, &w
, &h
))) {
298 return mozilla
::Some
(mozilla
::CSSIntSize
(w
, h
));
300 return mozilla
::Nothing
();
304 [noscript
, notxpcom
] Encoding getReloadEncodingAndSource
(out int32_t aSource
);
305 [noscript
, notxpcom
] void setReloadEncodingAndSource
(in Encoding aEncoding
, in int32_t aSource
);
306 [noscript
, notxpcom
] void forgetReloadEncoding
();
313 using XPCOMPermitUnloadAction
= nsIDocumentViewer
::PermitUnloadAction
;
314 using PermitUnloadResult
= nsIDocumentViewer
::PermitUnloadResult
;
317 } // namespace mozilla