nsISHEntry.idl 14.3 KB
Newer Older
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
4
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6

/**
7
 * The interface to nsISHentry. Each document or subframe in
8
9
10
 * Session History will have a nsISHEntry associated with it which will
 * hold all information required to recreate the document from history
 */
11
12

#include "nsISupports.idl"
13

14
interface nsIContentSecurityPolicy;
15
interface nsIMutableArray;
16
interface nsILayoutHistoryState;
17
18
19
20
interface nsIContentViewer;
interface nsIURI;
interface nsIInputStream;
interface nsIDocShellTreeItem;
21
interface nsIStructuredCloneContainer;
22
interface nsIBFCacheEntry;
23
interface nsIPrincipal;
24
interface nsISHistory;
25
interface nsIReferrerInfo;
26

27
%{C++
28
#include "nsRect.h"
29
class nsDocShellEditorData;
30
31
32
33
34
35
36
37

namespace mozilla {
namespace dom {

class SHEntrySharedParentState;

}
}
38
39
class nsSHEntryShared;
class nsDocShellLoadState;
40
%}
41
[ref] native nsIntRect(nsIntRect);
42
[ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData);
43
[ptr] native nsDocShellLoadStatePtr(nsDocShellLoadState);
44

45
[builtinclass, scriptable, uuid(0dad26b8-a259-42c7-93f1-2fa7fc076e45)]
46
interface nsISHEntry : nsISupports
47
{
48
    /**
49
     * The URI of the current entry.
50
     */
51
    [infallible] attribute nsIURI URI;
52

53
    /**
54
55
     * The original URI of the current entry. If an entry is the result of a
     * redirect this attribute holds the original URI.
56
     */
57
    [infallible] attribute nsIURI originalURI;
58

59
60
61
62
    /**
     * URL as stored from nsILoadInfo.resultPrincipalURI.  See nsILoadInfo
     * for more details.
     */
63
    [infallible] attribute nsIURI resultPrincipalURI;
64

65
66
67
    /**
     *  This flag remembers whether channel has LOAD_REPLACE set.
     */
68
    [infallible] attribute boolean loadReplace;
69

70
    /**
71
     * The title of the current entry.
72
     */
73
    // XXX: make it [infallible] when AString supports that (bug 1491187).
74
    attribute AString title;
75
76

    /**
77
78
79
80
     * Was the entry created as a result of a subframe navigation?
     * - Will be 'false' when a frameset page is visited for the first time.
     * - Will be 'true' for all history entries created as a result of a
     *   subframe navigation.
81
     */
82
    [infallible] attribute boolean isSubFrame;
83

84
85
    /** Referrer Info*/
    [infallible] attribute nsIReferrerInfo referrerInfo;
86

87
    /** Content viewer, for fast restoration of presentation */
88
    [infallible] attribute nsIContentViewer contentViewer;
89
90

    /** Whether the content viewer is marked "sticky" */
91
    [infallible] attribute boolean sticky;
92
93

    /** Saved state of the global window object */
94
    [infallible] attribute nsISupports windowState;
95
96

    /** Saved refresh URI list for the content viewer */
97
    [infallible] attribute nsIMutableArray refreshURIList;
98
99

    /** Post Data for the document */
100
    [infallible] attribute nsIInputStream postData;
101
102

    /** LayoutHistoryState for scroll position and form values */
103
    [infallible] attribute nsILayoutHistoryState layoutHistoryState;
104
105

    /** parent of this entry */
106
    [infallible] attribute nsISHEntry parent;
107
108
109
110
111

    /**
     * The loadType for this entry. This is typically loadHistory except
     * when reload is pressed, it has the appropriate reload flag
     */
112
    [infallible] attribute unsigned long loadType;
113
114
115
116
117

    /**
     * An ID to help identify this entry from others during
     * subframe navigation
     */
118
    [infallible] attribute unsigned long ID;
119

120
121
    /** The cache key for the entry */
    [infallible] attribute unsigned long cacheKey;
122

123
124
    /** Should the layoutHistoryState be saved? */
    [infallible] attribute boolean saveLayoutStateFlag;
125

126
127
    /** Has the page already expired in cache? */
    [infallible] attribute boolean expirationStatus;
128
129
130
131
132

    /**
     * attribute to indicate the content-type of the document that this
     * is a session history entry for
     */
133
    // XXX: make it [infallible] when ACString supports that (bug 1491187).
134
    attribute ACString contentType;
135
136
137
138
139
140
141
142
143
144
145

    /**
     * If we created this SHEntry via history.pushState or modified it via
     * history.replaceState, and if we changed the SHEntry's URI via the
     * push/replaceState call, and if the SHEntry's new URI differs from its
     * old URI by more than just the hash, then we set this field to true.
     *
     * Additionally, if this SHEntry was created by calling pushState from a
     * SHEntry whose URI was modified, this SHEntry's URIWasModified field is
     * true.
     */
146
    [infallible] attribute boolean URIWasModified;
147

148
149
150
151
152
153
154
155
156
157
158
159
160
    /**
     * Get the principal, if any, that was associated with the channel
     * that the document that was loaded to create this history entry
     * came from.
     */
    [infallible] attribute nsIPrincipal triggeringPrincipal;

    /**
     * Get the principal, if any, that is used when the inherit flag
     * is set.
     */
    [infallible] attribute nsIPrincipal principalToInherit;

161
162
163
164
165
166
    /**
     * Get the storage principal, if any, that is used when the inherit flag is
     * set.
     */
    [infallible] attribute nsIPrincipal storagePrincipalToInherit;

167
168
169
170
171
172
173
    /**
     * Get the csp, if any, that was used for this document load. That
     * is not the CSP that was applied to subresource loads within the
     * document, but the CSP that was applied to this document load.
     */
    [infallible] attribute nsIContentSecurityPolicy csp;

174
175
176
177
178
179
180
181
182
183
    /**
     * Get/set data associated with this history state via a pushState() call,
     * serialized using structured clone.
     **/
    [infallible] attribute nsIStructuredCloneContainer stateData;

    /**
     * The history ID of the docshell.
     */
    // Would be [infallible], but we don't support that property for nsIDPtr.
184
    attribute nsIDRef docshellID;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211

    /**
     * True if this SHEntry corresponds to a document created by a srcdoc
     * iframe. Set when a value is assigned to srcdocData.
     */
    [infallible] readonly attribute boolean isSrcdocEntry;

    /**
     * Contents of the srcdoc attribute in a srcdoc iframe to be loaded instead
     * of the URI.  Similar to a Data URI, this information is needed to
     * recreate the document at a later stage.
     * Setting this sets isSrcdocEntry to true
     */
    // XXX: make it [infallible] when AString supports that (bug 1491187).
    attribute AString srcdocData;

    /**
     * When isSrcdocEntry is true, this contains the baseURI of the srcdoc
     * document for use in situations where it cannot otherwise be determined,
     * for example with view-source.
     */
    [infallible] attribute nsIURI baseURI;

    /**
     * Sets/gets the current scroll restoration state,
     * if true == "manual", false == "auto".
     */
212
    attribute boolean scrollRestorationIsManual;
213
214
215
216
217
218
219
220

    /**
     * Flag to indicate that the history entry was originally loaded in the
     * current process. This flag does not survive a browser process switch.
     */
    [infallible] readonly attribute boolean loadedInThisProcess;

    /**
221
     * The session history it belongs to.
222
     */
223
    [infallible] readonly attribute nsISHistory shistory;
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242

    /**
     * A number that is assigned by the sHistory when the entry is activated
     */
    [noscript, infallible] attribute unsigned long lastTouched;

    /**
     * The current number of nsISHEntries which are immediate children of this
     * SHEntry.
     */
    [infallible] readonly attribute long childCount;

    /**
     * When an entry is serving is within nsISHistory's array of entries, this
     * property specifies if it should persist. If not it will be replaced by
     * new additions to the list.
     */
    [infallible] attribute boolean persist;

243
244
245
246
    /**
     * Set/Get the visual viewport scroll position if session history is
     * changed through anchor navigation or pushState.
     */
247
248
    void setScrollPosition(in long x, in long y);
    void getScrollPosition(out long x, out long y);
249

250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
    /**
     * Saved position and dimensions of the content viewer; we must adjust the
     * root view's widget accordingly if this has changed when the presentation
     * is restored.
     */
    [noscript, notxpcom] void getViewerBounds(in nsIntRect bounds);
    [noscript, notxpcom] void setViewerBounds([const] in nsIntRect bounds);

    /**
     * Saved child docshells corresponding to contentViewer.  The child shells
     * are restored as children of the parent docshell, in this order, when the
     * parent docshell restores a saved presentation.
     */

    /** Append a child shell to the end of our list. */
    [noscript, notxpcom] void addChildShell(in nsIDocShellTreeItem shell);

    /**
     * Get the child shell at |index|; returns null if |index| is out of bounds.
     */
    [noscript] nsIDocShellTreeItem childShellAt(in long index);

    /**
     * Clear the child shell list.
     */
    [noscript, notxpcom] void clearChildShells();

    /**
     * Ensure that the cached presentation members are self-consistent.
     * If either |contentViewer| or |windowState| are null, then all of the
     * following members are cleared/reset:
     *  contentViewer, sticky, windowState, viewerBounds, childShells,
     *  refreshURIList.
     */
    [noscript, notxpcom] void syncPresentationState();

    /**
     * Initialises `layoutHistoryState` if it doesn't already exist
     * and returns a reference to it.
     */
    nsILayoutHistoryState initLayoutHistoryState();

292
    /** Additional ways to create an entry */
293
294
    [noscript] void create(in nsIURI URI, in AString title,
                           in nsIInputStream inputStream,
295
296
                           in unsigned long cacheKey,
                           in ACString contentType,
297
                           in nsIPrincipal triggeringPrincipal,
298
                           in nsIPrincipal principalToInherit,
299
                           in nsIPrincipal storagePrincipalToInherit,
300
                           in nsIContentSecurityPolicy aCsp,
301
                           in nsIDRef docshellID,
302
303
304
305
306
307
308
309
310
311
                           in boolean dynamicCreation,
                           in nsIURI originalURI,
                           in nsIURI resultPrincipalURI,
                           in bool loadReplace,
                           in nsIReferrerInfo referrerInfo,
                           in AString srcdoc,
                           in bool srcdocEntry,
                           in nsIURI baseURI,
                           in bool saveLayoutState,
                           in bool expired);
312

313
    nsISHEntry clone();
314

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
    /**
     * Gets the owning pointer to the editor data assosicated with
     * this shistory entry. This forgets its pointer, so free it when
     * you're done.
     */
    [noscript, notxpcom] nsDocShellEditorDataPtr forgetEditorData();

    /**
     * Sets the owning pointer to the editor data assosicated with
     * this shistory entry. Unless forgetEditorData() is called, this
     * shentry will destroy the editor data when it's destroyed.
     */
    [noscript, notxpcom] void setEditorData(in nsDocShellEditorDataPtr aData);

    /** Returns true if this shistory entry is storing a detached editor. */
    [noscript, notxpcom] boolean hasDetachedEditor();
331
332
333
334
335

    /**
     * Returns true if the related docshell was added because of
     * dynamic addition of an iframe/frame.
     */
336
    [noscript, notxpcom] boolean isDynamicallyAdded();
337
338
339
340
341
342
343

    /**
     * Returns true if any of the child entries returns true
     * when isDynamicallyAdded is called on it.
     */
    boolean hasDynamicallyAddedChild();

344
    /**
345
     * Does this SHEntry point to the given BFCache entry? If so, evicting
346
347
348
     * the BFCache entry will evict the SHEntry, since the two entries
     * correspond to the same document.
     */
349
    [noscript, notxpcom] boolean hasBFCacheEntry(in nsIBFCacheEntry aEntry);
350
351
352
353
354
355
356
357

    /**
     * Adopt aEntry's BFCacheEntry, so now both this and aEntry point to
     * aEntry's BFCacheEntry.
     */
    void adoptBFCacheEntry(in nsISHEntry aEntry);

    /**
358
     * Create a new BFCache entry and drop our reference to our old one. This
359
360
361
362
363
     * call unlinks this SHEntry from any other SHEntries for its document.
     */
    void abandonBFCacheEntry();

    /**
364
365
366
367
     * Does this SHEntry correspond to the same document as aEntry? This is
     * true iff the two SHEntries have the same BFCacheEntry. So in particular,
     * sharesDocumentWith(aEntry) is guaranteed to return true if it's
     * preceded by a call to adoptBFCacheEntry(aEntry).
368
369
     */
    boolean sharesDocumentWith(in nsISHEntry aEntry);
370

371
    /**
372
     * Sets an SHEntry to reflect that it is a history type load. As
373
374
375
376
377
378
379
     * nsIDocShellLoadInfo and its LoadType enum were removed, this is the
     * equivalent to doing
     *
     * shEntry.loadType = 4;
     *
     * in js, but easier to maintain and less opaque.
     */
380
    void setLoadTypeAsHistory();
381

382
383
384
    /**
     * Add a new child SHEntry. If offset is -1 adds to the end of the list.
     */
385
386
    void AddChild(in nsISHEntry aChild, in long aOffset,
                  [optional,default(false)] in bool aUseRemoteSubframes);
387
388
389
390

    /**
     * Remove a child SHEntry.
     */
391
    [noscript] void RemoveChild(in nsISHEntry aChild);
392
393
394
395
396
397

    /**
     * Get child at an index.
     */
    nsISHEntry GetChildAt(in long aIndex);

398
399
400
401
402
403
404
405
    /**
     * If this entry has no dynamically added child, get the child SHEntry 
     * at the given offset. The loadtype of the returned entry is set 
     * to its parent's loadtype.
     */
    [notxpcom] void GetChildSHEntryIfHasNoDynamicallyAddedChild(in long aChildOffset,
                                                                out nsISHEntry aChild);

406
407
408
409
410
    /**
     * Replaces a child which is for the same docshell as aNewChild
     * with aNewChild.
     * @throw if nothing was replaced.
     */
411
    [noscript] void ReplaceChild(in nsISHEntry aNewChild);
412
413
414
415
416

    /**
    * Remove all children of this entry and call abandonBFCacheEntry.
    */
    [notxpcom] void ClearEntry();
417
418
419
420
421
422
    
    /**
     * Create nsDocShellLoadState and fill it with information. 
     * Don't set nsSHEntry here to avoid serializing it.
     */
    [noscript] nsDocShellLoadStatePtr CreateLoadInfo();
423
424

    [infallible] readonly attribute unsigned long long bfcacheID;
425
426
427
428
429
430
431

    /**
     * synchronizeLayoutHistoryState() can be used to synchronize
     * layoutHistoryState object to the parent process in case session history
     * lives there. With in-process session history this method is no-op.
     */
    void synchronizeLayoutHistoryState();
432
};
433