Commit Graph

2080 Commits

Author SHA1 Message Date
Mike Welsh 137ac2887e core: Don't mouse pick children when invisible (fix #1242) 2020-10-11 04:10:25 -07:00
Mike Welsh 2c9cf6802d core: Squelch false AS3 error before initial SWF loads 2020-10-10 19:28:01 -07:00
Mike Welsh 5c3dd25638 avm1: Avoid unwrap in Sound constructor
At least avoid the panic in this case, but it can possibly fail
(see #701).
2020-10-10 18:13:08 -07:00
dependabot-preview[bot] 2c2a70e714 build(deps): bump syn from 1.0.43 to 1.0.44
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.43 to 1.0.44.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.43...1.0.44)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-10 16:35:50 -07:00
Mike Welsh 23660e49c9 core: Avoid panic due to invalid style IDs
If the shape converter encountered a fill/line style with an
ID > the number of styles, Ruffle would panic as it tried to grab
the non-existent style. This could occur if we mis-parsed some
shape data, or the SWF contained incorrect data. Now we the invalid
style is gracefully ignored.
2020-10-10 16:35:37 -07:00
Mike Welsh 10aaae9247 chore: Appease nightly clippy 2020-10-10 00:03:25 -07:00
dependabot-preview[bot] 4af9632761 build(deps): bump syn from 1.0.42 to 1.0.43
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.42 to 1.0.43.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.42...1.0.43)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-09 12:22:43 -07:00
David Wendt 5abebd5433 avm2: Yield an error if the caller specifies a label/scene pair and the label is not present within the scene. 2020-10-06 06:03:22 -07:00
David Wendt 1a10f1e004 avm2: Lock old movies (SWFv8 and earlier) to always use AVM1 2020-10-06 06:03:22 -07:00
David Wendt 693e56dc67 core: Always instantiate a new movie's library before creating it's root movieclip. 2020-10-06 06:03:22 -07:00
David Wendt 7c719bfb0c Only the first tag in a SWF file should be trusted to deliver file attributes. 2020-10-06 06:03:22 -07:00
David Wendt ddccede9d3 avm2: Make VM type non-optional.
This has the side effect of forcing the AVM check to happen at the time of library construction, which is already very early on in movie loading.
2020-10-06 06:03:22 -07:00
David Wendt ef665acaec avm2: Movie clips not explicitly granted a `symbol_class` should be constructed using the `MovieClip` class directly 2020-10-06 06:03:22 -07:00
David Wendt 12cf8022cd core: Remove useless uses of `matches!`. 2020-10-06 06:03:22 -07:00
David Wendt 007d54b389 avm2: Remove redundant implementations of `prev_frame` and `next_frame` 2020-10-06 06:03:22 -07:00
David Wendt 4c44ca8e77 avm2: Non-integer numbers should be handled as strings and integer-parsible strings should be handled as numbers. 2020-10-06 06:03:22 -07:00
David Wendt e2f21d0a7d avm2: Retire old references to the "VM tendency" nomenclature 2020-10-06 06:03:22 -07:00
David Wendt 896a5b37a5 avm2: Implement `new MovieClip()`. 2020-10-06 06:03:22 -07:00
David Wendt d399811eb8 avm2: Allow `MovieClip` to be constructed by users. 2020-10-06 06:03:22 -07:00
David Wendt 50dd9a6733 avm2: Implement the programmatically-playing flag that governs `isPlaying` behavior. 2020-10-06 06:03:22 -07:00
David Wendt 035c841eb5 tests: Add tests for `gotoAndStop` and rename the `gotoAndPlay` one 2020-10-06 06:03:22 -07:00
David Wendt 1f29497b8c tests: Add test for AS3 movieclip play 2020-10-06 06:03:22 -07:00
David Wendt 8152400a39 avm2: Implement `MovieClip.scenes`. 2020-10-06 06:03:22 -07:00
David Wendt c682868205 avm2: Implement `MovieClip.currentScene` 2020-10-06 06:03:22 -07:00
David Wendt 2483201bcd avm2: Store the lengths of each scene in a movie. 2020-10-06 06:03:22 -07:00
David Wendt 8a13d5fe10 avm2: Implement `Scene` object. 2020-10-06 06:03:22 -07:00
David Wendt 5e31c44b81 All objects should default to `toString`ing with their own classname. 2020-10-06 06:03:22 -07:00
David Wendt de186ed5f3 avm2: Implement `MovieClip.currentLabels` 2020-10-06 06:03:22 -07:00
David Wendt 77a86aef9b avm2: Implement `FrameLabel`. 2020-10-06 06:03:22 -07:00
David Wendt 86b07c0007 tests: Add tests for `prevScene` and `nextScene`. 2020-10-06 06:03:22 -07:00
David Wendt 542147d657 avm2: Run all AVM2 frame scripts on the action queue.
This is the same way that AVM1 actions run and it appears that frame scripts work exactly the same way. It fixes all outstanding bugs with movie clip navigation in AVM2 and allows me to remove a lot of weird workarounds I was writing for the old, incorrect behavior.

