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

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

mercurial