aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/dommatrix.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/dommatrix.rs')
-rw-r--r--components/script/dom/dommatrix.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs
index c5520c7d6a7..2cbc9aa011c 100644
--- a/components/script/dom/dommatrix.rs
+++ b/components/script/dom/dommatrix.rs
@@ -8,7 +8,7 @@ use crate::dom::bindings::codegen::UnionTypes::StringOrUnrestrictedDoubleSequenc
use crate::dom::bindings::error;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::inheritance::Castable;
-use crate::dom::bindings::reflector::reflect_dom_object;
+use crate::dom::bindings::reflector::reflect_dom_object2;
use crate::dom::bindings::root::DomRoot;
use crate::dom::dommatrixreadonly::{
dommatrixinit_to_matrix, entries_to_matrix, transform_to_matrix, DOMMatrixReadOnly,
@@ -17,7 +17,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use euclid::default::Transform3D;
-use js::rust::CustomAutoRooterGuard;
+use js::rust::{CustomAutoRooterGuard, HandleObject};
use js::typedarray::{Float32Array, Float64Array};
#[dom_struct]
@@ -27,10 +27,14 @@ pub struct DOMMatrix {
#[allow(non_snake_case)]
impl DOMMatrix {
- #[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
+ Self::new_with_proto(global, None, is2D, matrix)
+ }
+
+ #[allow(unrooted_must_root)]
+ fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
let dommatrix = Self::new_inherited(is2D, matrix);
- reflect_dom_object(Box::new(dommatrix), global)
+ reflect_dom_object2(Box::new(dommatrix), global, proto)
}
pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self {
@@ -42,10 +46,11 @@ impl DOMMatrix {
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly
pub fn Constructor(
global: &GlobalScope,
+ proto: Option<HandleObject>,
init: Option<StringOrUnrestrictedDoubleSequence>,
) -> Fallible<DomRoot<Self>> {
if init.is_none() {
- return Ok(Self::new(global, true, Transform3D::identity()));
+ return Ok(Self::new_with_proto(global, proto, true, Transform3D::identity()));
}
match init.unwrap() {
StringOrUnrestrictedDoubleSequence::String(ref s) => {
@@ -58,11 +63,11 @@ impl DOMMatrix {
return Ok(Self::new(global, true, Transform3D::identity()));
}
transform_to_matrix(s.to_string())
- .map(|(is2D, matrix)| Self::new(global, is2D, matrix))
+ .map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix))
},
StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(ref entries) => {
entries_to_matrix(&entries[..])
- .map(|(is2D, matrix)| Self::new(global, is2D, matrix))
+ .map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix))
},
}
}
@@ -84,6 +89,7 @@ impl DOMMatrix {
let vec: Vec<f64> = array.to_vec().iter().map(|&x| x as f64).collect();
DOMMatrix::Constructor(
global,
+ None,
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
)
}
@@ -96,6 +102,7 @@ impl DOMMatrix {
let vec: Vec<f64> = array.to_vec();
DOMMatrix::Constructor(
global,
+ None,
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
)
}