Window.idl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #import <Crypto/Crypto.idl>
  2. #import <CSS/MediaQueryList.idl>
  3. #import <CSS/Screen.idl>
  4. #import <CSS/VisualViewport.idl>
  5. #import <DOM/Document.idl>
  6. #import <DOM/EventHandler.idl>
  7. #import <DOM/EventTarget.idl>
  8. #import <HighResolutionTime/Performance.idl>
  9. #import <HTML/AnimationFrameProvider.idl>
  10. #import <HTML/CustomElements/CustomElementRegistry.idl>
  11. #import <HTML/Navigation.idl>
  12. #import <HTML/Navigator.idl>
  13. #import <HTML/WindowLocalStorage.idl>
  14. #import <HTML/WindowOrWorkerGlobalScope.idl>
  15. #import <HTML/WindowSessionStorage.idl>
  16. #import <RequestIdleCallback/IdleRequest.idl>
  17. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
  18. [Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties]
  19. interface Window : EventTarget {
  20. // the current browsing context
  21. [LegacyUnforgeable] readonly attribute WindowProxy window;
  22. [Replaceable] readonly attribute WindowProxy self;
  23. [LegacyUnforgeable] readonly attribute Document document;
  24. attribute DOMString name;
  25. [PutForwards=href, LegacyUnforgeable] readonly attribute Location location;
  26. readonly attribute History history;
  27. readonly attribute Navigation navigation;
  28. readonly attribute CustomElementRegistry customElements;
  29. undefined focus();
  30. // other browsing contexts
  31. [Replaceable] readonly attribute WindowProxy frames;
  32. [Replaceable] readonly attribute unsigned long length;
  33. [LegacyUnforgeable] readonly attribute WindowProxy? top;
  34. [Replaceable] readonly attribute WindowProxy? parent;
  35. readonly attribute Element? frameElement;
  36. WindowProxy? open(optional USVString url = "", optional DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = "");
  37. // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic
  38. // object on the prototype chain. Indeed, this does not make the global object an exotic object.
  39. // Indexed access is taken care of by the WindowProxy exotic object.
  40. getter object (DOMString name);
  41. // the user agent
  42. readonly attribute Navigator navigator;
  43. [ImplementedAs=navigator] readonly attribute Navigator clientInformation; // legacy alias of .navigator
  44. // user prompts
  45. undefined alert();
  46. undefined alert(DOMString message);
  47. boolean confirm(optional DOMString message = "");
  48. DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
  49. undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
  50. undefined postMessage(any message, optional WindowPostMessageOptions options = {});
  51. // https://dom.spec.whatwg.org/#interface-window-extensions
  52. [Replaceable] readonly attribute (Event or undefined) event; // legacy
  53. // https://w3c.github.io/csswg-drafts/cssom/#extensions-to-the-window-interface
  54. [NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional CSSOMString? pseudoElt);
  55. // https://w3c.github.io/csswg-drafts/cssom-view/#extensions-to-the-window-interface
  56. [NewObject] MediaQueryList matchMedia(CSSOMString query);
  57. [SameObject, Replaceable] readonly attribute Screen screen;
  58. [SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;
  59. // viewport
  60. [Replaceable] readonly attribute long innerWidth;
  61. [Replaceable] readonly attribute long innerHeight;
  62. // viewport scrolling
  63. [Replaceable] readonly attribute double scrollX;
  64. [Replaceable, ImplementedAs=scroll_x] readonly attribute double pageXOffset;
  65. [Replaceable] readonly attribute double scrollY;
  66. [Replaceable, ImplementedAs=scroll_y] readonly attribute double pageYOffset;
  67. undefined scroll(optional ScrollToOptions options = {});
  68. undefined scroll(unrestricted double x, unrestricted double y);
  69. [ImplementedAs=scroll] undefined scrollTo(optional ScrollToOptions options = {});
  70. [ImplementedAs=scroll] undefined scrollTo(unrestricted double x, unrestricted double y);
  71. undefined scrollBy(optional ScrollToOptions options = {});
  72. undefined scrollBy(unrestricted double x, unrestricted double y);
  73. // client
  74. [Replaceable] readonly attribute long screenX;
  75. [Replaceable, ImplementedAs=screen_x] readonly attribute long screenLeft;
  76. [Replaceable] readonly attribute long screenY;
  77. [Replaceable, ImplementedAs=screen_y] readonly attribute long screenTop;
  78. [Replaceable] readonly attribute long outerWidth;
  79. [Replaceable] readonly attribute long outerHeight;
  80. [Replaceable] readonly attribute double devicePixelRatio;
  81. // https://w3c.github.io/requestidlecallback/#window_extensions
  82. unsigned long requestIdleCallback(IdleRequestCallback callback, optional IdleRequestOptions options = {});
  83. undefined cancelIdleCallback(unsigned long handle);
  84. // https://w3c.github.io/selection-api/#extensions-to-window-interface
  85. Selection? getSelection();
  86. // FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope
  87. // https://w3c.github.io/hr-time/#the-performance-attribute
  88. [Replaceable] readonly attribute Performance performance;
  89. // https://w3c.github.io/webcrypto/#crypto-interface
  90. [SameObject] readonly attribute Crypto crypto;
  91. };
  92. Window includes AnimationFrameProvider;
  93. Window includes GlobalEventHandlers;
  94. Window includes WindowEventHandlers;
  95. Window includes WindowLocalStorage;
  96. Window includes WindowSessionStorage;
  97. Window includes WindowOrWorkerGlobalScope;
  98. enum ScrollBehavior { "auto", "instant", "smooth" };
  99. dictionary ScrollOptions {
  100. ScrollBehavior behavior = "auto";
  101. };
  102. dictionary ScrollToOptions : ScrollOptions {
  103. unrestricted double left;
  104. unrestricted double top;
  105. };
  106. dictionary WindowPostMessageOptions : StructuredSerializeOptions {
  107. USVString targetOrigin = "/";
  108. };