Window.idl 5.8 KB

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