I'm also removing the "last run script frame" rule as `run_frame_internal` already had rules to prevent stopped clips from rerunning actions.
2020-10-06 06:03:22 -07:00
David Wendt 996d7528d5 avm2: Implement `prevScene` and `nextScene`. 2020-10-06 06:03:22 -07:00
David Wendt 864c6a37f9 avm2: Dynamic properties should be retrievable before they are actually set. 2020-10-06 06:03:22 -07:00
David Wendt 6d0befad97 avm2: Implement `prevFrame` and `nextFrame`, with tests. 2020-10-06 06:03:22 -07:00
David Wendt bcf08b5bf7 avm2: Frame scripts should run when the frame number has changed, regardless of playhead state. 2020-10-06 06:03:22 -07:00
David Wendt 97048fb8bd avm2: Implement `stop` and `play`, with tests for the former. 2020-10-06 06:03:22 -07:00
David Wendt c8cd4d09cd core: Don't run frame scripts on stopped movie clips. 2020-10-06 06:03:22 -07:00
David Wendt 556c951b1c avm2: Implement `gotoAndPlay`/`gotoAndStop`, with test. 2020-10-06 06:03:22 -07:00
David Wendt 3513918149 avm2: Allow typechecking by prototype, rather than just by constructor. 2020-10-06 06:03:22 -07:00
David Wendt e837840bba core: Always skip frames after the current frame when getting the current scene or label. 2020-10-06 06:03:22 -07:00
David Wendt 5b83f6b4cc avm2: Add test for movieclip-specific properties. 2020-10-06 06:03:22 -07:00
David Wendt 3b6f8cff4e avm2: Implement `framesLoaded`, `isPlaying`, and `totalFrames`. 2020-10-06 06:03:22 -07:00
David Wendt 7ca34452a1 avm2: Implement `currentFrameLabel` and `currentFrame`. 2020-10-06 06:03:22 -07:00
David Wendt 6124ed468f core: Add `current_label` for getting the current label on a given clip.
This also fixes `current_scene` as well.
2020-10-06 06:03:22 -07:00
David Wendt c1b14b7639 avm2: Implement `currentFrame`. 2020-10-06 06:03:22 -07:00
David Wendt 7756fd530d core: Allow grabbing the movieclip's current scene, if scene labels are defined. 2020-10-06 06:03:22 -07:00
David Wendt d747ef7914 core: Store scene and frame labels generated by the `DefineSceneAndFrameLabelData` tag. 2020-10-06 06:03:22 -07:00
David Wendt 55fec14a1c tests: Add tests for timeline scripts. 2020-10-06 06:03:22 -07:00
David Wendt c04bf7d53c `addFrameScript` indexes by zero, not by one. 2020-10-06 06:03:22 -07:00
David Wendt ab45b9084d avm2: Parse `SymbolClass` package paths correctly. 2020-10-06 06:03:22 -07:00
David Wendt a1a21500d8 core: Warn when a movie clip is AVM2-constructed without an accompanying symbol class. 2020-10-06 06:03:22 -07:00
David Wendt 8c67260e68 core: Special-case ID 0 as the current movie timeline.
Note: This relies on the fact that SWF files do not stick `SymbolClass` declarations in child movieclips. If this isn't the case, then it will fail horribly, and we would then need to actually store clip 0 in the library somehow.
2020-10-06 06:03:22 -07:00
David Wendt f2c3466026 avm2: The AVM2 constructor should be an actual Class, not it's prototype. 2020-10-06 06:03:22 -07:00
David Wendt e915a07d4f core: ABC files should resolve at the time of discovery, not on the action queue. 2020-10-06 06:03:22 -07:00
David Wendt 7e898457b0 avm2: Implement `addFrameScript`. 2020-10-06 06:03:22 -07:00
David Wendt d991c49774 Implement `addFrameScript`. 2020-10-06 06:03:22 -07:00
David Wendt 664152d739 avm2: Mark `EventDispatcher` as implementing `IEventDispatcher`.
This doesn't actually implement any of it's methods yet, which *would* cause an error *if* we were verifying that.
2020-10-06 06:03:22 -07:00
David Wendt e72c9776ec avm2: Implement `IEventDispatcher`. 2020-10-06 06:03:22 -07:00
David Wendt c899b3080a avm2: Add function to unwrap a `StageObject` as it's underlying `DisplayObject`. 2020-10-06 06:03:22 -07:00
David Wendt a70e1be466 Add code to instantiate AVM2 movie clips correctly.
This also includes several bits to build an effective VM barrier.
2020-10-06 06:03:22 -07:00
David Wendt 247e79e61a core: Track the VM each movie has pledged to execute on.
This uses a "VM tendency" system wherein the presence of `DoAction` or `DoInitAction` tags defaults the movie to AVM1, while the presence of `DoABC` defaults to AVM2. The presence of a `FileAttributes` tag allows setting the VM tendency in the same manner using it's AS3 bit.

