Nathan Adams
1f8abc92fd
core: Keep track of cursor position in drawings
2020-05-21 18:38:10 +02:00
Nathan Adams
99574cfa72
core: Move drawing api out from `movie_clip` into `drawing`
2020-05-21 18:38:10 +02:00
Nathan Adams
4f69566f77
tests: Add test coverage for flash.geom.Matrix
2020-05-21 18:38:08 +02:00
dependabot-preview[bot]
898232394b
build(deps): bump syn from 1.0.22 to 1.0.23
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.22...1.0.23 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-21 03:49:03 +00:00
Nathan Adams
31b0a5ae76
avm1: Implement gradient matrix types
2020-05-20 14:54:41 +02:00
Nathan Adams
5098eb079d
avm1: Implement most of flash.geom.Matrix ( #303 )
2020-05-20 14:54:41 +02:00
Nathan Adams
14331da71b
avm1: Add flash.geom.Matrix and methods to convert between this and swf::Matrix
2020-05-20 14:54:41 +02:00
Nathan Adams
eda862c719
swf: Merged core::Matrix into swf::Matrix
2020-05-20 14:54:41 +02:00
Nathan Adams
61e464099c
core: Add initial drawing API to MovieClip
2020-05-20 14:54:40 +02:00
Nathan Adams
7ab6703fc9
render: Add RenderBackend::replace_shape method
2020-05-20 14:54:40 +02:00
Nathan Adams
4c80ae150c
core: Make DistilledShape use Boundingbox and not Rectangle
...
Rectangle more represents compressed swf data and isn't suited for performing operations, and the drawing api will be generating these dynamically
2020-05-20 14:54:33 +02:00
Nathan Adams
f7b5f14f65
core: Make RenderBack::register_bitmap* methods return a Result ( fixes #531 )
2020-05-19 07:12:36 -07:00
dependabot-preview[bot]
6134ae091f
build(deps): bump generational-arena from 0.2.7 to 0.2.8
...
Bumps [generational-arena](https://github.com/fitzgen/generational-arena ) from 0.2.7 to 0.2.8.
- [Release notes](https://github.com/fitzgen/generational-arena/releases )
- [Changelog](https://github.com/fitzgen/generational-arena/blob/master/CHANGELOG.md )
- [Commits](https://github.com/fitzgen/generational-arena/compare/0.2.7...0.2.8 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 23:54:45 -07:00
dependabot-preview[bot]
41a8b01fe7
build(deps): bump quote from 1.0.5 to 1.0.6
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.5...1.0.6 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 08:38:24 +00:00
dependabot-preview[bot]
3b163c2b6e
build(deps): bump syn from 1.0.21 to 1.0.22
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.21 to 1.0.22.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.21...1.0.22 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-16 09:46:08 +00:00
dependabot-preview[bot]
1f0e695465
build(deps): bump fnv from 1.0.6 to 1.0.7
...
Bumps [fnv](https://github.com/servo/rust-fnv ) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/servo/rust-fnv/releases )
- [Commits](https://github.com/servo/rust-fnv/compare/v1.0.6...v1.0.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-14 19:05:48 +00:00
dependabot-preview[bot]
1641d05d00
build(deps): bump syn from 1.0.20 to 1.0.21
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.20 to 1.0.21.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.20...1.0.21 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 17:18:29 +00:00
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
David Wendt
0313225164
Don't allow movie loads to be removed from the load manager unless they have completed or errored.
2020-02-26 18:03:45 -05:00
David Wendt
a023e161fc
Don't panic if our target handle was removed from the load manager. Instead, return an `Err` so that it can be properly reported on the console without killing the player.
2020-02-26 17:38:31 -05:00
Mike Welsh
223edb9bc1
core: Matrix translation is in twips
2020-02-26 12:47:47 -08:00
Mike Welsh
c4c02260fb
core: Implement keyUp event
2020-02-26 03:48:07 -08:00
Mike Welsh
db9bd1616e
chore: Remove unused deref impl from AudioBackend
2020-02-26 02:00:28 -08:00
Mike Welsh
86ec2c6cb8
input: Add InputBackend::set_mouse_cursor. Change cursor on buttons
...
It doesn't feel like Flash without having the hand cursor display
when hovering over buttons. First pass at implementing this;
core communicates which mouse cursor to use via
`InputBackend::set_mouse_cursor`.
TODO: Hand cursor only displayed for Button display objects
currently. Movie clips should also display this when they are in
"button mode" (when a button mouse event is set on them in AVM1,
or `buttonMode` property in AVM2).
2020-02-25 02:50:26 -08:00
Mike Welsh
a917fa4028
tests: Add temporary test for MovieClip.getRect
...
This is just testing that it exists and returns the same values as
getBounds for shapes without strokes.
TODO: When it is properly implemented for strokes, add stroked
shapes to testing.
2020-02-24 14:12:48 -08:00
Mike Welsh
d8079ac04a
core: Stub out MovieClip.getRect
...
Just defer to getBounds for now. TODO: getRect should return bounds
ignoring strokes, so in reality it is <= getBounds.
2020-02-24 14:12:48 -08:00
Mike Welsh
993c05cf19
core: Calculate bounds for each morphshape frame
2020-02-24 14:12:48 -08:00
Mike Welsh
a5c08f2e59
avm1: Implement MovieClip.getBounds and clean up bounding box methods
...
Implements MovieClip.getBounds, and also reorganized the
DisplayObject AABB methods:
* `self_bounds` calculates the inherent untransfomed bounds of
the object without children. All `DisplayObject`s must implement
this method. For example, `Bitmap` returns the size of bitmap.
Composite objects like `MovieClip` return a null AABB because they
are made up of only children.
* `bounds` calculates the untransformed bounds including children.
* `local_bounds` calculates the bounds relative to the object's
parent.
* `world_bounds` calculates the bounds in global stage space.
* `bounds_with_transform` calculates a tight AABB for the object
with a given transform, and is used to implement the above.
2020-02-24 14:12:48 -08:00
Mike Welsh
73a9a0e771
tests: Add test for MovieClip.getBounds
2020-02-24 14:12:48 -08:00
Mike Welsh
8c486b7544
chore: Use free functions for movie_clip methods
...
Try to keep style more consistent by using functions for all MC
methods. Previous was a mix of closures and functions (we're still
a little bad with this elsewhere)
2020-02-24 11:17:40 -08:00
Mike Welsh
f163afc5b4
core: Use collect to copy level pointers
2020-02-24 02:28:27 -08:00
Mike Welsh
1b08fb538d
chore: Rename layer -> level
...
Unify mix of 'layer' and 'level' in the code, and it's probably
better to stick with Flash nomenclature.
2020-02-23 23:41:55 -08:00
David Wendt
05e5fbb69c
For some reason, this color transform code broke on the moviefetch branch
2020-02-22 00:02:52 -05:00
David Wendt
abc1d00276
Fix incorrect preload of `_root` in `DefineFunction2` function calls.
...
This is caused by the fact that `avm.root_object` references the *current* stack frame, not the one we are about to introduce. Ergo, we need to pull the base clip of the *new* stack frame and find it's root.
This particular behavior only crops up in situations where there can be multiple root objects, at least until we implement `_lockroot`.
2020-02-22 00:02:51 -05:00
David Wendt
766ded6dfd
When replacing a movie clip with another movie, don't wipe out the entire display object base as that disassociates us from our parent, siblings, and most importantly, *layer depth*.
2020-02-22 00:02:51 -05:00
David Wendt
e0b4a0f193
Top-level layers are referenced via their path (`_leveln`) rather than name - in fact, their name is always the empty string.
2020-02-22 00:02:51 -05:00
David Wendt
00f88f9e87
Use the depth to indicate which layer a particular root clip is, and then use that to calculate it's `_leveln` path.
2020-02-22 00:02:50 -05:00
David Wendt
8ef759d377
Top-level layers do not get an instance name of `_leveln`.
2020-02-22 00:02:50 -05:00
David Wendt
9adf0f43d7
Allow levels to be read as scope variables, and add a test for this.
2020-02-22 00:02:50 -05:00
David Wendt
5a7e530c91
Add a test for cross-movie `_root`.
...
This test does not pass yet. Other layers need to resolve as target paths in order for this to happen.
2020-02-22 00:02:48 -05:00
David Wendt
aa6aba13dd
Abolish `context.root` completely.
...
`_root` is calculated dynamically based on the clip the currently executing function was called in.
Other things that used `context.root` have been changed to either update all layers or just update layer 0, which is the former `context.root`.
2020-02-22 00:02:46 -05:00
David Wendt
33d26b9149
Shorten `Pin<Box<dyn Future<Output=Result<T,E>> + 'static>>` into `OwnedFuture<T,E>`.
...
This is technically stricter on `fetch` impls, but right now we can't support non-`'static` futures at all.
2020-02-22 00:02:45 -05:00
David Wendt
aab339880d
Implement `XML.load()`, with tests.
...
Interestingly enough, very little actually has to be done inside the async process for XML. The async process basically just fetches data and fires an event handler when it's done. Everything else is handled via a system builtin, `XML.onData`.
2020-02-22 00:02:45 -05:00
David Wendt
538a5f05e5
Add tests for various forms of `loadVariables`.
...
Surprisingly enough these tests passed without any changes, somehow.
2020-02-22 00:02:43 -05:00
David Wendt
c00ecccd1f
Basic, stub implementation of `MovieClipLoader.getProgress`, plus test.
...
This implementation just returns the size of the current loaded movie. The test is also deliberately written to be loose on timings so that it likely won't see a partially loaded movie. (I don't want it to be a test of load events, so I just wait a few frames, rather than the correct way of waiting for `onLoadComplete`.)
Until we support streaming file loads, we can't faithfully support these properties. Still, it's better to have them, just in case.
2020-02-22 00:02:42 -05:00
David Wendt
3f7e3a9ed8
Implement `MovieClipLoader.unloadClip`, with tests.
2020-02-22 00:02:41 -05:00
David Wendt
a132226da4
Run `onLoadInit` at the *end* of a frame, rather than before the movie clip's own actions.
...
This is technically better, but it may make more sense to trigger `ClipEvent::Load` at the start of the next frame instead. Furthermore, I don't know if other forms of load events should trigger on the next frame (or end of the current one) like this.
2020-02-22 00:02:39 -05:00
David Wendt
55734619f7
`GetUrl2` can accept a `DisplayObject` as target in `LoadTargetFlag` mode.
...
I have no idea what happens to non-MovieClip objects, or if I'm really supposed to `coerce_to_string` here.
2020-02-22 00:02:36 -05:00
David Wendt
d49c0e9bf7
Rewrite some of the unload and cliploader tests to be more generous with load timing.
...
Loads in Flash Player, like all web technologies, are asynchronous tasks of some kind (probably a separate thread). They appear to operate on some kind of a delay. If I `trace` each frame out, like in the previous version of `mcl_loadclip`, you get a series of events that look like this:
1. Parent frame 1
2. Parent frame 2
3. Event: onLoadStart
4. Event: onLoadProgress
5. Event: onLoadComplete
6. Parent frame 3
7. Event: onLoadInit
If I run that version of the test on Ruffle, everything happens after frame 1. This is an artifact of how we're testing asynchronous behavior in Ruffle. In order to guarantee test determinism, we have a dummy implementation of `fetch` that does a blocking load, and we poll all futures every frame of execution. This means that there is a very specific order of execution with these tests, which is good for testing, but probably isn't 100% accurate.
Flash Player appears to delay all loads by at least one frame, even loads that are coming from disk which should load immediately. I don't know if this is intentional or not, so I don't want to implement a load delay just for the sake of making tests pass. Ergo, I'm loosening the tests to just test the ability to load and unload movies, and fire events from a loader.
Specifically:
1. `mcl_loadclip` no longer traces out frames of the parent timeline
2. `unloadmovie` et. all use a target movie that doesn't fail the test until 10 frames have passed.
If someone can find a movie network that breaks with fast loading, then I'll consider implementing explicit frame delays for async tasks. Otherwise, this is how we're testing this.
2020-02-22 00:01:22 -05:00
David Wendt
8ece2d1b31
Add another ignored test, this time measuring the timing of load events broadcasted by `MovieClipLoader`. We're loading too early, which is why this is ignored.
2020-02-22 00:01:20 -05:00
David Wendt
b56c3b6aed
Fire events directly onto `broadcastMessage` instead of the individual event handlers on the `MovieClipLoader`, so that listeners run correctly.
...
Also, this fixes a double-borrow for `onClipInit`.
2020-02-22 00:01:19 -05:00
David Wendt
89e5dd97f3
Implement `MovieClipLoader.loadClip`
2020-02-22 00:01:19 -05:00
David Wendt
162b6b70f8
Allow unloading a movie by sending `None` to `replace_with_movie`.
...
This also adjusts `MovieClip.unloadMovie` to do just that, instead of removing the clip from the display list. We also have to unload clips when loading new movies into them, since `unloadMovie` desugars to loading `""` as the URL.
2020-02-22 00:01:19 -05:00
David Wendt
8ef4a94672
Add new tests for `unloadMovie`, `unloadMovieNum`, and `MovieClip.unloadMovie`.
...
They currently fail in Ruffle, so they're ignored.
2020-02-22 00:01:18 -05:00
David Wendt
cc5dff4254
Add a test for `MovieClip.loadMovie`.
2020-02-22 00:01:17 -05:00
David Wendt
82d305a0f5
Add test for `loadmovienum`
2020-02-22 00:01:16 -05:00
David Wendt
a9621da47d
Add tests for `loadMovie`.
...
This test also includes changes to the SWF testing environment to allow asynchronous movie loads to execute.
2020-02-22 00:01:15 -05:00
David Wendt
a8545ee277
Implement `onLoadInit` by pulling `LoadManager` into all clip load events.
2020-02-22 00:01:14 -05:00
David Wendt
7ff885a0de
Implement `MovieClipLoader` event broadcasts for `onLoadStart`, `onLoadProgress`, `onLoadComplete`, and `onLoadError`.
...
Note that we do not implement `onLoadInit` yet - this requires some ability to trigger an event when another movie clip loads.
2020-02-22 00:01:14 -05:00
David Wendt
db41bec91e
Implement `MovieClipLoader`'s `addListener`, `removeListener`, and `broadcastMessage` methods.
...
Interestingly, this constitutes an implementation of `AsBroadcaster`. It appears Macromedia decided to implement event handling on `MovieClipLoader` in a very similar fashion to `AsBroadcaster`, down to invoking `broadcastMessage` and searching a `_listeners` property for listeners.
2020-02-22 00:01:12 -05:00
David Wendt
b7d318a897
Implement `MovieClip.loadMovie`, `MovieClip.loadVariables`, and `MovieClip.unloadMovie`.
...
*De*implement the free function versions of the above, as well as their `Num` variants, since they don't actually exist as callables. Instead, the ActionScript compiler treats them as preprocessor functions that represent various forms of `ActionGetURL`/`ActionGetURL2`.
2020-02-21 23:59:13 -05:00
David Wendt
31b1364b82
Implement `unloadMovie` / `unloadMovieNum`
2020-02-21 23:58:00 -05:00
David Wendt
b2b2a165fc
Implement `loadVariables` and `loadVariablesNum`.
2020-02-21 23:58:00 -05:00
David Wendt
c7539872f7
Add the ability to POST data from `fetch`, and allow methods that read AVM locals into form data to `GET` or `POST` them.
2020-02-21 23:58:00 -05:00
David Wendt
3fe6884c90
Refactor layer resolution into a separate function.
...
This function is part of `Avm1`, rather than a hypothetical `LayerManager`, because we're going to need to eventually construct layers differently for AVM2.
2020-02-21 23:57:59 -05:00
David Wendt
ea28c2c4a2
Impl `loadMovie` / `loadMovieNum` (sans local variable support)
2020-02-21 23:57:59 -05:00
David Wendt
07637fe676
Replaced movies should start out playing. This fixes a regression from a previous rebase.
2020-02-21 23:57:58 -05:00
David Wendt
64b787b73f
Implement `Collect` for `Loader`. (How did this compile without that?)
2020-02-21 23:57:58 -05:00
David Wendt
d84e11ed40
Introduce a new top-level object, `LoadManager`, which is responsible for all asynchronous behavior in the program. Migrate the existing async impls to it.
2020-02-21 23:57:58 -05:00
David Wendt
2d7a4fef28
`Sound` methods that reference sounds by library export name should default to `_layer0`'s library if the `Sound` was created without a movie clip target.
2020-02-21 23:57:57 -05:00
David Wendt
6b78ec6e03
More thoroughly clean `MovieClip`s that have movies loaded into them. This does everything except wipe the object it's attached to - I need further testing to see how Flash handles that.
2020-02-21 23:57:57 -05:00
David Wendt
2a82d21966
Change the layer list from a static array to a `BTreeMap`.
...
Flash allows creating layers at any 31-bit height without issue, so this should support similar limitations.
2020-02-21 23:57:57 -05:00
David Wendt
f4e4171ebe
Make spawned futures falliable, and report those errors.
2020-02-21 23:57:56 -05:00
David Wendt
5ce499d11e
Add separate libraries for each loaded movie.
2020-02-21 23:57:56 -05:00
David Wendt
e0c0779bd0
Make sure to preload all loaded clips.
2020-02-21 23:57:55 -05:00
David Wendt
6da374c567
Implement loading movies into `_leveln` via `ActionGetUrl`
2020-02-21 23:57:55 -05:00
David Wendt
ed799fd2b9
Split the player up into nine layers, each of which is a separate root movie clip.
2020-02-21 23:57:55 -05:00
David Wendt
8c9d290db7
Implement the MovieClip loading portion of `ActionGetURL2`.
2020-02-21 23:57:54 -05:00
David Wendt
5ed5876e9a
Merge SWF data and version into a single structure. Refactor everything that interacts with it to use `SwfSlice`s.
2020-02-21 23:57:53 -05:00
David Wendt
250ec13c12
Implement LoadVariablesFlag.
...
This has some subtle problems: we cannot hold references to garbage-collected data in Futures, so we have to arrange for the AVM itself to forcibly root them for us. Then we get them back when our async code is ready to do something to the AVM.
2020-02-21 23:44:06 -05:00
David Wendt
55149b7b7e
Reference count the Player and provide a weak reference in UpdateContext.
...
This allows the formation of `'static` futures that can still interact with a player. Async code will need to upgrade the weak reference in order to be able to interact with the player.
2020-02-21 23:44:06 -05:00
David Wendt
491d94c947
Pinbox all Futures.
...
Due to some strangeness with the way Rust implemented unsafe-to-move behavior, boxed futures are implicitly `Unpin`. Which is useless to us.
The reason for this is a little counter-intuitive. Actually, the fact that Rust supports memory pinning at all is a little odd, because the core language explicitly requires all types be movable. To get around this, Pin requires that all !Unpin types be *born pinned*. This is because you can't re-pin an already unpinned value in memory.
Anyway, this necessitates this silly API change.
2020-02-21 23:44:05 -05:00
David Wendt
00d25a768c
Extremely basic impl of fetch/spawn methods for getting data off the web
2020-02-21 23:44:05 -05:00
David Wendt
2137b9f1fd
Migrate `set_frame_rate` into the core `AudioBackend` trait
2020-02-21 23:44:05 -05:00
David Wendt
c1cf73ccb3
Add a public method to trigger a player update.
...
User-defined player updates are treated the same as if a stage frame had been run: queued actions are executed and garbage is collected.
2020-02-21 23:44:04 -05:00
Mike Welsh
f80c188048
core: Stop stream sounds when a clip is removed
2020-02-21 19:24:45 -08:00
Mike Welsh
6b503ac053
avm1: Fix DefineFunction2 preload order when _parent is undefined
...
The order is misdocumented in SWF19 (and also miscompiled assuming
this incorrect order by the Flash IDE!).
`_global` gets preloaded before `_parent`.
2020-02-20 12:58:26 -08:00
Mike Welsh
dc1f99e2ba
tests: Add test for misdocumented DefineFunction2 register preload
2020-02-20 12:58:26 -08:00
Mike Welsh
10fb6c7c04
tests: Add define_function2_preload test
2020-02-19 23:22:33 -08:00
Mike Welsh
19d0bf64a9
avm1: Preload _parent directly from base clip
...
When `_parent` is preloaded in a `DefineFunction2` action,
we previously resolve it on the scope chain. This could cause
double borrow panics as the parent object could already be
borrowed, and also this matches the behavior of the official Flash
player.
Addresses #398 .
2020-02-19 23:22:33 -08:00
Mike Welsh
8d7e58011e
avm1: undefined coerces to "" in SWFv6 and below
...
Except in the AVM1 trace op, which will print out "undefined".
2020-02-19 10:47:43 -08:00
Mike Welsh
dfde98da7d
tests: Add tests for coercing undefined to string in SWF6
2020-02-19 10:47:43 -08:00
Mike Welsh
452ac84f0e
tests: Uncomment Number.POSITIVE_INFINITY/Number.NEGATIVE_INFINITY tests
2020-02-18 10:17:55 -08:00
Mike Welsh
c073afb077
avm1: Use proper value for Number.MIN_VALUE
...
This is the smallest positive number, not the most negative value.
This is actually the smallest positive subnormal f64, which Rust
does not provide a constant for. This is ~5e-324.
2020-02-18 10:17:55 -08:00
Mike Welsh
6bbe1dbab8
avm1: Match Flash when converting exotic numbers to string ( fix #361 )
...
Match Flash's more closely when converting number to string:
* NAN -> NaN
* inf -> Infinity
* -inf -> -Infinity
* Use exponential notation for very large/very small
This is a little bit of a cheat by using Rust's number-to-string
formatting for exponentials, and shoving a sign in front of the
exponent.
2020-02-18 10:17:55 -08:00
Mike Welsh
324dd1c5e4
tests: Add swf_tests_approx macro
...
Use this macro to test numeric calculations that might have some
variance using approx_eq.
2020-02-17 15:42:29 -08:00
Mike Welsh
b6249cdb73
tests: Add localToGlobal/globalToLocal test
2020-02-17 15:42:29 -08:00
Mike Welsh
2af21d87e0
avm1: Implement MovieClip.localToGlobal/globalToLocal
2020-02-17 15:42:29 -08:00
Mike Welsh
cd94486f7e
desktop: Fix stream audio from prematurely ending ( fix #222 )
2020-02-14 20:32:25 -08:00
Mike Welsh
7c406732c7
audio: Ensure stream sounds stop upon goto/loop ( fix #370 )
2020-02-14 20:32:25 -08:00
Mike Welsh
9ad069e11a
avm1: Improve display object property setters for weird values
...
Setting a property such as _x to undefined or null should have no
effect. This was working for v7+ SWFs because it would coerce to
NaN and we toss out NaNs. But on v6 and below, these coerce to 0
and would end up setting the property to 0.
Explicitly check for undefined/null and bail out. Fixes #380 .
Also adjust the _visible setter, since this actually coerces to a
number (because of its legacy from SWFv4). For example,
_visible = "" should have no effect.
2020-02-14 15:34:14 -08:00
Mike Welsh
3a1a73ae11
tests: Add more tests for display object properties
...
Add more _x = weirdo value tests, and copy the test into a v6 SWF.
(because undefined etc. can coerce to 0 instead of NaN in SWFv6).
2020-02-14 15:34:14 -08:00
Mike Welsh
7d14b98f3b
avm1: Ignore undefined values in Color.setTransform
...
If a property is not set on the object passed to Color.setTransform,
then that channel is left unmodified. This fixes invisible objects
in some games (fixes #369 , addresses #380 ).
Also improve handling of wrapping/invalid values to better match the
behavior in the Flash Player (some work pending on #193 ).
2020-02-13 18:06:27 -08:00
Mike Welsh
21f117e7bc
avm1: Add Value::coerce_to_i16
2020-02-13 18:06:27 -08:00
Mike Welsh
19df074a79
tests: Add more tests for AVM1 Color object
...
Include not defined values, wrapping values, invalid values.
2020-02-13 18:06:27 -08:00
David Wendt
18516c8eac
Pre-strip HTML from HTML tags, rather than skipping them.
2020-02-03 19:32:05 -05:00
David Wendt
7d225f8b55
Fix overflow when shifting `u8`s
2020-02-03 14:46:36 -05:00
David Wendt
3d6b00c1e4
Impl the remaining text layout properties
2020-02-03 14:46:36 -05:00
David Wendt
517e7ce9ff
Add word-wrap for `measure_text` and caching for word-wrap calculations
2020-02-03 14:46:36 -05:00
David Wendt
5e808c8cd6
Adjust the wordwrap machinery to work in break points (indicies where new lines start) so we can cache them later
2020-02-03 14:46:35 -05:00
David Wendt
fb8664c818
Implement wordWrap and multiline rendering, poorly
2020-02-03 14:46:35 -05:00
David Wendt
7df8eb7674
Impl `is_multiline`'s effect of respecting newlines
2020-02-03 14:46:35 -05:00
David Wendt
f95ec777de
Also impl storage of the `wordWrap` flag
2020-02-03 14:46:34 -05:00
David Wendt
819757e2b6
Fix text measurement now that the underlying SWF tags are correctly parsed as `Twips`.
...
Transform coordinates are always in twips, so we have to convert pixels to twips when evaluating the font, and then convert back when measuring.
2020-02-03 14:46:34 -05:00
David Wendt
63b7d172f4
`TextRecord.height` is also in `Twips`.
...
Notably, the `Text` rendering code does not appear to actually work in pixel scale.
2020-02-03 14:46:34 -05:00
David Wendt
fde7715fb8
`EditText.height` is in `Twips`
2020-02-03 14:46:33 -05:00
David Wendt
75022f36d2
Pull `TextFormat` into the `font` module.
...
Also, since there's a separate function for attaching virtual properties to an AVM1 `TextField` object, let's use that!
2020-02-03 14:46:33 -05:00
David Wendt
4b3660bf2c
Impl get/set for `is_multiline`.
2020-02-03 14:46:32 -05:00
David Wendt
c1ff1d94d5
Pull the `EditText.evaluateFont` method into `Font`.
...
`Text` itself doesn't use this method, but it probably could with some changes.
2020-02-03 14:46:32 -05:00
David Wendt
81b7958090
Impl `textWidth` / `textHeight`, although it currently only works well for single-line scenarios.
2020-02-03 14:46:32 -05:00
David Wendt
2181f0d0d0
Impl `getNewTextFormat`/`setNewTextFormat`.
...
These don't actually do anything yet, because we don't track text spans, nor do we actually use those text spans to alter rendering or text layout.
2020-02-03 14:46:30 -05:00
David Wendt
db56217f20
`TextFormat` does *not* coerce `undefined` or `null`; instead those both become `null`.
2020-02-03 14:46:30 -05:00
David Wendt
8449d964ef
Implement `TextFormat` as a property bag.
2020-02-03 14:46:29 -05:00
David Wendt
2b0600ab1a
Impl `createTextField`.
2020-02-03 14:46:29 -05:00
Mike Welsh
2ff76775e0
core: Empty movie clips can not be used as a mask
...
When a movie clip or button is used as a mask, the masking will be
disabled if that object has no children; the maskee will be
completely visible. An empty movie clip inside an empty movie clip
successfully masks.
An EditText can also not be used as a masker (although it can be
wrapped inside a movie clip, and then the text successfully masks).
Add a `TDisplayObject::allow_mask` trait method that will
return whether the object can be used as a mask.
This fixes characters not being visible in Dad 'n' Me.
2020-02-01 01:15:31 -08:00
Mike Welsh
2e304a81ef
core: Flag as transformed-by-script after swapDepths
2020-01-31 19:44:42 -08:00
Mike Welsh
a55a378a73
avm1: Improve comments in MovieClip depth methods
2020-01-31 19:44:42 -08:00
Mike Welsh
4d1f7c4d4a
tests: Add movieclip depth method tests
2020-01-31 19:44:42 -08:00
Mike Welsh
a4e175a790
avm1: Implement MovieClip.getNextHighestDepth
2020-01-31 19:44:42 -08:00
Mike Welsh
4d12cd1566
avm1: Implement MovieClip.getDepth
2020-01-31 19:44:42 -08:00
Mike Welsh
9e337ede34
avm1: Implement MovieClip.swapDepths
2020-01-31 19:44:42 -08:00
dependabot-preview[bot]
2f98fd1a0e
build(deps-dev): bump webpack-dev-server in /web/selfhosted
...
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server ) from 3.10.1 to 3.10.2.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases )
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md )
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v3.10.1...v3.10.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-31 19:44:42 -08:00
Mike Welsh
0d91fb423e
core: Goto only runs if frame is an integer
2020-01-30 15:17:01 -08:00
Mike Welsh
c079cb3bca
core: Don't run frame actions when seeking past end of timeline
...
If you goto past the final loaded frame of a timeline, for example,
with gotoAndStop(9999), this seeks to the final frame on the
timeline, but it doesn't run the actions on this frame.
MovieClip::goto_frame now will not run the final frame actions if
the target frame was not reached.
2020-01-30 15:17:01 -08:00
Mike Welsh
8aae07bbf3
core: Frame labels are case insensitive
2020-01-30 15:17:01 -08:00
Mike Welsh
a835573f3c
tests: Add test for global GotoFrame action
2020-01-30 15:17:01 -08:00
Mike Welsh
62467bb880
avm1: Handle invalid parameters in GotoFrame2
...
Use the same code path for the global GotoFrame2 action and
MovieClip.gotoAndX, which properly handles out-of-range and invalid
values like NaN.
Fixes Disorderly hanging on game start
(https://www.newgrounds.com/portal/view/121896 )
2020-01-30 15:17:01 -08:00
David Wendt
a57d0e12b3
Do not apply a color filter at all unless rendering a bitmap or gradient.
...
This significantly improves render times, as browsers appear to apply filters in the most general, inefficient way possible.
2020-01-29 14:19:18 -05:00
dependabot-preview[bot]
dc8858505d
build(deps): bump smallvec from 1.1.0 to 1.2.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.1.0...v1.2.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-29 18:42:28 +00:00
Mike Welsh
003cc414aa
core: Create clips in execution order during a goto
...
The list of goto commands is now a Vec that will already be in order
of creation. This ensures that subsequent ActionScript in these clips
runs in the correct order.
2020-01-28 04:15:08 -08:00
Mike Welsh
81a1c05682
tests: Add goto_execution_order2 regression test
...
Tests execution order of children added during a goto.
2020-01-28 04:15:08 -08:00
Mike Welsh
7532e89aff
avm1: Use `resolve_target_display_object` in `Color`
...
Fixes the boss damage blinking in Alien Hominid. Target was a path
string.
2020-01-27 23:35:41 -08:00
Mike Welsh
69f19f03c4
avm1: Output trace warning for invalid SetTarget ( fix #332 )
2020-01-27 23:35:41 -08:00
Mike Welsh
a0032b9aa1
avm1: Better handling of movie clip paths strings ( fix #317 )
...
Ops and functions that take a movie clip path in String form have
a very forgiving syntax. These include:
* `SetTarget`
* `CloneSprite`
* `RemoveSprite`
* `swapDepths`
This change adds `Avm1::resolve_target_display_object` to parse
these paths correctly, along with `target_paths` test to test a
wide variety of formats.
This also applies to `GetVariable`/`SetVariable`, which accept
target paths to variables and is used by some SWF4/5 content.
(fixes #324 , #337 ).
2020-01-27 23:35:41 -08:00
Mike Welsh
2751b89d4e
avm1: Root clip should not have a name
...
Previously we set the name of the root clip to `_level0`. Top-level
clips should actually have no name (`_root._name` returns `""`).
However, when constructing a dot path, `_level0` still gets inserted
by `DisplayObject::path` for the top-level, so that `trace(_root)`
still correctly prints `_level0`.
TODO: When `loadMovieNum` gets merged in, the proper level # needs
to be returned by `.DisplayObject::path`.
2020-01-27 23:35:41 -08:00
Mike Welsh
0446644742
tests: Add target_path test
2020-01-27 23:35:41 -08:00
David Wendt
db51ec9e3c
Implement a separate `Object` impl for functions that holds an `Executable`.
2020-01-27 21:57:32 -05:00
David Wendt
8eeb9a5c60
This technically isn't a test of `toString`, so remove stuff from the test that it relies upon.
2020-01-27 21:50:11 -05:00
David Wendt
d217f51c6c
Don't crash if `Function.prototype.call` is called without arguments.
2020-01-27 21:50:10 -05:00
David Wendt
0470b8d0a7
Add a test for `Function.call` and `Function.apply`
2020-01-27 21:50:10 -05:00
David Wendt
2c0d892154
Implement Function.call/apply
2020-01-27 21:50:09 -05:00
Mike Welsh
4b7bac706b
avm1: ActionNewMethod supports auto-boxing values
...
This allows `new ("FOO".bar)()`, although there is probably no
good reason to do this. :-)
2020-01-21 18:24:49 -08:00
Mike Welsh
70bec9437f
tests: Boolean() returns undefined
2020-01-21 18:24:49 -08:00
Mike Welsh
d9e7a6a960
avm1: Implement Boolean class
2020-01-21 18:24:49 -08:00
Mike Welsh
e71099edd5
tests: Add primitive_type_globals test
2020-01-21 18:24:49 -08:00
Mike Welsh
8263d13fd0
avm1: Implement Number class
2020-01-21 18:24:49 -08:00
Mike Welsh
b49357e46f
avm1: Boxing a value calls the object constructor
2020-01-21 18:24:49 -08:00
Mike Welsh
ccf62979a1
avm1: Implement String methods
2020-01-21 18:24:49 -08:00
Mike Welsh
5f12ce78b6
tests: Add string method tests
2020-01-21 18:24:49 -08:00
David Wendt
2f9d50cdb8
Very rudimentary/basic/not-good implementation of `String`, plus auto-boxing for primitive strings getting their methods taken.
2020-01-21 18:24:49 -08:00
David Wendt
4d1e49882b
Add another object class for boxed primitive values, because the language demands it.
2020-01-21 18:24:49 -08:00
Mike Welsh
13b4cd4c1b
avm1: Add Value::coerce_to_i32/u32/u16 methods
...
Add these methods that will explicilty coerce a value to an int,
following the wrapping behavior in the ECMAScript specs (ToInt32,
ToUInt32, ToUInt16).
This also fixed an off-by-one error for negative numbers in the
previous implementation.
These will call `valueOf` if necessary. AVM code that requires an
integer will probably use one of these (`coerce_to_i32` usually).
2020-01-20 13:28:27 -08:00
dependabot-preview[bot]
87e96212e4
build(deps): bump syn from 1.0.13 to 1.0.14
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.13 to 1.0.14.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.13...1.0.14 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-20 18:56:56 +00:00
Nathan Adams
4ad6ef8b83
core: Implemented Key.getCode()
2020-01-17 15:11:38 -08:00
Nathan Adams
adceceed5d
avm1: Removed redundant double registration of Key
2020-01-17 15:11:38 -08:00
Nathan Adams
cef7d3eba2
avm1: Implement Key constants
2020-01-17 15:11:38 -08:00
Mike Welsh
8cb4278903
tests: Use pretty_assertions for nice output on test fail
2020-01-17 13:54:39 -08:00
Mike Welsh
cf7a564f2c
core: Fix properties not resetting in goto when rewinding
...
Properties of a display object would not reset when rewinding if
it existed in both the initial and final frames of the goto.
This fixes the weapons toggles in UFA.
2020-01-16 09:58:33 -08:00
Mike Welsh
8448fc80ef
avm1: Don't panic when calling ActionRandom with <= 0
2020-01-14 00:05:13 -08:00
Mike Welsh
4eef8a1821
tests: Add test for ActionCall
2020-01-14 00:04:11 -08:00
Mike Welsh
2d3801dac8
avm1: Implement ActionCall opcode
2020-01-14 00:04:11 -08:00
Nathan Adams
fdf1d38d21
avm1: Implement remainder of Math
2020-01-13 15:57:56 -08:00
dependabot-preview[bot]
6c2f5143b3
build(deps): bump rand from 0.7.2 to 0.7.3
...
Bumps [rand](https://github.com/rust-random/rand ) from 0.7.2 to 0.7.3.
- [Release notes](https://github.com/rust-random/rand/releases )
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md )
- [Commits](https://github.com/rust-random/rand/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-13 18:38:15 +00:00
Mike Welsh
001a931afe
avm1: Avm1::pop should always succeed
...
Don't return a Result from `pop`. Instead, emit a warning and
return Undefined if there is an underflow.
2020-01-07 15:59:14 -08:00
Mike Welsh
170813ffbf
audio: Assume little endian for PCM unknown endian sounds
2020-01-07 02:40:09 -08:00
Mike Welsh
a28e97d8c3
avm1: Don't push returns from non-function stack frames
2020-01-06 20:49:05 -08:00
Mike Welsh
7e05da6147
avm1: Fix issues with traversing the scope chain in SetVariable
...
When setting a variable in a function-local scope, if that variable
has not been defined in the function scope, it should be defined in
the executing movieclip's scope. Previously it would get defined
in the function's scope. Changed Scope::overwrite to Scope::set,
and modified the behavior to stop traversing and define the value
when it hits a movie clip Target scope.
Also, modified With scopes to properly add onto the end of the scope
chain.
2020-01-06 20:49:05 -08:00
Mike Welsh
a60fadf0bb
tests: Add test for correct scope in SetVariable
2020-01-06 20:49:05 -08:00
David Wendt
0d1d0e8de7
Don't bother preserving the `Cow`ness of unescaped strings when we're going to clone them anyway.
2020-01-05 00:31:45 -05:00
David Wendt
7957434036
This is a copy type, copy it
2020-01-05 00:24:31 -05:00
David Wendt
f8b5b8a032
Use `unwrap_or_default` where available
2020-01-05 00:22:36 -05:00
David Wendt
ef7c5d7eb9
Move XML properties to separate functions rather than closures
2020-01-05 00:17:57 -05:00
David Wendt
14dba0d100
Log errors encountered when removing the children of a node we plan to parse XML into.
...
Also, remove a handful of unnecessary `#[allow(unused_must_use)]` instances.
2020-01-05 00:04:45 -05:00
David Wendt
464563a703
Change the no-double-introduction warning into a proper `assert!`. Add doc warning about the panic.
2020-01-05 00:00:29 -05:00
David Wendt
750e6e4370
Replace bare number constants for XML errors with symbolic `const` values
2020-01-04 23:56:10 -05:00
David Wendt
fd541fabea
Implement `status`.
...
I'm not entirely sure how to test this one - the list of errors that Flash kicks out for XML and the list of errors that `quick_xml` kicks out don't line up at all; so I just ensured that any error is a negative number (currently the one for OOM errors) and stuck whatever errors *did* match up together.
Consequently I don't know entirely *how* to write tests for this.
2020-01-04 19:00:49 -05:00
David Wendt
fec95dd226
Add regression test for `idMap`.
2020-01-04 19:00:49 -05:00
David Wendt
f3226537bf
Implement `idMap`.
...
`idMap` is a strange property; it's only populated with nodes which had a given `id` *at the time of parsing*, and said nodes continue to be referenced even if the node is removed from the document. I have yet to find a way by which nodes can be deleted from `idMap`.
It also takes expandos, so this has to be a new retained object on the XML document. I originally considered not creating *another* `Object` impl and populating a regular `ScriptObject` with nodes, but that meant we couldn't lazy-instantiate their AVM1 side counterparts. Boo. :/
2020-01-04 19:00:48 -05:00
David Wendt
1722558d44
Add test for `XML.parseXML`
2020-01-04 19:00:47 -05:00
David Wendt
823e8602ff
Impl `XML.parseXML`
2020-01-04 19:00:46 -05:00
David Wendt
d00ef01965
Add a convenience method: `XMLNode.into_string`
2020-01-04 19:00:46 -05:00
David Wendt
b4b722e1d6
Add another test for AVM1 XML's failure to roundtrip unsupported node types (e.g. comments).
2020-01-04 19:00:45 -05:00
David Wendt
2c790f1d41
Filter non-AS2 compatible nodes from toString output, and add non-SWF tests for XML filtering.
2020-01-04 19:00:45 -05:00
David Wendt
ce1b958abb
Add some more tests for XML namespace URIs.
2020-01-04 19:00:45 -05:00
David Wendt
e2fa685d41
Fix tagname parsing.
...
There is a bug in `quick_xml` - or at least, I *think* it's a bug - where the `unescaped` method of `BytesStart` yields a bunch of attributes if you have slightly invalid crap in your tag like `xmlns:`. To work around it, I turned off unescaping; we're instead using `name` and ignoring unescaping. This will probably fail somewhere.
2020-01-04 19:00:44 -05:00
David Wendt
e1034fce31
clippy compliance
2020-01-04 19:00:44 -05:00
David Wendt
7ac3204759
format prev commit
2020-01-04 19:00:43 -05:00
David Wendt
d2aa3dd987
Add a test for `createElement` and `createTextNode`.
2020-01-04 19:00:43 -05:00
David Wendt
db38982ffb
For some reason, text nodes have an attributes object.
2020-01-04 19:00:42 -05:00
David Wendt
91155d6870
Text nodes have empty arrays for `childNodes` rather than being `undefined`.
2020-01-04 19:00:42 -05:00
David Wendt
d28094a019
Implement `createElement` and `createTextNode`.
2020-01-04 19:00:42 -05:00
David Wendt
97bcb6b2dc
Add an ignored test for `xmlDecl`.
...
Test is currently ignored because AS2 XML currently handles XML declarations in ways not compatible with our current parser. Investigating hacky ways around this.
2020-01-04 19:00:41 -05:00
David Wendt
c02da74afa
Expose the `<?xml ?>` declaration to ActionScript.
...
I can't write proper tests for this because our underlying XML parsing technology doesn't let us do what AS2 XML does: just copy the first xml tag out of the document and into a string. No, seriously, anything at the start of the parsed XML that starts with `<?xml` and ends with `?>` gets copied into Flash's moral equivalent of `xml::Document` as a string. We parse the whole thing, which is wrong, so we'll need to additionally retain the original xmldecl string in order to pass the test I wrote for this.
2020-01-04 19:00:41 -05:00
David Wendt
ce0546fc2c
Add test for `docTypeDecl`.
2020-01-04 19:00:40 -05:00
David Wendt
a7a349b02b
Expose `docTypeDecl` to ActionScript.
...
This also involves storing the `DocType` node on the document object and retrieving it later.
2020-01-04 19:00:40 -05:00
David Wendt
a80aab1b08
Document roots can store an attributes object, even though they don't have attributes
2020-01-04 19:00:40 -05:00
David Wendt
6a472d32bb
Filter incompatible nodes from the sibling and child lists.
2020-01-04 19:00:39 -05:00
David Wendt
fd14d0c9df
Doctype nodes should be represented as text nodes to ActionScript (if they somehow grab hold of them)
2020-01-04 19:00:38 -05:00
David Wendt
6b4bbee195
Create and store `DocType` nodes on the tree when we encounter a `<!DOCTYPE...>` tag.
2020-01-04 19:00:38 -05:00
David Wendt
aa749dc1b0
Store the XML document version, encoding, and standalone flags.
2020-01-04 19:00:38 -05:00
David Wendt
a869107480
The `DocumentRoot` node type should have it's own node type ID, and AS2 XML should filter it out. This also filters out comment nodes as text, which isn't technically wrong but we should do better
2020-01-04 19:00:37 -05:00
David Wendt
7965045d87
Add test for XMLNode.toString.
2020-01-04 19:00:37 -05:00
David Wendt
673f85f067
XMLNode type 1 is an element, not a text node.
2020-01-04 19:00:36 -05:00
David Wendt
88aa5f8004
Add extra whitespace to empty tags.
2020-01-04 19:00:36 -05:00
David Wendt
0c7a1fe667
Text and comment nodes are stored plain and must be escaped for XML
2020-01-04 19:00:36 -05:00
David Wendt
c7e1f34a5d
Print empty nodes as empty tags rather than start/end
2020-01-04 19:00:35 -05:00
David Wendt
c76e5ce447
appendChild also refuses to orphan nodes already part of another XML tree.
2020-01-04 19:00:35 -05:00
David Wendt
bff851e6a4
Add test for insertBefore
2020-01-04 19:00:34 -05:00
David Wendt
34cbe2e04b
insertNode rejects child nodes that already have a parent
2020-01-04 19:00:34 -05:00
David Wendt
7b4a509ebc
Avoid double-borrows when moving a child within it's parent
2020-01-04 19:00:33 -05:00
David Wendt
7753e20fe3
Add a test for XML.removeNode().
2020-01-04 19:00:33 -05:00
David Wendt
30266b2ce7
remove_child should also ensure the child disowns the parent.
2020-01-04 19:00:33 -05:00
David Wendt
8c5dcfe662
Swap in newly constructed nodes *before* filling them with content.
...
Fixes a bug where new XML("<node />").childNode[0].parentNode did NOT refer to the overall document object, but to a phantom text node.
This is because the swap operation used to construct an XMLObject's node in-place was happening AFTER parsing, which means that referents already existed to the temporary XMLNode created by XMLObject::new. swap is not to be called after tree structure has been created; it does not update referents to the swapped nodes.
In the future I should examine the implications of explicitly reconstructing already existing nodes, e.g. through XML.apply(some_xml). Right now, the existing node will be swapped with a new one, and two nodes will exist pointing to the same script object, which is a huge problem with our overall design. We should, at the very least, disassociate swapped nodes from their script object, just in case they still have referents.
Ideally, we wouldn't have to swap nodes, but to avoid a swap, I'd have to instead have a second layer of indirection just to hold a rewritable pointer that every XMLObject points to. This isn't really worth it unless I HAVE to do it, so I'm not going to do it.
2020-01-04 19:00:32 -05:00
David Wendt
568d90f4dc
Warn if XML.removeNode fails for whatever reason
2020-01-04 19:00:32 -05:00
David Wendt
1577f51730
Expose elided objects as pointers when debugging XML nodes
2020-01-04 19:00:32 -05:00
David Wendt
19ca11b08c
Impl `toString`
2020-01-04 19:00:31 -05:00
David Wendt
513460e4e0
Implement `insertBefore`
2020-01-04 19:00:31 -05:00
David Wendt
b0dce445b0
Impl `removeNode`
2020-01-04 19:00:29 -05:00
David Wendt
00319f14a8
Implement `namespaceURI`
2020-01-04 19:00:29 -05:00
David Wendt
73da72db98
Add a test for `appendChild`.
2020-01-04 19:00:28 -05:00
David Wendt
7c95eff048
Flag an error if we accidentally introduce a second script object by accident.
2020-01-04 19:00:28 -05:00
David Wendt
abb2690367
When constructing new XML nodes or documents, always ensure that the new node we swap in is properly linked to the same script object so that we don't accidentally recreate them.
2020-01-04 19:00:28 -05:00
David Wendt
8939dae90c
Implement `XMLNode.attributes` w/ read tests
2020-01-04 19:00:27 -05:00
David Wendt
6f48f3436f
Expose `previousSibling` and `nextSibling` to ActionScript.
...
This commit also fixes a bug caused by excessive use of copypaste, which was detected by the included test.
2020-01-04 19:00:25 -05:00
David Wendt
223320c98c
Expose `parentNode` to ActionScript
2020-01-04 19:00:24 -05:00
David Wendt
807725d7aa
Expose `firstChild` and `lastChild` to ActionScript w/ tests
2020-01-04 19:00:24 -05:00
David Wendt
1d1e493e0e
Refactor the child adoption process to ensure the child also adopts it's siblings.
2020-01-04 19:00:23 -05:00
David Wendt
48d68bebc4
Implement `hasChildNodes()` and add test
2020-01-04 19:00:23 -05:00
David Wendt
c58e866236
Add test for `cloneNode`
2020-01-04 19:00:22 -05:00
David Wendt
881dcb76ab
`cloneNode` without arguments is morally equivalent to `false`
2020-01-04 19:00:21 -05:00
David Wendt
8e33566d07
Add namespacing test
2020-01-04 19:00:21 -05:00
David Wendt
69a1ab1649
Expose namespace prefix and URI lookups to ActionScript.
...
Also, fix the previous commit's half-assed impl.
2020-01-04 19:00:20 -05:00
David Wendt
fe7d2b5173
Extremely WIP impl of `lookup_uri_for_namespace`
2020-01-04 19:00:20 -05:00
David Wendt
55fa6ef09b
Add node cloning support
2020-01-04 19:00:19 -05:00
David Wendt
37f6efb753
Expose `appendChild` to ActionScript
2020-01-04 19:00:19 -05:00
David Wendt
08c0f273a6
Add sibling links to nodes.
2020-01-04 19:00:18 -05:00
David Wendt
7e45dee8cf
Clippy said so.
2020-01-04 19:00:18 -05:00
David Wendt
eec449422b
`XMLDocument.roots` is not necessary since you can just get the children of it's node form anyway...
2020-01-04 19:00:18 -05:00
David Wendt
f8f569440f
Add very basic XML test
2020-01-04 19:00:17 -05:00
David Wendt
cfacd397cf
Most XML properties return `null`, not `undefined`.
...
Furthermore, `prefix` does not distinguish between `<test>` and `<:test>` - they both have a `prefix` of `""`.
2020-01-04 19:00:17 -05:00
David Wendt
b491dd034e
Don't overflow stack when debug-printing an entire document, either.
2020-01-04 19:00:16 -05:00
David Wendt
e47a1d1e38
Fix newly constructed XML trees not actually containing the XML they just parsed.
2020-01-04 19:00:16 -05:00
David Wendt
960e4dad90
Don't cause stack overflow when debug-printing XML nodes.
2020-01-04 19:00:16 -05:00
David Wendt
bec60acc1e
`XML.prototype` should be an `XMLObject` so that instances of `XML` can hold a node
2020-01-04 19:00:15 -05:00
David Wendt
d058c83ac0
Document roots should accept children.
2020-01-04 19:00:15 -05:00
David Wendt
571c4bbd52
Cargo fmt compliance
2020-01-04 19:00:15 -05:00
David Wendt
0af248d81f
Expose `childNodes` to ActionScript
2020-01-04 19:00:14 -05:00
David Wendt
e7768d0802
Add methods to allow storing XML objects on the accompanying tree nodes, so that expando properties on child nodes will work.
2020-01-04 19:00:13 -05:00
David Wendt
b06dd5d15e
Add a special node to represent the document root in the node tree, and get rid of the explicit document reference type in `XMLObject`.
2020-01-04 19:00:12 -05:00
David Wendt
0fe0e4fe90
Separate `XMLName` into another module
2020-01-04 19:00:11 -05:00
David Wendt
3928c7cc51
Reject empty text nodes
2020-01-04 19:00:11 -05:00
David Wendt
7a9a16e598
Don't repeat yourself.
2020-01-04 19:00:11 -05:00
David Wendt
bd1ea56cc3
Implement `XMLNode` properties that don't require child or attribute iteration.
2020-01-04 19:00:10 -05:00
David Wendt
e2eb3d0bde
Add a test of XMLDocument::from_str.
...
This test technically works, but the results were slightly surprising. If it turns out Flash works differently from `quick_xml`, we'll change this test to match Flash.
2020-01-04 19:00:10 -05:00
David Wendt
6ae5ae3038
Add Comment parsing support
2020-01-04 19:00:10 -05:00
David Wendt
4f5ac09b73
Expose XML document constructor, including text parsing ability
2020-01-04 19:00:09 -05:00
David Wendt
554f0dc1e5
Add XMLNode class and constructor impl
2020-01-04 19:00:07 -05:00
David Wendt
6a65e984ae
Add a new `XMLObject` variant to the AVM1 object ecosystem.
...
This particular variant is actually a two-in-one deal: `XMLObject`s may either refer to a document or a node.
2020-01-04 18:58:42 -05:00
David Wendt
89c9753520
Add rudimentary custom DOM impl on top of `quick_xml`.
...
`quick_xml` was chosen due to it's high performance and support for zero-copy use cases. However, we are not using `minidom`, which is the already-extant DOM impl that uses `quick_xml` as it's parsing provider. This is because `minidom` nodes are not amenable to garbage collection.
Specifically: we want to be able to construct a new `Object` variant that holds part of an XML node. However, `minidom::Element` directly owns it's children, meaning that we can't hold references to it from within `Object` while also keeping those objects to the `'gc` lifetime. Hence, we provide a GC-exclusive DOM implementation.
I ruled out solutions such as holding an entire XML tree in an `Rc` and having AVM objects that shadow them. This works for `SwfSlice` because indexing an array is cheap; but traversing a tree can get very expensive. XML is used in many places in Flash Player, so it's important that we treat it like a first-class citizen.
2020-01-04 18:48:17 -05:00
Mike Welsh
4ce67535b0
tests: Add test for Color
2020-01-03 20:31:32 -08:00
Mike Welsh
36b3e5b34f
avm1: Implement Color class
2020-01-03 20:31:32 -08:00
Mike Welsh
4bf29f677f
avm1: Implement Sound.duration
...
Add AudioBackend::get_sound_duration.
2020-01-03 17:11:00 -08:00
Mike Welsh
b9d24d9a49
avm1: First pass at implementing Sound.stop
2020-01-03 17:11:00 -08:00
Mike Welsh
d0142f1d67
audio: Add AudioBackend::stop_sound
2020-01-03 17:11:00 -08:00
Mike Welsh
63dd92259b
avm1: First pass of Sound object
2020-01-03 17:11:00 -08:00
dependabot-preview[bot]
a01e5b7854
build(deps): bump syn from 1.0.12 to 1.0.13
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.12 to 1.0.13.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.12...1.0.13 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 19:15:37 +00:00
dependabot-preview[bot]
b4a47e17da
build(deps): bump generational-arena from 0.2.6 to 0.2.7
...
Bumps [generational-arena](https://github.com/fitzgen/generational-arena ) from 0.2.6 to 0.2.7.
- [Release notes](https://github.com/fitzgen/generational-arena/releases )
- [Changelog](https://github.com/fitzgen/generational-arena/blob/master/CHANGELOG.md )
- [Commits](https://github.com/fitzgen/generational-arena/compare/0.2.6...0.2.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 19:14:43 +00:00
dependabot-preview[bot]
1048170235
build(deps): bump syn from 1.0.11 to 1.0.12
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.11 to 1.0.12.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.11...1.0.12 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 08:24:29 +00:00
Mike Welsh
87158647d1
core: Implement keyPress button events
2019-12-24 03:06:03 -08:00
Mike Welsh
2f0963fa6c
core: Fix button action with multiple conditions not firing ( fix #195 )
...
If a button event had both a keyPress condition and another
condition:
on(release, keyPress "A") { }
these actions would not fire on click, because it would still
check if the key was down (which doesn't apply to clicks!)
Fixes #195 .
2019-12-22 15:55:03 -08:00
Nathan Adams
9000451d58
core: Implemented Mouse.show() & Mouse.hide()
2019-12-22 14:33:46 -08:00
Mike Welsh
4cdeec5b64
avm1: Fix number coercion in arithmetic ops
...
A lot of the arithmetic ops were still using SWFv4 style coercion
(`Value::into_number_v1`) even though they use full ECMA-262
coercion in SWF5+. This would cause `undefined` to turn into 0
isntead of NaN, for example.
Fixes disappearing player in Achievement Unlocked
(https://www.newgrounds.com/portal/view/474371 )
It's possible even the older ops such as ActionAdd should do this,
too. Handcrafted bytecode will need to be used to test as you
cannot export these ops in newer SWF versions from the Flash IDE.
2019-12-22 03:01:58 -08:00
Mike Welsh
c9e0bdeaf5
core: GC trace Button::object
2019-12-21 23:54:50 -08:00
Mike Welsh
1d8ae9154b
tests: Add tests for AVM1 logical ops
2019-12-21 23:01:10 -08:00
Mike Welsh
a4a307cf9a
avm1: Use proper bool conversions for logical ops
...
ActionAnd, ActionOr, and ActionNot were incorrectly comparing
to 0. This only works for SWF<4. Now they all go through the
Value::as_bool method to handle version specific behavior.
Value::from_bool_v1 was also renamed to Value::from_bool.
2019-12-21 23:01:10 -08:00
Mike Welsh
00fdc74f1f
tests: Add test for property updating in fast-forward gotos
2019-12-21 21:16:27 -08:00
Mike Welsh
fd92bd5f78
core: Fix PlaceObject modifications in fast-forward gotos
...
When fast-forwarding with a goto, modifications were not taking
effect to objects that exist both in the starting and the final
frame.
2019-12-21 21:16:27 -08:00
Nathan Adams
eedc4bbe24
core: Added Input backend, currently unimplemented, for polling user input
2019-12-21 19:08:06 -08:00
Nathan Adams
6c484fe29d
core: Changed KeyCode into an enum that maps out every Flash key code
2019-12-21 19:08:06 -08:00
Mike Welsh
d7df15989f
core: Clear drag if object is removed while dragging
2019-12-21 16:28:41 -08:00
Mike Welsh
531e4d640d
avm1: Implement StartDrag/EndDrag
2019-12-21 16:28:41 -08:00
Mike Welsh
713e959ce4
core: Implement DisplayObject::object for Button
2019-12-21 16:28:41 -08:00
Mike Welsh
4bd54cc2ea
core: Fix DisplayObject::global_to_local and local_to_global
2019-12-21 16:28:41 -08:00
Mike Welsh
f2d31b222b
core: Implement DefineButtonCxform SWF tag
...
(Although nothing uses this... it was only used in SWF version 2
and below!)
2019-12-20 19:20:25 -08:00
dependabot-preview[bot]
e8e0b83d23
build(deps): bump smallvec from 1.0.0 to 1.1.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.0.0...v1.1.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-20 22:36:07 +00:00
Mike Welsh
4026e22bbf
core: Handle DefineButtonSound SWF tag
...
This plays sounds whenever a button is hovered/clicked. Fixes
gun sounds in Pico's School.
2019-12-20 01:08:28 -08:00
Mike Welsh
d459bbe010
avm1: Functions store their base clip
...
Functions now store their base clip (the code that contains the
executing bytecode). This is because `GotoFrame` and other actions
will execute on the clip the bytecode exists on, not on `this`.
(Note that `this.gotoAndStop` uses `GetMember` actions, which
worked correctly).
`Activation` now stores `target_clip`, and `Avm1::target_clip` and
`target_clip_or_root` grab this from the current stack frame.
Renamed `start_clip` to `base_clip` to match Flash conventions.
Removed `active_clip` as this was superfluous. Now you can use
`Avm1::target_clip_or_root`.
`UpdateContext` no longer contains `target_clip` etc.
2019-12-19 17:30:50 -08:00
Mike Welsh
c4b446ff78
tests: Add test for functions closing over base clip
2019-12-19 17:30:50 -08:00
Mike Welsh
13c43ed171
tests: Update movieclip_hittest to verify points are in root coordinates
2019-12-19 12:35:56 -08:00
Mike Welsh
540b03090a
avm1: hitTest point is actually in root coordinates ( fix #185 )
2019-12-19 12:35:56 -08:00
Nathan Adams
f6f358b4de
avm1: Expose TextFields and allow setting their .text
2019-12-19 10:19:43 -08:00
Mike Welsh
c9a5d2dbb3
chore: Fix clippy lints in 1.40
2019-12-19 09:10:41 -08:00
Nathan Adams
d3848f97ea
avm1: Implemented MovieClip.hittest, without shape flag
2019-12-18 15:21:14 -08:00
Nathan Adams
5f6eea6f25
chore: Refactor system listeners into a reusable system
2019-12-18 15:15:56 -08:00
Mike Welsh
3a8256a993
avm1: Allow setting _name
2019-12-18 14:07:32 -08:00
Mike Welsh
9079b69991
avm1: Push Undefined when trying to construct invalid object
2019-12-18 13:47:01 -08:00
Mike Welsh
bb6a4c119c
avm1: Warn and clear operand stack if not empty after execution
...
Add a check and clear the stack if it isn't empty at the end of
`run_stack_till_empty`. This is probably a bug on our side
and we a good place for breakpoints.
2019-12-18 13:47:01 -08:00
Mike Welsh
8b9aedc4c8
avm1: Fix extra stack frame in event handlers
...
When running an clip event handler (e.g. onEnterFrame), a stack
frame is pushed to get the property value. However, this frame
was causing an extra Undefined to be pushed on the operand stack in
`Avm1::retire_stack_frame`, which would blow out the stack.
Now this stack frame is popped after the property is resolved and
before the function is executed. The function will push its own
stack frame when it executes.
2019-12-18 13:47:01 -08:00
Mike Welsh
3e003ed9dd
avm1: Add missing stage.rs
2019-12-17 22:36:53 -08:00
Mike Welsh
3ebc1ed928
avm1: Stub out Stage properties
...
This is a very rough stub out of Stage.width and height to get
basic V-cams to start functioning.
TODO: Implement the different stage scaling modes. We will probably
want to add a "Stage" display object to handle this.
2019-12-17 22:28:44 -08:00
Mike Welsh
2af76e10f8
core: Mark scale/rotation as dirty when matrix changes
2019-12-17 22:06:34 -08:00
Mike Welsh
74aa127b74
avm1: Fix double borrow in Executable::exec
2019-12-17 21:35:22 -08:00
Mike Welsh
32953d5c5c
avm1: Allow objects in ActionSetTarget2
...
Fixes 8-Bit Theater 3 soft locking on the first frame.
2019-12-17 18:32:25 -08:00
Mike Welsh
a9baf72c53
avm1: Handle trailing / in slash paths
2019-12-17 04:00:01 -08:00
Mike Welsh
28faf2030b
tests: Add failing case to slash_syntax test
2019-12-17 04:00:01 -08:00
Mike Welsh
dae3e27fb3
avm1: Rename Library::instantiate_by_id
2019-12-17 03:27:05 -08:00
Mike Welsh
fc3878d6d9
tests: Add tests for movie clip cloning/removing
2019-12-17 03:20:01 -08:00
Mike Welsh
1476930e0c
avm1: Implement MovieClip.removeMovieClip
2019-12-17 03:20:01 -08:00
Mike Welsh
1668e823e6
avm1: Implement MovieClip.createEmptyMovieClip
2019-12-17 03:02:07 -08:00
Mike Welsh
d33a8278d7
avm1: Implement MovieClip.duplicateMovieClip
2019-12-17 03:00:56 -08:00
Mike Welsh
009da39f12
avm1: Implement MovieClip.attachMovie
2019-12-17 03:00:56 -08:00
Mike Welsh
d0504104b7
core: Use i32 for display object depth
2019-12-17 02:48:55 -08:00
Mike Welsh
4cb2cefc5b
swf: Switch depth to u16
2019-12-17 02:48:55 -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
b6df9fded0
core: Remove boxes from library items
2019-12-16 19:32:34 -08:00
Nathan Adams
45e497826b
avm1: Implement `Mouse` listeners & events (excluding scroll)
2019-12-16 19:22:10 -08:00
Mike Welsh
c2f4633cdb
avm1: Trace constant_pool in Collect for Activation
2019-12-16 16:14:49 -08:00
Mike Welsh
c61842a72a
tests: Add test for slash syntax
2019-12-16 15:33:57 -08:00
Mike Welsh
f270a278c0
avm1: Push Undefined on GetVariable with invalid slash path
2019-12-16 15:33:16 -08:00
Mike Welsh
8b85212513
avm1: Handle .. in slash syntax
2019-12-16 15:24:25 -08:00
Mike Welsh
f4f755e958
avm1: Remove warnings on _currentframe/_totalframe
2019-12-16 10:21:37 -08:00
Nathan Adams
84ff69854a
avm1: Pass mouse events down to movie clips
2019-12-16 10:11:23 -08:00
Nathan Adams
c8e42123cf
avm1: Implemented `_xmouse` and `_ymouse`
2019-12-16 10:11:23 -08:00
Nathan Adams
783037e8cc
chore: Removed array debug code that snuck in. Oops!
2019-12-16 09:56:46 -08:00
Mike Welsh
e4af2502dc
avm1: Fix mismatched action/init_action stack frames
...
DoAction was accidentally creating its stack frame using
Avm1::insert_stack_frame_for_init_action, causing a dummy
Undefined to be pushed and blowing out the stack.
2019-12-16 01:14:06 -08:00
Mike Welsh
b2cdc19f55
tests: Add test for goto MovieClip methods
2019-12-16 00:52:27 -08:00
Mike Welsh
bf0b777246
avm1: Use ECMA-262 ToInt32 modulo behavior
...
Everything is a double in ES land, so when converting a number to
int, the double is modulo'd to allow for wrapping 32-bit int
semantics.
See ToInt32 and ToUInt32 in the specs:
https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%202nd%20edition,%20August%201998.pdf
2019-12-16 00:52:27 -08:00
Mike Welsh
39f54b4a16
avm1: Add gotoAndPlay and gotoAndStop MovieClip methods
2019-12-16 00:52:27 -08:00
Mike Welsh
a3e316847b
core: Clamp goto frame in range
2019-12-16 00:52:27 -08:00
Mike Welsh
fa5a168fad
avm1: Clean up MovieClip prototype
2019-12-16 00:52:27 -08:00
Mike Welsh
46365c5702
avm1: Implement clip event method callbacks
2019-12-15 20:01:50 -08:00
Mike Welsh
eb3aa1c878
core: Move `ClipAction` into crate::events
2019-12-15 19:22:23 -08:00
Mike Welsh
1fe170400c
tests: Add clip_events regression test
2019-12-15 19:22:23 -08:00
Mike Welsh
76e94dda1c
core: Implement "unload" clip event
...
Fire unload clip event when a movie clip is removed. Added
`ActionType` enum used by `ActionQueue::queue_actions` that
determines the type of action that is running (replaces `is_init`
parameter).
2019-12-15 19:00:16 -08:00
Mike Welsh
38ebdd9d05
core: Fire "load" and "enterFrame" clip events
...
MovieClips will now fire their "load" and "enterFrame" clip events.
Added `MovieClipFlags` to store various flags for the movie clip.
2019-12-15 19:00:16 -08:00
Mike Welsh
174426856f
avm1: Use `EnumSet::from_bits` in `object::as_set_prop_func`
2019-12-15 14:26:43 -08:00
David Wendt
d9aac0f2cf
Adjust `SuperObject` based on actual Flash behavior.
2019-12-15 13:32:04 -08:00
David Wendt
edf7a19eb7
Implement `Function.prototype.toString`.
2019-12-15 13:32:04 -08:00
David Wendt
33c66571f5
Allow `is_instance_of` to inspect the prototype chains of implemented interfaces.
...
This makes the `extends_chain` test pass.
2019-12-15 13:32:04 -08:00
David Wendt
854526923e
Calls to `super` inherently bind to itself.
...
This requires some subclassing nonsense to be able to smuggle a self-reference into `SuperObject`s. When successfully smuggled, all calls to `call` will be invoked with the `super` object as `this`. This allows constructor chaining to work.
Note that not all `Object` trait methods are implemented on `SuperObject`, so things like `delete this.x` in super constructors will randomly fail. This should be fixed.
2019-12-15 13:32:04 -08:00
David Wendt
548f19ffbb
`ActionExtends` uses the class's explicit prototype, not it's implicit prototype which should almost always be `Function.prototype`.
2019-12-15 13:32:04 -08:00
David Wendt
eb06501492
Since `get_local` doesn't scale the prototype chain anymore, we don't need to change the prototype chain traversal anymore.
2019-12-15 13:32:04 -08:00
David Wendt
e08cfcd288
Enable the `as2-oop` test since it now passes.
2019-12-15 13:32:04 -08:00
David Wendt
5c1ac19c1b
Implement `super`, mostly.
...
We implement `super` by way of a new `Object` impl which wraps arbitrary objects with a modified prototype chain. Specifically, the lowest layer of the prototype chain is omitted. This new `SuperObject` script is composable: a chain of two `SuperObject`s will go two levels of inheritance upwards while still maintaining non-prototype property access.
2019-12-15 13:32:04 -08:00
David Wendt
681b4adfa4
Functions close over the constant pool they were defined with.
2019-12-15 13:17:41 -08:00
David Wendt
71d9655f6d
Implement `ASSetPropFlags`
2019-12-15 13:17:41 -08:00
David Wendt
d173e91de6
AS2 OOP test. This won't actually pass until we have interfaces, init actions, and constant pool closures merged in. Hence, it's ignored.
2019-12-15 13:17:41 -08:00
David Wendt
213b3cfca1
Store implemented interfaces on the prototype, not the constructor, so that InstanceOf can get at them.
2019-12-15 13:17:41 -08:00
David Wendt
fcb37bd273
Implement `ActionCastOp`.
2019-12-15 13:17:41 -08:00
David Wendt
1b459f522d
Implement `ActionImplementsOp`.
...
This commit title has won the "World's Lowest-Entropy Commit Title" award for 2019.
2019-12-15 13:17:41 -08:00
David Wendt
ee4b47d062
Add interface support, and add interface checking to `ActionInstanceOf`.
2019-12-15 13:17:41 -08:00
David Wendt
ca93bba5c1
Implement ActionExtends.
2019-12-15 13:14:21 -08:00
Mike Welsh
81e5c7ba1d
core: Rename get_length etc. -> length
2019-12-15 12:33:24 -08:00
Mike Welsh
bc42004db5
core: Implement From for Object variants to Value/ReturnValue
2019-12-15 12:33:24 -08:00
Nathan Adams
133a1c3c91
core: Interacting with memebers on something that isn't an object isn't a hard error
2019-12-15 12:33:24 -08:00
Nathan Adams
aca746eee7
core: Implemented Array.splice with tests
2019-12-15 12:33:24 -08:00
Nathan Adams
31b84c5f19
core: Made arrays a storage property of objects, not a unique object type. Added more corner case tests.
2019-12-15 12:33:24 -08:00
Nathan Adams
3bdf710af6
core: Add another array.concat test
2019-12-15 12:33:24 -08:00
Nathan Adams
32a1eda080
core: Implement Arrays & array prototype
2019-12-15 12:33:24 -08:00
Nathan Adams
46b6ce570b
core: Added array tests
2019-12-15 12:33:24 -08:00
Mike Welsh
3c83d9ac9d
docs: Shuffle some docs in DisplayObject
2019-12-15 10:17:33 -08:00
Mike Welsh
95755b5fb3
tests: Add test for TransformedByScript flag
2019-12-15 10:17:33 -08:00
Mike Welsh
d7393dc81d
core: Add DisplayObjectFlags::TransformedByScript
...
This is set when a DisplayObject is dynamically moved by AS code,
which causes further modification from PlaceObject tags to be
ignored.
2019-12-15 10:17:33 -08:00
Mike Welsh
f6c50efe5a
tests: Clean up stage_object_propreties and add _name and _target
2019-12-15 10:17:33 -08:00
Mike Welsh
8c27097240
core: Implement _target property
...
Add DisplayObject::slash_path to get the Flash 4-style slash path
to the clip. This fixes the tellTarget regression test and removes
the superfluous `target_path` from `UpdateContext`.
2019-12-15 10:17:33 -08:00
Mike Welsh
d5f7521061
core: Ignore NaN in StageObject setters
2019-12-15 10:17:33 -08:00
Mike Welsh
e36dbad7d2
tests: Add stage_object_properties test
2019-12-15 10:17:33 -08:00
Mike Welsh
c9864eb557
core: Add StageObject properties
2019-12-15 10:17:33 -08:00
Mike Welsh
3986a8dc4a
tests: Add regression test for display object properties
2019-12-15 08:54:26 -08:00
Mike Welsh
d30506dc59
tests: Add test for enumerating child instances
2019-12-15 08:54:26 -08:00
Mike Welsh
f2422a2c9f
avm1: Add attributes for _global/_root/_parent
2019-12-15 08:54:26 -08:00
Mike Welsh
11f2b46b6a
tests: Add test for stage instances
2019-12-15 08:54:26 -08:00
Mike Welsh
c29b042f5e
avm1: Get child clip instances in StageObject
...
Add the logic to get children display objects as properties in
`StageObject`.
2019-12-15 08:54:26 -08:00
Mike Welsh
783ede6f79
core: Add DisplayObject::path
2019-12-15 08:54:26 -08:00
Mike Welsh
73604a891e
core: Move get_child_by_name to DisplayObject
2019-12-15 08:54:26 -08:00
David Wendt
724f845037
Remove the `DisplayNode` slot from `ScriptObject`, since all display node objects should be `StageObject`s now.
2019-12-15 08:54:26 -08:00
David Wendt
fa9329df68
Instantiate all MovieClips as StageObjects.
2019-12-15 08:54:26 -08:00
David Wendt
3df6c7eeef
Always post-instantiate display objects when running tests.
2019-12-15 08:54:26 -08:00
David Wendt
73655c0c88
Add a separate native object type for objects tied to the stage.
2019-12-15 08:54:26 -08:00
Mike Welsh
f0c6b2d8d8
core: Remove this from Object::get/set
2019-12-15 08:54:26 -08:00
dependabot-preview[bot]
251fb01572
build(deps): bump jpeg-decoder from 0.1.17 to 0.1.18
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.17 to 0.1.18.
- [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>
2019-12-11 18:21:42 +00:00
Mike Welsh
b59bf40c78
core: Remove this from Object::get/set
2019-12-10 01:36:02 -08:00
Mike Welsh
f7822141b7
core: Rename display_node methods to display_object
2019-12-10 01:36:02 -08:00
Mike Welsh
71e4eb87d7
core: Remove as_*_mut methods on DisplayObject/Object
2019-12-10 01:36:02 -08:00
Mike Welsh
d7740bc3ad
core: Don't touch UpdateContext::active_clip in DisplayObjects
...
DisplayObject code no longer has to manage
UpdateContext::active_clip before calling out to children, because
each child still has access to its Gc pointer.
2019-12-10 01:36:02 -08:00
Mike Welsh
25b86c14ae
core: Move method impls from Button to ButtonData
2019-12-10 01:36:02 -08:00
Mike Welsh
78e65a01df
core: Move method impls from MovieClip to MovieClipData
2019-12-10 01:36:01 -08:00
Mike Welsh
12c1bf7cf1
core: Clean up UpdateContext creation
...
Added Player::mutate_with_update_context, which takes a closure
and passes it an UpdateContext.
2019-12-10 01:36:01 -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
Mike Welsh
b27bc578e0
core: Add enum_trait_object proc macro
...
The enum_trait_object attribute macro can be used to define an enum where
each variant holds an implementor of a trait. It implements all
methods to forward to the underlying object, as well as `From` impls.
This an aliternative to using trait objects that gets along nicer
with `gc-arena`.
2019-12-10 01:36:01 -08:00
dependabot-preview[bot]
86c0fa327b
build(deps): bump jpeg-decoder from 0.1.16 to 0.1.17
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.16 to 0.1.17.
- [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>
2019-12-09 17:39:42 +00:00
Mike Welsh
cbe0f873af
tests: Add test for Object.addProperty
2019-12-03 15:01:39 -08:00
Mike Welsh
90b6858bb2
avm1: Fix return value of `Object.addProperty`
2019-12-03 14:59:37 -08:00
Mike Welsh
28364f7d00
avm1: Fix `this` object in GetMember/SetMember
2019-12-03 14:59:01 -08:00
Mike Welsh
1a1cdfa757
desktop: Allow audio creation to fail
...
Switch to NullAudioBackend if CpalAudioBackend fails to initialize.
(This happens on my laptop which doesn't have an audio device!)
2019-11-30 20:08:34 -08:00
Nathan Adams
eb185982cd
Add more Number(x) tests, and corrected primitive_as_number to match
2019-11-29 16:07:35 -08:00
Nathan Adams
85b9ffe102
core: Merge both test macros into a generic test_method
2019-11-29 13:12:00 -08:00
Nathan Adams
1f4405189a
core: Make math test_std also take in versions
2019-11-29 13:12:00 -08:00
Nathan Adams
999bb128de
core: Allow global test_std to test multiple swf versions
2019-11-29 13:12:00 -08:00
Nathan Adams
4c7d37c498
core: Added `avm_debug!` macro
2019-11-29 12:59:45 -08:00
Nathan Adams
d1b73582ce
core: Add feature `avm_debug` that toggles tracing avm actions and stack history
2019-11-29 12:59:45 -08:00
David Wendt
9ec85c3892
Add tests for SWF6 numerical coercions.
2019-11-28 21:32:10 -05:00
David Wendt
f856243247
Primitive coercions should not yield an object just because valueOf is undefined.
2019-11-28 20:53:32 -05:00
David Wendt
ec3ac4e5d6
`undefined` coerces to `0.0` on SWF6
2019-11-28 20:53:32 -05:00
David Wendt
89e060be4e
Add a regression test for `_global` being a bare object
2019-11-28 20:53:31 -05:00
David Wendt
16259ad74a
Calling uncallable values does not actually cause a runtime error in Flash; it just returns null.
...
This was discovered almost by accident: @Dinnerbone noticed that `_global == null`, and surmised that `valueOf` was the culprit. However, this doesn't really make sense: `_global` is a bare object, so it shouldn't have a `valueOf` (and in practice, it doesn't).
The ultimate cause of such an odd comparison is as such:
1. Flash coerces the `_global` object to a numerical primitive by calling `valueOf`.
2. `_global.valueOf` is undefined. Flash handles calls to any uncallable value by literally just having it return `undefined`. In other words, all values are implicitly callable as empty functions.
3. `undefined` is then compared to `null`. These two values *are* equal under abstract equality (`==`). Hence, `_global == null`.
For comparison, modern ECMAScript engines throw errors on calls to uncallable values; and won't attempt to use an invalid `valueOf` to coerce objects. So none of this applies to, say, standard JavaScript in your browser.
2019-11-28 20:53:31 -05:00
Nathan Adams
68760007fc
Lessthan can return `undefined`, not just booleans
2019-11-28 20:53:30 -05:00
Nathan Adams
638231e7fb
swf4 doesn't have NaN or Infinity
2019-11-28 20:53:20 -05:00
Nathan Adams
581d0940b2
NaN == NaN without coercion
2019-11-28 20:43:59 -05:00
Nathan Adams
f33229a2a1
`_global` == null && `_global` == undefined
2019-11-28 20:43:58 -05:00
Nathan Adams
ec5ed4f140
Change regression_test to use `actual, expected` so tools (like intelliJ) diff it correctly
2019-11-28 20:43:54 -05:00
Nathan Adams
f5b78f6fb0
Typo in test filename
2019-11-28 20:41:26 -05:00
Nathan Adams
bda72728ac
Assume that NaN == NaN for ruffle
2019-11-28 20:41:25 -05:00
Nathan Adams
c9c4749bb0
core: Added battery of tests for lessthan, greaterthan, equals and strictequals between swf4-swf7
2019-11-28 20:41:23 -05:00
Nathan Adams
3f4597f081
Add tests for lessthan
2019-11-28 20:31:02 -05:00
David Wendt
504f962256
Add a test for every string coercion I could find.
2019-11-28 20:28:46 -05:00
David Wendt
129d50bfa6
Implement ECMAScript compliant type coercions.
...
This includes ECMA-262 2ed `ToNumber`, `ToPrimitive` (Number), `ToString`, and abstract equality and less-than implementations. Note that `ToPrimitive` is only the "number hint" variant, and Flash specifically *never* calls `toString` like how ECMA-262 specifies.
Several builtins inherit numerical coercion - I'm not 100% sure if that's correct.
The following ActionScript opcodes now perform ECMA-262 style coercions:
`ActionAdd2` (uses `valueOf` / "ToPrimitive hint Number")
`ActionDecrement` (uses `valueOf`)
`ActionEquals2` (uses `valueOf`)
`ActionGetMember` (member names, uses `toString`)
`ActionIncrement` (uses `valueOf`)
`ActionLess2` (uses `valueOf`)
`ActionGreater` (uses `valueOf`)
`ActionSetMember` (member names, uses `toString`)
`ActionStringEquals` (uses `toString`)
`ActionStringGreater` (uses `toString`)
`ActionStringLess` (uses `toString`)
`ActionToNumber` (uses `valueOf`)
`ActionToString` (uses `toString`)
`ActionTrace` (uses `toString`)
The following functions now gained user-specified coercions via `toString`:
`_global.number` (uses `valueOf`)
`_global.is_nan` (uses `valueOf`)
Every function in `Math` (uses `valueOf`)
2019-11-28 20:23:39 -05:00
Nathan Adams
2650433271
Fixed get_keys with prototypes
2019-11-27 22:30:31 +01:00
Nathan Adams
585c520b87
Added prototype_enumerate test, `for (key in obj)`
2019-11-27 21:46:21 +01:00
Nathan Adams
fdbd16a5d9
Ignore extends_chain, that's NYI
2019-11-27 21:11:03 +01:00
Nathan Adams
57d8469e3b
Added a test for isPrototypeOf
2019-11-27 21:09:14 +01:00
David Wendt
1eb4dfa696
Merge remote-tracking branch 'dinnerbone/feature/extends_test' into feature/prototyping
2019-11-27 14:58:47 -05:00
David Wendt
5999aded7a
Merge remote-tracking branch 'dinnerbone/feature/prototype_tests' into feature/prototyping
2019-11-27 14:56:39 -05:00
David Wendt
46e58c3ecd
Remove `ReturnValue.ignore` entirely, since you really *do* need to resolve `ReturnValue`s, even if you don't want the result.
2019-11-27 14:52:07 -05:00
Nathan Adams
b0f0008596
Added test for hasOwnProperty
2019-11-27 20:51:40 +01:00
Nathan Adams
03713f32e9
Correct fla for object_prototypes
2019-11-27 20:46:09 +01:00
Nathan Adams
b43436bdd2
Enable recursive_prototypes test as it now passes
2019-11-27 20:31:33 +01:00
David Wendt
2c87888e28
Implement prototype chain recursion limit of 255 prototypes.
...
In Flash, this also at least claims to halt ActionScript execution on the movie. No such implementation of AVM poisoning currently exists in Ruffle, primarily because it's unclear what gets poisoned and implementing some of these options isn't yet possible:
1. AVM (e.g. all movies) - we would need to make the AVM fail silently in this case. This is the most straightforward way to poison the movie, but I'm not sure if this is how Flash actually does it, or if it poisons...
2. Movie - the current structure of movies is incompatible with adding arbitrary data to them. We need to merge `moviefetch` in before we can attach data to loaded movies.
3. MovieClip - this would also be implementable but has problems. How do child MovieClips know that their parent has been poisoned, or vice versa? What if a movie clip is loaded from one movie and moved into another?
As a result, I have decided to hold off on implementing recursion poisoning until I know where it's supposed to go and how to implement that.
2019-11-27 08:59:16 -05:00
Nathan Adams
e9ad733e68
Add a test to see if the avm crashes with recursive prototypes.
...
Spoilers: it does.
2019-11-26 23:38:34 +01:00
Nathan Adams
de1f5417ec
Added test for extending MovieClip prototype
2019-11-26 23:22:07 +01:00
Nathan Adams
ffaf10b604
Add test for prototyping
2019-11-26 23:22:07 +01:00
Nathan Adams
3bcd9ed71b
Added test for class & interface hierarchy
2019-11-26 22:42:11 +01:00
David Wendt
4655ebe73f
Always push the constructed object on the stack.
2019-11-26 15:07:59 -05:00
David Wendt
b9f02c290c
Functions should be traceable.
2019-11-26 15:07:03 -05:00
David Wendt
0b1afcf8be
Implement `ActionInstanceOf` (for non-interface types)
2019-11-26 14:51:06 -05:00
David Wendt
3c8d9b9c1c
`new` should be called on the prototype - not the constructor function. This will allow different host object impls to subclass correctly.
2019-11-26 14:51:06 -05:00
David Wendt
e8632bbcaa
Implement `valueOf` for `Object` and fix the `toString` impl.
2019-11-26 14:51:06 -05:00
David Wendt
73c3b42cd4
Move `force_set` and `force_set_virtual` into the `Object` trait. They are now called `define_value` and `add_property`, respectively.
...
While I don't expect every host object to implement it correctly, this also gets rid of a lot of unnecessary `unwrap` calls that would allow a poorly-written Flash file to kill the interpreter.
2019-11-26 14:51:06 -05:00
David Wendt
983c0fb200
Add proto chain inspection to the object interface.
2019-11-26 14:51:06 -05:00
David Wendt
0e59e1c961
Allow host-provided constructors to override `new` and provide host objects to the AVM when a particular constructor is called.
2019-11-26 14:51:06 -05: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
6dd40f8354
Split properties into a separate module.
2019-11-26 14:51:05 -05:00
David Wendt
813783881b
Implement explicit prototypes on user-generated functions.
...
`Object::function` now returns a pre-allocated function object. You may supply it an explicit prototype to have it linked into the function object (which is why we have to return a cell).
2019-11-26 14:51:05 -05:00
David Wendt
f347992eeb
Add `as_usize` method to `Value`
2019-11-26 14:51:05 -05:00
David Wendt
207a157f20
Add missing usize conversion
2019-11-26 14:51:05 -05:00
kmeisthax
fb34f73159
Manually constructing `Value` should no longer be necessary
...
Co-Authored-By: Nathan Adams <dinnerbone@dinnerbone.com>
2019-11-26 14:51:05 -05:00
David Wendt
1cb374da8a
`ActionSetMember` accepts non-String names as parameters.
2019-11-26 14:51:04 -05:00
David Wendt
fafad818d4
Implement `ActionInitObject`
2019-11-26 14:51:04 -05:00
David Wendt
da315c7311
Fix docstrings on these modules
2019-11-26 14:51:04 -05:00
David Wendt
b4e9b8442e
Implement `isPropertyEnumerable` and `isPrototypeOf`.
2019-11-26 14:51:04 -05:00
David Wendt
aa7997b658
Expose user-defined virtual properties to AVM code
2019-11-26 14:51:04 -05:00
David Wendt
a8e1654c9e
Implement `ActionNewMethod` and `ActionNewObject`
2019-11-26 14:51:04 -05:00
David Wendt
2f965d1c64
First stab at moving system builtins to explicit prototypes
2019-11-26 14:51:03 -05:00
Nathan Adams
882373d969
Object prototyping
2019-11-26 14:51:03 -05:00
Mike Welsh
6eaab8efdf
core: Merge #113 , interworking of Rust + ActionScript
...
Internal support for interworking Rust and ActionScript code
2019-11-25 04:27:05 -08:00
David Wendt
b8c24890fc
Allow overwriting read-only virtual properties in scope chains.
...
The previous behavior had an oversight: if you tried to set a variable with the same name as an in-scope property, it would always try to overwrite that property. This can fail silently and doesn't match with Flash Player behavior. Now, an attempt to overwrite a read-only property is instead correctly rejected so that it can be defined in local scope.
2019-11-23 22:00:37 -05:00
dependabot-preview[bot]
2e75f06ee5
build(deps): bump gc-arena-derive from 0.1.1 to 0.2.0
...
Bumps [gc-arena-derive](https://github.com/kyren/gc-arena ) from 0.1.1 to 0.2.0.
- [Release notes](https://github.com/kyren/gc-arena/releases )
- [Changelog](https://github.com/kyren/gc-arena/blob/master/CHANGELOG.md )
- [Commits](https://github.com/kyren/gc-arena/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-22 18:07:50 +00:00
Nathan Adams
ae064b62be
chore: Change to no_drop from empty_drop for new gc-arena
2019-11-22 17:53:05 +00:00
dependabot-preview[bot]
238c575f16
build(deps): bump gc-arena from 0.1.1 to 0.2.0
...
Bumps [gc-arena](https://github.com/kyren/gc-arena ) from 0.1.1 to 0.2.0.
- [Release notes](https://github.com/kyren/gc-arena/releases )
- [Changelog](https://github.com/kyren/gc-arena/blob/master/CHANGELOG.md )
- [Commits](https://github.com/kyren/gc-arena/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-22 17:53:05 +00:00
David Wendt
bae0476113
Don't panic when double-locking a stack frame.
2019-11-20 14:30:34 -05:00
David Wendt
17215cc787
Remove the `NoResult` variant of `ReturnValue` as it is no longer useful or in use.
2019-11-20 14:30:33 -05:00
David Wendt
8c1d25b0f7
Add conversions for all the same conversions regular `Value`s have, so that you don't have to constantly mark things as `ReturnValue::Immediate`
2019-11-20 14:30:33 -05:00
David Wendt
e4eb930d44
Remove all references to stack continuations from our documentation.
2019-11-20 14:30:33 -05:00
David Wendt
5bf90653c4
Add implicit coercions to remove most instances of manually constructing a `ReturnValue`.
2019-11-20 14:30:33 -05:00
David Wendt
4b824370f4
Remove the stack continuation system. If we decide to structure this system in the same way in the future, we'll probably use async functions or something like that.
2019-11-20 14:30:33 -05:00
David Wendt
2aa5b62b44
Make most code that might touch user-defined functions falliable.
2019-11-20 14:30:32 -05:00
David Wendt
a49af7815c
Resolve all existing return values on the Rust stack.
2019-11-20 14:30:32 -05:00
David Wendt
bb1cde5557
Avoid double borrow panic caused by unreasonably long lifetime of `.write()` temporary
2019-11-20 14:30:32 -05:00
David Wendt
7284794c0b
Store the return value on the activation object when it's retired.
2019-11-20 14:30:32 -05:00
David Wendt
e2dcf47c56
Add a method to force resolve a `ReturnValue` on the Rust stack via recursion.
2019-11-20 14:30:31 -05:00
David Wendt
bc74b2fc4a
Track the no-double-reader flag on a per-frame basis, and add a "run until current frame exits" routine.
2019-11-20 14:30:31 -05:00
David Wendt
dd4462c104
Warn when attempting to attach a second continuation onto an existing stack frame, since we don't support that use case.
2019-11-20 14:30:31 -05:00
David Wendt
a2ee7f9e3a
Replace `Option<Value<'gc>>` with a dedicated `ReturnValue<'gc>` type with associated methods.
...
This type explicitly signals if an immediate value is to be returned, if a value is to be returned on the stack, or if no return value is to be generated. Holders of a `ReturnValue` can also use `and_then` to schedule a `StackContinuation` to be executed when and if that value is ready.
`StackContinuations` now yield `ReturnValues` as well, so they have a moderate level of composability. For example, if you need to get a property from an object and push it on the stack, you can return the result of calling `get` directly and the machinery ensures it eventually gets there.
2019-11-20 14:30:31 -05:00
David Wendt
2a3d324a33
Implement the "reschedule same continuation" behavior in AVM
2019-11-20 14:30:31 -05:00
David Wendt
40dbc535fc
Remove force_get now that everything can read virtual properties correctly.
2019-11-20 14:30:30 -05:00
David Wendt
e36a0d8350
Allow native functions to resolve on the AVM stack for whatever reason.
2019-11-20 14:30:30 -05:00
David Wendt
4dffe448e4
Get rid of the automatic `this` on stack continuations
2019-11-20 14:30:30 -05:00
David Wendt
9d422dc269
Allow getters to resolve on the AVM1 stack.
...
This involved yet another macro, `and_then!`, to avoid a ridiculous amount of duplicate code. It calls a continuation whenever it's value is ready, even if the value resolved on the Rust stack.
`locals_into_form_values` does not currently support this. It skips any property that does not resolve on the Rust stack. Future work is required to resolve this.
2019-11-20 14:30:30 -05:00
David Wendt
a59fffbc4e
Ensure that the value of the newly constructed `this` is returned in all cases.
...
This involves the use of a "stack continuation" system. Due to previous lifetime issues with using closures directly (see `8ea6c6234dba925ec5fbc61502627fb62b05916c`), we instead use a macro that constructs a `Collect`able type holding the things the continuation needs to continue working with. The syntax is largely similar to Rust closures but with the addition of an explicit list of bound variables, all of which must be `Collect`.
2019-11-20 14:30:29 -05:00
David Wendt
a95861d596
Stack continuations can now directly manipulate the return value of an ActionScript function.
2019-11-20 14:30:29 -05:00
David Wendt
8485e919db
Add a notion of "and_then" to activation objects.
...
This effectively constitutes the ability to assign arbitrary native contiuations to the AVM stack.
2019-11-20 14:30:29 -05:00
dependabot-preview[bot]
387feaf76c
build(deps): bump rand from 0.6.5 to 0.7.2 ( #124 )
2019-11-20 18:30:54 +00:00
dependabot-preview[bot]
6d124a6ac2
build(deps): bump smallvec from 0.6.13 to 1.0.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 0.6.13 to 1.0.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v0.6.13...v1.0.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-19 18:51:19 +00:00
Mike Welsh
e3d0d9031d
core: Handle empty JPEGTables tags ( fix #116 )
2019-11-11 17:08:08 -05:00
David Wendt
1236b5491e
Ensure calls to `getURL`, invocations of `ActionGetURL`, and other functionality that writes locals doesn't panic due to double mutable borrows.
2019-11-11 14:09:25 -05:00
David Wendt
4e16c91dbb
Add tests for `locals_into_form_values`.
2019-11-11 14:09:25 -05:00
Mike Welsh
b05745da01
audio: Fix uninit warnings in MP3 decoder in Rust 1.39
2019-11-11 14:06:41 -05:00
Mike Welsh
7d98c87a33
desktop: Implement event sound envelopes
2019-10-30 19:26:19 -07:00
David Wendt
0d4e21162a
Implement `ActionEnumerate2`.
2019-10-30 19:26:06 -07:00
Mike Welsh
63be104739
docs: Add module documentation for MovieClip
...
(Really an excuse to kick CI to re-run)
2019-10-30 10:59:53 -07:00
Mike Welsh
ab58c37feb
core: Handle gaps between StreamSoundBlocks
2019-10-29 23:36:51 -07:00
Mike Welsh
443dcfaeea
core: Stop stream sound when gaps are encountered
...
Generally there is one SoundStreamBlock per frame in a MovieClip.
However, if there are gaps between stream sounds, the stream must
stop and then pick up when the next block is encountered.
TODO: Sometimes Flash will do weird stuff and export a stream that
is plainly out of sync if there are gaps between sounds (the old
trick was to put a silent stream across the entire timeline to fix
this). This happens when the streams are too close together with
MP3 encoding. Investigate this more.
2019-10-29 23:36:51 -07:00
Mike Welsh
1a7959b96d
audio: Initial syncing of stream sound to MovieClip timeline
2019-10-29 23:36:51 -07:00
Mike Welsh
9e83f27afd
tests: Add test for DoInitAction
2019-10-29 11:11:25 -07:00
David Wendt
6a81b5327d
Implement `DoInitAction`.
...
This pushes an extra `undefined` onto the stack to fix underflow in AS2 interface declarations.
It is currently unknown if this is a miscompilation or if some other value is supposed to be there.
# Conflicts:
# core/src/avm1.rs
# core/src/avm1/object.rs
2019-10-29 11:11:25 -07:00
Mike Welsh
33c0bbd0ce
desktop: Fix incorrect rendering of bitmaps w/ color transforms
...
The premultiplied alpha was not properly considered when there was
a color transform on a bitmap. Now the shader unmultiplies the
alpha before applying the color transform, and the remultiplies it.
2019-10-29 00:03:29 -07:00
Mike Welsh
35be57553e
desktop: Improve animation sync
...
The timing on desktop was causing the movie to run too slow,
causing it to get out of sync. Now it should run at the correct
speed.
2019-10-28 21:05:18 -07:00
Mike Welsh
cb26342a24
core: Fix regression in goto when replacing a previous child
...
Goto forward that did a replace was not replacing the previous child.
TODO: Figure out how to write a regression test for this; will
need a special test harness probably because this only happens with
Graphics, not MovieClips, so we can't attach AS to them to get
trace output.
2019-10-28 03:47:57 -07:00
Mike Welsh
eaea6aaf20
audio: Fix audio for ADPCM stream sounds
...
When a stream sound uses ADPCM compression, the ADPCM header is
included in each SoundStreamBlock (as opposed to stream sounds
in the other formats). This header wasn't being parsed, resulting
in corrupted audio (see https://homestarrunner.com/main12.swf ).
2019-10-28 02:51:46 -07:00
Mike Welsh
01f47d675c
core: Move UpdateContext into context submodule
2019-10-27 13:49:47 -07:00
Mike Welsh
dddfb42e1e
core: Merge ActionContext into UpdateContext
2019-10-27 13:49:47 -07:00
Mike Welsh
c4c895c6c9
core: Move display objects to display_object module
2019-10-26 15:04:52 -07:00
Mike Welsh
2cdb8d3656
tests: execution_order -> execution_order1
2019-10-26 03:35:58 -07:00
Mike Welsh
247fd3b9c6
core: Run gotos immediately
...
Gotos now goto the specified frames immediately as opposed to
queuing. Actions on the new frame will still be queued,
and are executed after any current actions are completed.
2019-10-26 03:35:58 -07:00
Mike Welsh
e78be0f06f
core: Remove avm from UpdateContext
2019-10-26 02:21:48 -07:00
Mike Welsh
c718a6c8cb
core: Add more properties to ActionContext
...
ActionContext needs to be able to call goto, so it needs access
to most of UpdateContext.
TODO: Remove ActionContext, and only have UpdateContext?
2019-10-26 02:21:46 -07:00
Mike Welsh
09fa755405
core: Make Library::device_font optional
2019-10-26 02:20:42 -07:00
Mike Welsh
57a737357b
core: Remove RefMut/Ref from UpdateContext
2019-10-26 02:20:42 -07:00
Mike Welsh
838944b5a1
tests: Add tests for goto execution order
2019-10-26 02:20:42 -07:00
Mike Welsh
863801371b
tests: Better output when regression test fails
2019-10-26 01:52:42 -07:00
Mike Welsh
6da55f4fc2
tests: Remove ignore on execution order test
2019-10-26 01:52:42 -07:00
Mike Welsh
a4bed6c643
core: Improve execution order of AS
2019-10-26 01:52:42 -07:00
Mike Welsh
666075c651
tests: Allow attributes in swf_tests macro
...
Also ignore failing execution_order test
2019-10-26 01:52:42 -07:00
Mike Welsh
008581f1bd
tests: Add test for parent-child execution order
...
(currently fails)
2019-10-26 01:52:42 -07:00
Nathan Adams
6a2806b44a
chore: Allow Into<Value> for test results
2019-10-21 17:22:03 +02:00
Nathan Adams
348e7f6adb
chore: Impl From<numeric> for Value, better dev ergonomics
2019-10-21 17:14:00 +02:00
Nathan Adams
83b7d679ed
chore: Impl From<GcCell<'gc, Object<'gc>>> for Value, better dev ergonomics
2019-10-21 13:00:52 +02:00
Nathan Adams
fa5616a4f9
chore: Impl From<bool> for Value, better dev ergonomics
2019-10-21 12:55:17 +02:00
Nathan Adams
4c81ac8a6d
chore: Take Into<Value> for Object.(force_)set
2019-10-21 12:48:45 +02:00
Nathan Adams
0ba9cef2f0
chore: Take Into<Value> for tests
2019-10-21 12:44:21 +02:00
Nathan Adams
f24ab37810
chore: Impl From<&str> for Value, better dev ergonomics
2019-10-21 12:33:49 +02:00
Nathan Adams
796c641b3b
chore: Impl From<String> for Value, better dev ergonomics
2019-10-21 12:30:59 +02:00
Mike Welsh
84cb00b44b
chore: Fix clippy lint in Value::as_bool
2019-10-21 02:11:50 -07:00
Will Brindle
019ea79551
core: return true for objects as boolean
2019-10-20 10:00:18 +01:00
Will Brindle
d3006cb37b
chore fix formatting
2019-10-19 10:36:24 +01:00
Will Brindle
5b298a0814
chore: refactor test code to share common methods
2019-10-19 10:31:37 +01:00
Will Brindle
3fa198d8f2
core: Add extra test cases for Number function and resolve the issues they highlight
2019-10-19 10:29:26 +01:00
Will Brindle
463d0fc352
core: implement isNaN and Number functions. Involves updating to_number function in Value. Note: this varies a little from the ECMA spec such as not allowing spaces in numbers (i.e. ' 5' => NaN). No definitive reference for this but was found experimentally. Same with not supporting 'Infinity'
2019-10-19 10:29:26 +01:00
Will Brindle
38c66b5b8d
core: implement Boolean function
2019-10-19 10:29:26 +01:00
Mike Welsh
b0624a3654
tests: Add define_function2 and register test
2019-10-15 17:20:48 -07:00
Mike Welsh
f5710854b2
avm1: Fix off-by-one bug in Activation::has_local_register
2019-10-15 17:10:34 -07:00
Mike Welsh
e315fcb6b3
swf: Store register count from DefineFunction2
...
Also update avm1::Function to use register_count.
2019-10-15 17:09:14 -07:00
David Wendt
ad17166c63
Store the player version in `Avm1` so that `current_swf_version` doesn't require the context.
2019-10-13 18:55:39 -04:00
David Wendt
7e2cf03789
Implement register underflow behavior.
...
This has the side effect of letting us remove the `Option` on register_count since setting this to `0` is equivalent now. Furthermore, we can skip an allocation if a function requests no registers.
2019-10-13 18:41:07 -04:00
David Wendt
911cf64cb0
Fix clippy lints
2019-10-13 17:58:21 -04:00
David Wendt
e830273fe5
Don't pull multiple borrows on the same `GcCell`
2019-10-13 17:54:09 -04:00
David Wendt
911de06584
Only version MovieClips. Unversioned display objects recursively read their parents' versions, or the default version otherwise.
2019-10-13 17:27:04 -04:00
David Wendt
269775c0e1
Implement the SWF5 version negotiation algorithm.
...
On SWF5, the SWF version of the callee depends on it's this parameter. Calling it as a function rather than a method downgrades the callee. SWF6+ use the callee's inherent SWF version and do not allow changing the SWF version like this.
2019-10-12 10:39:55 -04:00
David Wendt
d543e67528
Inline the first 8 registers with a `SmallVec`.
2019-10-12 10:39:54 -04:00