diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-03-16 09:46:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-16 13:46:14 +0000 |
commit | d35da38a2fd6f093967e74f704612391b4988e69 (patch) | |
tree | 96c8705a5a597be25ac74b58043e57b3e06992f4 /components/script/dom/subtlecrypto.rs | |
parent | 3ecd1c069978f6ceb20e4ee6af599fbef425e9da (diff) | |
download | servo-d35da38a2fd6f093967e74f704612391b4988e69.tar.gz servo-d35da38a2fd6f093967e74f704612391b4988e69.zip |
Cleanups for future script crate split (#35987)
* script: Avoid direct impl blocks on generated dicts and unions.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Remove references to codegen-specific import module.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix tidy.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/subtlecrypto.rs')
-rw-r--r-- | components/script/dom/subtlecrypto.rs | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/components/script/dom/subtlecrypto.rs b/components/script/dom/subtlecrypto.rs index 17c3ff752ae..a0211819a19 100644 --- a/components/script/dom/subtlecrypto.rs +++ b/components/script/dom/subtlecrypto.rs @@ -38,7 +38,6 @@ use crate::dom::bindings::codegen::UnionTypes::{ ArrayBufferViewOrArrayBuffer, ArrayBufferViewOrArrayBufferOrJsonWebKey, }; use crate::dom::bindings::error::{Error, Fallible}; -use crate::dom::bindings::import::module::SafeJSContext; use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object}; use crate::dom::bindings::root::DomRoot; @@ -258,7 +257,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto { /// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-sign> fn Sign( &self, - cx: SafeJSContext, + cx: JSContext, algorithm: AlgorithmIdentifier, key: &CryptoKey, data: ArrayBufferViewOrArrayBuffer, @@ -341,7 +340,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto { /// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-verify> fn Verify( &self, - cx: SafeJSContext, + cx: JSContext, algorithm: AlgorithmIdentifier, key: &CryptoKey, signature: ArrayBufferViewOrArrayBuffer, @@ -429,7 +428,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto { /// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-digest> fn Digest( &self, - cx: SafeJSContext, + cx: JSContext, algorithm: AlgorithmIdentifier, data: ArrayBufferViewOrArrayBuffer, comp: InRealm, @@ -533,7 +532,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto { /// <https://w3c.github.io/webcrypto/#SubtleCrypto-method-deriveKey> fn DeriveKey( &self, - cx: SafeJSContext, + cx: JSContext, algorithm: AlgorithmIdentifier, base_key: &CryptoKey, derived_key_type: AlgorithmIdentifier, @@ -663,7 +662,7 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto { /// <https://w3c.github.io/webcrypto/#dfn-SubtleCrypto-method-deriveBits> fn DeriveBits( &self, - cx: SafeJSContext, + cx: JSContext, algorithm: AlgorithmIdentifier, base_key: &CryptoKey, length: Option<u32>, @@ -2631,7 +2630,11 @@ fn data_to_jwk_params(alg: &str, size: &str, key: &[u8]) -> (DOMString, DOMStrin (jwk_alg, DOMString::from(data)) } -impl KeyAlgorithm { +trait AlgorithmFromName { + fn from_name(name: DOMString, out: MutableHandleObject, cx: JSContext); +} + +impl AlgorithmFromName for KeyAlgorithm { /// Fill the object referenced by `out` with an [KeyAlgorithm] /// of the specified name and size. #[allow(unsafe_code)] @@ -2644,7 +2647,16 @@ impl KeyAlgorithm { } } -impl HmacKeyAlgorithm { +trait AlgorithmFromLengthAndHash { + fn from_length_and_hash( + length: u32, + hash: DigestAlgorithm, + out: MutableHandleObject, + cx: JSContext, + ); +} + +impl AlgorithmFromLengthAndHash for HmacKeyAlgorithm { #[allow(unsafe_code)] fn from_length_and_hash( length: u32, @@ -2666,7 +2678,11 @@ impl HmacKeyAlgorithm { } } -impl AesKeyAlgorithm { +trait AlgorithmFromNameAndSize { + fn from_name_and_size(name: DOMString, size: u16, out: MutableHandleObject, cx: JSContext); +} + +impl AlgorithmFromNameAndSize for AesKeyAlgorithm { /// Fill the object referenced by `out` with an [AesKeyAlgorithm] /// of the specified name and size. #[allow(unsafe_code)] |