Window.idl 5.8 KB

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