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 COMPUTER, 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 COMPUTER, 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    JSCustomMarkFunction,
34    JSCustomToNativeObject,
35    CustomPutFunction,
36    EventTarget,
37    ExtendsDOMGlobalObject,
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#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
56    [DoNotCheckSecurity, CustomSetter] attribute Location location;
57#endif
58    [Replaceable, CustomGetter] readonly attribute Event event;
59
60    DOMSelection getSelection();
61
62    [CheckSecurityForNode] readonly attribute Element frameElement;
63
64    [DoNotCheckSecurity, CallWith=ScriptExecutionContext] void focus();
65    [DoNotCheckSecurity] void blur();
66    [DoNotCheckSecurity, CallWith=ScriptExecutionContext] void close();
67
68    void print();
69    void stop();
70
71    [Custom] DOMWindow open(DOMString url,
72                            DOMString name,
73                            optional DOMString options);
74
75    [Custom] any showModalDialog(DOMString url,
76                                       optional any dialogArgs,
77                                       optional DOMString featureArgs);
78
79    void alert([Default=Undefined] optional DOMString message);
80    boolean confirm([Default=Undefined] optional DOMString message);
81    [TreatReturnedNullStringAs=Null] DOMString prompt([Default=Undefined] optional DOMString message,
82                                                [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString defaultValue);
83
84    boolean find([Default=Undefined] optional DOMString string,
85                 [Default=Undefined] optional boolean caseSensitive,
86                 [Default=Undefined] optional boolean backwards,
87                 [Default=Undefined] optional boolean wrap,
88                 [Default=Undefined] optional boolean wholeWord,
89                 [Default=Undefined] optional boolean searchInFrames,
90                 [Default=Undefined] optional boolean showDialog);
91
92    [Replaceable] readonly attribute  boolean offscreenBuffering;
93
94    [Replaceable] readonly attribute long outerHeight;
95    [Replaceable] readonly attribute long outerWidth;
96    [Replaceable] readonly attribute long innerHeight;
97    [Replaceable] readonly attribute long innerWidth;
98    [Replaceable] readonly attribute long screenX;
99    [Replaceable] readonly attribute long screenY;
100    [Replaceable] readonly attribute long screenLeft;
101    [Replaceable] readonly attribute long screenTop;
102    [Replaceable] readonly attribute long scrollX;
103    [Replaceable] readonly attribute long scrollY;
104    readonly attribute long pageXOffset;
105    readonly attribute long pageYOffset;
106
107    void scrollBy([Default=Undefined] optional long x, [Default=Undefined] optional long y);
108    void scrollTo([Default=Undefined] optional long x, [Default=Undefined] optional long y);
109    void scroll([Default=Undefined] optional long x, [Default=Undefined] optional long y);
110    void moveBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
111    void moveTo([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
112    void resizeBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
113    void resizeTo([Default=Undefined] optional float width, [Default=Undefined] optional float height); // FIXME: this should take longs not floats.
114
115    [DoNotCheckSecurity] readonly attribute boolean closed;
116
117    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
118
119    attribute DOMString name;
120
121    attribute DOMString status;
122    attribute DOMString defaultStatus;
123#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
124    // This attribute is an alias of defaultStatus and is necessary for legacy uses.
125    attribute DOMString defaultstatus;
126#endif
127
128    // Self referential attributes
129    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow self;
130    [DoNotCheckSecurity] readonly attribute DOMWindow window;
131    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute  DOMWindow frames;
132
133    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow opener;
134    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow parent;
135    [DoNotCheckSecurityOnGetter] readonly attribute DOMWindow top;
136
137    // DOM Level 2 AbstractView Interface
138    readonly attribute Document document;
139
140    // CSSOM View Module
141    MediaQueryList matchMedia(DOMString query);
142
143    // styleMedia has been removed from the CSSOM View specification.
144    readonly attribute StyleMedia styleMedia;
145
146    // DOM Level 2 Style Interface
147    CSSStyleDeclaration getComputedStyle([Default=Undefined] optional Element element,
148                                                              [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString pseudoElement);
149
150    // WebKit extensions
151#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
152    CSSRuleList getMatchedCSSRules([Default=Undefined] optional Element element,
153                                   [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString pseudoElement);
154#endif
155
156    [Replaceable] readonly attribute double devicePixelRatio;
157
158    WebKitPoint webkitConvertPointFromPageToNode([Default=Undefined] optional Node node,
159                                                 [Default=Undefined] optional WebKitPoint p);
160    WebKitPoint webkitConvertPointFromNodeToPage([Default=Undefined] optional Node node,
161                                                 [Default=Undefined] optional WebKitPoint p);
162
163    readonly attribute DOMApplicationCache applicationCache;
164
165    [GetterRaisesException] readonly attribute Storage sessionStorage;
166    [GetterRaisesException] readonly attribute Storage localStorage;
167
168#if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS
169    // This is the interface orientation in degrees. Some examples are:
170    //  0 is straight up; -90 is when the device is rotated 90 clockwise;
171    //  90 is when rotated counter clockwise.
172    readonly attribute long orientation;
173#endif
174
175    [Replaceable] readonly attribute Console console;
176
177    // cross-document messaging
178#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
179    [DoNotCheckSecurity, Custom, RaisesException] void postMessage(SerializedScriptValue message, DOMString targetOrigin, optional Array messagePorts);
180#else
181    // There's no good way to expose an array via the ObjC bindings, so for now just allow passing in a single port.
182    [DoNotCheckSecurity, Custom, RaisesException] void postMessage(SerializedScriptValue message, optional MessagePort messagePort, DOMString targetOrigin);
183#endif
184
185#if defined(ENABLE_WEB_TIMING) && ENABLE_WEB_TIMING
186    [Replaceable] readonly attribute Performance performance;
187#endif
188
189    // Timers
190    [Custom] long setTimeout(any handler, [Default=Undefined] optional long timeout);
191    void clearTimeout([Default=Undefined] optional long handle);
192    [Custom] long setInterval(any handler, [Default=Undefined] optional long timeout);
193    void clearInterval([Default=Undefined] optional long handle);
194
195#if defined(ENABLE_REQUEST_ANIMATION_FRAME) && ENABLE_REQUEST_ANIMATION_FRAME
196    long requestAnimationFrame(RequestAnimationFrameCallback callback);
197    void cancelAnimationFrame(long id);
198    long webkitRequestAnimationFrame(RequestAnimationFrameCallback callback);
199    [ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);
200    [ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id); // This is a deprecated alias for webkitCancelAnimationFrame(). Remove this when removing vendor prefix.
201#endif
202
203    // Base64
204    [RaisesException] DOMString atob([TreatNullAs=NullString,Default=Undefined] optional DOMString string);
205    [RaisesException] DOMString btoa([TreatNullAs=NullString,Default=Undefined] optional DOMString string);
206
207    [Replaceable,Conditional=CSS3_CONDITIONAL_RULES] readonly attribute DOMWindowCSS CSS;
208
209    // Events
210    attribute EventListener onabort;
211    attribute EventListener onbeforeunload;
212    attribute EventListener onblur;
213    attribute EventListener oncanplay;
214    attribute EventListener oncanplaythrough;
215    attribute EventListener onchange;
216    attribute EventListener onclick;
217    attribute EventListener oncontextmenu;
218    attribute EventListener ondblclick;
219    attribute EventListener ondrag;
220    attribute EventListener ondragend;
221    attribute EventListener ondragenter;
222    attribute EventListener ondragleave;
223    attribute EventListener ondragover;
224    attribute EventListener ondragstart;
225    attribute EventListener ondrop;
226    attribute EventListener ondurationchange;
227    attribute EventListener onemptied;
228    attribute EventListener onended;
229    attribute EventListener onerror;
230    attribute EventListener onfocus;
231    attribute EventListener onhashchange;
232    attribute EventListener oninput;
233    attribute EventListener oninvalid;
234    attribute EventListener onkeydown;
235    attribute EventListener onkeypress;
236    attribute EventListener onkeyup;
237    attribute EventListener onload;
238    attribute EventListener onloadeddata;
239    attribute EventListener onloadedmetadata;
240    attribute EventListener onloadstart;
241    attribute EventListener onmessage;
242    attribute EventListener onmousedown;
243    attribute EventListener onmouseenter;
244    attribute EventListener onmouseleave;
245    attribute EventListener onmousemove;
246    attribute EventListener onmouseout;
247    attribute EventListener onmouseover;
248    attribute EventListener onmouseup;
249    attribute EventListener onmousewheel;
250    attribute EventListener onoffline;
251    attribute EventListener ononline;
252    attribute EventListener onpagehide;
253    attribute EventListener onpageshow;
254    attribute EventListener onpause;
255    attribute EventListener onplay;
256    attribute EventListener onplaying;
257    attribute EventListener onpopstate;
258    attribute EventListener onprogress;
259    attribute EventListener onratechange;
260    attribute EventListener onresize;
261    attribute EventListener onscroll;
262    attribute EventListener onseeked;
263    attribute EventListener onseeking;
264    attribute EventListener onselect;
265    attribute EventListener onstalled;
266    attribute EventListener onstorage;
267    attribute EventListener onsubmit;
268    attribute EventListener onsuspend;
269    attribute EventListener ontimeupdate;
270    attribute EventListener onunload;
271    attribute EventListener onvolumechange;
272    attribute EventListener onwaiting;
273
274    // Not implemented yet.
275    // attribute EventListener onafterprint;
276    // attribute EventListener onbeforeprint;
277    // attribute EventListener onreadystatechange;
278    // attribute EventListener onredo;
279    // attribute EventListener onshow;
280    // attribute EventListener onundo;
281
282    // Webkit extensions
283    attribute EventListener onreset;
284    attribute EventListener onsearch;
285    attribute EventListener onwebkitanimationend;
286    attribute EventListener onwebkitanimationiteration;
287    attribute EventListener onwebkitanimationstart;
288    attribute EventListener onwebkittransitionend;
289    attribute EventListener ontransitionend;
290#if defined(ENABLE_ORIENTATION_EVENTS) && ENABLE_ORIENTATION_EVENTS
291    attribute EventListener onorientationchange;
292#endif
293    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchstart;
294    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchmove;
295    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchend;
296    [Conditional=TOUCH_EVENTS] attribute EventListener ontouchcancel;
297
298    [Conditional=DEVICE_ORIENTATION] attribute EventListener ondevicemotion;
299    [Conditional=DEVICE_ORIENTATION] attribute EventListener ondeviceorientation;
300
301    [Conditional=PROXIMITY_EVENTS] attribute EventListener onwebkitdeviceproximity;
302
303    // EventTarget interface
304    [Custom] void addEventListener(DOMString type,
305                                  EventListener listener,
306                                  optional boolean useCapture);
307    [Custom] void removeEventListener(DOMString type,
308                                      EventListener listener,
309                                      optional boolean useCapture);
310    [RaisesException] boolean dispatchEvent(Event evt);
311
312    void captureEvents(/*in long eventFlags*/);
313    void releaseEvents(/*in long eventFlags*/);
314
315#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
316    // Additional constructors.
317    [CustomGetter, CustomConstructor] attribute HTMLImageElementNamedConstructor Image; // Usable with new operator
318    // Mozilla has a separate XMLDocument object for XML documents.
319    // We just use Document for this.
320    attribute DocumentConstructor XMLDocument;
321    [Conditional=BLOB] 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