Skip to content

Commit

Permalink
avm2: Remove last use of coerce_to_object outside of core code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Oct 22, 2024
1 parent 92079e6 commit 2b83e3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/src/avm2/globals/flash/display/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions core/src/avm2/globals/flash/geom/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ pub fn set_matrix<'gc>(
this: Object<'gc>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, 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);
Expand Down

0 comments on commit 2b83e3a

Please sign in to comment.