core: Unconstructed display objects should be `null`, not `undefined`.

This commit is contained in:
David Wendt 2022-12-27 19:34:07 -05:00 committed by kmeisthax
parent cbf2e94aba
commit 7eb0ca8ecc
10 changed files with 14 additions and 14 deletions

View File

@ -979,7 +979,7 @@ impl<'gc> BitmapData<'gc> {
pub fn object2(&self) -> Avm2Value<'gc> {
self.avm2_object
.map(|o| o.into())
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
pub fn init_object2(&mut self, object: Avm2Object<'gc>) {

View File

@ -1535,7 +1535,7 @@ pub trait TDisplayObject<'gc>:
}
fn object2(&self) -> Avm2Value<'gc> {
Avm2Value::Undefined // TODO: See above.
Avm2Value::Undefined // TODO: See above. Also, unconstructed objects should return null.
}
fn set_object2(&mut self, _mc: MutationContext<'gc, '_>, _to: Avm2Object<'gc>) {}

View File

@ -688,7 +688,7 @@ impl<'gc> TDisplayObject<'gc> for Avm2Button<'gc> {
.read()
.object
.map(Avm2Value::from)
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&mut self, mc: MutationContext<'gc, '_>, to: Avm2Object<'gc>) {

View File

@ -330,7 +330,7 @@ impl<'gc> TDisplayObject<'gc> for Bitmap<'gc> {
.read()
.avm2_object
.map(|o| o.into())
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&mut self, mc: MutationContext<'gc, '_>, to: Avm2Object<'gc>) {

View File

@ -322,7 +322,7 @@ pub trait TDisplayObjectContainer<'gc>:
//TODO: This is an awful, *awful* hack to deal with the fact
//that unloaded AVM1 clips see their parents, while AVM2 clips
//don't.
if !matches!(child.object2(), Avm2Value::Undefined) {
if !matches!(child.object2(), Avm2Value::Null) {
child.set_parent(context.gc_context, None);
}
}
@ -371,7 +371,7 @@ pub trait TDisplayObjectContainer<'gc>:
removed.unload(context);
if !matches!(removed.object2(), Avm2Value::Undefined) {
if !matches!(removed.object2(), Avm2Value::Null) {
removed.set_parent(context.gc_context, None);
}

View File

@ -1482,7 +1482,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
/// Construct objects placed on this frame.
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc, '_>) {
if context.is_action_script_3() && matches!(self.object2(), Avm2Value::Undefined) {
if context.is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
self.construct_as_avm2_object(context, (*self).into());
self.on_construction_complete(context);
}
@ -1535,7 +1535,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
.object
.and_then(|o| o.as_avm2_object())
.map(Avm2Value::from)
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&mut self, mc: MutationContext<'gc, '_>, to: Avm2Object<'gc>) {

View File

@ -131,7 +131,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc, '_>) {
if context.is_action_script_3() && matches!(self.object2(), Avm2Value::Undefined) {
if context.is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
let shape_constr = context.avm2.classes().shape;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
@ -235,7 +235,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
.read()
.avm2_object
.map(Avm2Value::from)
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&mut self, mc: MutationContext<'gc, '_>, to: Avm2Object<'gc>) {

View File

@ -2278,7 +2278,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
// it's exempted from frame construction.
if context.is_action_script_3() && self.frames_loaded() >= 1 {
let is_load_frame = !self.0.read().initialized();
let needs_construction = if matches!(self.object2(), Avm2Value::Undefined) {
let needs_construction = if matches!(self.object2(), Avm2Value::Null) {
self.allocate_as_avm2_object(context, (*self).into());
true
} else {
@ -2525,7 +2525,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
.object
.and_then(|o| o.as_avm2_object())
.map(Avm2Value::from)
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&mut self, mc: MutationContext<'gc, '_>, to: Avm2Object<'gc>) {

View File

@ -257,7 +257,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
.read()
.avm2_object
.map(|o| o.into())
.unwrap_or(Avm2Value::Undefined)
.unwrap_or(Avm2Value::Null)
}
fn set_object2(&mut self, mc: MutationContext<'gc, '_>, to: Avm2Object<'gc>) {

View File

@ -392,7 +392,7 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
}
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc, '_>) {
if context.is_action_script_3() && matches!(self.object2(), Avm2Value::Undefined) {
if context.is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
let video_constr = context.avm2.classes().video;
let mut activation = Avm2Activation::from_nothing(context.reborrow());
match Avm2StageObject::for_display_object_childless(