Skip to content

Commit 2b83e3a

Browse files
avm2: Remove last use of coerce_to_object outside of core code
1 parent 92079e6 commit 2b83e3a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

core/src/avm2/globals/flash/display/display_object.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,15 @@ pub fn set_transform<'gc>(
768768
// FIXME - consider 3D matrix and pixel bounds
769769
let matrix = transform
770770
.get_public_property("matrix", activation)?
771-
.coerce_to_object(activation)?;
771+
.as_object();
772+
773+
let Some(matrix) = matrix else {
774+
// FP seems to not do anything when setting to a Transform with a null matrix,
775+
// but we don't actually support setting the matrix to null anyway
776+
// (see the comment in `flash::geom::transform::set_matrix`)
777+
return Ok(Value::Undefined);
778+
};
779+
772780
let color_transform = transform
773781
.get_public_property("colorTransform", activation)?
774782
.as_object()

core/src/avm2/globals/flash/geom/transform.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ pub fn set_matrix<'gc>(
8080
this: Object<'gc>,
8181
args: &[Value<'gc>],
8282
) -> Result<Value<'gc>, Error<'gc>> {
83+
// TODO: Despite what the docs say, FP accepts a null matrix here, and returns
84+
// null when trying to get the matrix- but the DO's actual transform matrix will
85+
// remain its previous non-null value.
8386
let matrix = object_to_matrix(args.get_object(activation, 0, "value")?, activation)?;
8487
let dobj = get_display_object(this, activation)?;
8588
dobj.set_matrix(activation.context.gc_context, matrix);

0 commit comments

Comments
 (0)