Window.idl 5.9 KB

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