From f3cc4a6fa61a94777b8210f660a7eacf49b9e48d Mon Sep 17 00:00:00 2001 From: Lord-McSweeney Date: Sun, 6 Oct 2024 22:25:19 -0700 Subject: [PATCH] avm2: Remove last use of `coerce_to_object` outside of core code --- core/src/avm2/globals/flash/display/display_object.rs | 10 +++++++++- core/src/avm2/globals/flash/geom/transform.rs | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/avm2/globals/flash/display/display_object.rs b/core/src/avm2/globals/flash/display/display_object.rs index dd630d0f9644..3ed49d2d5bdf 100644 --- a/core/src/avm2/globals/flash/display/display_object.rs +++ b/core/src/avm2/globals/flash/display/display_object.rs @@ -768,7 +768,15 @@ pub fn set_transform<'gc>( // FIXME - consider 3D matrix and pixel bounds let matrix = transform .get_public_property("matrix", activation)? - .coerce_to_object(activation)?; + .as_object(); + + let Some(matrix) = matrix else { + // FP seems to not do anything when setting to a Transform with a null matrix, + // but we don't actually support setting the matrix to null anyway + // (see the comment in `flash::geom::transform::set_matrix`) + return Ok(Value::Undefined); + }; + let color_transform = transform .get_public_property("colorTransform", activation)? .as_object() diff --git a/core/src/avm2/globals/flash/geom/transform.rs b/core/src/avm2/globals/flash/geom/transform.rs index a18bdfe30c9b..50f197b4b249 100644 --- a/core/src/avm2/globals/flash/geom/transform.rs +++ b/core/src/avm2/globals/flash/geom/transform.rs @@ -80,6 +80,9 @@ pub fn set_matrix<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { + // TODO: Despite what the docs say, FP accepts a null matrix here, and returns + // null when trying to get the matrix- but the DO's actual transform matrix will + // remain its previous non-null value. let matrix = object_to_matrix(args.get_object(activation, 0, "value")?, activation)?; let dobj = get_display_object(this, activation)?; dobj.set_matrix(activation.context.gc_context, matrix);