summaryrefslogtreecommitdiffstats
path: root/dom/chrome-webidl/SessionStoreUtils.webidl
blob: 9032c784c4b637a0dd81e28fe3f11ea14454d145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* 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/. */

interface nsIDocShell;
interface nsISupports;
interface nsISessionStoreRestoreData;

/**
 * A callback passed to SessionStoreUtils.forEachNonDynamicChildFrame().
 */
callback SessionStoreUtilsFrameCallback = undefined (WindowProxy frame, unsigned long index);

/**
 * SessionStore utility functions implemented in C++ for performance reasons.
 */
[ChromeOnly, Exposed=Window]
namespace SessionStoreUtils {
  /**
   * Calls the given |callback| once for each non-dynamic child frame of the
   * given |window|.
   */
  [Throws]
  undefined forEachNonDynamicChildFrame(WindowProxy window,
                                        SessionStoreUtilsFrameCallback callback);

  /**
   * Takes the given listener, wraps it in a filter that filters out events from
   * dynamic docShells, and adds that filter as a listener for the given event
   * type on the given event target.  The listener that was added is returned
   * (as nsISupports) so that it can later be removed via
   * removeDynamicFrameFilteredListener.
   *
   * This is implemented as a native filter, rather than a JS-based one, for
   * performance reasons.
   */
  [Throws]
  nsISupports? addDynamicFrameFilteredListener(EventTarget target,
                                               DOMString type,
                                               any listener,
                                               boolean useCapture,
                                               optional boolean mozSystemGroup = false);

  /**
   * Remove the passed-in filtered listener from the given event target, if it's
   * currently a listener for the given event type there.  The 'listener'
   * argument must be something that was returned by
   * addDynamicFrameFilteredListener.
   *
   * This is needed, instead of the normal removeEventListener, because the
   * caller doesn't actually have something that WebIDL considers an
   * EventListener.
   */
  [Throws]
  undefined removeDynamicFrameFilteredListener(EventTarget target,
                                               DOMString type,
                                               nsISupports listener,
                                               boolean useCapture,
                                               optional boolean mozSystemGroup = false);

  /*
   * Save the docShell.allow* properties
   */
  ByteString collectDocShellCapabilities(nsIDocShell docShell);

  /*
   * Restore the docShell.allow* properties
   */
  undefined restoreDocShellCapabilities(nsIDocShell docShell,
                                        ByteString disallowCapabilities);

  /**
   * Collects scroll position data for any given |frame| in the frame hierarchy.
   *
   * @param document (DOMDocument)
   *
   * @return {scroll: "x,y"} e.g. {scroll: "100,200"}
   *         Returns null when there is no scroll data we want to store for the
   *         given |frame|.
   */
  CollectedData? collectScrollPosition(WindowProxy window);

  /**
   * Restores scroll position data for any given |frame| in the frame hierarchy.
   *
   * @param frame (DOMWindow)
   * @param value (object, see collectScrollPosition())
   */
  undefined restoreScrollPosition(Window frame, optional CollectedData data = {});

  /**
   * Collect form data for a given |frame| *not* including any subframes.
   *
   * The returned object may have an "id", "xpath", or "innerHTML" key or a
   * combination of those three. Form data stored under "id" is for input
   * fields with id attributes. Data stored under "xpath" is used for input
   * fields that don't have a unique id and need to be queried using XPath.
   * The "innerHTML" key is used for editable documents (designMode=on).
   *
   * Example:
   *   {
   *     id: {input1: "value1", input3: "value3"},
   *     xpath: {
   *       "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value2",
   *       "/xhtml:html/xhtml:body/xhtml:input[@name='input4']" : "value4"
   *     }
   *   }
   *
   * @return object
   *         Returns null when there is no scroll data
   */
  CollectedData? collectFormData(WindowProxy window);

  boolean restoreFormData(Document document, optional CollectedData data = {});

   nsISessionStoreRestoreData constructSessionStoreRestoreData();

   [Throws]
   Promise<undefined> initializeRestore(CanonicalBrowsingContext browsingContext,
                                        nsISessionStoreRestoreData? data);

   [NewObject]
   Promise<undefined> restoreDocShellState(
      CanonicalBrowsingContext browsingContext,
      UTF8String? url,
      ByteString? docShellCaps);

   undefined restoreSessionStorageFromParent(
     CanonicalBrowsingContext browsingContext,
     record<UTF8String, record<DOMString, DOMString>> sessionStorage);
};

[GenerateConversionToJS, GenerateInit]
dictionary CollectedFileListValue
{
  DOMString type = "file";
  required sequence<DOMString> fileList;
};

[GenerateConversionToJS, GenerateInit]
dictionary CollectedNonMultipleSelectValue
{
  required long selectedIndex;
  required DOMString value;
};

// object contains either a CollectedFileListValue or a CollectedNonMultipleSelectValue or Sequence<DOMString>
typedef (DOMString or boolean or object) CollectedFormDataValue;

dictionary CollectedData
{
  ByteString scroll;
  record<DOMString, CollectedFormDataValue> id;
  record<DOMString, CollectedFormDataValue> xpath;
  DOMString innerHTML;
  ByteString url;
  // mChildren contains CollectedData instances
  sequence<object?> children;
};

dictionary InputElementData {
  sequence<DOMString> id;
  sequence<DOMString> type;
  sequence<long> valueIdx;
  sequence<long> selectedIndex;
  sequence<DOMString> selectVal;
  sequence<DOMString> strVal;
  sequence<boolean> boolVal;
};