Commit Graph

4549 Commits

Author SHA1 Message Date
Aaron Hill ca030169f7 avm2: Implement BitmapData.rect and stub BitmapData.applyFilter
These are the last BitmapData methods needed for Solarmax
(the victory screen after beating the last level now renders).
2022-09-09 13:05:13 -05:00
Aaron Hill bb138d9082 avm2: Implement some of SharedObject
Our AVM2 `SharedObject` support is now *almost* equivalent
to our avm1 `SharedObject` support. We implement serialization
and deserialization for primitives, arrays, and `Object` instances
with local properties. We also implement serialization for `Date`,
but not `Xml` (since our AVM2 `Xml` class is just a stub at the moment).

This is enough to make 'This is the only level too' save level
progress to disk.

Currently, we always serialize to AMF3. When we implement
the `defaultObjectEncoding` and `objectEncoding`, we'll need
to adjust this.
2022-09-08 21:22:05 -05:00
Aaron Hill c090fe30ad core: Mark DisplayObject as non-removed when added to display list
An AVM2 movie can repeatedly remove and add a DisplayObject from/to
a parent. This was causing SolarMax to stop working after advancing
to the next level.
2022-09-08 18:19:25 -05:00
relrelb 7ec587355b text: Store background and border colors as `swf::Color`
Instead of `u32`.
2022-09-08 08:44:50 +03:00
EmperorBale ece4b9a76d avm2: Small cleanup 2022-09-07 13:54:33 -07:00
EmperorBale 7da912bbb4 avm2: Only store stack traces if avm_debug is enabled 2022-09-07 13:54:33 -07:00
EmperorBale a9d95b7d4e core: Fix code generator creating invalid code 2022-09-07 13:54:33 -07:00
EmperorBale 53ae55ff6f avm2: Improve stack trace output 2022-09-07 13:54:33 -07:00
EmperorBale 7fa19c2ea3 avm2: Store stack trace in Error objects 2022-09-07 13:54:33 -07:00
relrelb e0aba46bb2 chore: Remove unused `image` dependency
This basically reverts #7254 for all `.toml` files, except for `wgpu`
where it's actually needed on both desktop and web.
2022-09-07 13:09:29 -07:00
Aaron Hill 7218146e04 avm2: Implement BitmapData.dispose
We now check if a BitmapData has been disposed by checking
for a zero width or height (which cannot happen otherwise).
As a result, we no longer need the 'disposed' field on the AVM1
BitmapData object.
2022-09-07 11:02:53 -07:00
Aaron Hill b764c4f6c1 avm2: Implement BitmapData.fillRect and BitmapData.getPixel32 2022-09-07 12:29:49 -05:00
Mike Welsh 2ffbd8a1c7 core: Remove EditTextStaticData 2022-09-06 20:02:23 -07:00
Mike Welsh 459a19f146 core: Use bitflags for EditText 2022-09-06 20:02:23 -07:00
Mike Welsh b1404edfdc swf: Use bitflags for EditText 2022-09-06 20:02:23 -07:00
dowgird 53ed748a54 avm2: added flash.utils.escapeMultiByte 2022-09-06 19:44:48 -07:00
Mike Welsh f438e2032f avm1: Add is_streaming flag to Sound
`Sound.loadSound` with `isStreaming` of true causes any previously
playing audio on the same object to be stopped.
2022-09-06 19:04:16 -07:00
Mike Welsh dec4e30655 avm2: Add SoundLoaderContext 2022-09-06 19:04:16 -07:00
Mike Welsh e2f1f0174b audio: Implement Mp3Decoder::seek_to_sample_frame 2022-09-06 19:04:16 -07:00
Mike Welsh fe46d5046a avm2: Implement Sound.load 2022-09-06 19:04:16 -07:00
Mike Welsh 4a04923d04 audio: Add mp3_metadata function 2022-09-06 19:04:16 -07:00
Mike Welsh 3137306975 audio: Support loading external MP3s 2022-09-06 19:04:16 -07:00
Aaron Hill 93607aa86e
avm2: Implement `BitmapData.draw` for `wgpu` backend (#7254)
* avm2: Implement `BitmapData.draw` for `wgpu` backend

This method requires us to have the ability to render directly to a
texture. Fortunately, the `wgpu` backend already supports this in
the form of `TextureTarget`. However, the rendering code required
some refactoring in order to avoid creating duplicate `wgpu` resources.

The current implementation blocks on copying the pixels back
from the GPU to the CPU, so that we can immediately set them in
the Ruffle `BitmapData`. This is likely very inefficient, but will
work for a first implementation.

In the future, we could explore allowing the CPU image data and GPU
texture to be out of sync, and only synchronized when explicitly
necessary (e.g. on `getPixel` or `setPixel` calls).

* Rename `with_offscreen_backend` to `render_offscreen` and use Bitmap

* Don't panic when backend doesn't implement `render_offscreen`
2022-09-06 16:38:48 -05:00
Aaron Hill 54bf3d25f8 avm2: Remove `GcCell` from `local_registers`
We already have `&mut self` available whenever we write to it,
and we never made use of the `Clone` impl. As far as I can tell,
we don't have any unimplemented features that would require a `GcCell`.
2022-09-05 20:47:50 -07:00
Aaron Hill 45960de7dc avm2: Correctly implement DisplayObject.mask
The stub implementation was breaking code that relied on being
able to set a value for 'mask' and then retrieve it
(which used to work on a dynamic class like `MovieClip`).
2022-09-05 16:43:20 -07:00
dependabot[bot] 7f40b42131 build(deps): bump serde-xml-rs from 0.5.1 to 0.6.0
Bumps [serde-xml-rs](https://github.com/RReverser/serde-xml-rs) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/RReverser/serde-xml-rs/releases)
- [Commits](https://github.com/RReverser/serde-xml-rs/compare/0.5.1...0.6.0)

---
updated-dependencies:
- dependency-name: serde-xml-rs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 16:27:37 -07:00
dependabot[bot] aacc3c231a build(deps): bump clap from 3.2.18 to 3.2.20
Bumps [clap](https://github.com/clap-rs/clap) from 3.2.18 to 3.2.20.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.20/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v3.2.18...v3.2.20)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-05 14:47:03 -07:00
onkrot 1e0b59dbad avm2: Implement `String`.`localeCompare`, `search`, `toLocaleLowerCase`, `toLocaleUpperCase` methods. 2022-09-05 12:15:53 -07:00
= 2b3249c9a4 core: Made core no longer depend on software video decoders 2022-09-04 17:46:58 -07:00
= f0013bdec8 video: Moved individual decoders to software video backend 2022-09-04 17:46:58 -07:00
= bf242bfb09 video: Moved SoftwareVideoBackend to software decoder crate 2022-09-04 17:46:58 -07:00
= 7c839ef8ae video: Add software video crate, moved VideoDecoder to it 2022-09-04 17:46:58 -07:00
= 8b12185d61 video: Moved NullVideoBackend from core to video 2022-09-04 17:46:58 -07:00
= aff49cd891 video: Moved VideoBackend from core to video 2022-09-04 17:46:58 -07:00
= 7c464295e2 video: Moved VideoStreamHandle from core to video 2022-09-04 17:46:58 -07:00
= fd7086adef video: Moved EncodedFrame, DecodedFrame and FrameDependency from core to video 2022-09-04 17:46:58 -07:00
= b7cf800f88 video: Made ruffle_video crate, moved core video Error to it 2022-09-04 17:46:58 -07:00
= 72da1535b7 core: Made video::Error not depend on invidiaul codecs 2022-09-04 17:46:58 -07:00
Adrian Wielgosik acdb767862 avm2: Swap Multiname flags to bitflags 2022-09-04 16:56:32 -07:00
Adrian Wielgosik 782f670c39 avm2: Store uninitialized Multinames in txunit, behind Gc 2022-09-04 16:56:32 -07:00
Adrian Wielgosik c28549ed9e avm2: Store multi-namespaces behind Gc And single namespaces directly 2022-09-04 16:56:32 -07:00
EmperorBale dd2bc1ea78
avm2: Add automatic linting for AS3 playerglobals 2022-09-04 16:33:35 -07:00
= ce0752c225 avm1: Removed export of SystemPrototypes and SharedObject 2022-09-04 12:27:29 -07:00
= 6ed1dd5942 avm1: Replace avm1::AvmString with string::AvmString 2022-09-04 12:27:29 -07:00
= ddaee950f8 avm1: Removed all public access into Avm1 modules, export only what's needed 2022-09-04 12:27:29 -07:00
= 7d7309d165 avm1: Moved start_drag from Avm1 root to activation module 2022-09-04 12:27:29 -07:00
= f2c9ae7c50 avm1: Moved root_error_handler from avm1 root to runtime module 2022-09-04 12:27:29 -07:00
= 7645c84980 avm1: Moved skip_actions from avm1 root to runtime module 2022-09-04 12:27:29 -07:00
= 2d24ed539e avm1: Moved Avm1 struct into its own file, fixing field access as needed 2022-09-04 12:27:29 -07:00
Adrian Wielgosik 9cf6f64d06 avm2: Guarantee that int+/-int makes an int 2022-09-04 08:57:18 +03:00
Adrian Wielgosik cc6abab72f avm2: Remove Value::Unsigned, add minimal implicit int->float conversion 2022-09-04 08:57:18 +03:00
TÖRÖK Attila 2b681e85b2 avm2: Remove unnecessary `extends Object` from some class stubs
As it's implicit.
2022-09-03 10:43:33 -07:00
TÖRÖK Attila 27b67d01d0 avm2: `Vector` -> `Vector.<Number>` in `ShaderEvent` 2022-09-03 10:43:33 -07:00
TÖRÖK Attila 92a2b6206e avm2: Fix the stub for `Vector` 2022-09-03 10:43:33 -07:00
relrelb 32c55dda22 core: Avoid some clones of `Matrix` and `ColorTransform`
Change `set_matrix` and `set_color_transform` to accept owned structs,
instead of references. This allows callers that already have an owned
struct to pass it directly, thus saving an unnecessary borrow + clone.

This also aligns with other methods, such as `set_sound_transform`,
which currently accepts an owned struct.
2022-09-03 09:36:51 -07:00
TÖRÖK Attila 2e3fad9165 core: Log errors coming from timer callbacks 2022-09-02 22:22:03 -07:00
TÖRÖK Attila 89434d65e8 core: Don't panic when an error occurs in an AVM2 timer callback 2022-09-02 22:22:03 -07:00
TÖRÖK Attila f75eee389a core/mp3: More lenient MP3 buffer underrun detection 2022-09-02 20:38:24 -07:00
relrelb fb39bb2b71 swf: Remove `Copy` from `Rectangle`
Use `.clone()` explicitly where needed.
2022-09-02 18:21:13 -07:00
relrelb 299da43c16 swf: Extract `ShapeFlag` 2022-09-02 18:21:13 -07:00
Aaron Hill ae452d29b8 avm2: Stub DisplayObject.mask getter/setter
This allows the loaded ArmorGames API swf to run in
'This is the only level too'
2022-09-02 17:12:18 -07:00
relrelb af006a3053 avm1: Introduce `NativeObject`
The existing `Object` enum representation is problematic for inherited
native objects, since "regular" `ScriptObject`s cannot be turned into
native objects, but rather a completely new native object needs to be
created. `TObject::create_bare_object` is an attempt to aid this
situation, but it works only for `ActionExtends` inheritance, and not
when the user manually wires up `prototype`/`__proto__` (#701).

In Flash, it seems like derived constructors initially have a "regular"
`this` object. But once the `super()` constructor is invoked, the same
`this` object becomes a native object.

To allow this in Ruffle, introduce a new `NativeObject` enum, and
store it as a member in `ScriptObject`. For a start, move `TextFormatObject`
from the `Object` enum to `NativeObject`. The plan is to gradually
move all `Object` enum variants to `NativeObject`, except for `ScriptObject`.
2022-09-02 16:41:27 -07:00
golfinq 08917b49cb
avm2: Add actionscript event classes 2022-09-02 14:35:01 -07:00
Aaron Hill 7a7ea87679 avm2: Implement Sprite.startDrag and Sprite.stopDrag
For now, I've left 'dropTarget' unimplemented - unlike in
AVM1, the drop target can be non-interactive objects like `Shape`,
so we'll need additional refactoring to implement it.

This allows 'This is the only level too' to be playable
2022-09-02 13:03:14 -07:00
relrelb d2a463b08f core: Remove unused parameter of `MovieClip::show_frame` 2022-09-02 10:42:09 -07:00
relrelb 16a1b7b832 swf: Remove `length` parameter of `read_frame_label`
Use `unwrap_or_default()` to optionally read a byte.
Also remove unused `context` parameter of `MovieClip::frame_label`.
2022-09-02 10:42:09 -07:00
relrelb 9ec3137891 swf: Remove `tag_length` parameter of `read_define_button_cxform`
It was not needed since `Reader` accounts for it internally.
2022-09-02 10:42:09 -07:00
relrelb 3da3567365 core: Avoid some allocations on JPEG tags
Read a slice instead of allocating a new `Vec`.
2022-09-02 10:42:09 -07:00
relrelb cc166439d8 avm2: `Activation::is_of_type` is infallible 2022-09-02 10:10:40 -07:00
relrelb ce5bf557f5 avm2: `ExternalValue::from_avm2` is infallible 2022-09-02 10:10:40 -07:00
relrelb c2e78ffead chore: Appease clippy
Resolve 2 instances of `only_used_in_recursion`.
2022-09-02 10:10:40 -07:00
relrelb 0d6462cfab render: Remove `gc-arena` dependency
It was only used to make structs `#[derive(gc_arena::Collect)]`, and
generally it doesn't make much sense that `render` needs to be GC-aware.
So instead annotate `render` fields in `core` with `#[collect(require_static)]`.
2022-09-02 09:49:18 -07:00
Aaron Hill cc9e283191 avm2: Improve Debug impl for EventObject 2022-08-30 09:35:20 -05:00
Aaron Hill 1a7c5339a7 avm2: Implement DisplayObject.localToGlobal and DisplayObject.globalToLocal
While writing tests for these methods, I discovered and fixed some
issues with how 'scrollRect' interacted with 'dobj.transform.matrix'
2022-08-29 23:12:40 -05:00
relrelb 3645061910 core: Simplify `DisplayObjectContainer::highest_depth`
The `less_than` parameter remained just `Depth::MAX` since #7199,
which makes it useless. As such it can be removed.
2022-08-29 17:26:15 -06:00
Aaron Hill e9697439de avm2: Skip over holes during array enumeration
This brings us closer to matching the Flash Player
enumeration behavior. Unfortunately, the precise enumeration
order for ScriptObject properties depends on the precise
order in the internal avmplus hashmap. This order is deterministic,
but adding/removing a property effectively randomizes it. Hopefully
there aren't any SWFS that depend on the *exact* order.
2022-08-29 15:53:44 -07:00
dependabot[bot] 802de0e7d1 build(deps): bump futures from 0.3.23 to 0.3.24
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.23 to 0.3.24.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.23...0.3.24)

---
updated-dependencies:
- dependency-name: futures
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 23:38:43 +03:00
Toad06 c4e64c5e26 avm1: Function calls in SWF4 bump the version to 5 2022-08-29 02:17:09 -07:00
TÖRÖK Attila e86efd5c63 avm2: Add flash.utils.[set|clear][Timeout|Interval](...) 2022-08-29 01:44:57 -07:00
relrelb 5c29da6707 avm1: Implement `MovieClip.scrollRect`
The core functionality and AVM2 bindings were implemented in #7739.
2022-08-28 22:18:33 -07:00
= f180183ec5 core: Add audio feature, made dasp optional 2022-08-28 21:10:05 -07:00
= c6c22cebc9 core: Make nellymoser optional, enable on desktop and web 2022-08-28 21:10:05 -07:00
= f5245d72da core: Make core not use minimp3 by default - only desktop uses it 2022-08-28 21:10:05 -07:00
relrelb 81f803d77e avm1: Remove `DisplayObject::prev_avm1_clip`
It is no longer needed.
2022-08-28 19:21:03 -06:00
relrelb de6163569e avm1: Simplify frame execution logic
Handle removed clips inline in `Avm1::run_frame`, such that
`DisplayObject::prev_avm1_clip` is no longer used. Thus it can be
removed in a follow-up commit.
2022-08-28 19:21:03 -06:00
relrelb 0b7d8ea007 avm1: Move frame lifecycle logic to `Avm1::run_frame`
This allows better encapsulation of AVM1.
2022-08-28 19:21:03 -06:00
Aaron Hill 397de91a2a core: Do not run sounds on no-op goto.
When we run a 'goto' where the initial and target frame are the same,
we need to skip triggering any sounds in the target frame.
Some games like 'This is the only level too' rely on this behavior:
they repeatedly run 'movieClip.gotoAndStop(current_frame_id)',
where 'current_frame_id' is the id of a frame that starts playing
a sound. Without this change, the sound will restart every frame
intead of playing exactly once.
2022-08-28 18:55:29 -06:00
David Wendt e353553835 core: When reporting errors in the AVM2 constructor from MovieClip, also report the name of the class being constructed. 2022-08-28 18:17:57 -06:00
David Wendt 4b9ee55b56 avm2: The failsafe for self-referencing class properties should allow the use of `null` and `undefined`. 2022-08-28 17:54:22 -06:00
Aaron Hill ae8e5b2f33 avm2: Don't error when executing 'null as SomeType'
We previously used 'coerce_to_object', which produced
an error with `Value::Null`. Instead, we can just ues
`value.as_type_of`, which will correctly handle `null`
2022-08-28 16:33:15 -05:00
Aaron Hill c531994b1c avm2: Fire KeyboardEvent.KEY_UP and KeyboardEvent.KEY_DOWN
The 'charCode' and 'keyCode' properties are now implemented
on `KeyboardEvent`

The input injection code we use does not support keyboard events,
so we can't yet write a regression test for this. However,
both 'You need to burn the rope' and 'This is the Only Level TOO'
now properly handle keyboard events with this PR.
2022-08-28 14:15:57 -05:00
Aaron Hill e3e0488ed4 avm2: Delete enumerant when property is deleted 2022-08-28 12:03:19 -05:00
Aaron Hill 1296121dc5 avm2: Make 'set_local_property_is_enumerable` infallible
We always returned `Ok(())`
2022-08-28 12:03:19 -05:00
EmperorBale f8289b47d8
avm2: Implement call stack & stack traces (#7564)
* avm2: Implement call stack

* avm2: Class traits should have a special prefix

* avm2: Stack tracebacks should also contain error message

* avm2: Move method naming to Executable

* avm2: Handle getter and setter methods in tracebacks

* chore: Formatting

* chore: Add comments

* avm2: Make full_name write to a string, instead of creating a new one

* core: Make GcArena publicly accessible

* core: Add Deref impl for Either type

* desktop: Add AVM2 call stack to panic message

* avm2: Prefix native methods with a `/`

* chore: Appease clippy

* avm2: Check if method actually contains bytecode instead of unwrapping

* web: Add AVM2 stack trace to panic message

* chore: Formatting

* chore: Clippy

* avm2: Fix stack traces for free standing functions

* core: Remove global data from context

* core: Rename GcGlobalData to GcCallstack

* core: Introduce StaticCallstack, make GcArena private again

Co-authored-by: Adrian Wielgosik <4729533+adrian17@users.noreply.github.com>
2022-08-28 18:30:20 +02:00
Aaron Hill 6a01fa93c5 avm2: Implement `String.toLowerCase` and `String.toUpperCase`
These are implemented in the same way as in AVM1. Testing
in Flash Player shows that the behavior is the same.
2022-08-28 01:32:53 -05:00
Aaron Hill 576c35a768 avm2: Declare 'Array.concat' as a public method
Previously, it was only declared in the AS3 namespace. However,
some SWFs look it up as a public method.
2022-08-27 20:20:19 -05:00
relrelb 2f106da04c avm2: Port toplevel constants to ActionScript
Declare `NaN`, `Infinity` and `undefined` in ActionScript, similarly
to how `avmplus` does in its `actionscript.lang.as`.

Note that `null` is only removed, without an ActionScript declaration,
as it seems like `avmplus` neither declares it. Probably `null` is
only usable as a compile-time constant.
2022-08-26 15:45:36 -07:00
Callum Thomson 046514eeb9
avm1: Enumerate should push Undefined if the target isn't an object 2022-08-26 14:01:42 -07:00
Aaron Hill 249648674c Fix bounds computation 2022-08-26 13:04:01 -07:00
Aaron Hill 5fb95e6961 Use round-to-even for scrollRect 2022-08-26 13:04:01 -07:00
Aaron Hill fa0c843a4d avm2: Implement DisplayObject.scrollRect
This property causes a DisplayObject to be both translated
and cropped.
2022-08-26 13:04:01 -07:00
relrelb 72d8c152b9 core: Make `Player::load_device_font` infallible
It is always called with the same known data, which should parse
successfully.
2022-08-26 12:24:15 -07:00
relrelb ad84c2bbcb avm2: Rename `Avm2::load_abc` to `Avm2::do_abc`
This aligns with the name of `DoAbc` tags.
2022-08-26 11:37:04 -07:00
relrelb ad91992cb5 swf: Simplify `DoAbc` tag handling
Extract `swf::Reader::read_do_abc()` which, as the name suggests,
reads a `DoAbc` tag, and use it before calling to `Avm2::load_abc`.
Finally, introduce `DoAbcFlag` using `bitflags`.
This greatly simplifies the ABC loading code.
2022-08-26 11:37:04 -07:00
EmperorBale 18bd7879e5 core: Add better error message when java could not be found 2022-08-26 10:11:35 +02:00
Aaron Hill c4157fd0ce Miscellaneous stubs
This gets Solarmax to the main level select screen
(once BitmapData.draw support is added)
2022-08-25 19:57:03 -07:00
Aaron Hill 61d0f73fdb core: Use catchup_display_object_to_frame in Loader 2022-08-25 19:24:56 -06:00
David Wendt 2c93da9a70 docs: Add comments documenting subtle points of AS3 loop & tag queueing behavior 2022-08-25 19:24:56 -06:00
David Wendt 074f2ff76f core: Replace `Vec` of queued tags with a more restrictive enum that enforces our queueing invariants 2022-08-25 19:24:56 -06:00
David Wendt 59623a8452 core: Fix a potential stack overflow caused by gotos triggering frame scripts on one another. 2022-08-25 19:24:56 -06:00
David Wendt 05caa0fceb core: Explicit gotos drain the tag queue of any prior operations.
This is in keeping with the whole idea of a "recursive frame": gotos run the entire frame lifecycle on the target clip, including broadcasts for `frameConstructed` and `exitFrame`.
2022-08-25 19:24:56 -06:00
David Wendt 6f0de246ed core: Clear queued tags if AS3 attempts a goto in the middle of a loop. 2022-08-25 19:24:56 -06:00
David Wendt ed28578c12 core: Fast-forwarding gotos should run frame scripts on all removed children 2022-08-25 19:24:56 -06:00
David Wendt bcb1030883 core: Only `Construct` and `Enter` phases want forced script frames on gotos 2022-08-25 19:24:56 -06:00
David Wendt 3677a0107b core: Only force-queue frame scripts if the goto is not a no-op. 2022-08-25 19:24:56 -06:00
David Wendt ac2b82f26e core: Gotos *always* queue the target frame's scripts on the target clip, even if we already executed that script beforehand. 2022-08-25 19:24:56 -06:00
David Wendt 9bff6406d1 core: Allow queueing both a remove and a place tag at the same depth, in that order only. 2022-08-25 19:24:56 -06:00
David Wendt 2929681a93 core: No-op gotos should be treated as rewinding. 2022-08-25 19:24:56 -06:00
David Wendt 7a09bbfaab core: In AVM2, run removals before frame advance.
We still retain the queue system as events are fired at removal time, and those events can trigger more gotos. If such a goto happens, AS3 code will hit a clip still in the old state rather than an inconsistent one. I don't have test coverage for this exact scenario just yet.
2022-08-25 19:24:56 -06:00
David Wendt d691543c4c core: Child removals appear to resolve in reverse render order. 2022-08-25 19:24:56 -06:00
David Wendt 8feb3fc7b0 core: Fast-forward removals as the result of a goto happen before the frame number advances. 2022-08-25 19:24:56 -06:00
David Wendt 66c24ff188 core: Queue new object placement at loop time on the tag queue. 2022-08-25 19:24:56 -06:00
David Wendt 0353d176e4 core: Movie clip rewinds should not remove any children until after the new timeline position has been set. 2022-08-25 19:24:56 -06:00
David Wendt 99003643ac core: Same-frame gotos should only proceed on AVM2. 2022-08-25 19:24:56 -06:00
David Wendt cdfc6f5eae core: Explicit gotos must run even if they are no-ops. 2022-08-25 19:24:56 -06:00
David Wendt cb86340fb1 core: `frameConstructed` during a goto fires after the goto commands have fully completed. 2022-08-25 19:24:56 -06:00
David Wendt 51401ae660 core: Remove AVM2 compatibility hacks surrounding place frame.
They are no longer needed, frame advance happens at enterframe time.
2022-08-25 19:24:56 -06:00
David Wendt 1eef8a47c9 core: Movie clips run all their tags at `enter_frame`, and place/remove actions are queued until later.
This prevents repeated place/remove actions at the same depth from resulting in repeated event dispatches.
2022-08-25 19:24:56 -06:00
David Wendt 963144e59c core: Centralize all the various calls to `enter_frame`/`construct_frame` into a single method, `catchup_display_object_to_frame`.
The rationale for the catch-up logic is as follows:

 * We must always enter-frame and construct objects, even if those respective display events haven't happened yet.
 * Display objects created in event handlers still need to run catchup phases, otherwise they will tag-stream desync
 * Frame scripts are never triggered by catchup phases
 * `exit_frame` is not a catchup phase as it is *only* an event broadcast currently
2022-08-25 19:24:56 -06:00
David Wendt 0400d4dee4 core: `Player` should start in the `Idle` phase 2022-08-25 19:24:56 -06:00
David Wendt f0ef8adb42 core: Add a new frame phase to represent non-frame work such as input event handlers. 2022-08-25 19:24:56 -06:00
David Wendt ae530b5d6b core: Track what part of the frame processing loop we're in 2022-08-25 19:24:56 -06:00
David Wendt ee2454e09f core: Frame actions should start with `enterFrame`; not `exitFrame`. 2022-08-25 19:24:56 -06:00
David Wendt 1f0b8bdda4 core: In AVM2, movie clips process `RemoveObject` before any other frame actions are done. 2022-08-25 19:24:56 -06:00
David Wendt 318b018da8 core: `enter_frame` should be an event that all display objects get and can respond to 2022-08-25 19:24:56 -06:00
relrelb d152cc3e64 avm2: Port `Math` to ActionScript 2022-08-25 16:03:08 -07:00
relrelb 4e9cc919a1 avm2: Fix bindings of empty namespace
Previously native functions defined inside a `package {}` block
(without a package name) would cause a syntax error by two consecutive
`::`.
2022-08-25 16:03:08 -07:00
= 620820be9e core: Replaced tag_utils Error with an actual Error enum 2022-08-25 23:43:21 +02:00
= 67eb34fbc5 core: Remove Error from player.rs, it wasn't needed 2022-08-25 23:43:21 +02:00
= b7dcd26c38 core: Use Cow<str> for FullscreenError in UI backend, as it can't ever be anything else 2022-08-25 23:43:21 +02:00
= 1c7bfd8c5f core: Use real Error enums for video backend 2022-08-25 23:43:21 +02:00
= 461c977be0 render: unregister_bitmap is infallible, removed error path 2022-08-25 23:43:21 +02:00
= 03eb769a33 render: Made render use a real Error enum and not generic box<error> 2022-08-25 23:43:21 +02:00
= 5b5ee7d448 core: Made audio backend use actual real error enums, and not box<error> 2022-08-25 23:43:21 +02:00
= 2d2869f44f core: Font::from_swf_tag is currently infallible, remove error path 2022-08-25 23:43:21 +02:00
= 1df8de5bac core: set_text and set_html_text are currently infallible, remove error path 2022-08-25 23:43:21 +02:00
Mike Welsh 78247a37ab avm1: Load correct _root and _parent registers if base clip is removed
Normally a function closures also closes around its base clip.
If the base clip is removed, and then the function is executed, the
base clip then defaults to `this`.

However, Ruffle was incorrectly using the wrong base clip when
loading the `_root` and `_parent` registers in this case.

Fixes #5645.
2022-08-25 00:01:02 -07:00
Roman Rogowski 66d144bbdd core: Fix incorrect rendering of word-wrap text boxes (close #1095) 2022-08-24 22:51:51 -07:00
relrelb a8edce8294 core: Remove unneeded `Box` 2022-08-24 22:36:20 +03:00
Aaron Hill c7216bf842 avm2: Set URLRequest.method default to GET
This was missed when I added 'method'
2022-08-23 17:54:10 -05:00
onkrot 14abd01e91 avm2: Pull flash.crypto package method from globals to crypto.as 2022-08-23 09:58:19 -05:00
onkrot db22992b86 avm2: Pull flash.utils package methods from globals to utils.as 2022-08-23 09:58:19 -05:00
onkrot 1a243bdd86 avm2: Implement all remaining matrix methods 2022-08-23 10:44:12 +02:00
Aaron Hill 86e6983943 avm2: Partially implement Loader.load
This PR implements the `Loader.load` method, as well as
the associated `LoaderInfo` properties and events.

We can now load in an external AVM2 SWf: it will be added
as a child of `Loader` object, and will render properly
to the screen.

Limitations:
* The only supported `URLRequest` property is `url`
* `LoaderContext` is not supported at all - we always use the default
  behavior
* Only `Loader.load` is implemented - we do not yet support unloading.
* We fire a plain 'Event' for the 'progress' event, instead of using
  the (not yet implemented) 'ProgressEvent' class

The main changes in this PR are:
* The AVM2 `Loader` class now has an associated display object,
  `LoaderDisplay`. This is basically a stub, and just renders
  its single child (if it exists).
* `LoaderStream::Stage` is renamed to `LoaderStream::NotYetLoaded`.
  This is used for both the `Stage` and an 'uninitialized'
  `Loader.contentLoaderInfo`. In both cases, certain properties throw
  errors, while others return actual values.
* The rust `Loader` manager now handles both AVM1 and AVM2 movie loads.
2022-08-22 19:36:29 -07:00
dependabot[bot] 25a77869ab build(deps): bump serde from 1.0.143 to 1.0.144
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.143 to 1.0.144.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.143...v1.0.144)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 16:51:56 -07:00
Aaron Hill 98c7f443ce core: Only store viewport dimensions in `RenderBackend`
Previously, the viewport height and width were stored in
both `Stage` and the `RenderBackend`. Any changes to the viewport
dimensions (e.g. due to window resizing) needed to be updated in both
places to keep our handling of the viewport consistent.

This PR adds a new `ViewportDimensions` type, which holds the
width, height, and scale factor. It is stored inside the
`RenderBackend` impl, and is retrieved using the newly added
method `RenderBackend.get_viewport_dimensions`. After a `Player`
has been constructed, any code that needes access to the viewport
dimensions will ultimate go through this method.

Unfortunately, `Stage` needs to use the viewport dimensions
in `build_matrices`. Therefore, any code modifying the viewport
dimensions should go through `player.set_viewport_dimensions`,
which ensures that the stage matrices are rebuilt after the render
backend is updated.
2022-08-22 13:44:30 -07:00
Mike Welsh 3629a55c00 core: Mouse picking respects order of children (fix #7393)
When doing mouse picking, interactive children were considered
before all non-interactives, which could cause an `_droptarget` to
be set to an underlying movieclip even if a shape occluded it.

Now consider all children in render order so that the top-most
shape will capture the mouse input.
2022-08-21 21:16:02 -07:00
= 3a1947445e core: Made SwfSlice::to_subslice return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
= 44cfaa9200 core: Made SwfSlice::to_unbounded_subslice return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
= 55566037f7 core: Made SwfSlice::resize_to_reader return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
= 0cfbdc0385 core: Made SwfSlice::to_start_and_end return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
Adrian Wielgosik b18329c8fe web: Allow modifying player volume via JS 2022-08-20 11:53:42 -07:00
Mike Welsh b38fce230d audio: Add AudioBackend::volume/set_volume 2022-08-20 11:53:42 -07:00
David Wendt f66e54bd03 core: Log a `debug` message every time we run a goto. 2022-08-19 18:52:21 -07:00
David Wendt fe828d7c24 core: At the end of a goto, fix tag stream desyncs caused by not hitting the target frame.
If we try to go to a frame that doesn't exist, or hasn't been loaded yet, we will stop on the last available frame, but skip any tags that would have run there. This is technically a desync, but it hasn't caused any problems so far as any further timeline interaction would trigger a rewind (which isn't affected by desyncs).

Of course, now that we're actually testing the tag stream position it *does* cause problems. We actually have to fix up the position to be correct even though it will never be used (hopefully). It may be prudent to do this outside of the `timeline_debug` feature as well in the future.
2022-08-19 18:52:21 -07:00
David Wendt 32542fdbc8 core: When `timeline_debug` is enabled, assert every goto's tag stream positions against the list of stream boundaries. 2022-08-19 18:52:21 -07:00
David Wendt 72e40423fa core: Calculate the start and end position of every frame when the `timeline_debug` feature is enabled. 2022-08-19 18:52:21 -07:00
Mike Welsh 89cb1212ad render: Disable most blend modes
Avoid blend modes except ADD and SUBTRACT until they can be
implemented properly.
2022-08-19 14:59:08 -07:00
relrelb c7941e7248 avm1: Remove `ScriptObject::bare_object`
Use `ScriptObject::new` instead.
2022-08-19 12:22:48 -07:00
relrelb 5cbfcde784 avm1: Remove `ScriptObject::object_cell`
Use `ScriptObject::new` instead.
2022-08-19 12:22:48 -07:00
relrelb 04b4a6cabe avm1: Rename `ScriptObject::object` to `ScriptObject::new` 2022-08-19 12:22:48 -07:00
Aaron Hill f3feaaf2be avm1: Set init object properties in reverse order
Fixes #7667

This behavior is by setter functions, and some SWFS
depend on it.
2022-08-19 11:49:40 -07:00
Aaron Hill 0cd6d13783
avm2: Stub ContextMenu.builtInItems (#7652) 2022-08-18 20:50:42 -04:00
Mike Welsh 7a53322cbb avm1: Wire up Button.blendMode 2022-08-18 16:38:17 -07:00
Mike Welsh 1e389112a1 avm1: Wire up MovieClip.blendMode 2022-08-18 16:38:17 -07:00
Mike Welsh b450b99e3e avm2: Wire up DisplayObject.blendMode 2022-08-18 16:38:17 -07:00
Mike Welsh 2e83bb570d core: Warn when setting a blend mode 2022-08-18 16:38:17 -07:00
Mike Welsh 7aee05cf75 core: Apply blend mode from PlaceObject tags
* Set blend mode in `DisplayObject::apply_place_object`.
 * Change `DisplayObject::set_blend_mode` to take `&self`.
2022-08-18 16:38:17 -07:00
Aaron Hill f7205a02a9 render: Add BlendMode infrastructure and implement BlendMode.ADD
Each render backend keeps track of a stack of BlenModes,
which are pushed and popped by 'core' as we render objects
in the displaay tree. For now, I've just implemented BlendMode.ADD,
which maps directly onto blend mode supported by each backend.

All other blend modes (besides 'NORMAL') will produce a warning
when we try to render using them. This may produce a very large amount
of log output, but it's simpler than emitting each warning only once,
and will help to point developers in the right direction when they
get otherwise inexplicable rendering issues (due to a blend mode
not being implemented).

The wgpu implementation is by far the most complicated, as we need
to construct a `RenderPipeline` for each possible
`(BlendMode, MaskState)`. I haven't been able to find any documentation
about the maximum supported number of (simultaneous) WebGPU render
pipelines - if this becomes an issue, we may need to register them
on-demand when a particular blend mode is requested.
2022-08-18 16:38:17 -07:00
Aaron Hill 1e18fc2227 avm2: Convert filters to ActionScript
We still don't implement the actual filter logic for `DisplayObject`,
but the classes themselves are fully implemented.
2022-08-17 12:55:03 -07:00
dowgird 038264a7a9 avm2: Implement stageFocusRect stub 2022-08-16 13:59:12 -05:00
relrelb 4d8e4111e3 core: Remove `AvmType`
Simply use `is_action_script_3()` instead.
2022-08-16 13:04:02 +03:00
dependabot[bot] ad2b1bbd24 build(deps): bump futures from 0.3.21 to 0.3.23
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.21 to 0.3.23.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.21...0.3.23)

---
updated-dependencies:
- dependency-name: futures
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 23:37:47 +03:00
Aaron Hill 6f20e8882d avm2: Implement DisplayObject.transform and most of Transform
This PR implements the 'DisplayObject.transform' getters/setters,
and most of the getters/setters in the `Transform` class

From testing in FP, it appears that each call to the
'DisplayObject.transform' property produces a new
'Transform' instance, which is permanently tied to the
owner 'DisplayObject'. All of the getters/setters in
`Transform` operate directly on owner `DisplayObject`.
However, note that the `Matrix` and `ColorTransform`
valuse *produced* the getter are plain ActionScript objects,
and have no further tie to the `DisplayObject`.

Using the `DisplayObject.transform` setter results in
values being *copied* from the input `Transform` object.
The input object retains its original owner `DisplayObject`.

Not implemented:
* Transform.concatenatedColorTransform
* Transform.pixelBounds

When a DisplayObject is not a descendant of the stage,
the `concatenatedMatrix` property produces a bizarre matrix:
a scale matrix that the depends on the global state quality.
Any DisplayObject that *is* a descendant of the stage has
a `concatenatedMatrix` that does not depend on the stage quality.
I'm not sure why the behavior occurs - for now, I just manually
mimic the values prdduced by FP. However, these values may indicate
that we need to do some internal scaling based on stage quality values,
and then 'undo' this in certain circumstances when constructing
an ActionScript matrix.

Unfortunately, some of the computed 'concatenatedMatrix' values
are off by f32::EPSILON. This is likely due to us storing some
internal values in pixels rather than twips (the rounding introduced
by round-trip twips conversions could cause this slight difference0.
For now, I've opted to mark these tests as 'approximate'.

To support this, I've extended our test framework to support providing
a regex that matches floating-point values in the output. This allows
us to print out 'Matrix.toString()' and still perform approximate
comparisons between strings of the format
'(a=0, b=0, c=0, d=0, tx=0, ty=0)'
2022-08-14 19:12:25 -07:00
Nathan Adams 824b4aa8d1 render: Moved render backend from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 760da753fb render: Moved Transform from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams f088d8ac3a render: Moved color_transform from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 35082b687f render: Moved shape_utils from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams b3afb59b53 render: Moved BoundingBox from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 91a7047ebb render: Moved Matrix from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 9fd8fd938e render: Moved render utils from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams bc0c7cbccb render: Made new render crate, moved Bitmap stuff to it 2022-08-14 18:38:14 -07:00
Nathan Adams 94282dfe73 core: Moved render utils into own module 2022-08-14 18:38:14 -07:00
Nathan Adams 0bb14193c6 core: Moved Bitmap into its own module for refactoring rendering 2022-08-14 18:38:14 -07:00
Nathan Adams beab50cde7 core: Moved NullRenderer into its own module in preparation for refactoring 2022-08-14 18:38:14 -07:00
relrelb d70697b4f3 web: Refactor `WebNavigatorBackend`
Store `base_url` as `Option<Url>` instead of `Option<String>`, so
we don't need to parse it on each URL resolve.
2022-08-14 17:49:05 -07:00
Aaron Hill a99c7e381b avm2: Improve `Debug` impl for `StageObject`
This builds off of the previous work for `ScriptObject` and
`ClassObject`. We now print both the class name and the stored
`DisplayObject`.
2022-08-14 15:31:53 -05:00
Aaron Hill d6532c87c2 avm2: Stub TimerEvent.updateAfterEvent
This is the last stub needed for Wonderputt to reach the
main game screen.

As far as I know, ActionScript cannot observe a frame being rendered,
so implementing this method isn't actually necessary for correctness.

The benefit of implementing this would be to make certain animations
appear smoother, since we'll render changes to the scene without
needing to wait for the next frame. However, actually rendering
*immediately* after the event would require some refactoring -
we have a `&mut UpdateContext` while running timers, but we'd need
to bail out and obtain a `&mut Player`.
2022-08-13 19:24:56 +02:00
Aaron Hill ef4a955e65 avm2: Always get loaderInfo from the root object 2022-08-13 02:06:38 -07:00
relrelb 8a7e96b0d5 avm2: Split `names.rs`
Into `namespace.rs`, `multiname.rs` and `qname.rs`, for better code
organization.
2022-08-13 02:12:53 +03:00
Nathan Adams 7dff19b559 core: Use a fixed seed when using deterministic feature 2022-08-12 13:11:46 +03:00
Aaron Hill 4a42bae333 avm2: Fix ApplicationDomain property declarations
Many of the class property defintiions were wrong -
instance methods were defined as class properties,
and class properties were defined as instance properties.
2022-08-12 10:45:03 +02:00
Aaron Hill 91993eb872 avm2: Stub URLRequest.data
This allows Wonderputt to get further (it deliberately assigns
'null' to 'URLRequest.data'). We throw an exception for any other
value, to prevent confusing errors caused by attempting an
unexpected request to a web server with a missig body.
2022-08-12 10:14:36 +02:00
Aaron Hill 9d1f27484b avm2: Implement 'throw' opcode
We currently lack the ability to preserve the original
`Value<'gc>` in the error, so we're forced to stringify the error.

This means that only typeless 'catch' blocks will work properly -
however, they're the only kind of 'catch' block that we currently
implement. Implementing support for typed 'catch' blocks will naturally
allow us to preserve the original 'Value<'gc>' in the 'throw'
implementation, since we'll need to switch to a custom `Error<'gc>`
type.
2022-08-11 17:20:53 -05:00
Adrian Wielgosik 4a7cb51148 avm2: Make missing props on sealed classes throw properly 2022-08-11 21:28:18 +02:00
Aaron Hill 71571b9594 avm2: Add URLRequest.method and use it URLLoader 2022-08-11 19:50:58 +02:00
Aaron Hill ed0512ca9d avm2: Show class name in `ClassObject` Debug impl
Before: `ClassObject(GcCell(Gc { ptr: 0x7f69f8300a28 }))`
After:  `ClassObject { name: flash.net::URLRequest, ptr: 0x7fe9cc2e7820 }`
2022-08-11 18:54:11 +02:00
TÖRÖK Attila d5b86f60a1 avm2: Add `flash.system.LoaderContext`, stub `flash.system.SecurityDomain`
Also add AS stubs for the preexisting `flash.display.DisplayObjectContainer`
and `flash.system.ApplicationDomain` natively defined classes.
2022-08-11 10:01:03 +02:00
dowgird b6fd670410 address review comments 2022-08-10 01:34:08 +02:00
dowgird 38f50f83ef removed a now unused function, added a test 2022-08-10 01:34:08 +02:00
dowgird e5b0937461 changed catch_scope() back to taking MutationContext 2022-08-10 01:34:08 +02:00
dowgird 5ccc981357 Used install_instance_slots() instead of adding slots manually 2022-08-10 01:34:08 +02:00
dowgird fb0a984415 Rebase and fix clippy warnings. 2022-08-10 01:34:08 +02:00
dowgird 31ed697acd Fixes from review 2022-08-10 01:34:08 +02:00
dowgird 26b41199fb avm2: Implemented newcatch and basic exception handling 2022-08-10 01:34:08 +02:00
Adrian Wielgosik 54f9824ce0 avm1: Update drag in stopDrag() in case it wasn't called before 2022-08-10 00:20:09 +02:00
Nathan Adams 07da3f6c0f exporter: Add --skip-unsupported to skip (and not crash) avm2 movies 2022-08-09 23:19:42 +02:00
Nathan Adams 8efd69b525 core: Track 'actions since timeout check' globally instead of per Activation 2022-08-09 20:56:18 +03:00
Nathan Adams fb1ebcb9cc avm1: loadMovieNum with blank url is an unload, not a load - fixes #7337 2022-08-09 18:53:57 +03:00
Nathan Adams 4b19910791 audio: Avoid panic with supposed MP3s that are too small 2022-08-09 17:59:02 +03:00
dependabot[bot] 4603e5964e build(deps): bump serde from 1.0.141 to 1.0.143
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.141 to 1.0.143.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.141...v1.0.143)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-09 11:54:47 +03:00
dependabot[bot] ab44ff8c13 build(deps): bump syn from 1.0.98 to 1.0.99
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.98 to 1.0.99.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.98...1.0.99)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-09 09:25:48 +03:00
dependabot[bot] 8acb77dc2c build(deps): bump proc-macro2 from 1.0.42 to 1.0.43
Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.42 to 1.0.43.
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.42...1.0.43)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-09 08:51:01 +03:00
dependabot[bot] ed1ebe8fb5 build(deps): bump quote from 1.0.20 to 1.0.21
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.20 to 1.0.21.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.20...1.0.21)

---
updated-dependencies:
- dependency-name: quote
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-08 23:58:43 +02:00
TÖRÖK Attila 5e2804f992 avm2: Implement `flash.geom.Vector3D` 2022-08-08 22:15:09 +03:00
CUB3D 05bfa3770e chore: Fix warnings with cargo doc 2022-08-08 20:20:18 +03:00
relrelb e42a6b62e6 core: Require `target` in `NavigatorBackend::navigate_to_url`
Make the `target` parameter just a `String` instead of an `Option<String>`.
`None` is not needed as it's totally equivalent to an empty string.
2022-08-06 11:20:03 +03:00
Aaron Hill 2f8dde86af
avm2: Include class name in ScriptObject debug (#7512)
* avm2: Include class name in ScriptObject debug

Currently, the `ScriptObject` debug impl is almost useless -
while you determine if two printed objects are the same
by comparing the pointer value, you'll have no idea what
kind of object it actually is.

This PR now formats the `ScriptObject` output as a struct,
printing a (fake) "class" field containing the class name.

Before/after:

```
[ERROR ruffle_core::avm2::activation] AVM2 error: Cannot coerce Object(ScriptObject(ScriptObject(GcCell(Gc { ptr: 0x55f863936db8 })))) to an QName { ns: Private("Test.as$38"), name: "Second" }
[ERROR ruffle_core::avm2::activation] AVM2 error: Cannot coerce Object(ScriptObject(ScriptObject { class: "Object", ptr: 0x55ee0ad161e0 })) to an QName { ns: Private("Test.as$38"), name: "Second" }
```

Getting access to the class name from a `Debug` impl is tricky:

Developers can (and should be able to) insert logging statements
whereever they want, so any `GcCell` may be mutably borrowed.
Panics in debug impls are extremely frustrating to deal with,
so I've ensured that we only use `try_borrow` at each step.
If any of the attempted borrows fail, we print out an error message
in the "class_name" field, but we're still able to print the
rest of the `ScriptObject`.

Additionally, we have no access to a `MutationContext`, so we
cannot allocate a new `AvmString`. To get around this,
I've created a new method `QName::to_qualified_name_no_mc`,
which uses an `Either` to return a `WString` instead of allocating
an `AvmString`. This is more cumbersome to work with than the
nrmal `QName::to_qualified_name`, so we'll only want to use
it when we have no other choice.
2022-08-04 22:13:00 -07:00
Aaron Hill 2383e6850f avm2: Continue to process event when a handler produces an error
An exception thrown by one event handler shoud not prevent other event
handlers from running on this same event. Some SWFs like Wonderputt
depend on this behavior, as they have buggy event handlers that throw
errors.
2022-08-03 22:29:41 +03:00
Aaron Hill ad19c29c03 Remove `null` from `getChildByName` for missing child
This matches the behavior of Flash - no error is produced.
2022-08-03 21:45:59 +03:00
dependabot[bot] f7f84418f9 build(deps): bump proc-macro2 from 1.0.41 to 1.0.42
Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.41 to 1.0.42.
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.41...1.0.42)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-02 22:37:35 +03:00
dependabot[bot] 3b7f6976a4 build(deps): bump serde from 1.0.140 to 1.0.141
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.140 to 1.0.141.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.140...v1.0.141)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-02 19:34:44 +03:00
Adrian Wielgosik e214dd5ce5 avm2: Implement BitmapData.scroll/copyPixels, stub lock() 2022-08-01 22:31:42 +03:00
Adrian Wielgosik 17f090d1d5 avm2: Stub Loader.contentLoaderInfo 2022-08-01 22:31:42 +03:00
TÖRÖK Attila 820196d066 audio: Handle AudioCompression::UncompressedUnknownEndian in AudioMixer::make_seekable_decoder()
The same way as it is done in decoders::make_decoder().
2022-08-01 21:39:01 +03:00
Aaron Hill 2ce6679643
avm2: Store PropertyClass in `VtableData`
Calling `get_trait` copies the returned `Property`, so the caching
we performed in `PropertyClass` was never actually getting used.

Instead, we now store our `PropertyClass` values in a `Vec`
indexed by slot id. `set_property` and `init_property` now perform
coercions by going through the `VTable,` which writes the updated
`PropertyClass` back into the array.
2022-07-30 17:58:50 -07:00
Adrian Wielgosik 5be7f425f0 avm2: Migrate all Events to AS, remove EventData. 2022-07-30 12:34:12 -07:00
relrelb d01a03b4ca avm1: Correct `ActionURShift`
In SWF8 and SWF9, unsigned right shift actually has a signed result.
2022-07-29 14:44:21 -07:00
Ali MJ Al-Nasrawy 67fbc84ba3 don't rely on a rustc bug
context: https://github.com/rust-lang/rust/pull/98835
2022-07-29 15:27:46 -05:00
Aaron Hill 0d3e046b0e
avm2: Allow classes to reference their own type from a static variable
FP allows code like
`class Foo { static var INSTANCE: Foo = new Foo(); }`

However, this breaks our current property type coercion setup -
we cannot resolve the type `Foo` when setting the property `INSTANCE`,
since `Foo` is still being constructed.

Fortunately, we can perform this 'coercion' by just checking if
the object's class name and domain match the type name and domain
of the property.
2022-07-29 13:24:37 -07:00
relrelb 79f36964b4 web: Bump wasm-bindgen to 0.2.82
As usual, also bump its helper crates (`js-sys`, `web-sys` and
`wasm-bindgen-futures`) to the latest versions.
2022-07-29 09:40:14 -07:00
Mike Welsh 30b185cbd4 audio: Reset symphonia decoder on loop 2022-07-28 21:25:33 -07:00
TÖRÖK Attila 7249db9052 audio: Fix crash/gap at the end of MP3 loops 2022-07-28 21:25:33 -07:00
Mike Welsh ffb57467eb audio: Add `AudioBackend::position_resolution`
This returns the approximate interval that the audio backend
updates the sound position information. This is used for syncing
animation to embedded "stream" audio tracks, and fixes some
stuttering in cases where the syncing was being too strict.
2022-07-28 21:25:33 -07:00
Mike Welsh 405c7194b0 audio: Remove `AudioBackend::preload_sound_stream` fns
No longer necessary now that web audio mixing is done on Rust side.
2022-07-28 21:25:33 -07:00
Aaron Hill f2deeb4de8 Fix typo 2022-07-27 22:38:49 -07:00
Aaron Hill 49d1a985ca avm2: Store `LoaderInfo` object on `MovieClip` and `Stage`
Previously, we would create a fresh `LoaderInfo` object each
time the `loaderInfo` property was accessed. However, users can
add event handlers to a `LoaderInfo`, so we need to create and
store exactly one `LoaderInfo` object per movie (and stage).

To verify that we're correctly handling the storage of `LoaderInfo`,
I've implemented firing the "init" event. This required a new
`on_frame_exit` hook, so that we can properly fire the "init"
event after the "exitFrame" for the initial frame but before
the "enterFrame" of the next frame.
2022-07-27 22:38:49 -07:00
EmperorBale d14b868c4f core: Simplify new_utf8_bytes 2022-07-25 10:52:56 -07:00
EmperorBale a2261cd556 chore: Formatting 2022-07-25 10:52:56 -07:00
EmperorBale d6604f538c wstr: Implement custom UTF-8 decoding routine 2022-07-25 10:52:56 -07:00