Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bindings for CanvasTransform.setTransform(DOMMatrix2DInit) #3580

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
* Add unstable bindings for the Prioritized Task Scheduling API.
[#3566](https://github.com/rustwasm/wasm-bindgen/pull/3566)

* Add bindings for `CanvasTransform.setTransform(DOMMatrix2DInit)`.
[#3580](https://github.com/rustwasm/wasm-bindgen/pull/3580)

### Changed

* Updated the WebGPU WebIDL.
Expand Down
2 changes: 2 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ DomError = []
DomException = []
DomImplementation = []
DomMatrix = ["DomMatrixReadOnly"]
DomMatrix2dInit = []
DomMatrixInit = []
DomMatrixReadOnly = []
DomParser = []
DomPoint = ["DomPointReadOnly"]
Expand Down
2 changes: 1 addition & 1 deletion crates/web-sys/src/features/gen_CanvasPattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(this: &CanvasPattern, matrix: &SvgMatrix);
pub fn set_transform_with_default_dom_matrix_2d_init(this: &CanvasPattern, matrix: &SvgMatrix);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change (and not really a desirable one, either).

I can see what happened here: you used FIXED_INTERFACES to prevent CanvasRenderingContext2d::set_transform being changed to mean the DomMatrix overload with its default value, but that affected this method too since it doesn't distinguish between methods on different types.

I think FIXED_INTERFACES will have to be extended to allow specifying both the type name and method name to fix this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, I missed that somehow ... thank you @Liamolucko.

}
20 changes: 20 additions & 0 deletions crates/web-sys/src/features/gen_CanvasRenderingContext2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,26 @@ extern "C" {
e: f64,
f: f64,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "CanvasRenderingContext2D" , js_name = setTransform)]
#[doc = "The `setTransform()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CanvasRenderingContext2d`*"]
pub fn set_transform_with_default_dom_matrix_2d_init(
this: &CanvasRenderingContext2d,
) -> Result<(), JsValue>;
#[cfg(feature = "DomMatrix2dInit")]
# [wasm_bindgen (catch , method , structural , js_class = "CanvasRenderingContext2D" , js_name = setTransform)]
#[doc = "The `setTransform()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CanvasRenderingContext2d`, `DomMatrix2dInit`*"]
pub fn set_transform_with_dom_matrix_2d_init(
this: &CanvasRenderingContext2d,
transform: &DomMatrix2dInit,
) -> Result<(), JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "CanvasRenderingContext2D" , js_name = transform)]
#[doc = "The `transform()` method."]
#[doc = ""]
Expand Down
184 changes: 184 additions & 0 deletions crates/web-sys/src/features/gen_DomMatrix2dInit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = DOMMatrix2DInit)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `DomMatrix2dInit` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub type DomMatrix2dInit;
}
impl DomMatrix2dInit {
#[doc = "Construct a new `DomMatrix2dInit`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[doc = "Change the `a` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn a(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("a"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `b` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn b(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("b"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `c` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn c(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("c"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `d` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn d(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("d"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `e` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn e(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("e"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `f` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn f(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("f"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `m11` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn m11(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("m11"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `m12` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn m12(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("m12"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `m21` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn m21(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("m21"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `m22` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn m22(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("m22"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `m41` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn m41(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("m41"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `m42` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DomMatrix2dInit`*"]
pub fn m42(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("m42"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
impl Default for DomMatrix2dInit {
fn default() -> Self {
Self::new()
}
}
Loading