Home | History | Annotate | Download | only in frame
      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 // HTML 5 draft spec:
     28 // http://www.w3.org/html/wg/drafts/html/master/browsers.html#window
     29 // FIXME: explain all uses of [DoNotCheckSecurity]
     30 [
     31     CheckSecurity=Frame,
     32     Custom=ToV8,
     33     ImplementedAs=LocalDOMWindow,
     34     PrimaryGlobal,
     35     WillBeGarbageCollected,
     36 ] interface Window : EventTarget {
     37     // DOM Level 0
     38     readonly attribute Screen screen;
     39     readonly attribute History history;
     40     [Replaceable, MeasureAs=BarPropLocationbar] readonly attribute BarProp locationbar;
     41     [Replaceable, MeasureAs=BarPropMenubar] readonly attribute BarProp menubar;
     42     [Replaceable, MeasureAs=BarPropPersonalbar] readonly attribute BarProp personalbar;
     43     [Replaceable, MeasureAs=BarPropScrollbars] readonly attribute BarProp scrollbars;
     44     [Replaceable, MeasureAs=BarPropStatusbar] readonly attribute BarProp statusbar;
     45     [Replaceable, MeasureAs=BarPropToolbar] readonly attribute BarProp toolbar;
     46     [LogActivity=GetterOnly] readonly attribute Navigator navigator;
     47     [Replaceable] readonly attribute Navigator clientInformation;
     48     [DoNotCheckSecurity, Unforgeable, Replaceable, LogActivity, PutForwards=href] readonly attribute Location location;
     49     [Custom, MeasureAs=WindowEvent, NotEnumerable] attribute Event event;
     50 
     51     Selection getSelection();
     52 
     53     [CheckSecurity=Node, Custom=Getter] readonly attribute Element frameElement;
     54 
     55     [DoNotCheckSecurity, CallWith=ExecutionContext] void focus();
     56     [DoNotCheckSecurity] void blur();
     57     [DoNotCheckSecurity, CallWith=ExecutionContext] void close();
     58 
     59     void print();
     60     void stop();
     61 
     62     [Custom] Window open(DOMString url,
     63                             DOMString name,
     64                             optional DOMString options);
     65 
     66     [RuntimeEnabled=ShowModalDialog, Custom] any showModalDialog(DOMString url,
     67                                        optional any dialogArgs,
     68                                        optional DOMString featureArgs);
     69 
     70     void alert();
     71     void alert(DOMString message);
     72     boolean confirm(optional DOMString message = null);
     73     [TreatReturnedNullStringAs=Null] DOMString prompt(optional DOMString message = null,
     74                                                       optional DOMString defaultValue = null);
     75 
     76     boolean find([Default=Undefined] optional DOMString string,
     77                  [Default=Undefined] optional boolean caseSensitive,
     78                  [Default=Undefined] optional boolean backwards,
     79                  [Default=Undefined] optional boolean wrap,
     80                  [Default=Undefined] optional boolean wholeWord,
     81                  [Default=Undefined] optional boolean searchInFrames,
     82                  [Default=Undefined] optional boolean showDialog);
     83 
     84     [Replaceable, MeasureAs=WindowOffscreenBuffering] readonly attribute boolean offscreenBuffering;
     85 
     86     [Replaceable] readonly attribute long outerHeight;
     87     [Replaceable] readonly attribute long outerWidth;
     88     [Replaceable] readonly attribute long innerHeight;
     89     [Replaceable] readonly attribute long innerWidth;
     90     [Replaceable] readonly attribute long screenX;
     91     [Replaceable] readonly attribute long screenY;
     92     [Replaceable] readonly attribute long screenLeft;
     93     [Replaceable] readonly attribute long screenTop;
     94     [Replaceable] readonly attribute long scrollX;
     95     [Replaceable] readonly attribute long scrollY;
     96     readonly attribute long pageXOffset;
     97     readonly attribute long pageYOffset;
     98 
     99     // Overloading can be replaced by optional if RuntimeEnabled is removed, by
    100     // changing the third argument to *optional* Dictionary scrollOptions
    101     void scrollBy(long x, long y);
    102     [RuntimeEnabled=CSSOMSmoothScroll, RaisesException] void scrollBy(long x, long y, Dictionary scrollOptions);
    103     void scrollTo(long x, long y);
    104     [RuntimeEnabled=CSSOMSmoothScroll, RaisesException] void scrollTo(long x, long y, Dictionary scrollOptions);
    105     void scroll(long x, long y);
    106     [RuntimeEnabled=CSSOMSmoothScroll, RaisesException] void scroll(long x, long y, Dictionary scrollOptions);
    107     void moveBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
    108     void moveTo([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
    109     void resizeBy([Default=Undefined] optional float x, [Default=Undefined] optional float y); // FIXME: this should take longs not floats.
    110     void resizeTo([Default=Undefined] optional float width, [Default=Undefined] optional float height); // FIXME: this should take longs not floats.
    111 
    112     [DoNotCheckSecurity] readonly attribute boolean closed;
    113 
    114     [Replaceable, DoNotCheckSecurity] readonly attribute unsigned long length;
    115 
    116     attribute DOMString name;
    117 
    118     attribute DOMString status;
    119     [MeasureAs=WindowDefaultStatus] attribute DOMString defaultStatus;
    120     // This attribute is an alias of defaultStatus and is necessary for legacy uses.
    121     [ImplementedAs=defaultStatus, MeasureAs=WindowDefaultstatus] attribute DOMString defaultstatus;
    122 
    123     // Self referential attributes
    124     [Replaceable, DoNotCheckSecurity] readonly attribute Window self;
    125     [DoNotCheckSecurity, Unforgeable] readonly attribute Window window;
    126     [Replaceable, DoNotCheckSecurity] readonly attribute  Window frames;
    127 
    128     [DoNotCheckSecurity, Custom=Setter] attribute Window opener;
    129     [Replaceable, DoNotCheckSecurity] readonly attribute Window parent;
    130     [DoNotCheckSecurity, Unforgeable] readonly attribute Window top;
    131 
    132     // DOM Level 2 AbstractView Interface
    133     readonly attribute Document document;
    134 
    135     // CSSOM View Module
    136     MediaQueryList matchMedia(DOMString query);
    137 
    138     // styleMedia has been removed from the CSSOM View specification.
    139     readonly attribute StyleMedia styleMedia;
    140 
    141     // DOM Level 2 Style Interface
    142     CSSStyleDeclaration getComputedStyle([Default=Undefined] optional Element element,
    143                                                             [TreatNullAs=NullString, TreatUndefinedAs=NullString, Default=Undefined] optional DOMString pseudoElement);
    144 
    145     // WebKit extensions
    146     [MeasureAs=GetMatchedCSSRules] CSSRuleList getMatchedCSSRules([Default=Undefined] optional Element element,
    147                                                                   [TreatNullAs=NullString, TreatUndefinedAs=NullString, Default=Undefined] optional DOMString pseudoElement);
    148 
    149     [Replaceable] readonly attribute double devicePixelRatio;
    150 
    151     [MeasureAs=PrefixedConvertPointFromPageToNode] WebKitPoint webkitConvertPointFromPageToNode([Default=Undefined] optional Node node,
    152                                                                                                 [Default=Undefined] optional WebKitPoint p);
    153     [MeasureAs=PrefixedConvertPointFromNodeToPage] WebKitPoint webkitConvertPointFromNodeToPage([Default=Undefined] optional Node node,
    154                                                                                                 [Default=Undefined] optional WebKitPoint p);
    155 
    156     [RuntimeEnabled=ApplicationCache, LogActivity=GetterOnly] readonly attribute ApplicationCache applicationCache;
    157 
    158     [RuntimeEnabled=SessionStorage, LogActivity=GetterOnly, RaisesException=Getter] readonly attribute Storage sessionStorage;
    159     [RuntimeEnabled=LocalStorage, LogActivity=GetterOnly, RaisesException=Getter] readonly attribute Storage localStorage;
    160 
    161     // This is the interface orientation in degrees. Some examples are:
    162     //  0 is straight up; -90 is when the device is rotated 90 clockwise;
    163     //  90 is when rotated counter clockwise.
    164     [RuntimeEnabled=OrientationEvent, MeasureAs=WindowOrientation] readonly attribute long orientation;
    165 
    166     [Replaceable] readonly attribute Console console;
    167 
    168     // cross-document messaging
    169     [DoNotCheckSecurity, Custom, RaisesException] void postMessage(SerializedScriptValue message, DOMString targetOrigin, optional MessagePort[] messagePorts);
    170 
    171     [Replaceable] readonly attribute Performance performance;
    172 
    173     [MeasureAs=UnprefixedRequestAnimationFrame] long requestAnimationFrame(RequestAnimationFrameCallback callback);
    174     void cancelAnimationFrame(long id);
    175     [DeprecateAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(RequestAnimationFrameCallback callback);
    176     [DeprecateAs=PrefixedCancelAnimationFrame, ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);
    177     [DeprecateAs=PrefixedCancelRequestAnimationFrame, ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(long id);
    178 
    179     [Replaceable] readonly attribute CSS CSS;
    180 
    181     // Event handler attributes
    182     [RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationend;
    183     [RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationiteration;
    184     [RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationstart;
    185     [RuntimeEnabled=OrientationEvent] attribute EventHandler onorientationchange;
    186     attribute EventHandler onsearch;
    187     [RuntimeEnabled=Touch] attribute EventHandler ontouchcancel;
    188     [RuntimeEnabled=Touch] attribute EventHandler ontouchend;
    189     [RuntimeEnabled=Touch] attribute EventHandler ontouchmove;
    190     [RuntimeEnabled=Touch] attribute EventHandler ontouchstart;
    191     attribute EventHandler ontransitionend;
    192     attribute EventHandler onwebkitanimationend;
    193     attribute EventHandler onwebkitanimationiteration;
    194     attribute EventHandler onwebkitanimationstart;
    195     attribute EventHandler onwebkittransitionend;
    196     [LogActivity=SetterOnly] attribute EventHandler onwheel;
    197 
    198     [MeasureAs=WindowCaptureEvents] void captureEvents();
    199     [MeasureAs=WindowReleaseEvents] void releaseEvents();
    200 
    201     // Additional constructors.
    202     [MeasureAs=PrefixedTransitionEventConstructor] attribute TransitionEventConstructor WebKitTransitionEvent;
    203     [RuntimeEnabled=CSSAnimationUnprefixed] attribute WebKitAnimationEventConstructor AnimationEvent;
    204     [MeasureAs=PrefixedWindowURL] attribute URLConstructor webkitURL; // FIXME: deprecate this.
    205     [MeasureAs=PrefixedMutationObserverConstructor] attribute MutationObserverConstructor WebKitMutationObserver;
    206 
    207     // window.toString() requires special handling in V8
    208     [DoNotCheckSignature, DoNotCheckSecurity, Custom, NotEnumerable] DOMString toString();
    209 
    210     [NotEnumerable] getter Window (unsigned long index);
    211     [Custom, NotEnumerable] getter Window (DOMString name);
    212 };
    213 
    214 Window implements GlobalEventHandlers;
    215 Window implements WindowBase64;
    216 Window implements WindowEventHandlers;
    217 Window implements WindowTimers;
    218