Skip to content

Commit 9078d76

Browse files
chore: Add comments explaining why we skip display object initializer calls
1 parent 66f7556 commit 9078d76

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

core/src/display_object/morph_shape.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
119119
if self.movie().is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
120120
let class = context.avm2.classes().morphshape;
121121
let object = Avm2StageObject::for_display_object(context.gc(), self.into(), class);
122+
// We don't need to call the initializer method, as AVM2 can't link
123+
// a custom class to a MorphShape, and the initializer method for
124+
// MorphShape itself is a no-op
122125
self.set_object2(context, object.into());
123126

124127
self.on_construction_complete(context);

core/src/display_object/stage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
766766

767767
// TODO: Replace this when we have a convenience method for constructing AVM2 native objects.
768768
// TODO: We should only do this if the movie is actually an AVM2 movie.
769-
// This is necessary for EventDispatcher super-constructor to run.
769+
// This is necessary for DisplayObject and EventDispatcher super-constructors to run.
770770
let global_domain = context.avm2.stage_domain();
771771
let mut activation = Avm2Activation::from_domain(context, global_domain);
772772
let avm2_stage = Avm2StageObject::for_display_object_childless(

core/src/display_object/text.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
272272
if self.movie().is_action_script_3() {
273273
let statictext = context.avm2.classes().statictext;
274274
let object = Avm2StageObject::for_display_object(context.gc(), self.into(), statictext);
275+
// We don't need to call the initializer method, as AVM2 can't link
276+
// a custom class to a StaticText, and the initializer method for
277+
// StaticText itself is a no-op
275278
self.set_object2(context, object.into());
276279

277280
self.on_construction_complete(context);

core/src/display_object/video.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
451451
let video_constr = context.avm2.classes().video;
452452
let object =
453453
Avm2StageObject::for_display_object(context.gc(), self.into(), video_constr);
454+
// We don't need to call the initializer method, as AVM2 can't link
455+
// a custom class to a Video, and the initializer method for Video
456+
// itself only sets the size of the Video- the Video already has the
457+
// correct size at this point.
454458

455459
self.set_object2(context, object.into());
456460

0 commit comments

Comments
 (0)