Window.idl 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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);
  50. // FIXME: undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
  51. // FIXME: undefined postMessage(any message, optional WindowPostMessageOptions options = {});
  52. // https://dom.spec.whatwg.org/#interface-window-extensions
  53. [Replaceable] readonly attribute (Event or undefined) event; // legacy
  54. // https://w3c.github.io/csswg-drafts/cssom/#extensions-to-the-window-interface
  55. [NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional CSSOMString? pseudoElt);
  56. // https://w3c.github.io/csswg-drafts/cssom-view/#extensions-to-the-window-interface
  57. [NewObject] MediaQueryList matchMedia(CSSOMString query);
  58. [SameObject, Replaceable] readonly attribute Screen screen;
  59. [SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;
  60. // viewport
  61. [Replaceable] readonly attribute long innerWidth;
  62. [Replaceable] readonly attribute long innerHeight;
  63. // viewport scrolling
  64. [Replaceable] readonly attribute double scrollX;
  65. [Replaceable, ImplementedAs=scroll_x] readonly attribute double pageXOffset;
  66. [Replaceable] readonly attribute double scrollY;
  67. [Replaceable, ImplementedAs=scroll_y] readonly attribute double pageYOffset;
  68. undefined scroll(optional ScrollToOptions options = {});
  69. undefined scroll(unrestricted double x, unrestricted double y);
  70. [ImplementedAs=scroll] undefined scrollTo(optional ScrollToOptions options = {});
  71. [ImplementedAs=scroll] undefined scrollTo(unrestricted double x, unrestricted double y);
  72. undefined scrollBy(optional ScrollToOptions options = {});
  73. undefined scrollBy(unrestricted double x, unrestricted double y);
  74. // client
  75. [Replaceable] readonly attribute long screenX;
  76. [Replaceable, ImplementedAs=screen_x] readonly attribute long screenLeft;
  77. [Replaceable] readonly attribute long screenY;
  78. [Replaceable, ImplementedAs=screen_y] readonly attribute long screenTop;
  79. [Replaceable] readonly attribute long outerWidth;
  80. [Replaceable] readonly attribute long outerHeight;
  81. [Replaceable] readonly attribute double devicePixelRatio;
  82. // https://w3c.github.io/requestidlecallback/#window_extensions
  83. unsigned long requestIdleCallback(IdleRequestCallback callback, optional IdleRequestOptions options = {});
  84. undefined cancelIdleCallback(unsigned long handle);
  85. // https://w3c.github.io/selection-api/#extensions-to-window-interface
  86. Selection? getSelection();
  87. // FIXME: Everything from here on should be shared through WindowOrWorkerGlobalScope
  88. // https://w3c.github.io/hr-time/#the-performance-attribute
  89. [Replaceable] readonly attribute Performance performance;
  90. // https://w3c.github.io/webcrypto/#crypto-interface
  91. [SameObject] readonly attribute Crypto crypto;
  92. };
  93. Window includes AnimationFrameProvider;
  94. Window includes GlobalEventHandlers;
  95. Window includes WindowEventHandlers;
  96. Window includes WindowLocalStorage;
  97. Window includes WindowSessionStorage;
  98. Window includes WindowOrWorkerGlobalScope;
  99. enum ScrollBehavior { "auto", "instant", "smooth" };
  100. dictionary ScrollOptions {
  101. ScrollBehavior behavior = "auto";
  102. };
  103. dictionary ScrollToOptions : ScrollOptions {
  104. unrestricted double left;
  105. unrestricted double top;
  106. };