mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Propagate CanGc through dommatrix, dommatrixreadonly, and testbindings (#33822)
* CanGc fixes starting from dommatrix.rs fixed conflicts Signed-off-by: L Ashwin B <lashwinib@gmail.com> ~ * cleaning up Signed-off-by: L Ashwin B <lashwinib@gmail.com> * fixed cannot find value can_gc in this scope error Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
parent
bdd5fb2e5b
commit
92f12ff7cd
8 changed files with 124 additions and 62 deletions
|
@ -1552,12 +1552,12 @@ impl CanvasState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
||||||
pub fn get_transform(&self, global: &GlobalScope) -> DomRoot<DOMMatrix> {
|
pub fn get_transform(&self, global: &GlobalScope, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
let (sender, receiver) = ipc::channel::<Transform2D<f32>>().unwrap();
|
let (sender, receiver) = ipc::channel::<Transform2D<f32>>().unwrap();
|
||||||
self.send_canvas_2d_msg(Canvas2dMsg::GetTransform(sender));
|
self.send_canvas_2d_msg(Canvas2dMsg::GetTransform(sender));
|
||||||
let transform = receiver.recv().unwrap();
|
let transform = receiver.recv().unwrap();
|
||||||
|
|
||||||
DOMMatrix::new(global, true, transform.cast::<f64>().to_3d())
|
DOMMatrix::new(global, true, transform.cast::<f64>().to_3d(), can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
||||||
|
|
|
@ -57,7 +57,7 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'CanvasRenderingContext2D': {
|
'CanvasRenderingContext2D': {
|
||||||
'canGc': ['CreateImageData', 'CreateImageData_', 'GetImageData'],
|
'canGc': ['GetTransform','GetImageData', 'CreateImageData', 'CreateImageData_'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'DOMImplementation': {
|
'DOMImplementation': {
|
||||||
|
@ -68,6 +68,14 @@ DOMInterfaces = {
|
||||||
'canGc': ['ParseFromString'],
|
'canGc': ['ParseFromString'],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'DOMMatrix': {
|
||||||
|
'canGc': ['FromMatrix', 'FromFloat32Array', 'FromFloat64Array'],
|
||||||
|
},
|
||||||
|
|
||||||
|
'DOMMatrixReadOnly': {
|
||||||
|
'canGc': ['Multiply', 'Inverse', 'Scale', 'Translate', 'Rotate', 'RotateFromVector','FlipY', 'ScaleNonUniform', 'Scale3d', 'RotateAxisAngle', 'SkewX', 'SkewY', 'FlipX', 'TransformPoint', 'FromFloat32Array', 'FromFloat64Array','FromMatrix'],
|
||||||
|
},
|
||||||
|
|
||||||
'Document': {
|
'Document': {
|
||||||
'canGc': ['Close', 'CreateElement', 'CreateElementNS', 'ImportNode', 'SetTitle', 'Write', 'Writeln', 'CreateEvent', 'CreateRange', 'Open', 'Open_'],
|
'canGc': ['Close', 'CreateElement', 'CreateElementNS', 'ImportNode', 'SetTitle', 'Write', 'Writeln', 'CreateEvent', 'CreateRange', 'Open', 'Open_'],
|
||||||
},
|
},
|
||||||
|
@ -161,7 +169,11 @@ DOMInterfaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'OffscreenCanvasRenderingContext2D': {
|
'OffscreenCanvasRenderingContext2D': {
|
||||||
'canGc': ['CreateImageData', 'CreateImageData_', 'GetImageData'],
|
'canGc': ['CreateImageData', 'CreateImageData_', 'GetImageData', 'GetTransform'],
|
||||||
|
},
|
||||||
|
|
||||||
|
'PaintRenderingContext2D': {
|
||||||
|
'canGc': ['GetTransform'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'Promise': {
|
'Promise': {
|
||||||
|
@ -193,6 +205,7 @@ DOMInterfaces = {
|
||||||
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
|
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
|
||||||
'TestBinding': {
|
'TestBinding': {
|
||||||
'inRealms': ['PromiseAttribute', 'PromiseNativeHandler'],
|
'inRealms': ['PromiseAttribute', 'PromiseNativeHandler'],
|
||||||
|
'canGc': ['InterfaceAttribute', 'GetInterfaceAttributeNullable', 'ReceiveInterface', 'ReceiveInterfaceSequence', 'ReceiveNullableInterface'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'TestWorklet': {
|
'TestWorklet': {
|
||||||
|
|
|
@ -199,8 +199,8 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
||||||
fn GetTransform(&self) -> DomRoot<DOMMatrix> {
|
fn GetTransform(&self, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
self.canvas_state.get_transform(&self.global())
|
self.canvas_state.get_transform(&self.global(), can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
||||||
|
|
|
@ -29,8 +29,13 @@ pub struct DOMMatrix {
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl DOMMatrix {
|
impl DOMMatrix {
|
||||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
pub fn new(
|
||||||
Self::new_with_proto(global, None, is2D, matrix, CanGc::note())
|
global: &GlobalScope,
|
||||||
|
is2D: bool,
|
||||||
|
matrix: Transform3D<f64>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Self> {
|
||||||
|
Self::new_with_proto(global, None, is2D, matrix, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -51,8 +56,12 @@ impl DOMMatrix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_readonly(global: &GlobalScope, ro: &DOMMatrixReadOnly) -> DomRoot<Self> {
|
pub fn from_readonly(
|
||||||
Self::new(global, ro.is2D(), *ro.matrix())
|
global: &GlobalScope,
|
||||||
|
ro: &DOMMatrixReadOnly,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Self> {
|
||||||
|
Self::new(global, ro.is2D(), *ro.matrix(), can_gc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +91,7 @@ impl DOMMatrixMethods for DOMMatrix {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
return Ok(Self::new(global, true, Transform3D::identity()));
|
return Ok(Self::new(global, true, Transform3D::identity(), can_gc));
|
||||||
}
|
}
|
||||||
transform_to_matrix(s.to_string())
|
transform_to_matrix(s.to_string())
|
||||||
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
||||||
|
@ -95,20 +104,25 @@ impl DOMMatrixMethods for DOMMatrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-frommatrix
|
||||||
fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> {
|
fn FromMatrix(
|
||||||
dommatrixinit_to_matrix(other).map(|(is2D, matrix)| Self::new(global, is2D, matrix))
|
global: &GlobalScope,
|
||||||
|
other: &DOMMatrixInit,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> Fallible<DomRoot<Self>> {
|
||||||
|
dommatrixinit_to_matrix(other).map(|(is2D, matrix)| Self::new(global, is2D, matrix, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-fromfloat32array
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-fromfloat32array
|
||||||
fn FromFloat32Array(
|
fn FromFloat32Array(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
array: CustomAutoRooterGuard<Float32Array>,
|
array: CustomAutoRooterGuard<Float32Array>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<DOMMatrix>> {
|
) -> Fallible<DomRoot<DOMMatrix>> {
|
||||||
let vec: Vec<f64> = array.to_vec().iter().map(|&x| x as f64).collect();
|
let vec: Vec<f64> = array.to_vec().iter().map(|&x| x as f64).collect();
|
||||||
DOMMatrix::Constructor(
|
DOMMatrix::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -117,12 +131,13 @@ impl DOMMatrixMethods for DOMMatrix {
|
||||||
fn FromFloat64Array(
|
fn FromFloat64Array(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
array: CustomAutoRooterGuard<Float64Array>,
|
array: CustomAutoRooterGuard<Float64Array>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<DOMMatrix>> {
|
) -> Fallible<DomRoot<DOMMatrix>> {
|
||||||
let vec: Vec<f64> = array.to_vec();
|
let vec: Vec<f64> = array.to_vec();
|
||||||
DOMMatrix::Constructor(
|
DOMMatrix::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,13 @@ pub struct DOMMatrixReadOnly {
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl DOMMatrixReadOnly {
|
impl DOMMatrixReadOnly {
|
||||||
pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> {
|
pub fn new(
|
||||||
Self::new_with_proto(global, None, is2D, matrix, CanGc::note())
|
global: &GlobalScope,
|
||||||
|
is2D: bool,
|
||||||
|
matrix: Transform3D<f64>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<Self> {
|
||||||
|
Self::new_with_proto(global, None, is2D, matrix, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
|
@ -453,7 +458,7 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if s.is_empty() {
|
if s.is_empty() {
|
||||||
return Ok(Self::new(global, true, Transform3D::identity()));
|
return Ok(Self::new(global, true, Transform3D::identity(), can_gc));
|
||||||
}
|
}
|
||||||
transform_to_matrix(s.to_string())
|
transform_to_matrix(s.to_string())
|
||||||
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
.map(|(is2D, matrix)| Self::new_with_proto(global, proto, is2D, matrix, can_gc))
|
||||||
|
@ -466,20 +471,25 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-frommatrix
|
||||||
fn FromMatrix(global: &GlobalScope, other: &DOMMatrixInit) -> Fallible<DomRoot<Self>> {
|
fn FromMatrix(
|
||||||
dommatrixinit_to_matrix(other).map(|(is2D, matrix)| Self::new(global, is2D, matrix))
|
global: &GlobalScope,
|
||||||
|
other: &DOMMatrixInit,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> Fallible<DomRoot<Self>> {
|
||||||
|
dommatrixinit_to_matrix(other).map(|(is2D, matrix)| Self::new(global, is2D, matrix, can_gc))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-fromfloat32array
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-fromfloat32array
|
||||||
fn FromFloat32Array(
|
fn FromFloat32Array(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
array: CustomAutoRooterGuard<Float32Array>,
|
array: CustomAutoRooterGuard<Float32Array>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<DOMMatrixReadOnly>> {
|
) -> Fallible<DomRoot<DOMMatrixReadOnly>> {
|
||||||
let vec: Vec<f64> = array.to_vec().iter().map(|&x| x as f64).collect();
|
let vec: Vec<f64> = array.to_vec().iter().map(|&x| x as f64).collect();
|
||||||
DOMMatrixReadOnly::Constructor(
|
DOMMatrixReadOnly::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -488,12 +498,13 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
fn FromFloat64Array(
|
fn FromFloat64Array(
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
array: CustomAutoRooterGuard<Float64Array>,
|
array: CustomAutoRooterGuard<Float64Array>,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> Fallible<DomRoot<DOMMatrixReadOnly>> {
|
) -> Fallible<DomRoot<DOMMatrixReadOnly>> {
|
||||||
let vec: Vec<f64> = array.to_vec();
|
let vec: Vec<f64> = array.to_vec();
|
||||||
DOMMatrixReadOnly::Constructor(
|
DOMMatrixReadOnly::Constructor(
|
||||||
global,
|
global,
|
||||||
None,
|
None,
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
Some(StringOrUnrestrictedDoubleSequence::UnrestrictedDoubleSequence(vec)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -635,8 +646,8 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-translate
|
||||||
fn Translate(&self, tx: f64, ty: f64, tz: f64) -> DomRoot<DOMMatrix> {
|
fn Translate(&self, tx: f64, ty: f64, tz: f64, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).TranslateSelf(tx, ty, tz)
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).TranslateSelf(tx, ty, tz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale
|
||||||
|
@ -648,14 +659,15 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
originX: f64,
|
originX: f64,
|
||||||
originY: f64,
|
originY: f64,
|
||||||
originZ: f64,
|
originZ: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
) -> DomRoot<DOMMatrix> {
|
) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self)
|
DOMMatrix::from_readonly(&self.global(), self, can_gc)
|
||||||
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
.ScaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scalenonuniform
|
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-scalenonuniform
|
||||||
fn ScaleNonUniform(&self, scaleX: f64, scaleY: f64) -> DomRoot<DOMMatrix> {
|
fn ScaleNonUniform(&self, scaleX: f64, scaleY: f64, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).ScaleSelf(
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).ScaleSelf(
|
||||||
scaleX,
|
scaleX,
|
||||||
Some(scaleY),
|
Some(scaleY),
|
||||||
1.0,
|
1.0,
|
||||||
|
@ -666,67 +678,88 @@ impl DOMMatrixReadOnlyMethods for DOMMatrixReadOnly {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-scale3d
|
||||||
fn Scale3d(&self, scale: f64, originX: f64, originY: f64, originZ: f64) -> DomRoot<DOMMatrix> {
|
fn Scale3d(
|
||||||
DOMMatrix::from_readonly(&self.global(), self).Scale3dSelf(scale, originX, originY, originZ)
|
&self,
|
||||||
|
scale: f64,
|
||||||
|
originX: f64,
|
||||||
|
originY: f64,
|
||||||
|
originZ: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<DOMMatrix> {
|
||||||
|
DOMMatrix::from_readonly(&self.global(), self, can_gc)
|
||||||
|
.Scale3dSelf(scale, originX, originY, originZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotate
|
||||||
fn Rotate(&self, rotX: f64, rotY: Option<f64>, rotZ: Option<f64>) -> DomRoot<DOMMatrix> {
|
fn Rotate(
|
||||||
DOMMatrix::from_readonly(&self.global(), self).RotateSelf(rotX, rotY, rotZ)
|
&self,
|
||||||
|
rotX: f64,
|
||||||
|
rotY: Option<f64>,
|
||||||
|
rotZ: Option<f64>,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<DOMMatrix> {
|
||||||
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).RotateSelf(rotX, rotY, rotZ)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotatefromvector
|
||||||
fn RotateFromVector(&self, x: f64, y: f64) -> DomRoot<DOMMatrix> {
|
fn RotateFromVector(&self, x: f64, y: f64, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).RotateFromVectorSelf(x, y)
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).RotateFromVectorSelf(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-rotateaxisangle
|
||||||
fn RotateAxisAngle(&self, x: f64, y: f64, z: f64, angle: f64) -> DomRoot<DOMMatrix> {
|
fn RotateAxisAngle(
|
||||||
DOMMatrix::from_readonly(&self.global(), self).RotateAxisAngleSelf(x, y, z, angle)
|
&self,
|
||||||
|
x: f64,
|
||||||
|
y: f64,
|
||||||
|
z: f64,
|
||||||
|
angle: f64,
|
||||||
|
can_gc: CanGc,
|
||||||
|
) -> DomRoot<DOMMatrix> {
|
||||||
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).RotateAxisAngleSelf(x, y, z, angle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewx
|
||||||
fn SkewX(&self, sx: f64) -> DomRoot<DOMMatrix> {
|
fn SkewX(&self, sx: f64, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).SkewXSelf(sx)
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).SkewXSelf(sx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-skewy
|
||||||
fn SkewY(&self, sy: f64) -> DomRoot<DOMMatrix> {
|
fn SkewY(&self, sy: f64, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).SkewYSelf(sy)
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).SkewYSelf(sy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-multiply
|
||||||
fn Multiply(&self, other: &DOMMatrixInit) -> Fallible<DomRoot<DOMMatrix>> {
|
fn Multiply(&self, other: &DOMMatrixInit, can_gc: CanGc) -> Fallible<DomRoot<DOMMatrix>> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).MultiplySelf(other)
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).MultiplySelf(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipx
|
||||||
fn FlipX(&self) -> DomRoot<DOMMatrix> {
|
fn FlipX(&self, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
let is2D = self.is2D.get();
|
let is2D = self.is2D.get();
|
||||||
let flip = Transform3D::new(
|
let flip = Transform3D::new(
|
||||||
-1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
|
-1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
|
||||||
);
|
);
|
||||||
let matrix = flip.then(&self.matrix.borrow());
|
let matrix = flip.then(&self.matrix.borrow());
|
||||||
DOMMatrix::new(&self.global(), is2D, matrix)
|
DOMMatrix::new(&self.global(), is2D, matrix, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-flipy
|
||||||
fn FlipY(&self) -> DomRoot<DOMMatrix> {
|
fn FlipY(&self, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
let is2D = self.is2D.get();
|
let is2D = self.is2D.get();
|
||||||
let flip = Transform3D::new(
|
let flip = Transform3D::new(
|
||||||
1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
|
1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
|
||||||
);
|
);
|
||||||
let matrix = flip.then(&self.matrix.borrow());
|
let matrix = flip.then(&self.matrix.borrow());
|
||||||
DOMMatrix::new(&self.global(), is2D, matrix)
|
DOMMatrix::new(&self.global(), is2D, matrix, can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-inverse
|
||||||
fn Inverse(&self) -> DomRoot<DOMMatrix> {
|
fn Inverse(&self, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
DOMMatrix::from_readonly(&self.global(), self).InvertSelf()
|
DOMMatrix::from_readonly(&self.global(), self, can_gc).InvertSelf()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
// https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-transformpoint
|
||||||
fn TransformPoint(&self, point: &DOMPointInit) -> DomRoot<DOMPoint> {
|
fn TransformPoint(&self, point: &DOMPointInit, _can_gc: CanGc) -> DomRoot<DOMPoint> {
|
||||||
// Euclid always normalizes the homogeneous coordinate which is usually the right
|
// Euclid always normalizes the homogeneous coordinate which is usually the right
|
||||||
// thing but may (?) not be compliant with the CSS matrix spec (or at least is
|
// thing but may (?) not be compliant with the CSS matrix spec (or at least is
|
||||||
// probably not the behavior web authors will expect even if it is mathematically
|
// probably not the behavior web authors will expect even if it is mathematically
|
||||||
|
|
|
@ -501,8 +501,8 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
||||||
fn GetTransform(&self) -> DomRoot<DOMMatrix> {
|
fn GetTransform(&self, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
self.canvas_state.get_transform(&self.global())
|
self.canvas_state.get_transform(&self.global(), can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
||||||
|
|
|
@ -28,6 +28,7 @@ use crate::dom::canvaspattern::CanvasPattern;
|
||||||
use crate::dom::canvasrenderingcontext2d::CanvasRenderingContext2D;
|
use crate::dom::canvasrenderingcontext2d::CanvasRenderingContext2D;
|
||||||
use crate::dom::dommatrix::DOMMatrix;
|
use crate::dom::dommatrix::DOMMatrix;
|
||||||
use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope;
|
use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope;
|
||||||
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct PaintRenderingContext2D {
|
pub struct PaintRenderingContext2D {
|
||||||
|
@ -121,8 +122,8 @@ impl PaintRenderingContext2DMethods for PaintRenderingContext2D {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform
|
||||||
fn GetTransform(&self) -> DomRoot<DOMMatrix> {
|
fn GetTransform(&self, can_gc: CanGc) -> DomRoot<DOMMatrix> {
|
||||||
self.context.GetTransform()
|
self.context.GetTransform(can_gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
// https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform
|
||||||
|
|
|
@ -178,11 +178,11 @@ impl TestBindingMethods for TestBinding {
|
||||||
TestEnum::_empty
|
TestEnum::_empty
|
||||||
}
|
}
|
||||||
fn SetEnumAttribute(&self, _: TestEnum) {}
|
fn SetEnumAttribute(&self, _: TestEnum) {}
|
||||||
fn InterfaceAttribute(&self) -> DomRoot<Blob> {
|
fn InterfaceAttribute(&self, can_gc: CanGc) -> DomRoot<Blob> {
|
||||||
Blob::new(
|
Blob::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
fn SetInterfaceAttribute(&self, _: &Blob) {}
|
||||||
|
@ -324,11 +324,11 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> {
|
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> {
|
||||||
Some(TestEnum::_empty)
|
Some(TestEnum::_empty)
|
||||||
}
|
}
|
||||||
fn GetInterfaceAttributeNullable(&self) -> Option<DomRoot<Blob>> {
|
fn GetInterfaceAttributeNullable(&self, can_gc: CanGc) -> Option<DomRoot<Blob>> {
|
||||||
Some(Blob::new(
|
Some(Blob::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
|
||||||
|
@ -419,11 +419,11 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn ReceiveEnum(&self) -> TestEnum {
|
fn ReceiveEnum(&self) -> TestEnum {
|
||||||
TestEnum::_empty
|
TestEnum::_empty
|
||||||
}
|
}
|
||||||
fn ReceiveInterface(&self) -> DomRoot<Blob> {
|
fn ReceiveInterface(&self, can_gc: CanGc) -> DomRoot<Blob> {
|
||||||
Blob::new(
|
Blob::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn ReceiveAny(&self, _: SafeJSContext) -> JSVal {
|
fn ReceiveAny(&self, _: SafeJSContext) -> JSVal {
|
||||||
|
@ -468,11 +468,11 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn ReceiveSequence(&self) -> Vec<i32> {
|
fn ReceiveSequence(&self) -> Vec<i32> {
|
||||||
vec![1]
|
vec![1]
|
||||||
}
|
}
|
||||||
fn ReceiveInterfaceSequence(&self) -> Vec<DomRoot<Blob>> {
|
fn ReceiveInterfaceSequence(&self, can_gc: CanGc) -> Vec<DomRoot<Blob>> {
|
||||||
vec![Blob::new(
|
vec![Blob::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
)]
|
)]
|
||||||
}
|
}
|
||||||
fn ReceiveUnionIdentity(
|
fn ReceiveUnionIdentity(
|
||||||
|
@ -534,11 +534,11 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn ReceiveNullableEnum(&self) -> Option<TestEnum> {
|
fn ReceiveNullableEnum(&self) -> Option<TestEnum> {
|
||||||
Some(TestEnum::_empty)
|
Some(TestEnum::_empty)
|
||||||
}
|
}
|
||||||
fn ReceiveNullableInterface(&self) -> Option<DomRoot<Blob>> {
|
fn ReceiveNullableInterface(&self, can_gc: CanGc) -> Option<DomRoot<Blob>> {
|
||||||
Some(Blob::new(
|
Some(Blob::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
BlobImpl::new_from_bytes(vec![], "".to_owned()),
|
||||||
CanGc::note(),
|
can_gc,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
fn ReceiveNullableObject(&self, cx: SafeJSContext) -> Option<NonNull<JSObject>> {
|
fn ReceiveNullableObject(&self, cx: SafeJSContext) -> Option<NonNull<JSObject>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue