Commit Graph

929 Commits

Author SHA1 Message Date
dependabot-preview[bot] e22da9ac4c build(deps): bump quote from 1.0.4 to 1.0.5
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.4...1.0.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 14:42:48 +00:00
Mike Welsh 031f5d6501 core: Avoid undefined behavior in f64_to_wrapping functions 2020-05-13 02:41:50 -07:00
Mike Welsh b59140ee01 render: Add support for GIF decoding in DefineBitsJPEG tags 2020-05-13 00:15:09 -07:00
Mike Welsh 5d84d33710 render: Handle PNG data in DefineBitsJPEG tags (fix #530) 2020-05-13 00:15:09 -07:00
dependabot-preview[bot] f68edb37b5 build(deps): bump syn from 1.0.19 to 1.0.20
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.19...1.0.20)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-12 00:10:19 -07:00
Nathan Adams b82b869950 core: Don't panic when NullNavigatorBackend can't do futures 2020-05-11 01:09:07 -07:00
Nathan Adams 2343074c56 core: Make RenderBackend downcastable 2020-05-11 01:09:07 -07:00
Nathan Adams edcd1e6d65 core: Add keyboard shortcut to dump every variable (ctrl+alt+V, same as Flash Player) 2020-05-10 23:39:54 -07:00
Nathan Adams c787e28fcd render: Introduce a DistilledShape and use that instead of swf::Shape for the rendering API 2020-05-10 22:03:56 -07:00
Nathan Adams 5767fb1772 swf: Added utility method for `Color::from_rgb(rgb, alpha)` 2020-05-10 22:03:56 -07:00
Nathan Adams 601715aa19 render: Merge begin_frame and clear as they're always called together 2020-05-10 22:03:56 -07:00
dependabot-preview[bot] 60ca1da468 build(deps): bump syn from 1.0.18 to 1.0.19
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.18...1.0.19)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 03:12:14 +00:00
Nathan Adams 054e6f1ac6 chore: Fix new rust check lint about std::mem::replace 2020-05-10 03:29:25 -07:00
Nathan Adams bac99368be chore: Fix new clippy lints about cloning 2020-05-10 03:29:25 -07:00
dependabot-preview[bot] a81adfa336 build(deps): bump num_enum from 0.4.3 to 0.5.0
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.4.3 to 0.5.0.
- [Release notes](https://github.com/illicitonion/num_enum/releases)
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.3...0.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-10 10:27:38 +00:00
dependabot-preview[bot] 08a786a213 build(deps): bump libflate from 0.1.27 to 1.0.0
Bumps [libflate](https://github.com/sile/libflate) from 0.1.27 to 1.0.0.
- [Release notes](https://github.com/sile/libflate/releases)
- [Commits](https://github.com/sile/libflate/compare/0.1.27...1.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-05 08:12:26 +00:00
Nathan Adams 47a44a5fe8 desktop: Prime window with known width/height of the movie 2020-05-04 16:07:38 -07:00
Nathan Adams 51d9f3ef36 core: Change Player::new to take in a SwfMovie, not &[u8] 2020-05-04 16:07:38 -07:00
Nathan Adams 84f6b4d06e core: Set init_object values after prototype but before constructor 2020-05-03 12:46:55 -07:00
Nathan Adams 96d1f8fd30 tests: Add test for order of init_object vs constructor when attaching movies 2020-05-03 12:46:55 -07:00
Nathan Adams 0152f384ea core: Run any on(construct) events at the appropriate time 2020-05-03 12:46:55 -07:00
Nathan Adams 2b9219e8f9 tests: Add test for undocumented on(construct) property (note: this swf is hand-crafted) 2020-05-03 12:46:55 -07:00
Mike Welsh f09bd8c079 core: Clean up tick/render loop
Don't call `render` from `Player::tick`; instead, require the
frontends to explicitly call `render` when they wish to redraw.
The frontend can query `Player::needs_render` to see if the stage
is dirty and needs a redraw. Update desktop and web to use this
new method.

This fits better with the newer winit event loop model, which
requires explicitly calling `request_redraw`, and should avoid
spurious renders.
2020-05-02 04:25:21 -07:00
Mike Welsh 6339c74d67
render: Add wgpu backend (merge #527)
Adds a wgpu-rs render backend.
2020-05-02 03:42:05 -07:00
Nathan Adams 8384847084 avm1: Deleting on a non-object is a silent failure & warning, not a hard error 2020-04-30 14:18:54 -07:00
dependabot-preview[bot] 04660a9540 build(deps): bump quote from 1.0.3 to 1.0.4
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.3 to 1.0.4.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.3...1.0.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-30 21:18:17 +00:00
Nathan Adams 99d15aef0d render: Cache color transforms in wgpu backend, don't re-upload unchanged values 2020-04-30 16:33:41 +02:00
dependabot-preview[bot] 014df249a8 build(deps): bump jpeg-decoder from 0.1.18 to 0.1.19
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.1.18 to 0.1.19.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-28 04:54:23 +00:00
Mike Welsh 8aa12d181f render: Remove RenderBackend::draw_pause_overlay 2020-04-27 04:45:53 -07:00
David Wendt ed29b1c3bb It turns out Macromedia just used an undocumented but user-modifiable property called `__constructor__` to store the constructor.
A previous version of this PR (whose history has been scrubbed, but go check 918d88abe68b7467a4194738b95e5bf3e9b5bb72 if you're curious) implemented a new `TObject` property which basically every line of code that dealt with object construction had to populate. It was terrible.
2020-04-25 14:37:24 -04:00
David Wendt bb879870ec Add test for the constructor property on v6 and v7 SWFs 2020-04-25 13:25:21 -04:00
Nathan Adams b3322acc8c tests: Copy as2_super_and_this test for manual prototype setting, used by mx (currently broken) 2020-04-25 13:25:20 -04:00
David Wendt aaa6f481ac Add a v6 version of the super-and-this test, which is exactly the same source compiled to SWF version 6. 2020-04-25 13:25:20 -04:00
David Wendt 17d96a0fa6 Constructing a new object sets `constructor` on that object for SWFv6 and lower. 2020-04-25 13:25:20 -04:00
David Wendt b8fd1eac9c Invoke virtual setters defined in the prototype chain.
This is accomplished via two new `TObject` methods: `has_own_virtual` and `call_setter`. If an object does not contain it's own version of a property, it will first crawl the prototype chain to see if there is an overwritable virtual. If so, it will invoke that prototype's setter.

A bit of borrow finangling was required to do this; `super` now no longer caches it's proto and constr values and instead dynamically constructs them. This also means it can't be downcasted to `Executable` anymore.

With this commit, virtual setters and super-setters now work correctly.
2020-04-25 13:25:19 -04:00
David Wendt 35197f889f `Property.set` should return a `ReturnValue` as it can potentially execute AVM code 2020-04-25 13:25:19 -04:00
David Wendt e76ba4de87 Method calls on `super` objects should substitute the child object instead of itself as `this`. 2020-04-25 13:25:19 -04:00
David Wendt 869cbd17da Extend `as2_super_and_this` to cover accessing object properties in super-methods, super-getters, and super-setters. 2020-04-25 13:25:18 -04:00
David Wendt 9c5cd79e2c Refactor how `SuperObject` works to use `base_proto` and avoid handing copies of itself as `this`.
This allows supercalled functions to properly read and mutate the object they were called on.
2020-04-25 13:25:18 -04:00
David Wendt f3b3db51cb Alter AVM1 to keep track of each function call's *base prototype*: the object from which a particular function was retrieved from.
A base prototype is only applicable in cases where a method is being called as a property on an object. Bare function calls, `apply`/`call` calls, and so on do not generate a base prototype.

We also add a convenience method, `call_method`, to all objects. This method automatically calculates the correct base prototype for a method call on an object, which is the only operation that should generate base prototypes.
2020-04-25 13:25:18 -04:00
David Wendt 15a19f4cf8 Add test from @Dinnerbone that checks to make sure super-called functions can still initialize the object they are a part of. 2020-04-25 13:25:17 -04:00
dependabot-preview[bot] c5a8402eae build(deps): bump syn from 1.0.17 to 1.0.18
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.17 to 1.0.18.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.17...1.0.18)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-25 10:19:18 +00:00
Mike Welsh fd114959f9 core: Fix regressions from init order changes in #498
Revert to the old action queue method of popping off actions in a
loop, as new actions can be queued while iterating. Store proto
changes in a separate queue to maintain the high priority behavior.
2020-04-25 03:06:54 -07:00
Mike Welsh bad34c4d8f tests: Fix tests for regressions caused by #498
Changes to the action queue caused actions queued during other
actions to run too late. These regressions weren't caught by the
tests because many of the goto tests ran for more frames than was
necessary, allowing the late actions to still run.
2020-04-25 03:06:54 -07:00
Mike Welsh c1dc69c6b7 chore: rustfmt 2020-04-24 22:16:16 -07:00
dependabot-preview[bot] 24a26541a3 build(deps): bump smallvec from 1.3.0 to 1.4.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.3.0...v1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-24 12:20:39 +00:00
Nathan Adams b43d0c2430 core: Pass SwfMovies along to empty movie clips 2020-04-21 05:49:25 -07:00
Nathan Adams a673e7108d tests: Add test for movieclip.createEmptyMovieClip().attachMovie()` 2020-04-21 05:49:25 -07:00
Nathan Adams 8b34fbdd81 chore: Removed debug code from a test 2020-04-21 05:48:17 -07:00
Nathan Adams 330e6b40f0 core: post_instantiation should happen after properties are set, but before first frame or actions 2020-04-17 23:48:58 -07:00
Nathan Adams 9318290336 core: Execute init actions immediately, do not queue them up
Clip initializers can and will influence how the next clips are loaded, and must execute before that

This fixes #418
2020-04-17 23:48:58 -07:00
Nathan Adams fe6b79a9b7 chore: Make avm1 accessible to MovieClip::preload 2020-04-17 23:48:58 -07:00
Nathan Adams 46d31548b0 chore: Move MovieClipData::do_init_action to MovieClip::do_init_action
No functional changes, just replaces `self` with `self.0.read()` and removed `self_display_object` argument
2020-04-17 23:48:58 -07:00
Nathan Adams c0d1dec7dd chore: Move MovieClipData::preload to MovieClip::preload
No functional changes, just replaced `self` with `self.0.read/write`.
2020-04-17 23:48:58 -07:00
Nathan Adams 601fcbfebd core: Queue up changes of movieclip prototypes, don't execute it immediately (but at a higher priority than normal actions) 2020-04-17 23:48:58 -07:00
Nathan Adams 6b48e77b61 avm1: Add TObject::set_proto 2020-04-17 23:48:58 -07:00
Nathan Adams 6316d7e0b3 tests: Add (currently failing) test for init order when combined with register_class 2020-04-17 23:48:58 -07:00
Nathan Adams d0fd26a89c avm1: Fix panic with [].unshift(x) 2020-04-17 21:17:13 -07:00
Nathan Adams bf639e1802 avm1: Don't crash when enumerating non-objects, it's a silent fail 2020-04-15 05:26:09 -07:00
Mike Welsh b7d464f367 chore: Bump enumset to 1.0.0 2020-04-13 04:14:29 -07:00
dependabot-preview[bot] 2146c42863 build(deps): bump smallvec from 1.2.0 to 1.3.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.2.0...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-09 21:19:11 +00:00
Mike Welsh 47e936fcc2 tests: Add tests for Array.sort 2020-04-01 18:46:12 -07:00
Mike Welsh bd0d2031bc avm1: Implement Array.sort and constants 2020-04-01 18:46:12 -07:00
Mike Welsh 2bdbac9247 tests: Test that Color has no effect when target is undefined 2020-03-30 01:09:05 -07:00
Mike Welsh e47c2aa356 avm1: Color object has no effect if target is undefined/empty 2020-03-30 01:01:37 -07:00
Mike Welsh d5bd7c2dd8 avm1: Math.round rounds towards infinity 2020-03-29 18:44:28 -07:00
Mike Welsh 0c0d3dfd41 core: Add Navigator::time_since_launch to use for getTimer
Change `ActionGetTime` (`getTimer`) to use a new backend method.
This allows it to return updated times if it is called multiple
times in a single frame. This fixes hangs caused by games that use
busy-loop "frame limiter" code.
2020-03-28 22:28:07 -07:00
Mike Welsh f7375c3700 avm1: Use `PropertyMap::get_index` for stage object properties 2020-03-28 16:22:02 -07:00
Mike Welsh 4ea609cca1 tests: Don't special case enumeration tests 2020-03-28 16:22:02 -07:00
Mike Welsh 8da9487c0a avm1: Match Flash's property enumeration order (fix #153) 2020-03-28 16:22:02 -07:00
Mike Welsh 2cdf780e6f avm1: Handle case sensitivity in DisplayObject children
Alter `get_child_by_name` and alter `get_level_by_path` to respect
case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh 81a0bb370b tests: Add test for SWF<=6 case insensitivty 2020-03-28 16:22:02 -07:00
Mike Welsh ea245895b0 avm1: Use PropertyMap for stage object magic properties 2020-03-28 16:22:02 -07:00
Mike Welsh 7d848f4f34 avm1: Add avm parameter to TObject methods
This is necessary to get the current SWF version for properly
handing case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh 1ef698f2ea core: Add PropertyMap for handling AVM1 object properties
`PropertyMap` wraps over `IndexMap` to handle object properties in
AVM1. All insert/remove/get methods require and `swf_version`
parameter, and the `PropertyMap` will take care of handling case
senstivity and maintaing iteration order based on the SWF version.
2020-03-28 16:22:02 -07:00
Mike Welsh d42a402522 avm1: Add display object methods to TextField 2020-03-26 14:19:18 -07:00
Mike Welsh 7865ec1021 avm1: Implement Button object
First implementation of Button object. Hook up to the button
display object and run onRelease etc. methods as appropriate.

Pull out common display object methods into globals::display_object.
2020-03-26 00:21:21 -07:00
Mike Welsh 4df1128c19
core: Implement Object.registerClass (merge #344)
Implement Object.registerClass
2020-03-25 18:55:49 -07:00
dependabot-preview[bot] ef5ee3a889 build(deps): bump syn from 1.0.16 to 1.0.17
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.16 to 1.0.17.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.16...1.0.17)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-21 01:37:48 +00:00
Mike Welsh e9cb05aeb4 avm1: Correct order of modulo operands
Addresses part of #458.
2020-03-20 16:00:28 -07:00
hthh a16885d84b avm1: Fix string-to-number octal and whitespace handling
This conversion allows negative octal values, but not negative
hex values, and ignores only leading ASCII whitespace. A test
for this behavior is included.
2020-03-20 04:27:41 -07:00
Nathan Adams b4624fddce avm1: GetVariable and SetVariable look through the scope chain. Fixes #414
GetVariable and SetVariable attempt to resolve paths on each scope
in the scope chain.
2020-03-19 19:58:16 -07:00
Mike Welsh 454cd29ed6 chore: EditText::font takes self by value 2020-03-17 19:42:57 -07:00
Mike Welsh 068f4c3bee core: Edit text uses device fonts when outline flag isn't set
Specifically fall back to the device font when the UseOutlines
flag is not set in DefineEditText (SWF19 p.172). Fixes #451.

Note that since we only use a single font for "device" rendering,
this may sometimes be a different font than is specified in the
Flash IDE.
2020-03-17 19:13:20 -07:00
dependabot-preview[bot] da3398c832 build(deps): bump bitstream-io from 0.8.4 to 0.8.5
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits/v0.8.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:08:59 +00:00
dependabot-preview[bot] 2bfa2502a9 build(deps): bump num_enum from 0.4.2 to 0.4.3
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/illicitonion/num_enum/releases)
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.2...0.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:07:35 +00:00
Mike Welsh c2ce9892b1 core: Clamp RGBA when un-multiplying alpha
Fixes some bad pixels sometimes appearing in decoded JPEGs (such
as in #437 and in Dad 'n' Me).
2020-03-16 16:11:59 -07:00
dependabot-preview[bot] 0f7f36681d build(deps): bump quick-xml from 0.17.2 to 0.18.1
Bumps [quick-xml](https://github.com/tafia/quick-xml) from 0.17.2 to 0.18.1.
- [Release notes](https://github.com/tafia/quick-xml/releases)
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md)
- [Commits](https://github.com/tafia/quick-xml/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 05:34:45 +00:00
Mike Welsh 24a557807d chore: Fix more clippy lints 2020-03-12 21:40:48 -07:00
Mike Welsh 13b039fa34 chore: Fix clippy iter-nth-zero warnings
New lint added in latest clippy versions.
2020-03-12 21:16:30 -07:00
Mike Welsh 098bf33068 chore: Bump quote to 1.0.3 2020-03-08 18:58:39 -07:00
dependabot-preview[bot] a0ee19fd37 build(deps): bump syn from 1.0.14 to 1.0.16
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.14 to 1.0.16.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.14...1.0.16)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 20:26:50 +00:00
dependabot-preview[bot] ba185d3d43 build(deps): bump minimp3 from 0.3.3 to 0.3.5
Bumps [minimp3](https://github.com/germangb/minimp3-rs) from 0.3.3 to 0.3.5.
- [Release notes](https://github.com/germangb/minimp3-rs/releases)
- [Commits](https://github.com/germangb/minimp3-rs/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 19:07:25 +00:00
dependabot-preview[bot] 3f28554285 build(deps): bump enumset from 0.4.4 to 0.4.5
Bumps [enumset](https://github.com/Lymia/enumset) from 0.4.4 to 0.4.5.
- [Release notes](https://github.com/Lymia/enumset/releases)
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md)
- [Commits](https://github.com/Lymia/enumset/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 18:14:25 +00:00
Nathan Adams 751b15beec chore: Raise errors during Object.registerClass 2020-02-29 23:13:02 +01:00
Nathan Adams 7bed4d4940 chore: Document each trace in attach_movie avm1 tests 2020-02-29 23:05:17 +01:00
Nathan Adams 041bb6b44c avm1: Implement `Object.registerClass` 2020-02-29 23:05:17 +01:00
Nathan Adams d850443c84 avm1: Refactor to expose `avm, context` in `post_instantiate` 2020-02-29 23:05:15 +01:00
David Wendt fdce33ff5e Return an `Err` when decompression fails, rather than just logging it and returning an empty vec. 2020-02-26 18:18:24 -05:00
David Wendt ded7737ac0 `SwfMovie::from_data` is falliable and we should not hide those errors behind panics. 2020-02-26 18:15:01 -05:00