Commit Graph

55 Commits

Author SHA1 Message Date
David Wendt f33976f4c0 avm2: Store symbol / class relationships using the class constructor, not the prototype. 2021-04-23 00:26:10 -07:00
David Wendt 9b19cc1570 Store the movie associated with a given symbol being constructed. 2021-04-23 00:26:10 -07:00
David Wendt 282508a281 core: Make the AVM2 constructor registry global 2021-04-23 00:26:10 -07:00
David Wendt 555d97006a core: Add an AVM2 constructor registry 2021-04-23 00:26:10 -07:00
David Wendt 78c519cce0 avm2: Don't except when creating a dynamic TextField. 2021-03-19 12:39:57 -07:00
David Wendt 6dc96f5d58 core: Allow instantiation of videos 2021-02-16 19:03:48 -08:00
Adrian Wielgosik 1454e0d126
core: Don't copy Glyphs around; make Font methods take &self 2021-02-04 11:54:17 -08:00
relrelb abfa08c964 core: Allow exports to be overridden
Per SWF19 p.54, the latter export name is used.
2021-01-15 11:48:29 -08:00
Mike Welsh 3c31336c93 chore: Rename some getters 2021-01-13 15:38:38 -08:00
Moulins f394953331 core: Reimplement `Object.registerClass`.
Maintain an external mapping from symbol names to registered
constructors to properly handle `registerClass` being called on
not-yet-available symbols.

SWFs v6 and v7+ each have a separate global mapping, with
different case sensitivities.

Also returns the correct boolean value to the AVM.

