diff --git a/crates/web-sys/src/features/gen_CanvasPattern.rs b/crates/web-sys/src/features/gen_CanvasPattern.rs index cab7fbaebb73..bc939b0df178 100644 --- a/crates/web-sys/src/features/gen_CanvasPattern.rs +++ b/crates/web-sys/src/features/gen_CanvasPattern.rs @@ -19,5 +19,5 @@ extern "C" { #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `CanvasPattern`, `SvgMatrix`*"] - pub fn set_transform_with_default_dom_matrix_2d_init(this: &CanvasPattern, matrix: &SvgMatrix); + pub fn set_transform(this: &CanvasPattern, matrix: &SvgMatrix); } diff --git a/crates/webidl/src/constants.rs b/crates/webidl/src/constants.rs index 3d02b820bab8..651c99aac3b6 100644 --- a/crates/webidl/src/constants.rs +++ b/crates/webidl/src/constants.rs @@ -97,8 +97,10 @@ pub(crate) static IMMUTABLE_SLICE_WHITELIST: Lazy> = Lazy ]) }); -pub(crate) static FIXED_INTERFACES: Lazy> = Lazy::new(|| { - BTreeMap::from_iter(vec![ +pub(crate) static FIXED_INTERFACES: Lazy< + BTreeMap<&'static str, BTreeMap<&'static str, &'static str>>, +> = Lazy::new(|| { + let image_bitmap = BTreeMap::from_iter([ ("create_image_bitmap_with_html_image_element_and_i32_and_a_sy_and_a_sw_and_a_sh", "create_image_bitmap_with_html_image_element_and_a_sx_and_a_sy_and_a_sw_and_a_sh"), ("create_image_bitmap_with_svg_image_element_and_i32_and_a_sy_and_a_sw_and_a_sh", "create_image_bitmap_with_svg_image_element_and_a_sx_and_a_sy_and_a_sw_and_a_sh"), ("create_image_bitmap_with_html_canvas_element_and_i32_and_a_sy_and_a_sw_and_a_sh", "create_image_bitmap_with_html_canvas_element_and_a_sx_and_a_sy_and_a_sw_and_a_sh"), @@ -117,7 +119,26 @@ pub(crate) static FIXED_INTERFACES: Lazy> = ("create_image_bitmap_with_video_frame_and_i32_and_a_sy_and_a_sw_and_a_sh_and_a_options", "create_image_bitmap_with_video_frame_and_a_sx_and_a_sy_and_a_sw_and_a_sh_and_a_options"), ("create_image_bitmap_with_blob_and_i32_and_a_sy_and_a_sw_and_a_sh_and_a_options", "create_image_bitmap_with_blob_and_a_sx_and_a_sy_and_a_sw_and_a_sh_and_a_options"), ("create_image_bitmap_with_image_data_and_i32_and_a_sy_and_a_sw_and_a_sh_and_a_options", "create_image_bitmap_with_image_data_and_a_sx_and_a_sy_and_a_sw_and_a_sh_and_a_options"), - ("set_transform", "set_transform_with_default_dom_matrix_2d_init"), - ("set_transform_with_a_and_b_and_c_and_d_and_e_and_f", "set_transform"), + ]); + + let canvas_rendering_context = BTreeMap::from_iter([ + ( + "set_transform", + "set_transform_with_default_dom_matrix_2d_init", + ), + ( + "set_transform_with_a_and_b_and_c_and_d_and_e_and_f", + "set_transform", + ), + ]); + + BTreeMap::from_iter([ + ("Window", image_bitmap.clone()), + ("WorkerGlobalScope", image_bitmap), + ("CanvasRenderingContext2d", canvas_rendering_context.clone()), + ( + "OffscreenCanvasRenderingContext2d", + canvas_rendering_context, + ), ]) }); diff --git a/crates/webidl/src/lib.rs b/crates/webidl/src/lib.rs index 66f2ebd70be8..60a92d020f50 100644 --- a/crates/webidl/src/lib.rs +++ b/crates/webidl/src/lib.rs @@ -504,7 +504,7 @@ impl<'src> FirstPassRecord<'src> { } } - for x in self.create_imports(None, id, data, false, &HashSet::new()) { + for x in self.create_imports(None, None, id, data, false, &HashSet::new()) { functions.push(Function { name: x.name, js_name: x.js_name, @@ -588,7 +588,14 @@ impl<'src> FirstPassRecord<'src> { } for (id, op_data) in data.operations.iter() { - self.member_operation(&mut methods, data, id, op_data, unstable_types); + self.member_operation( + &name.to_string(), + &mut methods, + data, + id, + op_data, + unstable_types, + ); } for mixin_data in self.all_mixins(&js_name) { @@ -614,7 +621,14 @@ impl<'src> FirstPassRecord<'src> { } for (id, op_data) in mixin_data.operations.iter() { - self.member_operation(&mut methods, data, id, op_data, unstable_types); + self.member_operation( + &name.to_string(), + &mut methods, + data, + id, + op_data, + unstable_types, + ); } } @@ -702,6 +716,7 @@ impl<'src> FirstPassRecord<'src> { fn member_operation( &self, + type_name: &str, methods: &mut Vec, data: &InterfaceData<'src>, id: &OperationId<'src>, @@ -711,7 +726,14 @@ impl<'src> FirstPassRecord<'src> { let attrs = data.definition_attributes; let unstable = data.stability.is_unstable(); - for method in self.create_imports(attrs, id, op_data, unstable, unstable_types) { + for method in self.create_imports( + Some(type_name), + attrs, + id, + op_data, + unstable, + unstable_types, + ) { methods.push(method); } } diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index e1a47886ac9b..b5f5d79623bc 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -196,6 +196,7 @@ pub enum TypePosition { impl<'src> FirstPassRecord<'src> { pub fn create_imports( &self, + type_name: Option<&str>, container_attrs: Option<&ExtendedAttributeList<'src>>, id: &OperationId<'src>, data: &OperationData<'src>, @@ -500,8 +501,12 @@ impl<'src> FirstPassRecord<'src> { } for interface in &mut ret { - if let Some(fixed) = FIXED_INTERFACES.get(&interface.name.to_string().as_ref()) { - interface.name = rust_ident(fixed); + if let Some(type_name) = type_name { + if let Some(map) = FIXED_INTERFACES.get(type_name) { + if let Some(fixed) = map.get(&interface.name.to_string().as_ref()) { + interface.name = rust_ident(fixed); + } + } } }