1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/webidl/Window.webidl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,437 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + * 1.9 + * The origin of this IDL file is: 1.10 + * http://www.whatwg.org/specs/web-apps/current-work/ 1.11 + * https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html 1.12 + * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html 1.13 + * http://dev.w3.org/csswg/cssom/ 1.14 + * http://dev.w3.org/csswg/cssom-view/ 1.15 + * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html 1.16 + * https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html 1.17 + * https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html 1.18 + * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html 1.19 + */ 1.20 + 1.21 +interface ApplicationCache; 1.22 +interface IID; 1.23 +interface MozFrameRequestCallback; 1.24 +interface nsIBrowserDOMWindow; 1.25 +interface nsIMessageBroadcaster; 1.26 +interface nsIDOMCrypto; 1.27 +typedef any Transferable; 1.28 + 1.29 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.30 +[Global, NeedNewResolve] 1.31 +/*sealed*/ interface Window : EventTarget { 1.32 + // the current browsing context 1.33 + [Unforgeable, Throws, 1.34 + CrossOriginReadable] readonly attribute WindowProxy window; 1.35 + [Replaceable, Throws, 1.36 + CrossOriginReadable] readonly attribute WindowProxy self; 1.37 + [Unforgeable, StoreInSlot, Pure, Func="nsGlobalWindow::WindowOnWebIDL"] readonly attribute Document? document; 1.38 + [Throws] attribute DOMString name; 1.39 + [PutForwards=href, Unforgeable, Throws, 1.40 + CrossOriginReadable, CrossOriginWritable] readonly attribute Location? location; 1.41 + [Throws] readonly attribute History history; 1.42 + [Replaceable, Throws] readonly attribute BarProp locationbar; 1.43 + [Replaceable, Throws] readonly attribute BarProp menubar; 1.44 + [Replaceable, Throws] readonly attribute BarProp personalbar; 1.45 + [Replaceable, Throws] readonly attribute BarProp scrollbars; 1.46 + [Replaceable, Throws] readonly attribute BarProp statusbar; 1.47 + [Replaceable, Throws] readonly attribute BarProp toolbar; 1.48 + [Throws] attribute DOMString status; 1.49 + [Throws, CrossOriginCallable] void close(); 1.50 + [Throws, CrossOriginReadable] readonly attribute boolean closed; 1.51 + [Throws] void stop(); 1.52 + [Throws, CrossOriginCallable] void focus(); 1.53 + [Throws, CrossOriginCallable] void blur(); 1.54 + 1.55 + // other browsing contexts 1.56 + [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy frames; 1.57 + [Replaceable, CrossOriginReadable] readonly attribute unsigned long length; 1.58 + [Unforgeable, Throws, CrossOriginReadable] readonly attribute WindowProxy top; 1.59 + [Throws, CrossOriginReadable] attribute any opener; 1.60 + //[Throws] readonly attribute WindowProxy parent; 1.61 + [Replaceable, Throws, CrossOriginReadable] readonly attribute WindowProxy? parent; 1.62 + [Throws] readonly attribute Element? frameElement; 1.63 + //[Throws] WindowProxy open(optional DOMString url = "about:blank", optional DOMString target = "_blank", [TreatNullAs=EmptyString] optional DOMString features = "", optional boolean replace = false); 1.64 + [Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = ""); 1.65 + // We think the indexed getter is a bug in the spec, it actually needs to live 1.66 + // on the WindowProxy 1.67 + //getter WindowProxy (unsigned long index); 1.68 + //getter object (DOMString name); 1.69 + 1.70 + // the user agent 1.71 + [Throws] readonly attribute Navigator navigator; 1.72 +#ifdef HAVE_SIDEBAR 1.73 + [Replaceable, Throws] readonly attribute External external; 1.74 +#endif 1.75 + [Throws] readonly attribute ApplicationCache applicationCache; 1.76 + 1.77 + // user prompts 1.78 + [Throws] void alert(optional DOMString message = ""); 1.79 + [Throws] boolean confirm(optional DOMString message = ""); 1.80 + [Throws] DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); 1.81 + [Throws] void print(); 1.82 + //[Throws] any showModalDialog(DOMString url, optional any argument); 1.83 + [Throws] any showModalDialog(DOMString url, optional any argument, optional DOMString options = ""); 1.84 + 1.85 + [Throws, CrossOriginCallable] void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer); 1.86 + 1.87 + // also has obsolete members 1.88 +}; 1.89 +Window implements GlobalEventHandlers; 1.90 +Window implements WindowEventHandlers; 1.91 + 1.92 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.93 +[NoInterfaceObject] 1.94 +interface WindowTimers { 1.95 + [Throws] long setTimeout(Function handler, optional long timeout = 0, any... arguments); 1.96 + [Throws] long setTimeout(DOMString handler, optional long timeout = 0, any... unused); 1.97 + [Throws] void clearTimeout(optional long handle = 0); 1.98 + [Throws] long setInterval(Function handler, optional long timeout, any... arguments); 1.99 + [Throws] long setInterval(DOMString handler, optional long timeout, any... unused); 1.100 + [Throws] void clearInterval(optional long handle = 0); 1.101 +}; 1.102 +Window implements WindowTimers; 1.103 + 1.104 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.105 +[NoInterfaceObject] 1.106 +interface WindowBase64 { 1.107 + [Throws] DOMString btoa(DOMString btoa); 1.108 + [Throws] DOMString atob(DOMString atob); 1.109 +}; 1.110 +Window implements WindowBase64; 1.111 + 1.112 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.113 +[NoInterfaceObject] 1.114 +interface WindowSessionStorage { 1.115 + //[Throws] readonly attribute Storage sessionStorage; 1.116 + [Throws] readonly attribute Storage? sessionStorage; 1.117 +}; 1.118 +Window implements WindowSessionStorage; 1.119 + 1.120 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.121 +[NoInterfaceObject] 1.122 +interface WindowLocalStorage { 1.123 + [Throws] readonly attribute Storage? localStorage; 1.124 +}; 1.125 +Window implements WindowLocalStorage; 1.126 + 1.127 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.128 +partial interface Window { 1.129 + void captureEvents(); 1.130 + void releaseEvents(); 1.131 +}; 1.132 + 1.133 +// https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html 1.134 +partial interface Window { 1.135 + //[Throws] Selection getSelection(); 1.136 + [Throws] Selection? getSelection(); 1.137 +}; 1.138 + 1.139 +// https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html 1.140 +Window implements IDBEnvironment; 1.141 + 1.142 +// http://dev.w3.org/csswg/cssom/ 1.143 +partial interface Window { 1.144 + //[NewObject, Throws] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt = ""); 1.145 + [NewObject, Throws] CSSStyleDeclaration? getComputedStyle(Element elt, optional DOMString pseudoElt = ""); 1.146 +}; 1.147 + 1.148 +// http://dev.w3.org/csswg/cssom-view/ 1.149 +enum ScrollBehavior { "auto", "instant", "smooth" }; 1.150 + 1.151 +dictionary ScrollOptions { 1.152 + ScrollBehavior behavior = "auto"; 1.153 +}; 1.154 + 1.155 +partial interface Window { 1.156 + //[Throws,NewObject] MediaQueryList matchMedia(DOMString query); 1.157 + [Throws,NewObject] MediaQueryList? matchMedia(DOMString query); 1.158 + //[SameObject] 1.159 + [Throws] readonly attribute Screen screen; 1.160 + 1.161 + // browsing context 1.162 + //[Throws] void moveTo(double x, double y); 1.163 + //[Throws] void moveBy(double x, double y); 1.164 + //[Throws] void resizeTo(double x, double y); 1.165 + //[Throws] void resizeBy(double x, double y); 1.166 + [Throws] void moveTo(long x, long y); 1.167 + [Throws] void moveBy(long x, long y); 1.168 + [Throws] void resizeTo(long x, long y); 1.169 + [Throws] void resizeBy(long x, long y); 1.170 + 1.171 + // viewport 1.172 + //[Throws] readonly attribute double innerWidth; 1.173 + //[Throws] readonly attribute double innerHeight; 1.174 + [Throws] attribute long innerWidth; 1.175 + [Throws] attribute long innerHeight; 1.176 + 1.177 + // viewport scrolling 1.178 + //[Throws] readonly attribute double scrollX; 1.179 + //[Throws] readonly attribute double pageXOffset; 1.180 + //[Throws] readonly attribute double scrollY; 1.181 + //[Throws] readonly attribute double pageYOffset; 1.182 + //void scroll(double x, double y, optional ScrollOptions options); 1.183 + //void scrollTo(double x, double y, optional ScrollOptions options); 1.184 + //void scrollBy(double x, double y, optional ScrollOptions options); 1.185 + [Replaceable, Throws] readonly attribute long scrollX; 1.186 + [Throws] readonly attribute long pageXOffset; 1.187 + [Replaceable, Throws] readonly attribute long scrollY; 1.188 + [Throws] readonly attribute long pageYOffset; 1.189 + void scroll(long x, long y); 1.190 + void scrollTo(long x, long y); 1.191 + void scrollBy(long x, long y); 1.192 + 1.193 + // client 1.194 + //[Throws] readonly attribute double screenX; 1.195 + //[Throws] readonly attribute double screenY; 1.196 + //[Throws] readonly attribute double outerWidth; 1.197 + //[Throws] readonly attribute double outerHeight; 1.198 + [Throws] attribute long screenX; 1.199 + [Throws] attribute long screenY; 1.200 + [Throws] attribute long outerWidth; 1.201 + [Throws] attribute long outerHeight; 1.202 +}; 1.203 + 1.204 +// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html 1.205 +partial interface Window { 1.206 + [Throws] long requestAnimationFrame(FrameRequestCallback callback); 1.207 + [Throws] void cancelAnimationFrame(long handle); 1.208 +}; 1.209 +callback FrameRequestCallback = void (DOMHighResTimeStamp time); 1.210 + 1.211 +// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html 1.212 +partial interface Window { 1.213 + [Replaceable, Throws] readonly attribute Performance? performance; 1.214 +}; 1.215 + 1.216 +// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html 1.217 +partial interface Window { 1.218 + //[Throws] readonly attribute Crypto crypto; 1.219 + [Throws] readonly attribute nsIDOMCrypto crypto; 1.220 +}; 1.221 + 1.222 +#ifdef MOZ_WEBSPEECH 1.223 +// http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html 1.224 +[NoInterfaceObject] 1.225 +interface SpeechSynthesisGetter { 1.226 + [Throws, Pref="media.webspeech.synth.enabled"] readonly attribute SpeechSynthesis speechSynthesis; 1.227 +}; 1.228 + 1.229 +Window implements SpeechSynthesisGetter; 1.230 +#endif 1.231 + 1.232 +// http://www.whatwg.org/specs/web-apps/current-work/ 1.233 +[NoInterfaceObject] 1.234 +interface WindowModal { 1.235 + [Throws, Func="nsGlobalWindow::IsModalContentWindow"] readonly attribute any dialogArguments; 1.236 + [Throws, Func="nsGlobalWindow::IsModalContentWindow"] attribute any returnValue; 1.237 +}; 1.238 +Window implements WindowModal; 1.239 + 1.240 +// Mozilla-specific stuff 1.241 +partial interface Window { 1.242 + //[NewObject, Throws] CSSStyleDeclaration getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = ""); 1.243 + [NewObject, Throws] CSSStyleDeclaration? getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = ""); 1.244 + 1.245 + [Throws] long mozRequestAnimationFrame(MozFrameRequestCallback aCallback); 1.246 + 1.247 + /** 1.248 + * Cancel a refresh callback. 1.249 + */ 1.250 + [Throws] void mozCancelAnimationFrame(long aHandle); 1.251 + // Backwards-compat shim for now to make Google maps work 1.252 + [Throws] void mozCancelRequestAnimationFrame(long aHandle); 1.253 + 1.254 + /** 1.255 + * The current animation start time in milliseconds since the epoch. 1.256 + */ 1.257 + [Throws] readonly attribute long long mozAnimationStartTime; 1.258 + 1.259 + // Mozilla extensions 1.260 + /** 1.261 + * Method for scrolling this window by a number of lines. 1.262 + */ 1.263 + void scrollByLines(long numLines); 1.264 + 1.265 + /** 1.266 + * Method for scrolling this window by a number of pages. 1.267 + */ 1.268 + void scrollByPages(long numPages); 1.269 + 1.270 + /** 1.271 + * Method for sizing this window to the content in the window. 1.272 + */ 1.273 + [Throws] void sizeToContent(); 1.274 + 1.275 + // XXX Shouldn't this be in nsIDOMChromeWindow? 1.276 + [ChromeOnly, Replaceable, Throws] readonly attribute MozControllers controllers; 1.277 + 1.278 + [Throws] readonly attribute float mozInnerScreenX; 1.279 + [Throws] readonly attribute float mozInnerScreenY; 1.280 + [Throws] readonly attribute float devicePixelRatio; 1.281 + 1.282 + /* The maximum offset that the window can be scrolled to 1.283 + (i.e., the document width/height minus the scrollport width/height) */ 1.284 + [Replaceable, Throws] readonly attribute long scrollMaxX; 1.285 + [Replaceable, Throws] readonly attribute long scrollMaxY; 1.286 + 1.287 + [Throws] attribute boolean fullScreen; 1.288 + 1.289 + [Throws, ChromeOnly] void back(); 1.290 + [Throws, ChromeOnly] void forward(); 1.291 + [Throws, ChromeOnly] void home(); 1.292 + 1.293 + // XXX Should this be in nsIDOMChromeWindow? 1.294 + void updateCommands(DOMString action); 1.295 + 1.296 + /* Find in page. 1.297 + * @param str: the search pattern 1.298 + * @param caseSensitive: is the search caseSensitive 1.299 + * @param backwards: should we search backwards 1.300 + * @param wrapAround: should we wrap the search 1.301 + * @param wholeWord: should we search only for whole words 1.302 + * @param searchInFrames: should we search through all frames 1.303 + * @param showDialog: should we show the Find dialog 1.304 + */ 1.305 + [Throws] boolean find(optional DOMString str = "", 1.306 + optional boolean caseSensitive = false, 1.307 + optional boolean backwards = false, 1.308 + optional boolean wrapAround = false, 1.309 + optional boolean wholeWord = false, 1.310 + optional boolean searchInFrames = false, 1.311 + optional boolean showDialog = false); 1.312 + 1.313 + /** 1.314 + * Returns the number of times this document for this window has 1.315 + * been painted to the screen. 1.316 + */ 1.317 + [Throws] readonly attribute unsigned long long mozPaintCount; 1.318 + 1.319 + [Pure] 1.320 + attribute EventHandler onwheel; 1.321 + 1.322 + attribute EventHandler ondevicemotion; 1.323 + attribute EventHandler ondeviceorientation; 1.324 + attribute EventHandler ondeviceproximity; 1.325 + attribute EventHandler onuserproximity; 1.326 + attribute EventHandler ondevicelight; 1.327 + 1.328 +#ifdef MOZ_B2G 1.329 + attribute EventHandler onmoztimechange; 1.330 + attribute EventHandler onmoznetworkupload; 1.331 + attribute EventHandler onmoznetworkdownload; 1.332 +#endif 1.333 + 1.334 + void dump(DOMString str); 1.335 + 1.336 + /** 1.337 + * This method is here for backwards compatibility with 4.x only, 1.338 + * its implementation is a no-op 1.339 + */ 1.340 + void setResizable(boolean resizable); 1.341 + 1.342 + /** 1.343 + * This is the scriptable version of 1.344 + * nsIDOMWindow::openDialog() that takes 3 optional 1.345 + * arguments, plus any additional arguments are passed on as 1.346 + * arguments on the dialog's window object (window.arguments). 1.347 + */ 1.348 + [Throws, ChromeOnly] WindowProxy? openDialog(optional DOMString url = "", 1.349 + optional DOMString name = "", 1.350 + optional DOMString options = "", 1.351 + any... extraArguments); 1.352 + 1.353 + [Replaceable, Throws] readonly attribute object? content; 1.354 + 1.355 + [ChromeOnly, Throws] readonly attribute object? __content; 1.356 + 1.357 + [Throws, ChromeOnly] any getInterface(IID iid); 1.358 +}; 1.359 + 1.360 +Window implements TouchEventHandlers; 1.361 + 1.362 +Window implements OnErrorEventHandlerForWindow; 1.363 + 1.364 +// ConsoleAPI 1.365 +partial interface Window { 1.366 + [Replaceable, GetterThrows] 1.367 + readonly attribute Console console; 1.368 +}; 1.369 + 1.370 +#ifdef HAVE_SIDEBAR 1.371 +// Mozilla extension 1.372 +partial interface Window { 1.373 + [Replaceable, Throws] 1.374 + readonly attribute (External or WindowProxy) sidebar; 1.375 +}; 1.376 +#endif 1.377 + 1.378 +[Func="IsChromeOrXBL"] 1.379 +interface ChromeWindow { 1.380 + [Func="nsGlobalWindow::IsChromeWindow"] 1.381 + const unsigned short STATE_MAXIMIZED = 1; 1.382 + [Func="nsGlobalWindow::IsChromeWindow"] 1.383 + const unsigned short STATE_MINIMIZED = 2; 1.384 + [Func="nsGlobalWindow::IsChromeWindow"] 1.385 + const unsigned short STATE_NORMAL = 3; 1.386 + [Func="nsGlobalWindow::IsChromeWindow"] 1.387 + const unsigned short STATE_FULLSCREEN = 4; 1.388 + 1.389 + [Func="nsGlobalWindow::IsChromeWindow"] 1.390 + readonly attribute unsigned short windowState; 1.391 + 1.392 + /** 1.393 + * browserDOMWindow provides access to yet another layer of 1.394 + * utility functions implemented by chrome script. It will be null 1.395 + * for DOMWindows not corresponding to browsers. 1.396 + */ 1.397 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.398 + attribute nsIBrowserDOMWindow? browserDOMWindow; 1.399 + 1.400 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.401 + void getAttention(); 1.402 + 1.403 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.404 + void getAttentionWithCycleCount(long aCycleCount); 1.405 + 1.406 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.407 + void setCursor(DOMString cursor); 1.408 + 1.409 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.410 + void maximize(); 1.411 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.412 + void minimize(); 1.413 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.414 + void restore(); 1.415 + 1.416 + /** 1.417 + * Notify a default button is loaded on a dialog or a wizard. 1.418 + * defaultButton is the default button. 1.419 + */ 1.420 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.421 + void notifyDefaultButtonLoaded(Element defaultButton); 1.422 + 1.423 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.424 + readonly attribute nsIMessageBroadcaster messageManager; 1.425 + 1.426 + /** 1.427 + * On some operating systems, we must allow the window manager to 1.428 + * handle window dragging. This function tells the window manager to 1.429 + * start dragging the window. This function will fail unless called 1.430 + * while the left mouse button is held down, callers must check this. 1.431 + * 1.432 + * The optional panel argument should be set when moving a panel. 1.433 + * 1.434 + * Throws NS_ERROR_NOT_IMPLEMENTED if the OS doesn't support this. 1.435 + */ 1.436 + [Throws, Func="nsGlobalWindow::IsChromeWindow"] 1.437 + void beginWindowMove(Event mouseDownEvent, optional Element? panel = null); 1.438 +}; 1.439 + 1.440 +Window implements ChromeWindow;