|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * 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 * Session History will have a nsISHEntry associated with it which will |
|
9 * hold all information required to recreate the document from history |
|
10 * |
|
11 */ |
|
12 |
|
13 #include "nsISupports.idl" |
|
14 |
|
15 interface nsILayoutHistoryState; |
|
16 interface nsIContentViewer; |
|
17 interface nsIURI; |
|
18 interface nsIInputStream; |
|
19 interface nsIDocShellTreeItem; |
|
20 interface nsISupportsArray; |
|
21 interface nsIStructuredCloneContainer; |
|
22 interface nsIBFCacheEntry; |
|
23 |
|
24 %{C++ |
|
25 struct nsIntRect; |
|
26 class nsDocShellEditorData; |
|
27 class nsSHEntryShared; |
|
28 %} |
|
29 [ref] native nsIntRect(nsIntRect); |
|
30 [ptr] native nsDocShellEditorDataPtr(nsDocShellEditorData); |
|
31 [ptr] native nsSHEntryShared(nsSHEntryShared); |
|
32 |
|
33 [scriptable, uuid(9eed7e92-1121-46f2-95e5-2f5c0dca46f0)] |
|
34 interface nsISHEntry : nsISupports |
|
35 { |
|
36 /** |
|
37 * A readonly property that returns the URI |
|
38 * of the current entry. The object returned is |
|
39 * of type nsIURI |
|
40 */ |
|
41 readonly attribute nsIURI URI; |
|
42 |
|
43 /** |
|
44 * A readonly property that returns the title |
|
45 * of the current entry. The object returned |
|
46 * is a encoded string |
|
47 */ |
|
48 readonly attribute wstring title; |
|
49 |
|
50 /** |
|
51 * A readonly property that returns a boolean |
|
52 * flag which indicates if the entry was created as a |
|
53 * result of a subframe navigation. This flag will be |
|
54 * 'false' when a frameset page is visited for |
|
55 * the first time. This flag will be 'true' for all |
|
56 * history entries created as a result of a subframe |
|
57 * navigation. |
|
58 */ |
|
59 readonly attribute boolean isSubFrame; |
|
60 |
|
61 /** URI for the document */ |
|
62 void setURI(in nsIURI aURI); |
|
63 |
|
64 /** Referrer URI */ |
|
65 attribute nsIURI referrerURI; |
|
66 |
|
67 /** Content viewer, for fast restoration of presentation */ |
|
68 attribute nsIContentViewer contentViewer; |
|
69 |
|
70 /** Whether the content viewer is marked "sticky" */ |
|
71 attribute boolean sticky; |
|
72 |
|
73 /** Saved state of the global window object */ |
|
74 attribute nsISupports windowState; |
|
75 |
|
76 /** |
|
77 * Saved position and dimensions of the content viewer; we must adjust the |
|
78 * root view's widget accordingly if this has changed when the presentation |
|
79 * is restored. |
|
80 */ |
|
81 [noscript] void getViewerBounds(in nsIntRect bounds); |
|
82 [noscript] void setViewerBounds([const] in nsIntRect bounds); |
|
83 |
|
84 /** |
|
85 * Saved child docshells corresponding to contentViewer. The child shells |
|
86 * are restored as children of the parent docshell, in this order, when the |
|
87 * parent docshell restores a saved presentation. |
|
88 */ |
|
89 |
|
90 /** Append a child shell to the end of our list. */ |
|
91 void addChildShell(in nsIDocShellTreeItem shell); |
|
92 |
|
93 /** |
|
94 * Get the child shell at |index|; returns null if |index| is out of bounds. |
|
95 */ |
|
96 nsIDocShellTreeItem childShellAt(in long index); |
|
97 |
|
98 /** |
|
99 * Clear the child shell list. |
|
100 */ |
|
101 void clearChildShells(); |
|
102 |
|
103 /** Saved refresh URI list for the content viewer */ |
|
104 attribute nsISupportsArray refreshURIList; |
|
105 |
|
106 /** |
|
107 * Ensure that the cached presentation members are self-consistent. |
|
108 * If either |contentViewer| or |windowState| are null, then all of the |
|
109 * following members are cleared/reset: |
|
110 * contentViewer, sticky, windowState, viewerBounds, childShells, |
|
111 * refreshURIList. |
|
112 */ |
|
113 void syncPresentationState(); |
|
114 |
|
115 /** Title for the document */ |
|
116 void setTitle(in AString aTitle); |
|
117 |
|
118 /** Post Data for the document */ |
|
119 attribute nsIInputStream postData; |
|
120 |
|
121 /** LayoutHistoryState for scroll position and form values */ |
|
122 attribute nsILayoutHistoryState layoutHistoryState; |
|
123 |
|
124 /** parent of this entry */ |
|
125 attribute nsISHEntry parent; |
|
126 |
|
127 /** |
|
128 * The loadType for this entry. This is typically loadHistory except |
|
129 * when reload is pressed, it has the appropriate reload flag |
|
130 */ |
|
131 attribute unsigned long loadType; |
|
132 |
|
133 /** |
|
134 * An ID to help identify this entry from others during |
|
135 * subframe navigation |
|
136 */ |
|
137 attribute unsigned long ID; |
|
138 |
|
139 /** attribute to set and get the cache key for the entry */ |
|
140 attribute nsISupports cacheKey; |
|
141 |
|
142 /** attribute to indicate whether layoutHistoryState should be saved */ |
|
143 attribute boolean saveLayoutStateFlag; |
|
144 |
|
145 /** attribute to indicate whether the page is already expired in cache */ |
|
146 attribute boolean expirationStatus; |
|
147 |
|
148 /** |
|
149 * attribute to indicate the content-type of the document that this |
|
150 * is a session history entry for |
|
151 */ |
|
152 attribute ACString contentType; |
|
153 |
|
154 /** |
|
155 * If we created this SHEntry via history.pushState or modified it via |
|
156 * history.replaceState, and if we changed the SHEntry's URI via the |
|
157 * push/replaceState call, and if the SHEntry's new URI differs from its |
|
158 * old URI by more than just the hash, then we set this field to true. |
|
159 * |
|
160 * Additionally, if this SHEntry was created by calling pushState from a |
|
161 * SHEntry whose URI was modified, this SHEntry's URIWasModified field is |
|
162 * true. |
|
163 * |
|
164 */ |
|
165 attribute boolean URIWasModified; |
|
166 |
|
167 /** Set/Get scrollers' positon in anchored pages */ |
|
168 void setScrollPosition(in long x, in long y); |
|
169 void getScrollPosition(out long x, out long y); |
|
170 |
|
171 /** Additional ways to create an entry */ |
|
172 [noscript] void create(in nsIURI URI, in AString title, |
|
173 in nsIInputStream inputStream, |
|
174 in nsILayoutHistoryState layoutHistoryState, |
|
175 in nsISupports cacheKey, in ACString contentType, |
|
176 in nsISupports owner, |
|
177 in unsigned long long docshellID, |
|
178 in boolean dynamicCreation); |
|
179 |
|
180 nsISHEntry clone(); |
|
181 |
|
182 /** Attribute that indicates if this entry is for a subframe navigation */ |
|
183 void setIsSubFrame(in boolean aFlag); |
|
184 |
|
185 /** Return any content viewer present in or below this node in the |
|
186 nsSHEntry tree. This will differ from contentViewer in the case |
|
187 where a child nsSHEntry has the content viewer for this tree. */ |
|
188 nsIContentViewer getAnyContentViewer(out nsISHEntry ownerEntry); |
|
189 |
|
190 /** |
|
191 * Get the owner, if any, that was associated with the channel |
|
192 * that the document that was loaded to create this history entry |
|
193 * came from. |
|
194 */ |
|
195 attribute nsISupports owner; |
|
196 |
|
197 /** |
|
198 * Get/set data associated with this history state via a pushState() call, |
|
199 * serialized using structured clone. |
|
200 **/ |
|
201 attribute nsIStructuredCloneContainer stateData; |
|
202 |
|
203 /** |
|
204 * Gets the owning pointer to the editor data assosicated with |
|
205 * this shistory entry. This forgets its pointer, so free it when |
|
206 * you're done. |
|
207 */ |
|
208 [noscript, notxpcom] nsDocShellEditorDataPtr forgetEditorData(); |
|
209 |
|
210 /** |
|
211 * Sets the owning pointer to the editor data assosicated with |
|
212 * this shistory entry. Unless forgetEditorData() is called, this |
|
213 * shentry will destroy the editor data when it's destroyed. |
|
214 */ |
|
215 [noscript, notxpcom] void setEditorData(in nsDocShellEditorDataPtr aData); |
|
216 |
|
217 /** Returns true if this shistory entry is storing a detached editor. */ |
|
218 [noscript, notxpcom] boolean hasDetachedEditor(); |
|
219 |
|
220 /** |
|
221 * Returns true if the related docshell was added because of |
|
222 * dynamic addition of an iframe/frame. |
|
223 */ |
|
224 boolean isDynamicallyAdded(); |
|
225 |
|
226 /** |
|
227 * Returns true if any of the child entries returns true |
|
228 * when isDynamicallyAdded is called on it. |
|
229 */ |
|
230 boolean hasDynamicallyAddedChild(); |
|
231 |
|
232 /** |
|
233 * The history ID of the docshell. |
|
234 */ |
|
235 attribute unsigned long long docshellID; |
|
236 |
|
237 readonly attribute nsIBFCacheEntry BFCacheEntry; |
|
238 |
|
239 /** |
|
240 * Does this SHEntry point to the given BFCache entry? If so, evicting |
|
241 * the BFCache entry will evict the SHEntry, since the two entries |
|
242 * correspond to the same document. |
|
243 */ |
|
244 [notxpcom, noscript] |
|
245 boolean hasBFCacheEntry(in nsIBFCacheEntry aEntry); |
|
246 |
|
247 /** |
|
248 * Adopt aEntry's BFCacheEntry, so now both this and aEntry point to |
|
249 * aEntry's BFCacheEntry. |
|
250 */ |
|
251 void adoptBFCacheEntry(in nsISHEntry aEntry); |
|
252 |
|
253 /** |
|
254 * Create a new BFCache entry and drop our reference to our old one. This |
|
255 * call unlinks this SHEntry from any other SHEntries for its document. |
|
256 */ |
|
257 void abandonBFCacheEntry(); |
|
258 |
|
259 /** |
|
260 * Does this SHEntry correspond to the same document as aEntry? This is |
|
261 * true iff the two SHEntries have the same BFCacheEntry. So in |
|
262 * particular, sharesDocumentWith(aEntry) is guaranteed to return true if |
|
263 * it's preceeded by a call to adoptBFCacheEntry(aEntry). |
|
264 */ |
|
265 boolean sharesDocumentWith(in nsISHEntry aEntry); |
|
266 |
|
267 /** |
|
268 * True if this SHEntry corresponds to a document created by a srcdoc iframe. |
|
269 * Set when a value is assigned to srcdocData. |
|
270 */ |
|
271 readonly attribute boolean isSrcdocEntry; |
|
272 |
|
273 /** |
|
274 * Contents of the srcdoc attribute in a srcdoc iframe to be loaded instead |
|
275 * of the URI. Similar to a Data URI, this information is needed to |
|
276 * recreate the document at a later stage. |
|
277 * Setting this sets isSrcdocEntry to true |
|
278 */ |
|
279 attribute AString srcdocData; |
|
280 |
|
281 /** |
|
282 * When isSrcdocEntry is true, this contains the baseURI of the srcdoc |
|
283 * document for use in situations where it cannot otherwise be determined, |
|
284 * for example with view-source. |
|
285 */ |
|
286 attribute nsIURI baseURI; |
|
287 }; |
|
288 |
|
289 [scriptable, uuid(bb66ac35-253b-471f-a317-3ece940f04c5)] |
|
290 interface nsISHEntryInternal : nsISupports |
|
291 { |
|
292 [notxpcom] void RemoveFromBFCacheAsync(); |
|
293 [notxpcom] void RemoveFromBFCacheSync(); |
|
294 |
|
295 /** |
|
296 * A number that is assigned by the sHistory when the entry is activated |
|
297 */ |
|
298 attribute unsigned long lastTouched; |
|
299 |
|
300 /** |
|
301 * Some state, particularly that related to the back/forward cache, is |
|
302 * shared between SHEntries which correspond to the same document. This |
|
303 * method gets a pointer to that shared state. |
|
304 * |
|
305 * This shared state is the SHEntry's BFCacheEntry. So |
|
306 * hasBFCacheEntry(getSharedState()) is guaranteed to return true. |
|
307 */ |
|
308 [noscript, notxpcom] |
|
309 nsSHEntryShared getSharedState(); |
|
310 }; |
|
311 |
|
312 %{ C++ |
|
313 // {BFD1A791-AD9F-11d3-BDC7-0050040A9B44} |
|
314 #define NS_SHENTRY_CID \ |
|
315 {0xbfd1a791, 0xad9f, 0x11d3, {0xbd, 0xc7, 0x0, 0x50, 0x4, 0xa, 0x9b, 0x44}} |
|
316 |
|
317 #define NS_SHENTRY_CONTRACTID \ |
|
318 "@mozilla.org/browser/session-history-entry;1" |
|
319 |
|
320 %} |
|
321 |