Fixes #2343 and #1864.
2021-01-13 15:38:38 -08:00
Mike Welsh 9b6295f33a render: Pass library to RenderBackend::register_shape (fix #2037)
Pass the movie library to `register_shape` methods so that bitmap
charcter IDs can be resolved immediately on the proper SWF.

This fixes #2037, which cause incorrect bitmaps to be used when
multiple movies were loaded.
2020-12-31 13:10:21 -08:00
Mike Welsh 326a5b6212 core: Move device font to Library (fix #1995) 2020-12-17 23:20:22 -08:00
Mike Welsh 41f77fade1 avm1: Export names are case insensitive
Fixes capital letters not appearing in #1346
2020-10-21 17:09:31 -07:00
David Wendt d27360b282 avm2: Enable lazy initialization for ABCs that request it. 2020-10-17 03:32:09 -07:00
David Wendt 0d1676afda avm2: Create a separate domain for each loaded movie and pull symbols out of each. 2020-10-17 03:32:09 -07:00
Mike Welsh 2c9cf6802d core: Squelch false AS3 error before initial SWF loads 2020-10-10 19:28:01 -07:00
David Wendt 1a10f1e004 avm2: Lock old movies (SWFv8 and earlier) to always use AVM1 2020-10-06 06:03:22 -07:00
David Wendt 7c719bfb0c Only the first tag in a SWF file should be trusted to deliver file attributes. 2020-10-06 06:03:22 -07:00
David Wendt ddccede9d3 avm2: Make VM type non-optional.
This has the side effect of forcing the AVM check to happen at the time of library construction, which is already very early on in movie loading.
2020-10-06 06:03:22 -07:00
David Wendt e2f21d0a7d avm2: Retire old references to the "VM tendency" nomenclature 2020-10-06 06:03:22 -07:00
David Wendt a70e1be466 Add code to instantiate AVM2 movie clips correctly.
This also includes several bits to build an effective VM barrier.
2020-10-06 06:03:22 -07:00
David Wendt 247e79e61a core: Track the VM each movie has pledged to execute on.
This uses a "VM tendency" system wherein the presence of `DoAction` or `DoInitAction` tags defaults the movie to AVM1, while the presence of `DoABC` defaults to AVM2. The presence of a `FileAttributes` tag allows setting the VM tendency in the same manner using it's AS3 bit.

Particularly malformed SWFs may cause execution issues if Flash Player uses a dramatically different system from this.
2020-10-06 06:03:22 -07:00
David Wendt 361ea1f774 Index fonts by font name, boldness, and italicization.
This involves a new struct called a `FontDescriptor` which is generated whenever a font is registered and used to index the font in the library. When a font is requested, it goes through the descriptor system to get found.
2020-06-20 19:26:43 -04:00
David Wendt 4a2fac28d1 Add iterator for text spans 2020-06-20 19:16:17 -04:00
Nathan Adams d850443c84 avm1: Refactor to expose `avm, context` in `post_instantiate` 2020-02-29 23:05:15 +01:00
David Wendt 5ce499d11e Add separate libraries for each loaded movie. 2020-02-21 23:57:56 -05:00
Nathan Adams f6f358b4de avm1: Expose TextFields and allow setting their .text 2019-12-19 10:19:43 -08:00
Mike Welsh dae3e27fb3 avm1: Rename Library::instantiate_by_id 2019-12-17 03:27:05 -08:00
Mike Welsh 009da39f12 avm1: Implement MovieClip.attachMovie 2019-12-17 03:00:56 -08:00
Mike Welsh 0f3bad8f1b core: Wrap Font in a Gc 2019-12-17 02:48:55 -08:00
Mike Welsh 289e0b8aff core: Handle ExportAssets SWF tag 2019-12-16 19:32:34 -08:00
Mike Welsh 30ecbd0ecc core: Use enum_trait_object for DisplayObject 2019-12-10 01:36:01 -08:00
Mike Welsh 23ca66a7e3 avm1: Use enum_trait_object for avm1::Object 2019-12-10 01:36:01 -08:00
David Wendt d25bdbacf8 Separate `Object` into an interface trait and a standard implementation. Host object implementations may bypass `ScriptObject` and directly interface with the AVM using this trait.
Note that host objects that do so will *not* have access to their standard representation from within member functions - you will need to extend the interface to accomodate for them. This is due to long-standing limitations with type IDs and downcasting with types that bear lifetimes - it's entirely an unsafe operation and exposing such a facility to safe Rust is unsound. However, this will at least let us separate out several things from ScriptObject that don't need to be there for the time being.
2019-11-26 14:51:05 -05:00
David Wendt 2f965d1c64 First stab at moving system builtins to explicit prototypes 2019-11-26 14:51:03 -05:00
Mike Welsh e3d0d9031d core: Handle empty JPEGTables tags (fix #116) 2019-11-11 17:08:08 -05:00
Mike Welsh 09fa755405 core: Make Library::device_font optional 2019-10-26 02:20:42 -07:00
Mike Welsh 4aec120ffb core: Add Bitmap display object
Converts the Bitmap character to a proper display object. This can
be instantiated directly in a PlaceObject tag in SWFv9 movies,
compared to the previous versions which indirectly references
bitmaps from Shape tags.
2019-10-11 16:33:58 -07:00
Mike Welsh eded29ce6d text: Add dummy implementation of device text
Embed an SWF version of Noto Sans (core/assets/*) into the player.
The player will load this font and use it to render device text.

This is a quicky implementation to get dynamic device text
rendering.
2019-10-07 23:23:45 -07:00
Mike Welsh de1cedb653 core: Initial EditText implementation 2019-10-07 23:23:45 -07:00
Nathan Adams 2eca394a58 Implemented `typeof` for movieclips and functions 2019-08-31 14:09:37 +02:00
Nathan Adams 2fd7d456a4 Movie clip access from AS. Functions are now callable objects, and receive `this`. 2019-08-30 20:37:48 +02:00
Mike Welsh 5998876271 core: Don't panic on missing characters in button 2019-08-22 21:54:00 -07:00
Mike Welsh 4666d211a7 core: Add dyn to fix Rust 1.37 warnings
Omitting dyn on trait objects now emits a warning, so add missing
dyn where necessary.
2019-08-15 13:54:20 -07:00
Mike Welsh a3998b657b core: Remove invalid JPEG data from DefineBitsJPEG
DefineBitsJPEG tags can have some extraneous bytes inside the
stream. Splice these out when decoding the JPEG.

TODO: Docs say this should only happen for SWF versions before 8?
2019-08-12 15:45:40 -07:00
Mike Welsh 725cdae6c5 Begin AVM1 cleanup 2019-08-08 15:58:45 -07:00
Mike Welsh ce5faefe1f Work 2019-08-08 15:57:10 -07:00
Mike Welsh 79b3a7007d core: Initial morph shape implementation 2019-05-12 12:55:48 -04:00
Mike Welsh 7983d9eb96 Clean up DisplayObject instantiation 2019-05-07 03:22:58 -07:00
Mike Welsh 1a4734896d Event sounds and text on web 2019-05-05 15:55:27 -07:00