2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
28 // http://www.w3.org/html/wg/drafts/html/master/browsers.html#window
29 // FIXME: explain all uses of [DoNotCheckSecurity]
33 ImplementedAs=LocalDOMWindow,
35 ] interface Window : EventTarget {
37 readonly attribute Screen screen;
38 readonly attribute History history;
39 [Replaceable, MeasureAs=BarPropLocationbar] readonly attribute BarProp locationbar;
40 [Replaceable, MeasureAs=BarPropMenubar] readonly attribute BarProp menubar;
41 [Replaceable, MeasureAs=BarPropPersonalbar] readonly attribute BarProp personalbar;
42 [Replaceable, MeasureAs=BarPropScrollbars] readonly attribute BarProp scrollbars;
43 [Replaceable, MeasureAs=BarPropStatusbar] readonly attribute BarProp statusbar;
44 [Replaceable, MeasureAs=BarPropToolbar] readonly attribute BarProp toolbar;
45 [LogActivity=GetterOnly] readonly attribute Navigator navigator;
46 [Replaceable] readonly attribute Navigator clientInformation;
47 [DoNotCheckSecurity, Unforgeable, Replaceable, PutForwards=href] readonly attribute Location location;
48 [Custom, MeasureAs=WindowEvent, NotEnumerable] attribute Event event;
50 Selection getSelection();
52 [CheckSecurity=Node, Custom=Getter] readonly attribute Element frameElement;
54 [DoNotCheckSecurity, CallWith=ExecutionContext] void focus();
55 [DoNotCheckSecurity] void blur();
56 [DoNotCheckSecurity, CallWith=ExecutionContext] void close();
61 [Custom] Window open(DOMString url,
63 optional DOMString options);
65 [RuntimeEnabled=ShowModalDialog, Custom] any showModalDialog(DOMString url,
66 optional any dialogArgs,
67 optional DOMString featureArgs);
70 void alert(DOMString message);
71 boolean confirm(optional DOMString message = "");
72 DOMString? prompt(optional DOMString message = "",
73 optional DOMString defaultValue = "");
75 boolean find([Default=Undefined] optional DOMString string,
76 [Default=Undefined] optional boolean caseSensitive,
77 [Default=Undefined] optional boolean backwards,
78 [Default=Undefined] optional boolean wrap,
79 [Default=Undefined] optional boolean wholeWord,
80 [Default=Undefined] optional boolean searchInFrames,
81 [Default=Undefined] optional boolean showDialog);
83 [Replaceable, MeasureAs=WindowOffscreenBuffering] readonly attribute boolean offscreenBuffering;
85 [Replaceable] readonly attribute long outerHeight;
86 [Replaceable] readonly attribute long outerWidth;
87 [Replaceable] readonly attribute long innerHeight;
88 [Replaceable] readonly attribute long innerWidth;
89 [Replaceable] readonly attribute long screenX;
90 [Replaceable] readonly attribute long screenY;
91 [Replaceable] readonly attribute long screenLeft;
92 [Replaceable] readonly attribute long screenTop;
93 [Replaceable] readonly attribute double scrollX;
94 [Replaceable] readonly attribute double scrollY;
95 readonly attribute double pageXOffset;
96 readonly attribute double pageYOffset;
98 // Overloading can be replaced by optional if RuntimeEnabled is removed, by
99 // changing the third argument to *optional* Dictionary scrollOptions
100 void scrollBy(double x, double y);
101 [RuntimeEnabled=CSSOMSmoothScroll, RaisesException] void scrollBy(double x, double y, ScrollOptions scrollOptions);
102 void scrollTo(double x, double y);
103 [RuntimeEnabled=CSSOMSmoothScroll, RaisesException] void scrollTo(double x, double y, ScrollOptions scrollOptions);
104 void scroll(double x, double y);
105 [RuntimeEnabled=CSSOMSmoothScroll, RaisesException] void scroll(double x, double y, ScrollOptions scrollOptions);
106 void moveBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
107 void moveTo([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
108 void resizeBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
109 void resizeTo([Default=Undefined] optional float width, [Default=Undefined] optional float height); // FIXME: this should take longs not floats.
111 [DoNotCheckSecurity] readonly attribute boolean closed;
113 [Replaceable, DoNotCheckSecurity] readonly attribute unsigned long length;
115 attribute DOMString name;
117 attribute DOMString status;
118 [MeasureAs=WindowDefaultStatus] attribute DOMString defaultStatus;
119 // This attribute is an alias of defaultStatus and is necessary for legacy uses.
120 [ImplementedAs=defaultStatus, MeasureAs=WindowDefaultstatus] attribute DOMString defaultstatus;
122 // Self referential attributes
123 [Replaceable, DoNotCheckSecurity] readonly attribute Window self;
124 [DoNotCheckSecurity, Unforgeable] readonly attribute Window window;
125 [Replaceable, DoNotCheckSecurity] readonly attribute Window frames;
127 [DoNotCheckSecurity, Custom=Setter] attribute Window opener;
128 [Replaceable, DoNotCheckSecurity] readonly attribute Window parent;
129 [DoNotCheckSecurity, Unforgeable] readonly attribute Window top;
131 // DOM Level 2 AbstractView Interface
132 readonly attribute Document document;
135 MediaQueryList matchMedia(DOMString query);
137 // styleMedia has been removed from the CSSOM View specification.
138 readonly attribute StyleMedia styleMedia;
140 // DOM Level 2 Style Interface
141 CSSStyleDeclaration getComputedStyle([Default=Undefined] optional Element element,
142 [TreatUndefinedAs=NullString, Default=Undefined] optional DOMString? pseudoElement);
145 [MeasureAs=GetMatchedCSSRules] CSSRuleList getMatchedCSSRules([Default=Undefined] optional Element element,
146 [TreatUndefinedAs=NullString, Default=Undefined] optional DOMString? pseudoElement);
148 [Replaceable] readonly attribute double devicePixelRatio;
150 [RuntimeEnabled=ApplicationCache, LogActivity=GetterOnly] readonly attribute ApplicationCache applicationCache;
152 [RuntimeEnabled=SessionStorage, LogActivity=GetterOnly, RaisesException=Getter] readonly attribute Storage sessionStorage;
153 [RuntimeEnabled=LocalStorage, LogActivity=GetterOnly, RaisesException=Getter] readonly attribute Storage localStorage;
155 // This is the interface orientation in degrees. Some examples are:
156 // 0 is straight up; -90 is when the device is rotated 90 clockwise;
157 // 90 is when rotated counter clockwise.
158 [RuntimeEnabled=OrientationEvent, MeasureAs=WindowOrientation] readonly attribute long orientation;
160 [Replaceable] readonly attribute Console console;
162 // cross-document messaging
163 [DoNotCheckSecurity, Custom, RaisesException] void postMessage(SerializedScriptValue message, DOMString targetOrigin, optional sequence<Transferable> transfer);
165 [Replaceable] readonly attribute Performance performance;
167 [MeasureAs=UnprefixedRequestAnimationFrame] long requestAnimationFrame(RequestAnimationFrameCallback callback);
168 void cancelAnimationFrame(long id);
169 [DeprecateAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(RequestAnimationFrameCallback callback);
170 [DeprecateAs=PrefixedCancelAnimationFrame, ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);
171 [DeprecateAs=PrefixedCancelRequestAnimationFrame, ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id);
173 [Replaceable] readonly attribute CSS CSS;
175 // Event handler attributes
176 [RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationend;
177 [RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationiteration;
178 [RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationstart;
179 [RuntimeEnabled=OrientationEvent] attribute EventHandler onorientationchange;
180 attribute EventHandler onsearch;
181 [RuntimeEnabled=Touch] attribute EventHandler ontouchcancel;
182 [RuntimeEnabled=Touch] attribute EventHandler ontouchend;
183 [RuntimeEnabled=Touch] attribute EventHandler ontouchmove;
184 [RuntimeEnabled=Touch] attribute EventHandler ontouchstart;
185 attribute EventHandler ontransitionend;
186 attribute EventHandler onwebkitanimationend;
187 attribute EventHandler onwebkitanimationiteration;
188 attribute EventHandler onwebkitanimationstart;
189 attribute EventHandler onwebkittransitionend;
190 attribute EventHandler onwheel;
192 [MeasureAs=WindowCaptureEvents] void captureEvents();
193 [MeasureAs=WindowReleaseEvents] void releaseEvents();
195 // Additional constructors.
196 [MeasureAs=PrefixedTransitionEventConstructor] attribute TransitionEventConstructor WebKitTransitionEvent;
197 [RuntimeEnabled=CSSAnimationUnprefixed] attribute WebKitAnimationEventConstructor AnimationEvent;
198 [MeasureAs=PrefixedWindowURL] attribute URLConstructor webkitURL; // FIXME: deprecate this.
199 [MeasureAs=PrefixedMutationObserverConstructor] attribute MutationObserverConstructor WebKitMutationObserver;
201 // window.toString() requires special handling in V8
202 [DoNotCheckSignature, DoNotCheckSecurity, Custom, NotEnumerable] stringifier;
204 [NotEnumerable] getter Window (unsigned long index);
205 [Custom, NotEnumerable] getter Window (DOMString name);
208 // http://www.whatwg.org/specs/web-apps/current-work/#transferable-objects
210 // Expressing the Transferable typedef in IDL depends on http://crbug.com/240176.
211 // The postMessage() methods taking a Transferable array argument have custom
212 // binding code that is able to handle the Transferables that we currently
213 // recognize. To be able to declare a postMessage() signature that matches
214 // the implementation, we provide a Transferable typedef but with an
217 // FIXME: make this typedef accurate once enough of http://crbug.com/240176
219 // FIXME: consider putting this typedef in an .idl file containing spec-wide
220 // utility type definitions.
221 typedef MessagePort Transferable;
223 Window implements GlobalEventHandlers;
224 Window implements WindowBase64;
225 Window implements WindowEventHandlers;
226 Window implements WindowTimers;