Home | History | Annotate | Download | only in page
      1 /*
      2  * Copyright (C) 2006, 2007, 2008, 2009 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     CustomToV8,
     30     DoNotGenerateWrap,
     31     ImplementedAs=DOMWindow
     32 ] interface Window : EventTarget {
     33     // DOM Level 0
     34     [Replaceable] readonly attribute Screen screen;
     35     [Replaceable] readonly attribute History history;
     36     [Replaceable] readonly attribute BarProp locationbar;
     37     [Replaceable] readonly attribute BarProp menubar;
     38     [Replaceable] readonly attribute BarProp personalbar;
     39     [Replaceable] readonly attribute BarProp scrollbars;
     40     [Replaceable] readonly attribute BarProp statusbar;
     41     [Replaceable] readonly attribute BarProp toolbar;
     42     [Replaceable, PerWorldBindings, ActivityLog=GetterForIsolatedWorlds] readonly attribute Navigator navigator;
     43     [Replaceable] readonly attribute Navigator clientInformation;
     44     [DoNotCheckSecurity, CustomSetter, Unforgeable, Replaceable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds] readonly attribute Location location;
     45     [MeasureAs=WindowEvent, NotEnumerable, Replaceable, CustomGetter, CustomSetter] readonly attribute Event event;
     46 
     47     Selection getSelection();
     48 
     49     [CheckSecurityForNode] readonly attribute Element frameElement;
     50 
     51     [DoNotCheckSecurity, CallWith=ScriptExecutionContext] void focus();
     52     [DoNotCheckSecurity] void blur();
     53     [DoNotCheckSecurity, CallWith=ScriptExecutionContext] void close();
     54 
     55     void print();
     56     void stop();
     57 
     58     [Custom] Window open(DOMString url,
     59                             DOMString name,
     60                             optional DOMString options);
     61 
     62     [Custom] any showModalDialog(DOMString url,
     63                                        optional any dialogArgs,
     64                                        optional DOMString featureArgs);
     65 
     66     void alert([Default=Undefined] optional DOMString message);
     67     boolean confirm([Default=Undefined] optional DOMString message);
     68     [TreatReturnedNullStringAs=Null] DOMString prompt([Default=Undefined] optional DOMString message,
     69                                                 [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString defaultValue);
     70 
     71     boolean find([Default=Undefined] optional DOMString string,
     72                  [Default=Undefined] optional boolean caseSensitive,
     73                  [Default=Undefined] optional boolean backwards,
     74                  [Default=Undefined] optional boolean wrap,
     75                  [Default=Undefined] optional boolean wholeWord,
     76                  [Default=Undefined] optional boolean searchInFrames,
     77                  [Default=Undefined] optional boolean showDialog);
     78 
     79     [Replaceable] readonly attribute  boolean offscreenBuffering;
     80 
     81     [Replaceable] readonly attribute long outerHeight;
     82     [Replaceable] readonly attribute long outerWidth;
     83     [Replaceable] readonly attribute long innerHeight;
     84     [Replaceable] readonly attribute long innerWidth;
     85     [Replaceable] readonly attribute long screenX;
     86     [Replaceable] readonly attribute long screenY;
     87     [Replaceable] readonly attribute long screenLeft;
     88     [Replaceable] readonly attribute long screenTop;
     89     [Replaceable] readonly attribute long scrollX;
     90     [Replaceable] readonly attribute long scrollY;
     91     readonly attribute long pageXOffset;
     92     readonly attribute long pageYOffset;
     93 
     94     void scrollBy([Default=Undefined] optional long x, [Default=Undefined] optional long y);
     95     void scrollTo([Default=Undefined] optional long x, [Default=Undefined] optional long y);
     96     void scroll([Default=Undefined] optional long x, [Default=Undefined] optional long y);
     97     void moveBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
     98     void moveTo([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
     99     void resizeBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
    100     void resizeTo([Default=Undefined] optional float width, [Default=Undefined] optional float height); // FIXME: this should take longs not floats.
    101 
    102     [DoNotCheckSecurity] readonly attribute boolean closed;
    103 
    104     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
    105 
    106     attribute DOMString name;
    107 
    108     attribute DOMString status;
    109     attribute DOMString defaultStatus;
    110     // This attribute is an alias of defaultStatus and is necessary for legacy uses.
    111     attribute DOMString defaultstatus;
    112 
    113     // Self referential attributes
    114     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute Window self;
    115     [DoNotCheckSecurity, Unforgeable] readonly attribute Window window;
    116     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute  Window frames;
    117 
    118     [Replaceable, DoNotCheckSecurityOnGetter, CustomSetter] readonly attribute Window opener;
    119     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute Window parent;
    120     [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute Window top;
    121 
    122     // DOM Level 2 AbstractView Interface
    123     readonly attribute Document document;
    124 
    125     // CSSOM View Module
    126     MediaQueryList matchMedia(DOMString query);
    127 
    128     // styleMedia has been removed from the CSSOM View specification.
    129     readonly attribute StyleMedia styleMedia;
    130 
    131     // DOM Level 2 Style Interface
    132     [PerWorldBindings] CSSStyleDeclaration getComputedStyle([Default=Undefined] optional Element element,
    133                                                               [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString pseudoElement);
    134 
    135     // WebKit extensions
    136     CSSRuleList getMatchedCSSRules([Default=Undefined] optional Element element,
    137                                    [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString pseudoElement);
    138 
    139     [Replaceable] readonly attribute double devicePixelRatio;
    140 
    141     WebKitPoint webkitConvertPointFromPageToNode([Default=Undefined] optional Node node,
    142                                                  [Default=Undefined] optional WebKitPoint p);
    143     WebKitPoint webkitConvertPointFromNodeToPage([Default=Undefined] optional Node node,
    144                                                  [Default=Undefined] optional WebKitPoint p);
    145 
    146     [EnabledAtRuntime, PerWorldBindings, ActivityLog=GetterForIsolatedWorlds] readonly attribute DOMApplicationCache applicationCache;
    147 
    148     [EnabledAtRuntime, PerWorldBindings, ActivityLog=GetterForIsolatedWorlds, GetterRaisesException] readonly attribute Storage sessionStorage;
    149     [EnabledAtRuntime, PerWorldBindings, ActivityLog=GetterForIsolatedWorlds, GetterRaisesException] readonly attribute Storage localStorage;
    150 
    151     // This is the interface orientation in degrees. Some examples are:
    152     //  0 is straight up; -90 is when the device is rotated 90 clockwise;
    153     //  90 is when rotated counter clockwise.
    154     [Conditional=ORIENTATION_EVENTS] readonly attribute long orientation;
    155 
    156     [Replaceable] readonly attribute Console console;
    157 
    158     // cross-document messaging
    159     [DoNotCheckSecurity, Custom, RaisesException] void postMessage(SerializedScriptValue message, DOMString targetOrigin, optional Array messagePorts);
    160 
    161     [Replaceable] readonly attribute Performance performance;
    162 
    163     [MeasureAs=UnprefixedRequestAnimationFrame] long requestAnimationFrame(RequestAnimationFrameCallback callback);
    164     void cancelAnimationFrame(long id);
    165     [MeasureAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(RequestAnimationFrameCallback callback);
    166     [ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);
    167     [ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id); // This is a deprecated alias for webkitCancelAnimationFrame(). Remove this when removing vendor prefix.
    168 
    169     [Replaceable] readonly attribute CSS CSS;
    170 
    171     // Events
    172     attribute EventHandler onabort;
    173     attribute EventHandler onbeforeunload;
    174     attribute EventHandler onblur;
    175     attribute EventHandler oncanplay;
    176     attribute EventHandler oncanplaythrough;
    177     attribute EventHandler onchange;
    178     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onclick;
    179     attribute EventHandler oncontextmenu;
    180     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondblclick;
    181     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondrag;
    182     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragend;
    183     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragenter;
    184     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragleave;
    185     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragover;
    186     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragstart;
    187     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondrop;
    188     attribute EventHandler ondurationchange;
    189     attribute EventHandler onemptied;
    190     attribute EventHandler onended;
    191     attribute EventHandler onerror;
    192     attribute EventHandler onfocus;
    193     attribute EventHandler onhashchange;
    194     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler oninput;
    195     attribute EventHandler oninvalid;
    196     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeydown;
    197     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeypress;
    198     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeyup;
    199     attribute EventHandler onload;
    200     attribute EventHandler onloadeddata;
    201     attribute EventHandler onloadedmetadata;
    202     attribute EventHandler onloadstart;
    203     attribute EventHandler onmessage;
    204     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousedown;
    205     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseenter;
    206     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseleave;
    207     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousemove;
    208     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseout;
    209     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseover;
    210     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseup;
    211     [PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousewheel;
    212     attribute EventHandler onoffline;
    213     attribute EventHandler ononline;
    214     attribute EventHandler onpagehide;
    215     attribute EventHandler onpageshow;
    216     attribute EventHandler onpause;
    217     attribute EventHandler onplay;
    218     attribute EventHandler onplaying;
    219     attribute EventHandler onpopstate;
    220     attribute EventHandler onprogress;
    221     attribute EventHandler onratechange;
    222     attribute EventHandler onresize;
    223     attribute EventHandler onscroll;
    224     attribute EventHandler onseeked;
    225     attribute EventHandler onseeking;
    226     attribute EventHandler onselect;
    227     attribute EventHandler onstalled;
    228     attribute EventHandler onstorage;
    229     attribute EventHandler onsubmit;
    230     attribute EventHandler onsuspend;
    231     attribute EventHandler ontimeupdate;
    232     attribute EventHandler onunload;
    233     attribute EventHandler onvolumechange;
    234     attribute EventHandler onwaiting;
    235 
    236     // Not implemented yet.
    237     // attribute EventHandler onafterprint;
    238     // attribute EventHandler onbeforeprint;
    239     // attribute EventHandler onreadystatechange;
    240     // attribute EventHandler onredo;
    241     // attribute EventHandler onshow;
    242     // attribute EventHandler onundo;
    243 
    244     // Webkit extensions
    245     attribute EventHandler onreset;
    246     attribute EventHandler onsearch;
    247     attribute EventHandler onwebkitanimationend;
    248     attribute EventHandler onwebkitanimationiteration;
    249     attribute EventHandler onwebkitanimationstart;
    250     attribute EventHandler onwebkittransitionend;
    251     attribute EventHandler ontransitionend;
    252     [Conditional=ORIENTATION_EVENTS] attribute EventHandler onorientationchange;
    253     [EnabledAtRuntime=touch] attribute EventHandler ontouchstart;
    254     [EnabledAtRuntime=touch] attribute EventHandler ontouchmove;
    255     [EnabledAtRuntime=touch] attribute EventHandler ontouchend;
    256     [EnabledAtRuntime=touch] attribute EventHandler ontouchcancel;
    257 
    258     [EnabledAtRuntime=deviceMotion] attribute EventHandler ondevicemotion;
    259     [EnabledAtRuntime=deviceOrientation] attribute EventHandler ondeviceorientation;
    260 
    261     [DeprecateAs=CaptureEvents] void captureEvents();
    262     [DeprecateAs=ReleaseEvents] void releaseEvents();
    263 
    264     // Additional constructors.
    265     attribute TransitionEventConstructor WebKitTransitionEvent;
    266     [CustomConstructor] attribute HTMLImageElementConstructorConstructor Image; // Usable with new operator
    267     // Mozilla has a separate XMLDocument object for XML documents.
    268     // We just use Document for this.
    269     attribute DocumentConstructor XMLDocument;
    270     attribute URLConstructor webkitURL; // FIXME: deprecate this.
    271     attribute MutationObserverConstructor WebKitMutationObserver; // FIXME: Add metrics to determine when we can remove this.
    272     attribute IDBCursorConstructor webkitIDBCursor;
    273     attribute IDBDatabaseConstructor webkitIDBDatabase;
    274     attribute IDBFactoryConstructor webkitIDBFactory;
    275     attribute IDBIndexConstructor webkitIDBIndex;
    276     attribute IDBKeyRangeConstructor webkitIDBKeyRange;
    277     attribute IDBObjectStoreConstructor webkitIDBObjectStore;
    278     attribute IDBRequestConstructor webkitIDBRequest;
    279     attribute IDBTransactionConstructor webkitIDBTransaction;
    280 
    281     // Constructors whose name does not match the interface name.
    282     // FIXME: Remove these once [ImplementedAs] is used and once constructor names match interface names.
    283     [EnabledAtRuntime=mediaStream] attribute MediaStreamConstructor webkitMediaStream;
    284     [Conditional=WEB_AUDIO, EnabledAtRuntime=WebAudio] attribute AudioContextConstructor webkitAudioContext;
    285     [Conditional=WEB_AUDIO, EnabledAtRuntime=WebAudio] attribute OfflineAudioContextConstructor webkitOfflineAudioContext;
    286     [EnabledAtRuntime=peerConnection] attribute RTCPeerConnectionConstructor webkitRTCPeerConnection;
    287     [EnabledAtRuntime=scriptedSpeech] attribute SpeechGrammarConstructor webkitSpeechGrammar;
    288     [EnabledAtRuntime=scriptedSpeech] attribute SpeechGrammarListConstructor webkitSpeechGrammarList;
    289     [EnabledAtRuntime=scriptedSpeech] attribute SpeechRecognitionConstructor webkitSpeechRecognition;
    290     [EnabledAtRuntime=scriptedSpeech] attribute SpeechRecognitionErrorConstructor webkitSpeechRecognitionError;
    291     [EnabledAtRuntime=scriptedSpeech] attribute SpeechRecognitionEventConstructor webkitSpeechRecognitionEvent;
    292     [Conditional=WEB_AUDIO] attribute PannerNodeConstructor webkitAudioPannerNode;
    293 
    294     // Prefixed ShadowRoot constructor should be phased out eventually, but for the moment it must be always exposed.
    295     // Unprefixed ShadowRoot constructor should be visible when the feature flag is enabled.
    296     // FIXME: When it's ready to remove WebKitShadowRoot, get rid of both constructors from Window.idl and remove
    297     // [NoInterfaceObject] from ShadowRoot interface definition.
    298     [EnabledAtRuntime=ShadowDOM] attribute ShadowRootConstructor ShadowRoot;
    299     [MeasureAs=PrefixedShadowRootConstructor] attribute ShadowRootConstructor WebKitShadowRoot;
    300 
    301     // window.toString() requires special handling in V8
    302     [DoNotCheckSignature, DoNotCheckSecurity, Custom, NotEnumerable] DOMString toString();
    303 
    304     [ImplementedAs=anonymousIndexedGetter, NotEnumerable] getter Window(unsigned long index);
    305     [Custom, NotEnumerable] getter Window (DOMString name);
    306 };
    307 
    308 Window implements ImageBitmapFactories;
    309 Window implements WindowTimers;
    310 Window implements WindowBase64;
    311