dom/interfaces/base/nsIDOMWindow.idl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "domstubs.idl"
     8 interface nsIFrameRequestCallback;
     9 interface nsIControllers;
    10 interface nsIDOMBlob;
    11 interface nsIDOMLocation;
    12 interface nsIDOMOfflineResourceList;
    13 interface nsIDOMStorage;
    14 interface nsIPrompt;
    15 interface nsISelection;
    16 interface nsIVariant;
    18 /**
    19  * The nsIDOMWindow interface is the primary interface for a DOM
    20  * window object. It represents a single window object that may
    21  * contain child windows if the document in the window contains a
    22  * HTML frameset document or if the document contains iframe elements.
    23  *
    24  * @see <http://www.whatwg.org/html/#window>
    25  */
    27 [scriptable, uuid(1b4a23a2-2ccf-4690-9da7-f3a7a8308381)]
    28 interface nsIDOMWindow : nsISupports
    29 {
    30   // the current browsing context
    31   readonly attribute nsIDOMWindow                       window;
    33   /* [replaceable] self */
    34   readonly attribute nsIDOMWindow                       self;
    36   /**
    37    * Accessor for the document in this window.
    38    */
    39   readonly attribute nsIDOMDocument                     document;
    41   /**
    42    * Set/Get the name of this window.
    43    *
    44    * This attribute is "replaceable" in JavaScript
    45    */
    46            attribute DOMString                          name;
    48   /* The setter that takes a string argument needs to be special cased! */
    49   readonly attribute nsIDOMLocation                     location;
    51   readonly attribute nsISupports                        history;
    54   /* [replaceable] locationbar */
    55   /* BarProp */
    56   readonly attribute nsISupports                        locationbar;
    58   /* [replaceable] menubar */
    59   /* BarProp */
    60   readonly attribute nsISupports                        menubar;
    62   /* [replaceable] personalbar */
    63   /* BarProp */
    64   readonly attribute nsISupports                        personalbar;
    66   /**
    67    * Accessor for the object that controls whether or not scrollbars
    68    * are shown in this window.
    69    *
    70    * This attribute is "replaceable" in JavaScript
    71    */
    72   /* BarProp */
    73   readonly attribute nsISupports                        scrollbars;
    75   /* [replaceable] statusbar */
    76   /* BarProp */
    77   readonly attribute nsISupports                        statusbar;
    79   /* [replaceable] toolbar */
    80   /* BarProp */
    81   readonly attribute nsISupports                        toolbar;
    83   /* [replaceable] */
    84            attribute DOMString                          status;
    86   void                      close();
    87   void                      stop();
    88   void                      focus();
    89   void                      blur();
    92   // other browsing contexts
    93   /* [replaceable] length */
    94   readonly attribute unsigned long                      length;
    96   /**
    97    * |top| gets the root of the window hierarchy.
    98    *
    99    * This function does not cross chrome-content boundaries, so if this
   100    * window's parent is of a different type, |top| will return this window.
   101    *
   102    * When script reads the top property, we run GetScriptableTop, which
   103    * will not cross an <iframe mozbrowser> boundary.
   104    *
   105    * In contrast, C++ calls to GetTop are forwarded to GetRealTop, which
   106    * ignores <iframe mozbrowser> boundaries.
   107    *
   108    * This property is "replaceable" in JavaScript.
   109    */
   110   [binaryname(ScriptableTop)]
   111   readonly attribute nsIDOMWindow                       top;
   113   /**
   114    * You shouldn't need to call this function directly; call GetTop instead.
   115    */
   116   [noscript]
   117   readonly attribute nsIDOMWindow                       realTop;
   119   %{C++
   120   nsresult GetTop(nsIDOMWindow **aWindow)
   121   {
   122     return GetRealTop(aWindow);
   123   }
   124   %}
   126   /**
   127    * |parent| gets this window's parent window.  If this window has no parent,
   128    * we return the window itself.
   129    *
   130    * This property does not cross chrome-content boundaries, so if this
   131    * window's parent is of a different type, we return the window itself as its
   132    * parent.
   133    *
   134    * When script reads the property (or when C++ calls ScriptableTop), this
   135    * property does not cross <iframe mozbrowser> boundaries.  In contrast, when
   136    * C++ calls GetParent, we ignore the mozbrowser attribute.
   137    */
   138   [binaryname(ScriptableParent)]
   139   readonly attribute nsIDOMWindow                       parent;
   141   /**
   142    * You shouldn't need to read this property directly; call GetParent instead.
   143    */
   144   [noscript]
   145   readonly attribute nsIDOMWindow                       realParent;
   147   %{C++
   148   inline nsresult GetParent(nsIDOMWindow **aWindow)
   149   {
   150     return GetRealParent(aWindow);
   151   }
   152   %}
   154   [implicit_jscontext, binaryname(ScriptableOpener)]
   155            attribute jsval                              opener;
   157   [noscript, binaryname(Opener)]
   158            attribute nsIDOMWindow                       openerWindow;
   160   /**
   161    * |frameElement| gets this window's <iframe> or <frame> element, if it has
   162    * one.
   163    *
   164    * When script reads this property (or when C++ calls
   165    * ScriptableFrameElement), we return |null| if the window is inside an
   166    * <iframe mozbrowser>.  In contrast, when C++ calls GetFrameElement, we
   167    * ignore the mozbrowser attribute.
   168    */
   169   [binaryname(ScriptableFrameElement)]
   170   readonly attribute nsIDOMElement                      frameElement;
   172   /**
   173    * You shouldn't need to read this property directly; call GetFrameElement
   174    * instead.
   175    */
   176   [noscript]
   177   readonly attribute nsIDOMElement                      realFrameElement;
   179   %{C++
   180   inline nsresult GetFrameElement(nsIDOMElement **aElement)
   181   {
   182     return GetRealFrameElement(aElement);
   183   }
   184   %}
   187   // the user agent
   188   readonly attribute nsIDOMNavigator                    navigator;
   190   /**
   191    * Get the application cache object for this window.
   192    */
   193   readonly attribute nsIDOMOfflineResourceList          applicationCache;
   196   // user prompts
   197   void                      alert([optional, Null(Stringify)] in DOMString text);
   198   boolean                   confirm([optional] in DOMString text);
   200   // prompt() should return a null string if cancel is pressed
   201   DOMString                 prompt([optional] in DOMString aMessage,
   202                                    [optional] in DOMString aInitial);
   204   void                      print();
   206   [optional_argc]
   207   nsIVariant                showModalDialog(in DOMString aURI,
   208                                             [optional] in nsIVariant aArgs,
   209                                             [optional] in DOMString aOptions);
   212   // cross-document messaging
   213   /**
   214    * Implements a safe message-passing system which can cross same-origin
   215    * boundaries.
   216    *
   217    * This method, when called, causes a MessageEvent to be asynchronously
   218    * dispatched at the primary document for the window upon which this method is
   219    * called.  (Note that the postMessage property on windows is allAccess and
   220    * thus is readable cross-origin.)  The dispatched event will have message as
   221    * its data, the calling context's window as its source, and an origin
   222    * determined by the calling context's main document URI.  The targetOrigin
   223    * argument specifies a URI and is used to restrict the message to be sent
   224    * only when the target window has the same origin as targetOrigin (since,
   225    * when the sender and the target have different origins, neither can read the
   226    * location of the other).
   227    * 
   228    * @see <http://www.whatwg.org/html/#dom-window-postmessage>
   229    */
   230   [implicit_jscontext, binaryname(PostMessageMoz)]
   231     void postMessage(in jsval message, in DOMString targetOrigin,
   232                      [optional] in jsval transfer);
   235   // WindowBase64
   236   // Ascii base64 data to binary data and vice versa...
   237   DOMString                 atob(in DOMString aAsciiString);
   238   DOMString                 btoa(in DOMString aBase64Data);
   241   // WindowSessionStorage
   242   /**
   243    * Session storage for the current browsing context.
   244    */
   245   readonly attribute nsIDOMStorage sessionStorage;
   248   // WindowLocalStorage
   249   /**
   250    * Local storage for the current browsing context.
   251    */
   252   readonly attribute nsIDOMStorage localStorage;
   255   // IndexedDB
   256   // https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#requests
   257   // IDBEnvironment
   258   readonly attribute nsISupports indexedDB;
   259   readonly attribute nsISupports mozIndexedDB;
   262   // DOM Range
   263   /**
   264    * Method for accessing this window's selection object.
   265    */
   266   nsISelection              getSelection();
   269   // CSSOM-View
   270   // http://dev.w3.org/csswg/cssom-view/#extensions-to-the-window-interface
   271   nsISupports      matchMedia(in DOMString media_query_list);
   273   readonly attribute nsIDOMScreen                       screen;
   275   // viewport
   276            attribute long                               innerWidth;
   277            attribute long                               innerHeight;
   280   // viewport scrolling
   281   /**
   282    * Accessor for the current x scroll position in this window in
   283    * pixels.
   284    *
   285    * This attribute is "replaceable" in JavaScript
   286    */
   287   readonly attribute long                               scrollX;
   289   /* The offset in pixels by which the window is scrolled */
   290   readonly attribute long                               pageXOffset;
   292   /**
   293    * Accessor for the current y scroll position in this window in
   294    * pixels.
   295    *
   296    * This attribute is "replaceable" in JavaScript
   297    */
   298   readonly attribute long                               scrollY;
   300   /* The offset in pixels by which the window is scrolled */
   301   readonly attribute long                               pageYOffset;
   303   void                      scroll(in long xScroll, in long yScroll);
   305   /**
   306    * Method for scrolling this window to an absolute pixel offset.
   307    */
   308   void                      scrollTo(in long xScroll, in long yScroll);
   310   /**
   311    * Method for scrolling this window to a pixel offset relative to
   312    * the current scroll position.
   313    */
   314   void                      scrollBy(in long xScrollDif, in long yScrollDif);
   317   // client
   318            attribute long                        screenX;
   319            attribute long                        screenY;
   320            attribute long                        outerWidth;
   321            attribute long                        outerHeight;
   324   // CSSOM
   325   /**
   326    * @see <http://dev.w3.org/csswg/cssom/#dom-window-getcomputedstyle>
   327    */
   328   nsIDOMCSSStyleDeclaration getComputedStyle(in nsIDOMElement elt, 
   329                                              [optional] in DOMString pseudoElt);
   330   nsIDOMCSSStyleDeclaration getDefaultComputedStyle(in nsIDOMElement elt,
   331                                                     [optional] in DOMString pseudoElt);
   334   // Mozilla extensions
   335   /**
   336    * Get the window root for this window. This is useful for hooking
   337    * up event listeners to this window and every other window nested
   338    * in the window root.
   339    */
   340   [noscript] readonly attribute nsIDOMEventTarget windowRoot;
   342   /**
   343    * Accessor for the child windows in this window.
   344    */
   345   [noscript] readonly attribute nsIDOMWindowCollection  frames;
   347   /**
   348    * Set/Get the document scale factor as a multiplier on the default
   349    * size. When setting this attribute, a NS_ERROR_NOT_IMPLEMENTED
   350    * error may be returned by implementations not supporting
   351    * zoom. Implementations not supporting zoom should return 1.0 all
   352    * the time for the Get operation. 1.0 is equals normal size,
   353    * i.e. no zoom.
   354    */
   355   [noscript] attribute float                            textZoom;
   357   /**
   358    * Method for scrolling this window by a number of lines.
   359    */
   360   void                      scrollByLines(in long numLines);
   362   /**
   363    * Method for scrolling this window by a number of pages.
   364    */
   365   void                      scrollByPages(in long numPages);
   367   /**
   368    * Method for sizing this window to the content in the window.
   369    */
   370   void                      sizeToContent();
   372   /* [replaceable] content */
   373   [noscript] readonly attribute nsIDOMWindow            content;
   375   /* [replaceable] prompter */
   376   [noscript] readonly attribute nsIPrompt               prompter;
   378   readonly attribute boolean                            closed;
   380   readonly attribute nsIDOMCrypto                       crypto;
   382   // Note: this is [ChromeOnly] scriptable via WebIDL.
   383   [noscript] readonly attribute nsIControllers          controllers;
   385   readonly attribute float                              mozInnerScreenX;
   386   readonly attribute float                              mozInnerScreenY;
   387   readonly attribute float                              devicePixelRatio;
   389   /* The maximum offset that the window can be scrolled to
   390      (i.e., the document width/height minus the scrollport width/height) */
   391   readonly attribute long                               scrollMaxX;
   392   readonly attribute long                               scrollMaxY;
   394            attribute boolean                            fullScreen;
   396   void                      back();
   397   void                      forward();
   398   void                      home();
   400   void                      moveTo(in long xPos, in long yPos);
   401   void                      moveBy(in long xDif, in long yDif);
   402   void                      resizeTo(in long width, in long height);
   403   void                      resizeBy(in long widthDif, in long heightDif);
   405   /**
   406    * Open a new window with this one as the parent.  This method will
   407    * NOT examine the JS stack for purposes of determining a caller.
   408    * This window will be used for security checks during the search by
   409    * name and the default character set on the newly opened window
   410    * will just be the default character set of this window.
   411    */
   412   [noscript] nsIDOMWindow   open(in DOMString url, in DOMString name,
   413                                  in DOMString options);
   415   /**
   416    * This method works like open except that aExtraArgument gets
   417    * converted into the array window.arguments in JS, if
   418    * aExtraArgument is a nsISupportsArray then the individual items in
   419    * the array are inserted into window.arguments, and primitive
   420    * nsISupports (nsISupportsPrimitives) types are converted to native
   421    * JS types when possible.
   422    */
   423   [noscript] nsIDOMWindow   openDialog(in DOMString url, in DOMString name,
   424                                        in DOMString options,
   425                                        in nsISupports aExtraArgument);
   427   // XXX Should this be in nsIDOMChromeWindow?
   428   void                      updateCommands(in DOMString action);
   430   /* Find in page.
   431    * @param str: the search pattern
   432    * @param caseSensitive: is the search caseSensitive
   433    * @param backwards: should we search backwards
   434    * @param wrapAround: should we wrap the search
   435    * @param wholeWord: should we search only for whole words
   436    * @param searchInFrames: should we search through all frames
   437    * @param showDialog: should we show the Find dialog
   438    */
   439   boolean                   find([optional] in DOMString str,
   440                                  [optional] in boolean caseSensitive,
   441                                  [optional] in boolean backwards,
   442                                  [optional] in boolean wrapAround,
   443                                  [optional] in boolean wholeWord,
   444                                  [optional] in boolean searchInFrames,
   445                                  [optional] in boolean showDialog);
   447   /**
   448    * Returns the number of times this document for this window has
   449    * been painted to the screen.
   450    */
   451   readonly attribute unsigned long long mozPaintCount;
   453   /**
   454    * Request a refresh of this browser window.
   455    *
   456    * @see <http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html>
   457    */
   458   // Argument is optional only so we can warn when it's null
   459   long
   460     mozRequestAnimationFrame([optional] in nsIFrameRequestCallback aCallback);
   461   // jsval because we want a WebIDL callback here
   462   [implicit_jscontext]
   463   long requestAnimationFrame(in jsval aCallback);
   465   /**
   466    * Cancel a refresh callback.
   467    */
   468   void mozCancelAnimationFrame(in long aHandle);
   469   // Backwards-compat shim for now to make Google maps work
   470   void mozCancelRequestAnimationFrame(in long aHandle);
   471   void cancelAnimationFrame(in long aHandle);
   473   /**
   474    * The current animation start time in milliseconds since the epoch.
   475    */
   476   readonly attribute long long mozAnimationStartTime;
   478   /**
   479    * HTML5 event attributes that only apply to windows and <body>/<frameset>
   480    */
   481   [implicit_jscontext] attribute jsval onafterprint;
   482   [implicit_jscontext] attribute jsval onbeforeprint;
   483   [implicit_jscontext] attribute jsval onbeforeunload;
   484   [implicit_jscontext] attribute jsval onhashchange;
   485   [implicit_jscontext] attribute jsval onmessage;
   486   [implicit_jscontext] attribute jsval onoffline;
   487   [implicit_jscontext] attribute jsval ononline;
   488   [implicit_jscontext] attribute jsval onpopstate;
   489   [implicit_jscontext] attribute jsval onpagehide;
   490   [implicit_jscontext] attribute jsval onpageshow;
   491   // Not supported yet
   492   // [implicit_jscontext] attribute jsval onredo;
   493   [implicit_jscontext] attribute jsval onresize;
   494   // Not supported yet
   495   // [implicit_jscontext] attribute jsval onstorage;
   496   // Not supported yet
   497   // [implicit_jscontext] attribute jsval onundo;
   498   [implicit_jscontext] attribute jsval onunload;
   500   /**
   501    * Non-HTML5 window-specific event attributes
   502    */
   503   [implicit_jscontext] attribute jsval ondevicemotion;
   504   [implicit_jscontext] attribute jsval ondeviceorientation;
   505   [implicit_jscontext] attribute jsval ondeviceproximity;
   506   [implicit_jscontext] attribute jsval onuserproximity;
   507   [implicit_jscontext] attribute jsval ondevicelight;
   509   [implicit_jscontext] attribute jsval onmouseenter;
   510   [implicit_jscontext] attribute jsval onmouseleave;
   512   /**
   513    * Console API
   514    */
   515   [implicit_jscontext] attribute jsval console;
   516 };
   518 [scriptable, uuid(2146c906-57f7-486c-a1b4-8cdb57ef577f)]
   519 interface nsIDOMWindowPerformance : nsISupports
   520 {
   521   /**
   522    * A namespace to hold performance related data and statistics.
   523    */
   524   readonly attribute nsISupports performance;
   525 };
   527 /**
   528  * Empty interface for compatibility with older versions.
   529  * @deprecated Use nsIDOMWindow instead
   530  */
   531 [scriptable, uuid(2ec49e81-b2ba-4633-991a-f48f1e1d8800)]
   532 interface nsIDOMWindowInternal : nsIDOMWindow {};

mercurial