-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avm1: Remove incorrect properties from display object prototypes (fix #768) #6921
Conversation
…rs#768) Remove `_root`, `_parent` and `_global` from `MovieClip.prototype`. Instead, these are "magic" properties similar to `_x` and `_y`. Add `StageObject::resolve_path_property` to handle these, alongside the `_levelN` property. Fixes ruffle-rs#768.
* Avoid an extraneous check to `ScriptObject::has_own_property`. * Avoid magic property branches if property name does not start with `_`.
`MovieClip` and others do not have a `toString`; instead, stage objects are special cased to return their path when coerced to string.
This module is now mostly empty, so move the items up to `globals`. `getDepth` was the only shared method, so declare this property inline in each display object type. `Video` was also incorrectly declaring `getDepth`.
} | ||
|
||
// 2) Path properties such as `_root`, `_parent`, `_levelN` (obeys case sensitivity) | ||
let magic_property = name.starts_with(b'_'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this check if for performance only, since it doesn't affect the lookup logic at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, seemed a little wasteful to do extra hashes and string compares if we can tell quickly that it isn't a _
property. Haven't measured if it makes a noticeable difference though.
"[type Function]".into() | ||
} else { | ||
"[type Object]".into() | ||
if let Some(object) = object.as_display_object() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's another argument for #6548 (comment).
LGTM, I haven't found any regression in my testings. 👍 Checking the other related issues:
|
_root
,_global
, and_parent
fromMovieClip.prototype
and others.StageObject::resolve_path_property
.StageObject::get_local_stored
a bit.toString
fromMovieClip.prototype
and others. StageObjects instead naturally use their path when coerced to string.avm1::globals::display_object
is mostly empty, so remove it. Move the items up one level intoglobals
.Video.getDepth
declaration.Fixes #768.