diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c2ef677d7..c12cdcf4224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,9 @@ * Annotated methods in WebCodecs that throw. [#3970](https://github.com/rustwasm/wasm-bindgen/pull/3970) +* Update and stabilize the Clipboard API. + [#3992](https://github.com/rustwasm/wasm-bindgen/pull/3992) + ### Fixed * Copy port from headless test server when using `WASM_BINDGEN_TEST_ADDRESS`. diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index edb9ff187f0..59db9b49587 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -194,6 +194,7 @@ ClipboardEventInit = [] ClipboardItem = [] ClipboardItemOptions = [] ClipboardPermissionDescriptor = [] +ClipboardUnsanitizedFormats = [] CloseEvent = ["Event"] CloseEventInit = [] CodecState = [] diff --git a/crates/web-sys/src/features/gen_Clipboard.rs b/crates/web-sys/src/features/gen_Clipboard.rs index 66c456dda80..420f5389fc9 100644 --- a/crates/web-sys/src/features/gen_Clipboard.rs +++ b/crates/web-sys/src/features/gen_Clipboard.rs @@ -2,7 +2,6 @@ #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; -#[cfg(web_sys_unstable_apis)] #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = Clipboard , typescript_type = "Clipboard")] @@ -12,52 +11,48 @@ extern "C" { #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Clipboard`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub type Clipboard; - #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "Clipboard" , js_name = read)] #[doc = "The `read()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/read)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Clipboard`*"] + pub fn read(this: &Clipboard) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "ClipboardUnsanitizedFormats")] + # [wasm_bindgen (method , structural , js_class = "Clipboard" , js_name = read)] + #[doc = "The `read()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/read)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Clipboard`, `ClipboardUnsanitizedFormats`*"] #[doc = ""] #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn read(this: &Clipboard) -> ::js_sys::Promise; - #[cfg(web_sys_unstable_apis)] + pub fn read_with_formats( + this: &Clipboard, + formats: &ClipboardUnsanitizedFormats, + ) -> ::js_sys::Promise; # [wasm_bindgen (method , structural , js_class = "Clipboard" , js_name = readText)] #[doc = "The `readText()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Clipboard`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn read_text(this: &Clipboard) -> ::js_sys::Promise; - #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "Clipboard" , js_name = write)] #[doc = "The `write()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Clipboard`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn write(this: &Clipboard, data: &::wasm_bindgen::JsValue) -> ::js_sys::Promise; - #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "Clipboard" , js_name = writeText)] #[doc = "The `writeText()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Clipboard`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn write_text(this: &Clipboard, data: &str) -> ::js_sys::Promise; } diff --git a/crates/web-sys/src/features/gen_ClipboardItem.rs b/crates/web-sys/src/features/gen_ClipboardItem.rs index 435f1a474b3..879c6308b5e 100644 --- a/crates/web-sys/src/features/gen_ClipboardItem.rs +++ b/crates/web-sys/src/features/gen_ClipboardItem.rs @@ -2,7 +2,6 @@ #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; -#[cfg(web_sys_unstable_apis)] #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = :: js_sys :: Object , js_name = ClipboardItem , typescript_type = "ClipboardItem")] @@ -12,11 +11,7 @@ extern "C" { #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub type ClipboardItem; - #[cfg(web_sys_unstable_apis)] #[cfg(feature = "PresentationStyle")] # [wasm_bindgen (structural , method , getter , js_class = "ClipboardItem" , js_name = presentationStyle)] #[doc = "Getter for the `presentationStyle` field of this object."] @@ -24,52 +19,26 @@ extern "C" { #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/presentationStyle)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`, `PresentationStyle`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn presentation_style(this: &ClipboardItem) -> PresentationStyle; - #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (structural , method , getter , js_class = "ClipboardItem" , js_name = lastModified)] - #[doc = "Getter for the `lastModified` field of this object."] - #[doc = ""] - #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/lastModified)"] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn last_modified(this: &ClipboardItem) -> f64; - #[cfg(web_sys_unstable_apis)] - # [wasm_bindgen (structural , method , getter , js_class = "ClipboardItem" , js_name = delayed)] - #[doc = "Getter for the `delayed` field of this object."] - #[doc = ""] - #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/delayed)"] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn delayed(this: &ClipboardItem) -> bool; - #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (structural , method , getter , js_class = "ClipboardItem" , js_name = types)] #[doc = "Getter for the `types` field of this object."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/types)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn types(this: &ClipboardItem) -> ::js_sys::Array; - #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (method , structural , js_class = "ClipboardItem" , js_name = getType)] #[doc = "The `getType()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/getType)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn get_type(this: &ClipboardItem, type_: &str) -> ::js_sys::Promise; + # [wasm_bindgen (static_method_of = ClipboardItem , js_class = "ClipboardItem" , js_name = supports)] + #[doc = "The `supports()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/supports)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ClipboardItem`*"] + pub fn supports(type_: &str) -> bool; } diff --git a/crates/web-sys/src/features/gen_ClipboardItemOptions.rs b/crates/web-sys/src/features/gen_ClipboardItemOptions.rs index 5930f6d857a..0f8b5121183 100644 --- a/crates/web-sys/src/features/gen_ClipboardItemOptions.rs +++ b/crates/web-sys/src/features/gen_ClipboardItemOptions.rs @@ -2,7 +2,6 @@ #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; -#[cfg(web_sys_unstable_apis)] #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = :: js_sys :: Object , js_name = ClipboardItemOptions)] @@ -10,41 +9,29 @@ extern "C" { #[doc = "The `ClipboardItemOptions` dictionary."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItemOptions`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub type ClipboardItemOptions; #[cfg(feature = "PresentationStyle")] #[wasm_bindgen(method, setter = "presentationStyle")] fn presentation_style_shim(this: &ClipboardItemOptions, val: PresentationStyle); } -#[cfg(web_sys_unstable_apis)] impl ClipboardItemOptions { #[doc = "Construct a new `ClipboardItemOptions`."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItemOptions`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn new() -> Self { #[allow(unused_mut)] let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); ret } - #[cfg(web_sys_unstable_apis)] #[cfg(feature = "PresentationStyle")] #[doc = "Change the `presentationStyle` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `ClipboardItemOptions`, `PresentationStyle`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn presentation_style(&mut self, val: PresentationStyle) -> &mut Self { self.presentation_style_shim(val); self } } -#[cfg(web_sys_unstable_apis)] impl Default for ClipboardItemOptions { fn default() -> Self { Self::new() diff --git a/crates/web-sys/src/features/gen_ClipboardUnsanitizedFormats.rs b/crates/web-sys/src/features/gen_ClipboardUnsanitizedFormats.rs new file mode 100644 index 00000000000..a4e5fa3251e --- /dev/null +++ b/crates/web-sys/src/features/gen_ClipboardUnsanitizedFormats.rs @@ -0,0 +1,50 @@ +#![allow(unused_imports)] +#![allow(clippy::all)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = ClipboardUnsanitizedFormats)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `ClipboardUnsanitizedFormats` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ClipboardUnsanitizedFormats`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type ClipboardUnsanitizedFormats; + #[wasm_bindgen(method, setter = "unsanitized")] + fn unsanitized_shim(this: &ClipboardUnsanitizedFormats, val: &::wasm_bindgen::JsValue); +} +#[cfg(web_sys_unstable_apis)] +impl ClipboardUnsanitizedFormats { + #[doc = "Construct a new `ClipboardUnsanitizedFormats`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ClipboardUnsanitizedFormats`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `unsanitized` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ClipboardUnsanitizedFormats`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn unsanitized(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + self.unsanitized_shim(val); + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for ClipboardUnsanitizedFormats { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_Navigator.rs b/crates/web-sys/src/features/gen_Navigator.rs index e148cd27fc5..8b28f73df54 100644 --- a/crates/web-sys/src/features/gen_Navigator.rs +++ b/crates/web-sys/src/features/gen_Navigator.rs @@ -12,6 +12,14 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Navigator`*"] pub type Navigator; + #[cfg(feature = "Clipboard")] + # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = clipboard)] + #[doc = "Getter for the `clipboard` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Clipboard`, `Navigator`*"] + pub fn clipboard(this: &Navigator) -> Clipboard; #[cfg(feature = "Permissions")] # [wasm_bindgen (structural , catch , method , getter , js_class = "Navigator" , js_name = permissions)] #[doc = "Getter for the `permissions` field of this object."] @@ -126,18 +134,6 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn bluetooth(this: &Navigator) -> Option; #[cfg(web_sys_unstable_apis)] - #[cfg(feature = "Clipboard")] - # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = clipboard)] - #[doc = "Getter for the `clipboard` field of this object."] - #[doc = ""] - #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard)"] - #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `Clipboard`, `Navigator`*"] - #[doc = ""] - #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] - #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] - pub fn clipboard(this: &Navigator) -> Option; - #[cfg(web_sys_unstable_apis)] #[cfg(feature = "MediaSession")] # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = mediaSession)] #[doc = "Getter for the `mediaSession` field of this object."] diff --git a/crates/web-sys/src/features/gen_PresentationStyle.rs b/crates/web-sys/src/features/gen_PresentationStyle.rs index 1c1b92cf56c..2c0573d8553 100644 --- a/crates/web-sys/src/features/gen_PresentationStyle.rs +++ b/crates/web-sys/src/features/gen_PresentationStyle.rs @@ -1,14 +1,10 @@ #![allow(unused_imports)] #![allow(clippy::all)] use wasm_bindgen::prelude::*; -#[cfg(web_sys_unstable_apis)] #[wasm_bindgen] #[doc = "The `PresentationStyle` enum."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `PresentationStyle`*"] -#[doc = ""] -#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] -#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum PresentationStyle { Unspecified = "unspecified", diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index 486e99e0b18..593a3f5e0de 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -1139,6 +1139,13 @@ mod gen_ClipboardPermissionDescriptor; #[allow(unused_imports)] pub use gen_ClipboardPermissionDescriptor::*; +#[cfg(feature = "ClipboardUnsanitizedFormats")] +#[allow(non_snake_case)] +mod gen_ClipboardUnsanitizedFormats; +#[cfg(feature = "ClipboardUnsanitizedFormats")] +#[allow(unused_imports)] +pub use gen_ClipboardUnsanitizedFormats::*; + #[cfg(feature = "CloseEvent")] #[allow(non_snake_case)] mod gen_CloseEvent; diff --git a/crates/web-sys/webidls/enabled/Clipboard.webidl b/crates/web-sys/webidls/enabled/Clipboard.webidl new file mode 100644 index 00000000000..fbf98a2f379 --- /dev/null +++ b/crates/web-sys/webidls/enabled/Clipboard.webidl @@ -0,0 +1,54 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * Clipboard API and events + * Editor’s Draft, 4 June 2024 + * + * The origin of this IDL file is: + * https://w3c.github.io/clipboard-apis/#idl-index + */ + +dictionary ClipboardEventInit : EventInit { + DataTransfer? clipboardData = null; +}; + +[Exposed=Window] +interface ClipboardEvent : Event { + constructor(DOMString type, optional ClipboardEventInit eventInitDict = {}); + readonly attribute DataTransfer? clipboardData; +}; + +partial interface Navigator { + [SecureContext, SameObject] readonly attribute Clipboard clipboard; +}; + +typedef Promise<(DOMString or Blob)> ClipboardItemData; + +[SecureContext, Exposed=Window] +interface ClipboardItem { + [Throws] + constructor(record items, + optional ClipboardItemOptions options = {}); + + readonly attribute PresentationStyle presentationStyle; + readonly attribute FrozenArray types; + + Promise getType(DOMString type); + + static boolean supports(DOMString type); +}; + +enum PresentationStyle { "unspecified", "inline", "attachment" }; + +dictionary ClipboardItemOptions { + PresentationStyle presentationStyle = "unspecified"; +}; + +typedef sequence ClipboardItems; + +[SecureContext, Exposed=Window] +interface Clipboard : EventTarget { + Promise read(optional ClipboardUnsanitizedFormats formats = {}); + Promise readText(); + Promise write(ClipboardItems data); + Promise writeText(DOMString data); +}; diff --git a/crates/web-sys/webidls/enabled/ClipboardEvent.webidl b/crates/web-sys/webidls/enabled/ClipboardEvent.webidl deleted file mode 100644 index 51ceebfb2e9..00000000000 --- a/crates/web-sys/webidls/enabled/ClipboardEvent.webidl +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Clipboard API and events - * Editor’s Draft, 21 November 2023 - * - * The origin of this IDL file is: - * https://w3c.github.io/clipboard-apis/#clipboard-event-interfaces - */ - -dictionary ClipboardEventInit : EventInit { - DataTransfer? clipboardData = null; -}; - -[Exposed=Window] -interface ClipboardEvent : Event { - constructor(DOMString type, optional ClipboardEventInit eventInitDict = {}); - readonly attribute DataTransfer? clipboardData; -}; diff --git a/crates/web-sys/webidls/unstable/Clipboard.webidl b/crates/web-sys/webidls/unstable/Clipboard.webidl index c32a6556a06..91ecc637a45 100644 --- a/crates/web-sys/webidls/unstable/Clipboard.webidl +++ b/crates/web-sys/webidls/unstable/Clipboard.webidl @@ -1,51 +1,19 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * Clipboard API and events - * W3C Working Draft, 4 June 2021 + * Editor’s Draft, 4 June 2024 + * * The origin of this IDL file is: - * https://www.w3.org/TR/2021/WD-clipboard-apis-20210604/ + * https://w3c.github.io/clipboard-apis/#idl-index */ -partial interface Navigator { - [SecureContext, SameObject] readonly attribute Clipboard? clipboard; -}; - -typedef sequence ClipboardItems; - -[SecureContext, Exposed=Window] interface Clipboard : EventTarget { - Promise read(); - Promise readText(); - Promise write(ClipboardItems data); - Promise writeText(DOMString data); -}; - -typedef (DOMString or Blob) ClipboardItemDataType; -typedef Promise ClipboardItemData; - -callback ClipboardItemDelayedCallback = ClipboardItemData (); - -[Exposed=Window] interface ClipboardItem { - constructor(record items, - optional ClipboardItemOptions options = {}); - static ClipboardItem createDelayed( - record items, - optional ClipboardItemOptions options = {}); - - readonly attribute PresentationStyle presentationStyle; - readonly attribute long long lastModified; - readonly attribute boolean delayed; - - readonly attribute FrozenArray types; - - Promise getType(DOMString type); -}; - -enum PresentationStyle { "unspecified", "inline", "attachment" }; - -dictionary ClipboardItemOptions { - PresentationStyle presentationStyle = "unspecified"; +// There is no consensus by browsers to implement this API. +// See https://github.com/w3c/clipboard-apis/pull/197. +dictionary ClipboardUnsanitizedFormats { + sequence unsanitized; }; +// Also Chrome-only. dictionary ClipboardPermissionDescriptor : PermissionDescriptor { boolean allowWithoutGesture = false; }; diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 44dffb0af70..0f663978fd3 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -443,14 +443,9 @@ impl<'src> FirstPassRecord<'src> { // If any of the arguments types are `unstable` then this method is downgraded // to be unstable. let has_unstable_args = signature - .orig .args .iter() - .any(|arg| is_type_unstable(arg.ty, unstable_types)) - | signature - .args - .iter() - .any(|arg| is_idl_type_unstable(arg, unstable_types)); + .any(|arg| is_idl_type_unstable(arg, unstable_types)); let unstable = unstable || data.stability.is_unstable() || has_unstable_args; @@ -552,7 +547,9 @@ pub fn is_type_unstable(ty: &weedle::types::Type, unstable_types: &HashSet) -> bool { match ty { - IdlType::Interface(name) => unstable_types.contains(&Identifier(name)), + IdlType::Dictionary(name) | IdlType::Interface(name) => { + unstable_types.contains(&Identifier(name)) + } _ => false, } }