Particularly malformed SWFs may cause execution issues if Flash Player uses a dramatically different system from this.
2020-10-06 06:03:22 -07:00
David Wendt 3128bbcda6 core: Implement `SymbolClass` tag. 2020-10-06 06:03:22 -07:00
David Wendt edd31c4b83 core: Allow pulling the AVM2 Object out of a participating movie clip. 2020-10-06 06:03:22 -07:00
David Wendt f85319aa4c core: Allow `DisplayObject` to hold AVM2 objects.
This requires the use of an intermediary enum called `AvmObject` which can hold either object representation. Currently, it's mostly just being unwrapped as AVM1 objects, which we will need to fix.
2020-10-06 06:03:22 -07:00
David Wendt 63f411d231 avm2: Add `StageObject` object implementation for holding display objects in AVM2. 2020-10-06 06:03:22 -07:00
David Wendt 3fb186e5c0 avm1: Remove fscommand debug code 2020-10-01 13:53:00 -07:00
David Wendt 1a77874e04 avm1: For good measure, also unload on empty URL in `ActionGetURL`. 2020-10-01 13:53:00 -07:00
David Wendt bb5c367e91 chore: Remove dbg statement in loaders 2020-10-01 13:53:00 -07:00
David Wendt e73cdd7987 avm1: Actually unload movies when we get an empty URL in `GetURL2` and the target is a sprite. 2020-10-01 13:53:00 -07:00
CUB3D f0a02f00b5 core: Changes from review 2020-09-29 11:06:56 -07:00
CUB3D 110b9ec551 core: Fix edge cases and implement rest of bevel filter 2020-09-29 11:06:56 -07:00
CUB3D 2c3ee4d94b core: Add flash.filters.BevelFilter 2020-09-29 11:06:56 -07:00
Sean-Thomas 5701312527 desktop: Implement play/pause for CPAL backend
- removed default implementations for `play()` and `pause()` methods for AudioBackend trait
- Implemented `play()` and `pause()` methods for CPAL audio backend
- Implemented empty block for `play()` and `pause()` methods for NULL audio backend
2020-09-29 11:05:23 -07:00
Sean-Thomas a9538f81d0 web: Renamed "prime_audio" and "suspend_audio"
Renamed "prime_audio" and "suspend_audio" to "play" and "pause" respectfully.
2020-09-29 11:05:23 -07:00
Sean-Thomas 6b54cc4311 web: Add pause method for web player
Adds a suspend_audio method to compliment prime_audio on WebAudioBackend, as well as logic in player.rs on the set_is_playing method to suspend audio when is_playing is set to false. Exposes pause method for the ruffle player in JavaScript with logic to display the play button when paused.
2020-09-29 11:05:23 -07:00
Mike Welsh ead845ff33 chore: Appease clippy 2020-09-26 18:19:37 -07:00
Mike Welsh 98d2651e62 tests: Add tests for Array single-param ctor 2020-09-26 14:13:06 -07:00
Mike Welsh 366e8aa926 Array: Fix Array single-param ctor
The Array constructor with a single param sets the length if the
parameter is a number (no coercion is done); otherwise, it is
creates an 1-length Array containing the parameter. Previously
we coerced the parameter to a float.
2020-09-26 14:13:06 -07:00
Mike Welsh 9e13058e04 avm1: Fix list of elements in Array ctor (fix #1195) 2020-09-26 14:13:06 -07:00
David Wendt 6bb6bcab7a core: Store rotations in degrees to avoid floating-point conversion discrepancies. 2020-09-26 14:12:49 -07:00
David Wendt 28bf84bd8b core: Store object scale as percentages to avoid floating point precision problems.
Fixes a specific pattern of preloader design where animations were handled by just making the box bigger every frame until it's 100. Of course, direct equality of f64 is a terrible idea, but it works in Flash, which apparantly must store scale in percentages. So we must, too.
2020-09-26 14:12:49 -07:00
David Wendt f6f084098e tests: Add a test for floating point errors in the AVM1 representation of `_xscale`, `_yscale`, and `_rotation`. 2020-09-26 14:12:49 -07:00
dependabot-preview[bot] c5135fc737 build(deps): bump syn from 1.0.41 to 1.0.42
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.41 to 1.0.42.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.41...1.0.42)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-26 14:11:01 -07:00
dependabot-preview[bot] 0dfac7b1ac build(deps): bump gif from 0.11.0 to 0.11.1
Bumps [gif](https://github.com/image-rs/image-gif) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/image-rs/image-gif/releases)
- [Changelog](https://github.com/image-rs/image-gif/blob/master/Changes.md)
- [Commits](https://github.com/image-rs/image-gif/compare/v0.11.0...v0.11.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-25 13:22:07 -07:00
Mike Welsh 802636fbbf chore: Bump to gif 0.11.0 2020-09-21 18:30:27 -07:00
Luca Weiss 8a8075ca99
avm1: Fix registered function names for Sound object (#1209)
The functions are just stubs currently so this shouldn't change any
behavior.
2020-09-19 16:21:50 -07:00
Nathan Adams 4a83641a6c core: Support \r newlines in texts - fixes #1071, #808 2020-09-19 16:18:35 -07:00
Luca Weiss d5cb396331 *: fix spelling mistakes 2020-09-19 16:17:58 -07:00
Mike Welsh 2f84d468ee text: Default text span color should be black
Previosuly color defaulted to 0% alpha, causing text to be
invisible if the text field did not specify a defualt color.
2020-09-18 18:58:09 -07:00
Mike Welsh 6f2655cf95 tests: Add test for SWF4 string ops 2020-09-17 16:03:51 -07:00
Mike Welsh 7eeba10bef avm1: Clean up SWF4 string ops
Clean up SWF4 string ops:
 * Operate on UTF-16 code units (in SWF6+)
 * StringExtract indices are 1-based
2020-09-17 16:03:51 -07:00
Mike Welsh 4f6c017bc0 avm1: Move utf16 util methods to string_utils 2020-09-17 16:03:51 -07:00
Nathan Adams ef3d5c1538 core: Apply a mask when rendering text, fixes parts of #1167 2020-09-17 16:03:16 -07:00
Nathan Adams e008603426 core: Add draw_rect to the render backend API 2020-09-17 16:03:16 -07:00
Mike Welsh 3cc43265bf core: Always recurse down into movieclips when mouse picking
Was only consdering the world bounds, but buttons can have separate
hit areas that don't actually affect the bounds of the parent clip.
(TODO: Could have keep track of a separate mouse_bounds instead.)

Fixes regression in Mini-Putt 2 (#1120).
2020-09-15 02:34:32 -07:00
Mike Welsh 4593320d36 tests: Add more tests to hittest_shapeflag test 2020-09-15 02:34:32 -07:00
Mike Welsh fe3bf5cb59 core: Implement hit_test_shape for MorphShape 2020-09-15 02:34:32 -07:00
Mike Welsh 4d26ebe9b4 core: Implement hit_test_shape for EditText 2020-09-15 02:34:32 -07:00
Mike Welsh e9a2ef5d82 core: DisplayObject::hit_test_shape now takes UpdateContext
Make default implementation the same as hit_test_bounds.
2020-09-15 02:34:32 -07:00
Mike Welsh 0d111ca92f avm1: _target of root should be /
Also, levels other than 0 should be appened in slash syntax, e.g
_level1/clip
2020-09-15 02:20:24 -07:00
David Wendt f2380d828a chore: Don't capitalize our type arguments. 2020-09-15 02:20:11 -07:00
David Wendt 7e91c45950 avm2: Move trait methods into the AS3 namespace.
`toString`, `toLocaleString`, and `valueOf` are still `public`, because they're not supposed to be trait methods at all.
2020-09-15 02:20:11 -07:00
David Wendt 27eda5cdf1 avm2: Remove `ArrayIterator` trait.
I originally added this with the anticipation that `impl` return syntax only allowed one trait plus OIBITs. This was prior experience in Rust but apparantly the compiler accepts this just fine, so I suppose my defensive coding practice was a bad/outdated idea.
2020-09-15 02:20:11 -07:00
David Wendt de0bc93839 Fix `hasOwnProperty` yielding false on populated non-hole array indicies. 2020-09-15 02:20:11 -07:00
David Wendt e581704559 avm2: `new Array()` should reject negative and `NaN` length arguments as errors. 2020-09-15 02:20:11 -07:00
David Wendt 582df3bd7d avm2: Misc perf fixes and nits in Array globals. 2020-09-15 02:20:11 -07:00
David Wendt 07e14463e2 avm2: Array `join` and `toString` treat `undefined` and `null` as empty strings. 2020-09-15 02:20:11 -07:00
David Wendt 3b7922d222 avm2: Implement `Array.sortOn` 2020-09-15 02:20:11 -07:00
David Wendt 0aa2c50118 avm2: Implement `Array.sort` 2020-09-15 02:20:11 -07:00
David Wendt bb19699739 avm2: Add convenience method for converting a `Value` into an `EnumSet`. 2020-09-15 02:20:11 -07:00
David Wendt a653a62a93 avm2: Add array sorting constants. 2020-09-15 02:20:11 -07:00
David Wendt ca4982029b avm2: Impl `Array.toLocaleString`. 2020-09-15 02:20:11 -07:00
David Wendt 2ae3b6445b avm2: Partially implement `toLocaleString` insamuch as is necessary to run Array tests on it.
This appears to work almost like it's own TObject method; you can run `Object.prototype.toLocaleString` on all sorts of things and it has separate behavior to what the class method for it might be. I have attempted to match Flash Player as best as I can.
2020-09-15 02:20:11 -07:00
David Wendt dbaef812fa avm2: Impl `Array.splice`. 2020-09-15 02:20:11 -07:00
David Wendt 53b564bb52 avm2: Implement `Array.slice`. 2020-09-15 02:20:11 -07:00
David Wendt 685fbc12e0 tests: `Array.reverse`'s test should also include a check for holes. 2020-09-15 02:20:11 -07:00
David Wendt 036f7cbb90 avm2: Implement `Array.shift` and `Array.unshift`.
This also updates `Array.push` to support it's ability to push multiple arguments at once.
2020-09-15 02:20:11 -07:00
David Wendt 879aff3669 avm2: Implement `Array.reverse` 2020-09-15 02:20:11 -07:00
David Wendt 1ce78388a3 avm2: Implement `Array.push` and `Array.pop` 2020-09-15 02:20:11 -07:00
David Wendt 0ece924877 avm2: Implement `indexOf` and `lastIndexOf` 2020-09-15 02:20:11 -07:00
David Wendt 7aa1ab82e4 avm2: Avoid locking the array when running user code.
The array being iterated is explicitly handed to all callbacks, and it is legal for the callback to mutate the array. Hence, we can't actually hold a `Ref` to the array storage when we call user code. Instead, we implement a custom `Iterator` which iterates over the object like user code would.

This actually can't be an `Iterator` impl due to limitations of the underlying trait. Hence, we have to `while let` instead of `for`.
2020-09-15 02:20:11 -07:00
David Wendt 832bbdd711 avm2: Implement `forEach`, `map`, `filter`, `every`, and `some` on `Array`.
This also comes with some refactoring: building the resulting array object and resolving holes is now done in helper methods.
2020-09-15 02:20:11 -07:00
David Wendt 0eeee72be6 avm2: Implement `Array.join`, `Array.toString`, and `Array.valueOf` (w/tests) 2020-09-15 02:20:11 -07:00
David Wendt 79df789028 tests: Add test for `Array.concat`. 2020-09-15 02:20:11 -07:00
David Wendt 75e6018607 tests: Add test for `newarray`. 2020-09-15 02:20:11 -07:00
David Wendt 505018c3b8 avm2: Implement `newarray`. 2020-09-15 02:20:11 -07:00
David Wendt 27793092c2 tests: Add `array_holes` test. 2020-09-15 02:20:11 -07:00
David Wendt 3d37fda1ef tests: Add tests for `deleteproperty` on arrays. 2020-09-15 02:20:11 -07:00
David Wendt 04828663e8 avm2: `deleteproperty` should only ever yield `false` when attempting to delete unknown properties on a sealed class object. 2020-09-15 02:20:11 -07:00
David Wendt 6d9b9c9218 avm2: Attempts to get unknown properties on dynamic objects should yield `undefined`. 2020-09-15 02:20:11 -07:00
David Wendt 966dfc3902 avm2: Add method to get at the `Class` of non-class objects with a prototype.
The only unclassed objects should be bare objects, which are hard to get at.
2020-09-15 02:20:11 -07:00
David Wendt cac1717780 avm2: Add utility method `is_sealed` for `Class`. 2020-09-15 02:20:11 -07:00
David Wendt 1a8f041b77 tests: Add `array_storage` test. 2020-09-15 02:20:11 -07:00
David Wendt 34ba1643dd tests: Add test for reading properties of an array 2020-09-15 02:20:11 -07:00
David Wendt 5a29b781ec avm2: Ensure `ArrayObject` offers access to it's array properties for reading and writing. 2020-09-15 02:20:11 -07:00
David Wendt e054456286 avm2: Add method to check if a particular namespace is the public namespace. 2020-09-15 02:20:11 -07:00
David Wendt 1d3f5d80be tests: Add test for `new Array`'s arguments. 2020-09-15 02:20:11 -07:00
David Wendt a09ba9d263 avm2: Implement `length`. 2020-09-15 02:20:11 -07:00
David Wendt aaf586e3a7 avm2: `define_instance_trait` should actually define instance traits. 2020-09-15 02:20:11 -07:00
David Wendt 45c95cae02 avm2: Impl `Array.concat` 2020-09-15 02:20:11 -07:00
David Wendt 1092bf2bc5 avm2: Add the ability to wrap an already-constructed array in an object. 2020-09-15 02:20:11 -07:00
David Wendt bd35ebb793 avm2: Impl `Array` constructor 2020-09-15 02:20:11 -07:00
David Wendt bedd5fa007 avm2: Add a method for mutating the array storage of an object. 2020-09-15 02:20:11 -07:00
David Wendt d92d3023e7 avm2: Restore `as_number`.
This is for the sake of methods that want to change behavior based on if they're working with a number or some other kind of value. It should not be used otherwise.
2020-09-15 02:20:11 -07:00
David Wendt 16e1a1bdf3 avm2: Add Array class.
This code also ensures that the prototypes of each system object are created in the appropriate `TObject` impl. This ensures that, for example, `new Array` hands you back an actual array.
2020-09-15 02:20:11 -07:00
David Wendt 88fc9b1538 avm2: Implement base types for array-shaped objects. 2020-09-15 02:20:11 -07:00
dependabot-preview[bot] f0976cffc7 build(deps): bump syn from 1.0.40 to 1.0.41
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.40 to 1.0.41.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.40...1.0.41)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-14 12:02:03 -07:00
Nathan Adams 3ff399ca6b core: Trace only to the log backend, but have the default log backend trace to the log crate 2020-09-13 13:51:39 -07:00
Nathan Adams 319efabb47 tests: Make tests capture trace output through new backend 2020-09-13 13:51:39 -07:00
Nathan Adams e25e03a841 core: Log to new avm_trace method where we want things to show up 2020-09-13 13:51:39 -07:00
Nathan Adams de009c7673 core: Add Log backend, for capturing trace output specific to a movie 2020-09-13 13:51:39 -07:00
dependabot-preview[bot] 491526cc93 build(deps): bump bitstream-io from 0.8.5 to 0.9.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 0.8.5 to 0.9.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/compare/v0.8.5...v0.9.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 21:17:24 -07:00
Adrian Wielgosik 0fe88f23bb
avm1: Use fnv hash in PropertyMap 2020-09-09 10:44:52 -07:00
CUB3D 8a5434c956 core: Switch to enum for differentiating callable values from uncallable ones 2020-09-07 13:14:48 -07:00
CUB3D efa7e862fd core: Propagate this through scope and get_variable 2020-09-07 13:14:48 -07:00
CUB3D 91d5e0f74b core: Update tests 2020-09-07 13:14:48 -07:00
CUB3D 136a5664b0 core: Pass the correct this for CallFunction when in a with scope
fixes #805, #945, #1018
2020-09-07 13:14:48 -07:00
Mike Welsh a18e80baf2 chore: Fix clippy lints 2020-09-07 12:18:41 -07:00
dependabot-preview[bot] 08f1299595 build(deps): bump syn from 1.0.39 to 1.0.40
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.39 to 1.0.40.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.39...1.0.40)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:14:14 -07:00
dependabot-preview[bot] 07a6075765 build(deps): bump indexmap from 1.5.2 to 1.6.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.5.2...1.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:13:54 -07:00
David Wendt 35b589b2ac avm2: `in` should only ever query non-namespaced/public properties. 2020-09-07 11:07:07 -07:00
David Wendt 3b5411547a avm2: Implement `in` 2020-09-07 11:07:07 -07:00
David Wendt 11b8354905 avm2: `resolve_any` should resolve prototype properties. 2020-09-07 11:07:07 -07:00
Mike Welsh 64679e8796 avm1: typeof button/text should be object (fix #1110) 2020-09-04 11:33:40 -07:00
Nathan Adams b2dc564628 avm1: Fix String.lastIndexOf(undefined) 2020-09-04 11:32:16 -07:00
Nathan Adams ea7a9758c4 avm1: Fix String.indexOf(undefined) 2020-09-04 11:32:16 -07:00
Mike Welsh 86ab300ee8 core: Call post_instantiate on initial empty root (fix #946)
The `fake_root` did not have an object, which could cause the
player to panic if the SWF was not completely loaded when playing.
Calling `post_instantiate` ensures that this dummy root has an
object.
2020-09-04 11:31:04 -07:00
Mike Welsh 3a813f1f15 tests: Test for #1104 2020-09-03 19:09:48 -07:00
Mike Welsh 5ea06b0ce6 swf: Use Option for more PlaceObject parameters
There is a difference between empty/default (change value to default)
and none (don't modify), so make this explicit for some PlaceObject
parameters where it wasn't.

Fixes #1104.
2020-09-03 19:09:48 -07:00
Mike Welsh 151b13a424 avm1: ExternalInterface properties are read only 2020-09-03 18:17:44 -07:00
Nathan Adams b5531a48d0 web: Allow reentrant ExternalInterface callbacks 2020-09-03 18:17:44 -07:00
Nathan Adams a49e8d8587 web: Implement two-way communication with ExternalInterface 2020-09-03 18:17:44 -07:00
Nathan Adams 687c912067 core: Allow for reentry from ExternalInterface methods 2020-09-03 18:17:44 -07:00
Nathan Adams 32de953822 core: Allow passing arguments and returning values to/from ExternalInterface 2020-09-03 18:17:44 -07:00
Nathan Adams e1b3ac79d6 core: Add ability to call out to ExternalInterfaceProviders 2020-09-03 18:17:44 -07:00
Nathan Adams 502ea98ed4 core: Add ability to call in to ExternalInterface callbacks from outside of the player (+ test) 2020-09-03 18:17:44 -07:00
Nathan Adams 169c61bf96 tests: Added ability for tests to have a before_start and before_end, and added basic ExternalInterface test that uses it 2020-09-03 18:17:44 -07:00
Nathan Adams 3784f411b4 core: Add ExternalInterface::addCallback 2020-09-03 18:17:44 -07:00
Nathan Adams b66e9f8d16 avm1: Add ExternalInterface with only 'available' property right now 2020-09-03 18:17:44 -07:00
Nathan Adams 8f11141426 core: Add initial ExternalInterface structs 2020-09-03 18:17:44 -07:00
Nathan Adams c5ac707fb5 avm1: Iterating xmlnode attributes should list every attribute 2020-09-03 17:03:43 -07:00
Nathan Adams bcb64b9a62 avm1: Fix calling Function() as a function - fixes #1074 2020-09-03 17:01:20 -07:00
Nathan Adams 40cdb84656 tests: Add test for avm1 Function(foo) 2020-09-03 17:01:20 -07:00
Mike Welsh ce2b360ab7 core: Provide default impl for DisplayObject:hit_test_bounds 2020-09-02 17:51:55 -07:00
Mike Welsh b0c9795cad core: Graphic::from_swf_tag takes ownership of Shape 2020-09-02 17:51:55 -07:00
Mike Welsh f2f70cc882 core: Mouse picking for buttons uses shape hit tests 2020-09-02 17:51:55 -07:00
Mike Welsh d7a186b2cd avm1: Implement shape hit testing 2020-09-02 17:51:55 -07:00
Mike Welsh 2da3c0d319 tests: Add hitTest shapeflag test 2020-09-02 17:51:55 -07:00
Nathan Adams ec407a9514 avm1: Don't blanket impl From<i64> for Value, convert it explicitly where we know it's okay 2020-09-02 17:12:31 -07:00
Nathan Adams 0b5713557b desktop: Implement LocaleBackend for desktop 2020-09-02 17:12:31 -07:00
Nathan Adams f50b29151c avm1: If a NaN is provided to new Date(timestamp), fail immediately 2020-09-02 17:12:31 -07:00
Nathan Adams 9dfc20e1ba avm1: Implement Date.UTC 2020-09-02 17:12:31 -07:00
Nathan Adams 86eb6f2e50 avm1: Implement Date - #249 2020-09-02 17:12:31 -07:00
Nathan Adams 3d30ec67e2 test: Add more cases to registerClass tests 2020-09-02 15:18:59 -07:00
Nathan Adams 2178beec87 core: When constructing objects for DisplayObjects, make sure frames are run at the right moment 2020-09-02 15:18:59 -07:00
Mike Welsh 537cca7c38 tests: Add test for #1086 2020-09-02 13:25:53 -07:00
Mike Welsh bc08971066 core: Return version from MovieClip::swf_version (fix #1086)
MovieClip was not returning the proper SWF version, causing it to
default to the newest SWF version in some cases when it shouldn't.
2020-09-02 13:25:53 -07:00
dependabot-preview[bot] 03dcdcd494 build(deps): bump indexmap from 1.5.1 to 1.5.2
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Commits](https://github.com/bluss/indexmap/compare/1.5.1...1.5.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-02 12:39:18 -07:00
CUB3D e95c1ff758 core: Make blurX and blurY floating point 2020-09-02 10:59:00 -07:00
CUB3D 143ba03754 core: Fix clippy lints and format 2020-09-02 10:59:00 -07:00
CUB3D a2c151677b core: Add blurFilter and test 2020-09-02 10:59:00 -07:00
CUB3D d1ad095bad core: Add tests for bitmap_filter 2020-09-02 10:59:00 -07:00
CUB3D 34f485ca21 core: Add basic flash.filters.(BlurFilter|BitmapFilter) 2020-09-02 10:59:00 -07:00
Nathan Adams cb2461920b core: HTTP request values need to preserve order 2020-08-28 11:53:32 -07:00
dependabot-preview[bot] 4137a1cac0 build(deps): bump minimp3 from 0.4.0 to 0.5.0
Bumps [minimp3](https://github.com/germangb/minimp3-rs) from 0.4.0 to 0.5.0.
- [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-08-27 13:20:14 -07:00
dependabot-preview[bot] 9db07eb997 build(deps): bump minimp3 from 0.3.5 to 0.4.0
Bumps [minimp3](https://github.com/germangb/minimp3-rs) from 0.3.5 to 0.4.0.
- [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-08-26 09:57:40 -07:00
Mike Welsh f55bac2014 text: HTML tags and attributes are case insensitive (fix #1021)
Use eq_ignore_ascii_case when parsing HTML tags. Different versions
of Flash may export HTML tags with different cases, so this will
work a little better; however, we'll need a true HTML parser to
handle this robustly (for opening and closing tags with different
cases, for example).
2020-08-24 11:27:14 -07:00
Mike Welsh febada8a8e text: Fix duplicated characters when parsing HTML entities (fix #1026) 2020-08-24 11:27:14 -07:00
Mike Welsh e8178c35a3 core: Add MouseWheel player event 2020-08-23 13:38:59 -07:00
kmeisthax 559bc05b6a
avm2: Implement avm2 math opcodes (merge #1037)
* Implement `add`, with tests.

* Implement `add_i`.

There's no test, because for whatever reason, I can't figure out how to emit this from Animate CC 2020.

* avm2: Implement `bitand` with tests.

* Implement `bitnot` with tests.

* Implement `bitor` with tests.

* avm2: Implement `bitxor`

* avm2: Implement `declocal`, `declocal_i`, `decrement`, and `decrement_i`.

* tests: `swf_approx` tests should be allowed to print NaNs.

* avm2: Implement `divide`.

* avm2: Implement `inclocal`, `inclocal_i`, `increment`, and `increment_i`.

* avm2: Implement `lshift`.

* Implement `modulo`.

* avm2: Implement `multiply` and `multiply_i` (no tests for the latter)

* avm2: Implement `negate` and `negate_i` (no tests for the latter)

* avm2: Implement `rshift`

* avm2: Implement `subtract` and `subtract_i` (the latter without tests)

* avm2: Implement `urshift`.
2020-08-23 13:38:38 -07:00
Mike Welsh ba05894901 avm1: Don't mutably borrow self in TObject 2020-08-23 02:19:53 -07:00
Mike Welsh 2a84d924bb chore: Don't mutably borrow self in TDisplayObject 2020-08-22 11:56:19 -07:00
dependabot-preview[bot] 5d2ba7fee6 build(deps): bump syn from 1.0.38 to 1.0.39
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.38 to 1.0.39.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.38...1.0.39)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-21 12:54:02 -07:00
Mike Welsh 06b6d14367 avm1: Fix removeMovieClip depth range
removeMovieClip should only function on objects within a certain
depth range, usually to prevent removing timeline clips. However,
this wasn't working properly in some cases because the depth was
being biased incorrectly (removeMovieClip never takes a depth
parameter, so we should not bias the depth).
2020-08-21 00:55:35 -07:00
Mike Welsh 528b52ac7c tests: Activate unused remove_movie_clip test 2020-08-21 00:55:35 -07:00
Mike Welsh 1e6a053c56 avm1: Implement TargetPath 2020-08-20 18:14:01 -07:00
Mike Welsh bbc5e01009 tests: Add test for targetPath action 2020-08-20 18:14:01 -07:00
Mike Welsh e9f9cda34d tests: Rename target_path test to string_path 2020-08-20 18:14:01 -07:00
Mike Welsh b8f5a405b9 tests: Add test for flash.geom.Transform 2020-08-20 17:29:04 -07:00
Mike Welsh ca3ed34c2c avm1: Implement flash.geom.Transform 2020-08-20 17:29:04 -07:00
Mike Welsh 0a81dae7bb avm1: toString for display objects 2020-08-18 01:18:15 -07:00
Mike Welsh cefc0ce5c1 core: Add button children to execution list
Children of buttons were not getting linked up into the execution
list, which would cause certain methods to be incorrect (such as
button._width).
2020-08-18 01:18:15 -07:00
Mike Welsh d2c49c0f33 core: Remove some mut from TDisplayObject methods 2020-08-18 01:18:15 -07:00
Mike Welsh 544c1becc2 tests: Add test for button children 2020-08-18 01:18:15 -07:00
Mike Welsh 59ebd0167e core: Fix priority of conflicting instance names 2020-08-18 01:18:15 -07:00
Mike Welsh b5c7e1dab0 tests: Add test for conflicting instance names 2020-08-18 01:18:15 -07:00
Mike Welsh 13b4b6bbbb chore: Fix unused variable warning in url_from_relative_path 2020-08-16 18:44:57 -07:00
Floens 95acc14190 avm1: fix array unshift
update array_trivial test for it
2020-08-16 04:27:09 -07:00
Mike Welsh f782ea8020
avm2: AVM2 built-in class suport (merge #802)
Initial support for defining built-ins in AVM2
2020-08-16 03:45:02 -07:00
David Wendt 4c824fcefe Rename `trait.rs` to `traits.rs` to avoid the use of reserved keyword syntax. 2020-08-14 21:20:41 -04:00
David Wendt 7b7f0b20e6 Consolidate all of our copied `CollectWrapper`s. 2020-08-14 20:52:09 -04:00
Albert Safin e03373bceb avm1: parseInt 2020-08-13 00:40:20 -07:00
Mike Welsh cbd448522a chore: Allow unknown clippy lints
same_item_push was added on nightly, but is currently throwing
a false negative. I added an allow for it, but this causes a
warning on stable for an unknown lints, so allow unknown lints for
now.
2020-08-12 23:51:12 -07:00
Mike Welsh 6c89869210 chore: Fix clippy lints 2020-08-12 19:04:14 -07:00
dependabot-preview[bot] 9b6dd45439 build(deps): bump smallvec from 1.4.1 to 1.4.2
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.1...v1.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-12 11:13:33 -07:00
David Wendt 825eb34c67 avm1: `Button` should not hold write locks on itself when instantiating children.
This fixes a bug where a nested textfield within a button with variable linkages would panic in Ruffle.
2020-08-12 11:08:27 -07:00
David Wendt 354b194b69 avm1: Add test for nested text fields in buttons. 2020-08-12 11:08:27 -07:00
David Wendt 32aad6176b `FunctionObject::from_builtin_constr` should pull the scope and class off of it's given prototype and copy it onto the constructor function it returns. 2020-08-11 00:04:13 -04:00
David Wendt 11ddccfa6a Remove the two-step initialization process and construct an ES4 class for `Object`, `Function`, and `Class`.
This has some particularly annoying consequences for initialization order: notably, we can't actually create any ES4 classes using the standard machinery until after the three objects I just mentioned get created. Ergo, we have to create them through lower-level means, handing prototypes around, and then initialize AVM2's system prototypes list for it.

When we start adding more system prototypes, we'll also have to fill the extras with blank objects and then slot them in as we create them.
2020-08-11 00:02:12 -04:00
David Wendt 16d8c85d20 Load player globals as soon as possible.
We're about to massively change the initialization process, and we really don't want to create another situation where the player can get caught with it's pants down.
2020-08-10 23:35:37 -04:00
David Wendt a8e267ed16 Allow system prototypes to be initialized after the fact. 2020-08-10 23:35:37 -04:00
David Wendt b1bcceaa78 Allow accessing the `Class` off of a constructor or prototype that references it. 2020-08-10 23:35:33 -04:00
David Wendt 22ec96b85e `install_trait` and `install_foreign_trait` should return the value of the thing they installed. 2020-08-10 23:23:35 -04:00
David Wendt df95482eb1 Allow setting `slot_id` or `disp_id` (depending on kind). 2020-08-10 23:23:34 -04:00
David Wendt 4ed5050f56 Add function to change trait attributes. 2020-08-10 23:23:34 -04:00
David Wendt a5b62e833e Add trait attributes, similar to that of class attributes 2020-08-10 23:23:31 -04:00
David Wendt 60d42fa558 Allow creating slot/const traits. 2020-08-10 23:19:22 -04:00
David Wendt 3ca8dfd21a Allow constructing traits for getters, setters, and unbound free functions. 2020-08-10 23:19:22 -04:00
David Wendt d366ceab0e Allow setting the protected namespace of a builtin class. 2020-08-10 23:19:21 -04:00
David Wendt 9dc6cbe1ce Allow creating builtin traits from methods. 2020-08-10 23:19:21 -04:00