Source code

Revision control

Other Tools

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
5
#include "nsISupports.idl"
6
7
interface nsIDocShell;
8
interface nsISHEntry;
9
interface nsIPrintSettings;
10
webidl Document;
11
webidl Node;
12
13
%{ C++
14
#include "nsTArray.h"
15
#include "nsRect.h"
16
17
class nsIWidget;
18
class nsPresContext;
19
class nsView;
20
class nsDOMNavigationTiming;
21
namespace mozilla {
22
class Encoding;
23
class PresShell;
24
namespace dom {
25
class WindowGlobalChild;
26
} // namespace dom
27
} // namespace mozilla
28
%}
29
30
[ptr] native nsIWidgetPtr(nsIWidget);
31
[ref] native nsIntRectRef(nsIntRect);
32
[ptr] native nsPresContextPtr(nsPresContext);
33
[ptr] native nsViewPtr(nsView);
34
[ptr] native nsDOMNavigationTimingPtr(nsDOMNavigationTiming);
35
[ref] native nsIContentViewerTArray(nsTArray<nsCOMPtr<nsIContentViewer> >);
36
[ptr] native Encoding(const mozilla::Encoding);
37
[ptr] native PresShellPtr(mozilla::PresShell);
38
[ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild);
39
40
[scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
41
interface nsIContentViewer : nsISupports
42
{
43
[noscript] void init(in nsIWidgetPtr aParentWidget,
44
[const] in nsIntRectRef aBounds,
45
in WindowGlobalChildPtr aWindowActor);
46
47
attribute nsIDocShell container;
48
49
[noscript,notxpcom,nostdcall] void loadStart(in Document aDoc);
50
[can_run_script] void loadComplete(in nsresult aStatus);
51
[notxpcom,nostdcall] readonly attribute boolean loadCompleted;
52
53
[notxpcom,nostdcall] readonly attribute boolean isStopped;
54
55
/**
56
* aPermitUnloadFlags are passed to PermitUnload to indicate what action to take
57
* if a beforeunload handler wants to prompt the user. It is also used by
58
* permitUnloadInternal to ensure we only prompt once.
59
*
60
* ePrompt: Prompt and return the user's choice (default).
61
* eDontPromptAndDontUnload: Don't prompt and return false (unload not permitted)
62
* if the document (or its children) asks us to prompt.
63
* eDontPromptAndUnload: Don't prompt and return true (unload permitted) no matter what.
64
*/
65
const unsigned long ePrompt = 0;
66
const unsigned long eDontPromptAndDontUnload = 1;
67
const unsigned long eDontPromptAndUnload = 2;
68
69
/**
70
* Overload PermitUnload method for C++ consumers with no aPermitUnloadFlags
71
* argument.
72
*/
73
%{C++
74
nsresult PermitUnload(bool* canUnload) {
75
return PermitUnload(ePrompt, canUnload);
76
}
77
%}
78
79
/**
80
* Checks if the document wants to prevent unloading by firing beforeunload on
81
* the document, and if it does, takes action directed by aPermitUnloadFlags.
82
* The result is returned.
83
*/
84
boolean permitUnload([optional] in unsigned long aPermitUnloadFlags);
85
86
/**
87
* Exposes whether we're blocked in a call to permitUnload.
88
*/
89
readonly attribute boolean inPermitUnload;
90
91
/**
92
* As above, but this passes around the aPermitUnloadFlags argument to keep
93
* track of whether the user has responded to a prompt.
94
* Used internally by the scriptable version to ensure we only prompt once.
95
*/
96
[noscript,nostdcall] boolean permitUnloadInternal(inout unsigned long aPermitUnloadFlags);
97
98
/**
99
* Exposes whether we're in the process of firing the beforeunload event.
100
* In this case, the corresponding docshell will not allow navigation.
101
*/
102
readonly attribute boolean beforeUnloadFiring;
103
104
void pageHide(in boolean isUnload);
105
106
/**
107
* All users of a content viewer are responsible for calling both
108
* close() and destroy(), in that order.
109
*
110
* close() should be called when the load of a new page for the next
111
* content viewer begins, and destroy() should be called when the next
112
* content viewer replaces this one.
113
*
114
* |historyEntry| sets the session history entry for the content viewer. If
115
* this is null, then Destroy() will be called on the document by close().
116
* If it is non-null, the document will not be destroyed, and the following
117
* actions will happen when destroy() is called (*):
118
* - Sanitize() will be called on the viewer's document
119
* - The content viewer will set the contentViewer property on the
120
* history entry, and release its reference (ownership reversal).
121
* - hide() will be called, and no further destruction will happen.
122
*
123
* (*) unless the document is currently being printed, in which case
124
* it will never be saved in session history.
125
*
126
*/
127
void close(in nsISHEntry historyEntry);
128
void destroy();
129
130
void stop();
131
132
/**
133
* Returns the same thing as getDocument(), but for use from script
134
* only. C++ consumers should use getDocument().
135
*/
136
readonly attribute Document DOMDocument;
137
138
/**
139
* Returns DOMDocument without addrefing.
140
*/
141
[noscript,notxpcom,nostdcall] Document getDocument();
142
143
/**
144
* Allows setting the document.
145
*/
146
[noscript,nostdcall] void setDocument(in Document aDocument);
147
148
[noscript] void getBounds(in nsIntRectRef aBounds);
149
[noscript] void setBounds([const] in nsIntRectRef aBounds);
150
/**
151
* The 'aFlags' argument to setBoundsWithFlags is a set of these bits.
152
*/
153
const unsigned long eDelayResize = 1;
154
[noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds,
155
in unsigned long aFlags);
156
157
/**
158
* The previous content viewer, which has been |close|d but not
159
* |destroy|ed.
160
*/
161
[notxpcom,nostdcall] attribute nsIContentViewer previousViewer;
162
163
void move(in long aX, in long aY);
164
165
void show();
166
void hide();
167
168
attribute boolean sticky;
169
170
/*
171
* This is called when the DOM window wants to be closed. Returns true
172
* if the window can close immediately. Otherwise, returns false and will
173
* close the DOM window as soon as practical.
174
*/
175
176
boolean requestWindowClose();
177
178
/**
179
* Attach the content viewer to its DOM window and docshell.
180
* @param aState A state object that might be useful in attaching the DOM
181
* window.
182
* @param aSHEntry The history entry that the content viewer was stored in.
183
* The entry must have the docshells for all of the child
184
* documents stored in its child shell list.
185
*/
186
void open(in nsISupports aState, in nsISHEntry aSHEntry);
187
188
/**
189
* Clears the current history entry. This is used if we need to clear out
190
* the saved presentation state.
191
*/
192
void clearHistoryEntry();
193
194
/**
195
* Change the layout to view the document with page layout (like print preview), but
196
* dynamic and editable (like Galley layout).
197
*/
198
void setPageModeForTesting(in boolean aPageMode,
199
in nsIPrintSettings aPrintSettings);
200
201
/**
202
* Get the history entry that this viewer will save itself into when
203
* destroyed. Can return null
204
*/
205
readonly attribute nsISHEntry historyEntry;
206
207
/**
208
* Indicates when we're in a state where content shouldn't be allowed to
209
* trigger a tab-modal prompt (as opposed to a window-modal prompt) because
210
* we're part way through some operation (eg beforeunload) that shouldn't be
211
* rentrant if the user closes the tab while the prompt is showing.
212
* See bug 613800.
213
*/
214
readonly attribute boolean isTabModalPromptAllowed;
215
216
/**
217
* Returns whether this content viewer is in a hidden state.
218
*
219
* @note Only Gecko internal code should set the attribute!
220
*/
221
attribute boolean isHidden;
222
223
// presShell can be null.
224
[notxpcom,nostdcall] readonly attribute PresShellPtr presShell;
225
// presContext can be null.
226
[notxpcom,nostdcall] readonly attribute nsPresContextPtr presContext;
227
// aDocument must not be null.
228
[noscript] void setDocumentInternal(in Document aDocument,
229
in boolean aForceReuseInnerWindow);
230
/**
231
* Find the view to use as the container view for MakeWindow. Returns
232
* null if this will be the root of a view manager hierarchy. In that
233
* case, if mParentWidget is null then this document should not even
234
* be displayed.
235
*/
236
[noscript,notxpcom,nostdcall] nsViewPtr findContainerView();
237
/**
238
* Set collector for navigation timing data (load, unload events).
239
*/
240
[noscript,notxpcom,nostdcall] void setNavigationTiming(in nsDOMNavigationTimingPtr aTiming);
241
242
/** The amount by which to scale all text. Default is 1.0. */
243
attribute float textZoom;
244
245
/** The actual text zoom in effect, as modified by the system font scale. */
246
readonly attribute float effectiveTextZoom;
247
248
/** The amount by which to scale all lengths. Default is 1.0. */
249
attribute float fullZoom;
250
251
/**
252
* The actual full zoom in effect, as modified by the device context.
253
* For a requested full zoom, the device context may choose a slightly
254
* different effectiveFullZoom to accomodate integer rounding of app units
255
* per dev pixel. This property returns the actual zoom amount in use,
256
* though it may not be good user experience to report that a requested zoom
257
* of 90% is actually 89.1%, for example. This value is provided primarily to
258
* support media queries of dppx values, because those queries are matched
259
* against the actual native device pixel ratio and the actual full zoom.
260
*/
261
readonly attribute float deviceFullZoom;
262
263
/**
264
* The value used to override devicePixelRatio and media queries dppx.
265
* Default is 0.0, that means no overriding is done (only a positive value
266
* is applied).
267
*/
268
attribute float overrideDPPX;
269
270
/** Disable entire author style level (including HTML presentation hints) */
271
attribute boolean authorStyleDisabled;
272
273
/**
274
* XXX comm-central only: bug 829543. Not the Character Encoding menu in
275
* browser!
276
*/
277
attribute ACString forceCharacterSet;
278
279
/**
280
* XXX comm-central only: bug 829543.
281
*/
282
attribute ACString hintCharacterSet;
283
284
/**
285
* XXX comm-central only: bug 829543.
286
*/
287
attribute int32_t hintCharacterSetSource;
288
289
/**
290
* Requests the size of the content to the container.
291
*/
292
void getContentSize(out long width, out long height);
293
294
/**
295
* Returns the preferred width and height of the content, constrained to the
296
* given maximum values. If either maxWidth or maxHeight is less than zero,
297
* that dimension is not constrained.
298
*
299
* All input and output values are in device pixels, rather than CSS pixels.
300
*/
301
void getContentSizeConstrained(in long maxWidth, in long maxHeight,
302
out long width, out long height);
303
304
/**
305
* Append |this| and all of its descendants to the given array,
306
* in depth-first pre-order traversal.
307
*/
308
[noscript] void appendSubtree(in nsIContentViewerTArray array);
309
310
/**
311
* Instruct the refresh driver to discontinue painting until further
312
* notice.
313
*/
314
void pausePainting();
315
316
/**
317
* Instruct the refresh driver to resume painting after a previous call to
318
* pausePainting().
319
*/
320
void resumePainting();
321
322
/*
323
* Render the document as if being viewed on a device with the specified
324
* media type. This will cause a reflow.
325
*
326
* @param mediaType The media type to be emulated
327
*/
328
void emulateMedium(in AString aMediaType);
329
330
/*
331
* Restore the viewer's natural media type
332
*/
333
void stopEmulatingMedium();
334
335
cenum PrefersColorScheme : 8 {
336
PREFERS_COLOR_SCHEME_LIGHT,
337
PREFERS_COLOR_SCHEME_DARK,
338
PREFERS_COLOR_SCHEME_NO_PREFERENCE,
339
PREFERS_COLOR_SCHEME_NONE, /* This clears the override. */
340
};
341
342
/*
343
* Emulate or stop emulating the prefers color scheme on this page and
344
* subdocuments.
345
*/
346
void emulatePrefersColorScheme(in nsIContentViewer_PrefersColorScheme aPrefersColorScheme);
347
348
[noscript, notxpcom] Encoding getHintCharset();
349
[noscript, notxpcom] void setHintCharset(in Encoding aEncoding);
350
[noscript, notxpcom] Encoding getForceCharset();
351
[noscript, notxpcom] void setForceCharset(in Encoding aEncoding);
352
};