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/. */
7 interface nsISessionStoreRestoreData;
10 * A callback passed to SessionStoreUtils.forEachNonDynamicChildFrame().
12 callback SessionStoreUtilsFrameCallback = undefined (WindowProxy frame, unsigned long index);
15 * SessionStore utility functions implemented in C++ for performance reasons.
17 [ChromeOnly, Exposed=Window]
18 namespace SessionStoreUtils {
20 * Calls the given |callback| once for each non-dynamic child frame of the
24 undefined forEachNonDynamicChildFrame(WindowProxy window,
25 SessionStoreUtilsFrameCallback callback);
28 * Takes the given listener, wraps it in a filter that filters out events from
29 * dynamic docShells, and adds that filter as a listener for the given event
30 * type on the given event target. The listener that was added is returned
31 * (as nsISupports) so that it can later be removed via
32 * removeDynamicFrameFilteredListener.
34 * This is implemented as a native filter, rather than a JS-based one, for
35 * performance reasons.
38 nsISupports? addDynamicFrameFilteredListener(EventTarget target,
42 optional boolean mozSystemGroup = false);
45 * Remove the passed-in filtered listener from the given event target, if it's
46 * currently a listener for the given event type there. The 'listener'
47 * argument must be something that was returned by
48 * addDynamicFrameFilteredListener.
50 * This is needed, instead of the normal removeEventListener, because the
51 * caller doesn't actually have something that WebIDL considers an
55 undefined removeDynamicFrameFilteredListener(EventTarget target,
59 optional boolean mozSystemGroup = false);
62 * Save the docShell.allow* properties
64 ByteString collectDocShellCapabilities(nsIDocShell docShell);
67 * Restore the docShell.allow* properties
69 undefined restoreDocShellCapabilities(nsIDocShell docShell,
70 ByteString disallowCapabilities);
73 * Collects scroll position data for any given |frame| in the frame hierarchy.
75 * @param document (DOMDocument)
77 * @return {scroll: "x,y"} e.g. {scroll: "100,200"}
78 * Returns null when there is no scroll data we want to store for the
81 CollectedData? collectScrollPosition(WindowProxy window);
84 * Restores scroll position data for any given |frame| in the frame hierarchy.
86 * @param frame (DOMWindow)
87 * @param value (object, see collectScrollPosition())
89 undefined restoreScrollPosition(Window frame, optional CollectedData data = {});
92 * Collect form data for a given |frame| *not* including any subframes.
94 * The returned object may have an "id", "xpath", or "innerHTML" key or a
95 * combination of those three. Form data stored under "id" is for input
96 * fields with id attributes. Data stored under "xpath" is used for input
97 * fields that don't have a unique id and need to be queried using XPath.
98 * The "innerHTML" key is used for editable documents (designMode=on).
102 * id: {input1: "value1", input3: "value3"},
104 * "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value2",
105 * "/xhtml:html/xhtml:body/xhtml:input[@name='input4']" : "value4"
110 * Returns null when there is no scroll data
112 CollectedData? collectFormData(WindowProxy window);
114 boolean restoreFormData(Document document, optional CollectedData data = {});
116 nsISessionStoreRestoreData constructSessionStoreRestoreData();
119 Promise<undefined> initializeRestore(CanonicalBrowsingContext browsingContext,
120 nsISessionStoreRestoreData? data);
123 Promise<undefined> restoreDocShellState(
124 CanonicalBrowsingContext browsingContext,
126 ByteString? docShellCaps);
128 undefined restoreSessionStorageFromParent(
129 CanonicalBrowsingContext browsingContext,
130 record<UTF8String, record<DOMString, DOMString>> sessionStorage);
133 [GenerateConversionToJS, GenerateInit]
134 dictionary CollectedFileListValue
136 DOMString type = "file";
137 required sequence<DOMString> fileList;
140 [GenerateConversionToJS, GenerateInit]
141 dictionary CollectedNonMultipleSelectValue
143 required long selectedIndex;
144 required DOMString value;
147 [GenerateConversionToJS, GenerateInit]
148 dictionary CollectedCustomElementValue
150 (File or USVString or FormData)? value = null;
151 (File or USVString or FormData)? state = null;
154 // object contains either a CollectedFileListValue or a CollectedNonMultipleSelectValue or Sequence<DOMString>
155 // or a CollectedCustomElementValue
156 typedef (DOMString or boolean or object) CollectedFormDataValue;
158 dictionary CollectedData
161 record<DOMString, CollectedFormDataValue> id;
162 record<DOMString, CollectedFormDataValue> xpath;
165 // mChildren contains CollectedData instances
166 sequence<object?> children;
169 dictionary InputElementData {
170 sequence<DOMString> id;
171 sequence<DOMString> type;
172 sequence<long> valueIdx;
173 sequence<long> selectedIndex;
174 sequence<DOMString> selectVal;
175 sequence<DOMString> strVal;
176 sequence<boolean> boolVal;