Window.idl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/WindowLocalStorage.idl>
  13. #import <HTML/WindowOrWorkerGlobalScope.idl>
  14. #import <HTML/WindowSessionStorage.idl>
  15. #import <RequestIdleCallback/IdleRequest.idl>
  16. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
  17. [Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties]
  18. interface Window : EventTarget {
  19. // the current browsing context
  20. [LegacyUnforgeable] readonly attribute WindowProxy window;
  21. [Replaceable] readonly attribute WindowProxy self;
  22. [LegacyUnforgeable] readonly attribute Document document;
  23. attribute DOMString name;
  24. attribute DOMString status;
  25. undefined close();
  26. readonly attribute boolean closed;
  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. undefined blur();
  33. // other browsing contexts
  34. [Replaceable] readonly attribute WindowProxy frames;
  35. [Replaceable] readonly attribute unsigned long length;
  36. [LegacyUnforgeable] readonly attribute WindowProxy? top;
  37. attribute any opener;
  38. [Replaceable] readonly attribute WindowProxy? parent;
  39. readonly attribute Element? frameElement;
  40. WindowProxy? open(optional USVString url = "", optional DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = "");
  41. // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic
  42. // object on the prototype chain. Indeed, this does not make the global object an exotic object.
  43. // Indexed access is taken care of by the WindowProxy exotic object.
  44. getter object (DOMString name);
  45. // the user agent
  46. readonly attribute Navigator navigator;
  47. [ImplementedAs=navigator] readonly attribute Navigator clientInformation; // legacy alias of .navigator
  48. // user prompts
  49. undefined alert();
  50. undefined alert(DOMString message);
  51. boolean confirm(optional DOMString message = "");
  52. DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
  53. undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
  54. undefined postMessage(any message, optional WindowPostMessageOptions options = {});
  55. // https://dom.spec.whatwg.org/#interface-window-extensions
  56. [Replaceable] readonly attribute (Event or undefined) event; // legacy
  57. // https://w3c.github.io/csswg-drafts/cssom/#extensions-to-the-window-interface
  58. [NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional CSSOMString? pseudoElt);
  59. // https://w3c.github.io/csswg-drafts/cssom-view/#extensions-to-the-window-interface
  60. [NewObject] MediaQueryList matchMedia(CSSOMString query);
  61. [SameObject, Replaceable] readonly attribute Screen screen;
  62. [SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;
  63. undefined moveTo(long x, long y);
  64. undefined moveBy(long x, long y);
  65. undefined resizeTo(long x, long y);
  66. undefined resizeBy(long x, long y);
  67. // viewport
  68. [Replaceable] readonly attribute long innerWidth;
  69. [Replaceable] readonly attribute long innerHeight;
  70. // viewport scrolling
  71. [Replaceable] readonly attribute double scrollX;
  72. [Replaceable, ImplementedAs=scroll_x] readonly attribute double pageXOffset;
  73. [Replaceable] readonly attribute double scrollY;
  74. [Replaceable, ImplementedAs=scroll_y] readonly attribute double pageYOffset;
  75. undefined scroll(optional ScrollToOptions options = {});
  76. undefined scroll(unrestricted double x, unrestricted double y);
  77. [ImplementedAs=scroll] undefined scrollTo(optional ScrollToOptions options = {});
  78. [ImplementedAs=scroll] undefined scrollTo(unrestricted double x, unrestricted double y);
  79. undefined scrollBy(optional ScrollToOptions options = {});
  80. undefined scrollBy(unrestricted double x, unrestricted double y);
  81. // client
  82. [Replaceable] readonly attribute long screenX;
  83. [Replaceable, ImplementedAs=screen_x] readonly attribute long screenLeft;
  84. [Replaceable] readonly attribute long screenY;
  85. [Replaceable, ImplementedAs=screen_y] readonly attribute long screenTop;
  86. [Replaceable] readonly attribute long outerWidth;
  87. [Replaceable] readonly attribute long outerHeight;
  88. [Replaceable] readonly attribute double devicePixelRatio;
  89. // https://w3c.github.io/requestidlecallback/#window_extensions
  90. unsigned long requestIdleCallback(IdleRequestCallback callback, optional IdleRequestOptions options = {});
  91. undefined cancelIdleCallback(unsigned long handle);
  92. // https://w3c.github.io/selection-api/#extensions-to-window-interface
  93. Selection? getSelection();
  94. undefined captureEvents();
  95. undefined releaseEvents();
  96. // This function is non-standard.
  97. boolean find(optional DOMString string = "");
  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. };