| /* |
| * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| * Copyright (C) 2011 Google Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| * are met: |
| * 1. Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. |
| * |
| * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| // https://html.spec.whatwg.org/C/#the-window-object |
| |
| // FIXME: explain all uses of [CrossOrigin] |
| [ |
| CheckSecurity=Receiver, |
| ImplementedAs=DOMWindow, |
| Global=Window, |
| Exposed=Window |
| ] interface Window : EventTarget { |
| // the current browsing context |
| // FIXME: The spec uses the WindowProxy type for this and many other attributes. |
| [Affects=Nothing, Unforgeable, CrossOrigin] readonly attribute Window window; |
| [Replaceable, CrossOrigin] readonly attribute Window self; |
| [Affects=Nothing, Unforgeable, CachedAccessor] readonly attribute Document document; |
| attribute DOMString name; |
| [Affects=Nothing, PutForwards=href, Unforgeable, CrossOrigin=(Getter,Setter), Custom=Getter] readonly attribute Location location; |
| [CallWith=ScriptState] readonly attribute CustomElementRegistry customElements; |
| [Affects=Nothing] readonly attribute History history; |
| [Replaceable, MeasureAs=BarPropLocationbar] readonly attribute BarProp locationbar; |
| [Replaceable, MeasureAs=BarPropMenubar] readonly attribute BarProp menubar; |
| [Replaceable, MeasureAs=BarPropPersonalbar] readonly attribute BarProp personalbar; |
| [Replaceable, MeasureAs=BarPropScrollbars] readonly attribute BarProp scrollbars; |
| [Replaceable, MeasureAs=BarPropStatusbar] readonly attribute BarProp statusbar; |
| [Replaceable, MeasureAs=BarPropToolbar] readonly attribute BarProp toolbar; |
| attribute DOMString status; |
| [CrossOrigin, CallWith=Isolate] void close(); |
| [CrossOrigin] readonly attribute boolean closed; |
| void stop(); |
| [CrossOrigin, CallWith=Isolate] void focus(); |
| [CrossOrigin] void blur(); |
| |
| // other browsing contexts |
| [Replaceable, CrossOrigin] readonly attribute Window frames; |
| [Replaceable, CrossOrigin] readonly attribute unsigned long length; |
| [Unforgeable, CrossOrigin] readonly attribute Window? top; |
| // FIXME: opener should be of type any. |
| [CrossOrigin, Custom=Setter] attribute Window opener; |
| [Replaceable, CrossOrigin] readonly attribute Window? parent; |
| [CheckSecurity=ReturnValue, Custom=Getter] readonly attribute Element? frameElement; |
| [CallWith=Isolate, RaisesException] Window? open(optional URLString url="", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = ""); |
| |
| // indexed properties |
| // https://html.spec.whatwg.org/C/browsers.html#windowproxy-getownproperty |
| [NotEnumerable, CrossOrigin] getter Window (unsigned long index); |
| |
| // named properties |
| [Custom, NotEnumerable, CrossOrigin] getter object (DOMString name); |
| |
| // the user agent |
| [Affects=Nothing, LogActivity=GetterOnly] readonly attribute Navigator navigator; |
| [LogActivity=GetterOnly, SecureContext=RestrictAppCacheToSecureContexts] readonly attribute ApplicationCache applicationCache; |
| |
| // user prompts |
| [Measure, CallWith=ScriptState] void alert(); |
| [Measure, CallWith=ScriptState] void alert(DOMString message); |
| [Measure, CallWith=ScriptState] boolean confirm(optional DOMString message = ""); |
| [Measure, CallWith=ScriptState] DOMString? prompt(optional DOMString message = "", optional DOMString defaultValue = ""); |
| [Measure, CallWith=ScriptState] void print(); |
| |
| [CrossOrigin, CallWith=Isolate, RaisesException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []); |
| |
| [CrossOrigin, CallWith=Isolate, RaisesException] void postMessage(any message, optional WindowPostMessageOptions options); |
| |
| // WindowOrWorkerGlobalScope mixin |
| // https://html.spec.whatwg.org/C/#windoworworkerglobalscope-mixin |
| [Replaceable] readonly attribute DOMString origin; |
| void queueMicrotask(VoidFunction callback); |
| |
| // AnimationFrameProvider mixin |
| // https://html.spec.whatwg.org/C/#animation-frames |
| [MeasureAs=UnprefixedRequestAnimationFrame] long requestAnimationFrame(FrameRequestCallback callback); |
| void cancelAnimationFrame(long handle); |
| [RuntimeEnabled=PostAnimationFrame] long requestPostAnimationFrame(FrameRequestCallback callback); |
| [RuntimeEnabled=PostAnimationFrame] void cancelPostAnimationFrame(long handle); |
| |
| // HTML obsolete features |
| // https://html.spec.whatwg.org/C/#Window-partial |
| [MeasureAs=WindowCaptureEvents] void captureEvents(); |
| [MeasureAs=WindowReleaseEvents] void releaseEvents(); |
| |
| [Replaceable, SameObject] readonly attribute External external; |
| |
| // Cooperative Scheduling of Background Tasks |
| // https://www.w3.org/TR/requestidlecallback/#window_extensions |
| [Measure] long requestIdleCallback(IdleRequestCallback callback, optional IdleRequestOptions options); |
| void cancelIdleCallback(long handle); |
| |
| // CSS Object Model (CSSOM) |
| // https://drafts.csswg.org/cssom/#extensions-to-the-window-interface |
| [Affects=Nothing, NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString? pseudoElt); |
| |
| // CSSOM View Module |
| // https://drafts.csswg.org/cssom-view/#extensions-to-the-window-interface |
| [HighEntropy, Measure, NewObject] MediaQueryList matchMedia(DOMString query); |
| [SameObject, Replaceable] readonly attribute Screen screen; |
| |
| [RuntimeEnabled=ScriptedTaskQueue, SameObject, Replaceable] readonly attribute ScriptedTaskQueueController TaskQueue; |
| |
| // browsing context |
| void moveTo(long x, long y); |
| void moveBy(long x, long y); |
| void resizeTo(long x, long y); |
| void resizeBy(long x, long y); |
| |
| // viewport |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowInnerWidth, Replaceable] readonly attribute long innerWidth; |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowInnerHeight, Replaceable] readonly attribute long innerHeight; |
| |
| // viewport scrolling |
| [HighEntropy, MeasureAs=WindowScrollX, Replaceable] readonly attribute double scrollX; |
| [HighEntropy, MeasureAs=WindowPageXOffset, Replaceable] readonly attribute double pageXOffset; |
| [HighEntropy, MeasureAs=WindowScrollY, Replaceable] readonly attribute double scrollY; |
| [HighEntropy, MeasureAs=WindowPageYOffset, Replaceable] readonly attribute double pageYOffset; |
| void scroll(optional ScrollToOptions options); |
| void scroll(unrestricted double x, unrestricted double y); |
| void scrollTo(optional ScrollToOptions options); |
| void scrollTo(unrestricted double x, unrestricted double y); |
| void scrollBy(optional ScrollToOptions options); |
| void scrollBy(unrestricted double x, unrestricted double y); |
| |
| // Visual Viewport API |
| // https://github.com/WICG/ViewportAPI |
| [Replaceable, SameObject] readonly attribute VisualViewport visualViewport; |
| |
| // client |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowScreenX, Replaceable] readonly attribute long screenX; |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowScreenY, Replaceable] readonly attribute long screenY; |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowOuterWidth, Replaceable] readonly attribute long outerWidth; |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowOuterHeight, Replaceable] readonly attribute long outerHeight; |
| [Affects=Nothing, HighEntropy, MeasureAs=WindowDevicePixelRatio, Replaceable] readonly attribute double devicePixelRatio; |
| |
| // Selection API |
| // https://w3c.github.io/selection-api/#extensions-to-window-interface |
| [Affects=Nothing] Selection? getSelection(); |
| |
| // Console API |
| // https://console.spec.whatwg.org/#console-interface |
| // [Replaceable] readonly attribute Console console; |
| // Console is installed by v8 inspector when context is created |
| // and is left commented here just for documentation. |
| |
| // Compatibility |
| // https://compat.spec.whatwg.org/#windoworientation-interface |
| [RuntimeEnabled=OrientationEvent] attribute EventHandler onorientationchange; |
| // This is the interface orientation in degrees. Some examples are: |
| // 0 is straight up; -90 is when the device is rotated 90 clockwise; |
| // 90 is when rotated counter clockwise. |
| [HighEntropy, MeasureAs=WindowOrientation, RuntimeEnabled=OrientationEvent] readonly attribute long orientation; |
| |
| // Accessibility Object Model |
| // https://github.com/WICG/aom/blob/HEAD/explainer.md |
| [RuntimeEnabled=AccessibilityObjectModel, CallWith=ScriptState] Promise<ComputedAccessibleNode> getComputedAccessibleNode(Element element); |
| |
| // TODO(yhirano): Move this to url.idl when LegacyWindowAlias is supported. |
| attribute URLConstructor webkitURL; |
| |
| // Non-standard APIs |
| [MeasureAs=WindowClientInformation, Replaceable] readonly attribute Navigator clientInformation; |
| [Replaceable, MeasureAs=WindowEvent, Custom=Getter, NotEnumerable] readonly attribute Event event; |
| [MeasureAs=WindowFind] boolean find([DefaultValue=Undefined] optional DOMString string, |
| [DefaultValue=Undefined] optional boolean caseSensitive, |
| [DefaultValue=Undefined] optional boolean backwards, |
| [DefaultValue=Undefined] optional boolean wrap, |
| [DefaultValue=Undefined] optional boolean wholeWord, |
| [DefaultValue=Undefined] optional boolean searchInFrames, |
| [DefaultValue=Undefined] optional boolean showDialog); |
| [MeasureAs=WindowOffscreenBuffering, Replaceable, NotEnumerable] readonly attribute boolean offscreenBuffering; |
| [HighEntropy, MeasureAs=WindowScreenLeft, Replaceable] readonly attribute long screenLeft; |
| [HighEntropy, MeasureAs=WindowScreenTop, Replaceable] readonly attribute long screenTop; |
| [MeasureAs=WindowDefaultStatus] attribute DOMString defaultStatus; |
| [MeasureAs=WindowDefaultstatus, ImplementedAs=defaultStatus] attribute DOMString defaultstatus; |
| [MeasureAs=StyleMedia] readonly attribute StyleMedia styleMedia; |
| [DeprecateAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(FrameRequestCallback callback); |
| [DeprecateAs=PrefixedCancelAnimationFrame, ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id); |
| [MeasureAs=PrefixedMutationObserverConstructor] attribute MutationObserverConstructor WebKitMutationObserver; |
| |
| // Event handler attributes |
| attribute EventHandler onanimationend; |
| attribute EventHandler onanimationiteration; |
| attribute EventHandler onanimationstart; |
| attribute EventHandler onsearch; |
| attribute EventHandler ontransitionend; |
| attribute EventHandler onwebkitanimationend; |
| attribute EventHandler onwebkitanimationiteration; |
| attribute EventHandler onwebkitanimationstart; |
| attribute EventHandler onwebkittransitionend; |
| |
| // https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object |
| readonly attribute boolean isSecureContext; |
| |
| attribute DOMMatrixConstructor WebKitCSSMatrix; |
| |
| // TrustedTypes API: http://github.com/wicg/trusted-types |
| [RuntimeEnabled=TrustedDOMTypes, Unforgeable] readonly attribute TrustedTypePolicyFactory TrustedTypes; |
| }; |
| |
| Window includes GlobalEventHandlers; |
| Window includes WindowEventHandlers; |
| Window includes WindowOrWorkerGlobalScope; |