diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/custom_elements_registry.rs b/moli-renderer-v8/src/context_bootstrap/constructors/custom_elements_registry.rs index cabbb60886..b9a174b2c1 100644 --- a/moli-renderer-v8/src/context_bootstrap/constructors/custom_elements_registry.rs +++ b/moli-renderer-v8/src/context_bootstrap/constructors/custom_elements_registry.rs @@ -1,7 +1,6 @@ use super::*; use crate::web_api_interfaces; use crate::webidl; -use anyhow::Result; use moli_webapi_declare::WebApiFunctionTemplate; #[derive(WebApiFunctionTemplate)] @@ -49,7 +48,7 @@ struct CustomElementsDefineArgs<'s> { missing_message = "customElements.define(name, constructor) requires a constructor function" )] constructor: v8::Local<'s, v8::Function>, - #[webidl(with = parse_element_definition_options_arg)] + #[webidl(dictionary)] options: ElementDefinitionOptions, } @@ -225,18 +224,6 @@ pub(in crate::context_bootstrap) fn custom_elements_define_callback<'s>( } } -fn parse_element_definition_options_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> Result { - let context = webidl::Context::argument("CustomElementRegistry.define", (index + 1) as usize); - webidl::dictionary_arg(args, index, context)? - .map(|object| webidl::parse_dictionary_object::(scope, object)) - .transpose() - .map(|options| options.unwrap_or_default()) -} - pub(in crate::context_bootstrap) fn custom_elements_get_callback<'s>( scope: &mut v8::PinScope<'s, '_>, args: v8::FunctionCallbackArguments<'s>, diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs b/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs index fe481fec7a..e594c9b9ee 100644 --- a/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs +++ b/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs @@ -46,7 +46,7 @@ struct QuotaExceededErrorOptions { struct QuotaExceededErrorConstructorArgs { #[webidl(default = "")] message: String, - #[webidl(default = QuotaExceededErrorOptions::default(), with = quota_exceeded_error_options_arg)] + #[webidl(dictionary)] options: QuotaExceededErrorOptions, } @@ -636,20 +636,6 @@ pub(crate) fn new_dom_error_value<'s>( .into() } -fn quota_exceeded_error_options_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> Result { - let context = webidl::Context::argument("QuotaExceededError", (index + 1) as usize); - if args.length() <= index { - return Ok(QuotaExceededErrorOptions::default()); - } - let value = args.get(index); - webidl::parse_dictionary::(scope, value, context) - .map(|value| value.unwrap_or_default()) -} - pub(crate) fn quota_exceeded_error_constructor_callback<'s>( scope: &mut v8::PinScope<'s, '_>, args: v8::FunctionCallbackArguments<'s>, diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs b/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs index ad9fa402a2..8a51dceed3 100644 --- a/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs +++ b/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs @@ -109,7 +109,7 @@ struct TextEncoderEncodeIntoArgs<'s> { struct TextDecoderConstructorArgs { #[webidl(default = "utf-8")] label: String, - #[webidl(index = 1, with = parse_text_decoder_options_arg)] + #[webidl(index = 1, dictionary)] options: TextDecoderOptions, } @@ -127,7 +127,7 @@ struct TextDecoderOptions { struct TextDecoderDecodeArgs { #[webidl(converter = "buffer_source")] input: Option, - #[webidl(index = 1, with = parse_text_decode_options_arg)] + #[webidl(index = 1, dictionary)] options: TextDecodeOptions, } @@ -338,30 +338,6 @@ pub(in crate::context_bootstrap) fn text_decoder_constructor_callback<'s>( rv.set(args.this().into()); } -fn parse_text_decoder_options_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> Result { - let context = webidl::Context::argument("TextDecoder", (index + 1) as usize); - webidl::dictionary_arg(args, index, context)? - .map(|object| webidl::parse_dictionary_object(scope, object)) - .transpose() - .map(|options| options.unwrap_or_default()) -} - -fn parse_text_decode_options_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> Result { - let context = webidl::Context::argument("TextDecoder.decode", (index + 1) as usize); - webidl::dictionary_arg(args, index, context)? - .map(|object| webidl::parse_dictionary_object(scope, object)) - .transpose() - .map(|options| options.unwrap_or_default()) -} - fn text_decoder_decode_callback<'s>( scope: &mut v8::PinScope<'s, '_>, args: v8::FunctionCallbackArguments<'s>, diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs index 8fdc662a43..3db26ffe70 100644 --- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs +++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs @@ -88,7 +88,7 @@ struct GetCurrentPositionArgs { #[webidl(nullable, converter = "callback_function")] error_callback: Option, - #[webidl(with = position_options_arg)] + #[webidl(dictionary)] options: PositionOptions, } @@ -101,7 +101,7 @@ struct WatchPositionArgs { #[webidl(nullable, converter = "callback_function")] error_callback: Option, - #[webidl(with = position_options_arg)] + #[webidl(dictionary)] options: PositionOptions, } @@ -248,30 +248,6 @@ fn geolocation_clear_watch_callback<'s>( rv.set_undefined(); } -fn position_options_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> std::result::Result { - if args.length() <= index || args.get(index).is_undefined() { - return Ok(PositionOptions { - timeout: u32::MAX, - ..PositionOptions::default() - }); - } - webidl::parse_dictionary::( - scope, - args.get(index), - webidl::Context::argument("Geolocation", (index + 1) as usize), - ) - .map(|options| { - options.unwrap_or(PositionOptions { - timeout: u32::MAX, - ..PositionOptions::default() - }) - }) -} - fn clamped_unsigned_long_position_option<'s>( scope: &mut v8::PinScope<'s, '_>, object: v8::Local<'s, v8::Object>, diff --git a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs index 234df22f28..0175beedce 100644 --- a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs +++ b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs @@ -685,23 +685,10 @@ struct WorkletOptions { struct WorkletAddModuleArgs { #[webidl(required, converter = "usv_string")] module_url: String, - #[webidl(with = worklet_options_arg)] + #[webidl(dictionary)] options: WorkletOptions, } -fn worklet_options_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> Result { - webidl::parse_dictionary( - scope, - args.get(index), - webidl::Context::argument("Worklet.addModule", 2), - ) - .map(Option::unwrap_or_default) -} - fn audio_worklet_add_module_callback<'s>( scope: &mut v8::PinScope<'s, '_>, args: v8::FunctionCallbackArguments<'s>, diff --git a/moli-renderer-v8/src/network_host/xhr/bindings/progress_event.rs b/moli-renderer-v8/src/network_host/xhr/bindings/progress_event.rs index 0b7ff0267d..d5f2ed7ccb 100644 --- a/moli-renderer-v8/src/network_host/xhr/bindings/progress_event.rs +++ b/moli-renderer-v8/src/network_host/xhr/bindings/progress_event.rs @@ -41,24 +41,10 @@ struct ProgressEventConstructorArgs { missing_message = "Failed to construct 'ProgressEvent': 1 argument required, but only 0 present." )] event_type: String, - #[webidl(default = ProgressEventInitArgs::default(), with = progress_event_init_arg)] + #[webidl(dictionary)] init: ProgressEventInitArgs, } -fn progress_event_init_arg<'s>( - scope: &mut v8::PinScope<'s, '_>, - args: &v8::FunctionCallbackArguments<'s>, - index: i32, -) -> Result { - let context = webidl::Context::argument("ProgressEvent", (index + 1) as usize); - if args.length() <= index { - return Ok(ProgressEventInitArgs::default()); - } - let value = args.get(index); - webidl::parse_dictionary::(scope, value, context) - .map(|value| value.unwrap_or_default()) -} - pub(crate) fn progress_event_constructor_callback<'s>( scope: &mut v8::PinScope<'s, '_>, args: v8::FunctionCallbackArguments<'s>,