1/*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27[
28    CheckSecurity,
29    JSCustomDefineOwnProperty,
30    CustomDeleteProperty,
31    CustomGetOwnPropertySlot,
32    CustomEnumerateProperty,
33    CustomProxyToJSObject,
34    JSCustomMarkFunction,
35    JSCustomToNativeObject,
36    CustomPutFunction,
37    EventTarget,
38    JSGenerateToNativeObject,
39    ReplaceableConstructor,
40    JSLegacyParent=JSDOMWindowBase,
41    InterfaceName=Window,
42] interface DOMWindow {
43    // DOM Level 0
44    [Replaceable] readonly attribute Screen screen;
45    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute History history;
46    [Replaceable] readonly attribute BarProp locationbar;
47    [Replaceable] readonly attribute BarProp menubar;
48    [Replaceable] readonly attribute BarProp personalbar;
49    [Replaceable] readonly attribute BarProp scrollbars;
50    [Replaceable] readonly attribute BarProp statusbar;
51    [Replaceable] readonly attribute BarProp toolbar;
52    [Replaceable] readonly attribute Navigator navigator;
53    [Replaceable] readonly attribute Navigator clientInformation;
54    readonly attribute Crypto crypto;
55    [DoNotCheckSecurity, CustomSetter] attribute Location location;
56    [Replaceable, CustomGetter] readonly attribute Event event;
57
58    DOMSelection getSelection();
59
60    [CheckSecurityForNode] readonly attribute Element frameElement;
61
62    [DoNotCheckSecurity, CallWith=ScriptExecutionContext, ForwardDeclareInHeader] void focus();
63    [DoNotCheckSecurity, ForwardDeclareInHeader] void blur();
64    [DoNotCheckSecurity, CallWith=ScriptExecutionContext, ForwardDeclareInHeader] void close();
65
66    void print();
67    void stop();
68
69    [Custom] DOMWindow open(DOMString url,
70                            DOMString name,
71                            optional DOMString options);
72
73    [Custom] any showModalDialog(DOMString url,
74                                       optional any dialogArgs,
75                                       optional DOMString featureArgs);
76
77    void alert([Default=Undefined] optional DOMString message);
78    boolean confirm([Default=Undefined] optional DOMString message);
79    [TreatReturnedNullStringAs=Null] DOMString prompt([Default=Undefined] optional DOMString message,
80                                                [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString defaultValue);
81
82    boolean find([Default=Undefined] optional DOMString string,
83                 [Default=Undefined] optional boolean caseSensitive,
84                 [Default=Undefined] optional boolean backwards,
85                 [Default=Undefined] optional boolean wrap,
86                 [Default=Undefined] optional boolean wholeWord,
87                 [Default=Undefined] optional boolean searchInFrames,
88                 [Default=Undefined] optional boolean showDialog);
89
90    [Replaceable] readonly attribute  boolean offscreenBuffering;
91
92    [Replaceable] readonly attribute long outerHeight;
93    [Replaceable] readonly attribute long outerWidth;
94    [Replaceable] readonly attribute long innerHeight;
95    [Replaceable] readonly attribute long innerWidth;
96    [Replaceable] readonly attribute long screenX;
97    [Replaceable] readonly attribute long screenY;
98    [Replaceable] readonly attribute long screenLeft;
99    [Replaceable] readonly attribute long screenTop;
100    [Replaceable] readonly attribute long scrollX;
101    [Replaceable] readonly attribute long scrollY;
102    readonly attribute long pageXOffset;
103    readonly attribute long pageYOffset;
104
105    void scrollBy([Default=Undefined] optional long x, [Default=Undefined] optional long y);
106    void scrollTo([Default=Undefined] optional long x, [Default=Undefined] optional long y);
107    void scroll([Default=Undefined] optional long x, [Default=Undefined] optional long y);
108    void moveBy([Default=Undefined] optional unrestricted float x, [Default=Undefined] optional unrestricted float y); // FIXME: this should take longs not floats.
109    void moveTo([Default=Undefined] optional unrestricted float x, [Default=Undefined] optional unrestricted float y); // FIXME: this should take longs not floats.
110    void resizeBy([Default=Undefined] optional unrestricted float x, [Default=Undefined] optional unrestricted float y); // FIXME: this should take longs not floats.
111    void resizeTo([Default=Undefined] optional unrestricted float width, [Default=Undefined] optional unrestricted float height); // FIXME: this should take longs not floats.
112
113    [DoNotCheckSecurity, ForwardDeclareInHeader] readonly attribute boolean closed;
114
115    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
116
117    attribute DOMString name;
118
119    attribute DOMString status;
120    attribute DOMString defaultStatus;
121#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
122    // This attribute is an alias of defaultStatus and is necessary for legacy uses.
123    [ImplementedAs=defaultStatus] attribute DOMString defaultstatus;
124#endif
125
126    // Self referential attributes
127    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow self;
128    [DoNotCheckSecurity] readonly attribute DOMWindow window;
129    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute  DOMWindow frames;
130
131    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow opener;
132    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow parent;
133    [DoNotCheckSecurityOnGetter] readonly attribute DOMWindow top;
134
135    // DOM Level 2 AbstractView Interface
136    readonly attribute Document document;
137
138    // CSSOM View Module
139    MediaQueryList matchMedia(DOMString query);
140
141    // styleMedia has been removed from the CSSOM View specification.
142    readonly attribute StyleMedia styleMedia;
143
144    // DOM Level 2 Style Interface
145    CSSStyleDeclaration getComputedStyle([Default=Undefined] optional Element element,
146                                                              [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString pseudoElement);
147
148    // WebKit extensions
149#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
150    CSSRuleList getMatchedCSSRules([Default=Undefined] optional Element element,
151                                   [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString pseudoElement);
152#endif
153
154    [Replaceable] readonly attribute unrestricted double devicePixelRatio;
155
156    WebKitPoint webkitConvertPointFromPageToNode([Default=Undefined] optional Node node,
157                                                 [Default=Undefined] optional WebKitPoint p);
158    WebKitPoint webkitConvertPointFromNodeToPage([Default=Undefined] optional Node node,
159                                                 [Default=Undefined] optional WebKitPoint p);
160
161    readonly attribute DOMApplicationCache applicationCache;
162
163    [GetterRaisesException] readonly attribute Storage sessionStorage;
164    [GetterRaisesException] readonly attribute Storage localStorage;
165
166#if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS
167    // This is the interface orientation in degrees. Some examples are:
168    //  0 is straight up; -90 is when the device is rotated 90 clockwise;
169    //  90 is when rotated counter clockwise.
170    readonly attribute long orientation;
171#endif
172
173    // cross-document messaging
174#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
175    [DoNotCheckSecurity, Custom, RaisesException, ForwardDeclareInHeader] void postMessage(SerializedScriptValue message, DOMString targetOrigin, optional Array messagePorts);
176#else
177    // There's no good way to expose an array via the ObjC bindings, so for now just allow passing in a single port.
178    [DoNotCheckSecurity, Custom, RaisesException, ForwardDeclareInHeader] void postMessage(SerializedScriptValue message, optional MessagePort messagePort, DOMString targetOrigin);
179#endif
180
181#if defined(ENABLE_WEB_TIMING) && ENABLE_WEB_TIMING
182    [Replaceable] readonly attribute Performance performance;
183#endif
184
185#if defined(ENABLE_REQUEST_ANIMATION_FRAME) && ENABLE_REQUEST_ANIMATION_FRAME
186    long requestAnimationFrame(RequestAnimationFrameCallback callback);
187    void cancelAnimationFrame(long id);
188    long webkitRequestAnimationFrame(RequestAnimationFrameCallback callback);
189    [ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);
190    [ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id); // This is a deprecated alias for webkitCancelAnimationFrame(). Remove this when removing vendor prefix.
191#endif
192
193    [Replaceable,Conditional=CSS3_CONDITIONAL_RULES] readonly attribute DOMWindowCSS CSS;
194
195    // Events
196    attribute EventListener onabort;
197    attribute EventListener onbeforeunload;
198    attribute EventListener onblur;
199    attribute EventListener oncanplay;
200    attribute EventListener oncanplaythrough;
201    attribute EventListener onchange;
202    attribute EventListener onclick;
203    attribute EventListener oncontextmenu;
204    attribute EventListener ondblclick;
205    attribute EventListener ondrag;
206    attribute EventListener ondragend;
207    attribute EventListener ondragenter;
208    attribute EventListener ondragleave;
209    attribute EventListener ondragover;
210    attribute EventListener ondragstart;
211    attribute EventListener ondrop;
212    attribute EventListener ondurationchange;
213    attribute EventListener onemptied;
214    attribute EventListener onended;
215    attribute EventListener onerror;
216    attribute EventListener onfocus;
217    attribute EventListener onhashchange;
218    attribute EventListener oninput;
219    attribute EventListener oninvalid;
220    attribute EventListener onkeydown;
221    attribute EventListener onkeypress;
222    attribute EventListener onkeyup;
223    attribute EventListener onload;
224    attribute EventListener onloadeddata;
225    attribute EventListener onloadedmetadata;
226    attribute EventListener onloadstart;
227    attribute EventListener onmessage;
228    attribute EventListener onmousedown;
229    attribute EventListener onmouseenter;
230    attribute EventListener onmouseleave;
231    attribute EventListener onmousemove;
232    attribute EventListener onmouseout;
233    attribute EventListener onmouseover;
234    attribute EventListener onmouseup;
235    attribute EventListener onmousewheel;
236    attribute EventListener onoffline;
237    attribute EventListener ononline;
238    attribute EventListener onpagehide;
239    attribute EventListener onpageshow;
240    attribute EventListener onpause;
241    attribute EventListener onplay;
242    attribute EventListener onplaying;
243    attribute EventListener onpopstate;
244    attribute EventListener onprogress;
245    attribute EventListener onratechange;
246    attribute EventListener onresize;
247    attribute EventListener onscroll;
248    attribute EventListener onseeked;
249    attribute EventListener onseeking;
250    attribute EventListener onselect;
251    attribute EventListener onstalled;
252    attribute EventListener onstorage;
253    attribute EventListener onsubmit;
254    attribute EventListener onsuspend;
255    attribute EventListener ontimeupdate;
256    attribute EventListener onunload;
257    attribute EventListener onvolumechange;
258    attribute EventListener onwaiting;
259    attribute EventListener onwheel;
260
261    // Not implemented yet.
262    // attribute EventListener onafterprint;
263    // attribute EventListener onbeforeprint;
264    // attribute EventListener onreadystatechange;
265    // attribute EventListener onredo;
266    // attribute EventListener onshow;
267    // attribute EventListener onundo;
268
269    // Webkit extensions
270    attribute EventListener onreset;
271    attribute EventListener onsearch;
272    attribute EventListener onwebkitanimationend;
273    attribute EventListener onwebkitanimationiteration;
274    attribute EventListener onwebkitanimationstart;
275    attribute EventListener onwebkittransitionend;
276    attribute EventListener ontransitionend;
277#if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS
278    attribute EventListener onorientationchange;
279#endif
280    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchstart;
281    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchmove;
282    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchend;
283    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchcancel;
284
285    [Conditional=IOS_GESTURE_EVENTS] attribute EventListener ongesturestart;
286    [Conditional=IOS_GESTURE_EVENTS] attribute EventListener ongesturechange;
287    [Conditional=IOS_GESTURE_EVENTS] attribute EventListener ongestureend;
288
289    [Conditional=DEVICE_ORIENTATION] attribute EventListener ondevicemotion;
290    [Conditional=DEVICE_ORIENTATION] attribute EventListener ondeviceorientation;
291
292    [Conditional=PROXIMITY_EVENTS] attribute EventListener onwebkitdeviceproximity;
293
294    [Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealbottom;
295    [Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealleft;
296    [Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealright;
297    [Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealtop;
298
299    // EventTarget interface
300    [Custom] void addEventListener(DOMString type,
301                                  EventListener listener,
302                                  optional boolean useCapture);
303    [Custom] void removeEventListener(DOMString type,
304                                      EventListener listener,
305                                      optional boolean useCapture);
306    [RaisesException] boolean dispatchEvent(Event evt);
307
308    void captureEvents(/*in long eventFlags*/);
309    void releaseEvents(/*in long eventFlags*/);
310
311#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
312    // Additional constructors.
313    [CustomGetter, CustomConstructor] attribute HTMLImageElementNamedConstructor Image; // Usable with new operator
314    // Mozilla has a separate XMLDocument object for XML documents.
315    // We just use Document for this.
316    attribute DocumentConstructor XMLDocument;
317
318    [Conditional=IOS_TOUCH_EVENTS, CustomGetter] attribute TouchConstructor Touch; // Usable with the new operator
319    [Conditional=IOS_TOUCH_EVENTS, CustomGetter] attribute TouchListConstructor TouchList; // Usable with the new operator
320
321    attribute DOMURLConstructor webkitURL; // FIXME: deprecate this.
322    attribute MutationObserverConstructor WebKitMutationObserver; // FIXME: Add metrics to determine when we can remove this.
323    [Conditional=INDEXED_DATABASE] attribute IDBCursorConstructor webkitIDBCursor;
324    [Conditional=INDEXED_DATABASE] attribute IDBDatabaseConstructor webkitIDBDatabase;
325    [Conditional=INDEXED_DATABASE] attribute IDBFactoryConstructor webkitIDBFactory;
326    [Conditional=INDEXED_DATABASE] attribute IDBIndexConstructor webkitIDBIndex;
327    [Conditional=INDEXED_DATABASE] attribute IDBKeyRangeConstructor webkitIDBKeyRange;
328    [Conditional=INDEXED_DATABASE] attribute IDBObjectStoreConstructor webkitIDBObjectStore;
329    [Conditional=INDEXED_DATABASE] attribute IDBRequestConstructor webkitIDBRequest;
330    [Conditional=INDEXED_DATABASE] attribute IDBTransactionConstructor webkitIDBTransaction;
331#endif // defined(LANGUAGE_JAVASCRIPT)
332};
333
334DOMWindow implements WindowTimers;
335DOMWindow implements WindowBase64;
336