Commit Graph

4252 Commits

Author SHA1 Message Date
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
EmperorBale 6dab6ca557 avm2: Update set_data to convert bytes to string lossily 2022-07-25 10:52:56 -07:00
EmperorBale d79c68bbcd core: Implement AvmString::new_utf8_bytes_lossy 2022-07-25 10:52:56 -07:00
Aaron Hill 515c7bf518 Fix behavior when setting repeatCount, and improve tests 2022-07-24 20:43:00 -07:00
Aaron Hill b4f98190e9 avm2: Implement flash.utils.Timer and associated events
The current 'setInterval/setTimeout' implementation is
moved to 'core/src/timers.rs', and now works with both
AVM1 and AVM2 objects. The `flash.utils.Timer` class is implemented
mostly in ActionScript, with minimal modifications to the actual
Ruffle timer code.
2022-07-24 20:43:00 -07:00
relrelb 3bfe736262 core: Remove `From<Position<Twips>> for Transform`
Simply use `Matrix::translate` directly, which is more explicit and
intuitive.
2022-07-24 19:07:05 -07:00
relrelb bbfd272c15 avm1: Use `Matrix::scale`
Instead of a directly initialzed `Matrix`.
2022-07-24 22:11:31 +03:00
relrelb fc87a35572 core: Remove some dead `DisplayObject` methods 2022-07-23 22:22:20 +03:00
relrelb 8d30833d02 core: Don't use `saturating_sub` for `width` / `height`
Use regular subtraction, since it should never overflow.
Also remove `swf::Twips::saturating_sub`, which is now unused.
2022-07-23 10:33:12 -07:00
relrelb 29ae39a2d1 core: Remove unused parameter of `Avm1Button::from_swf_tag` 2022-07-23 10:18:53 -07:00
Rafał Dowgird fac32b488b
avm2: implement string replace(string, function) (#7456)
* avm2: implement string replace where pattern is string and replacement is a function

* * removed unnecessary vec!

  * fixed "no newline at the end of file"
2022-07-22 17:32:02 +03:00
Aaron Hill bb6f07ee1a
avm2: Add support for playerglobal instance allocators
This commit adds support for combining instance allocators with
ActionScript playerglobal class definitions. This is activated
by defining the metadata `[Ruffle(InstanceAllocator = "true")]`
on the ActionScript class definition.

The implementation of this feature is very similar to native methods:
`build_playerglobal` checks for the metadata described above,
and defines a const `NATIVE_INSTANCE_ALLOCATOR_TABLE` mapping
class ids to function pointers.

To demonstrate this feature, I've converted `Event` to ActionScript
(keeping the existing instance allocator function).
I've also converted `ActivityEvent` and `ContextMenuEvent` to
`ActionScript`, to demonstrate how this simplifies inheritance.
In a future PR, we can convert the remaining events to ActionScript,
and remove the `EventData` enum entirely.

Unfortunately, `flex-sdk`'s `asc.jar` compiler strips out all metadata
when the `-optimize` option is passed. As a result, I forked
`flex-sdk` and disabled this behavior:
https://github.com/ruffle-rs/flex-sdk/releases/tag/ruffle-1.0.0

The modified `asc.jar` (built from the forked repository)
is included in this PR, and replaces the our previous 'asc.jar'
downloaded from the official Flex SDK release.

* Change metadata to `[Ruffle(InstanceAllocator)]`

* Strip out metadata before saving bytecode
2022-07-20 23:11:46 -07:00
Mike Welsh ef838a3536 avm1: lineStyle scale mode defaults to normal 2022-07-19 15:01:17 -07:00
Mike Welsh 1980d6f420 canvas: Scale stroke width based on shape transform 2022-07-19 15:01:17 -07:00
relrelb 23fdc2b2ee chore: Appease clippy 2022-07-19 09:26:46 +03:00
Rafał Dowgird 934cb05371
avm2: implement string.replace(...) with fn, for now regex only. (#7429)
* avm2: implement string.replace(...) with fn, for now regex only.

  * string - added path for replacing regex with fn (replacing string
  with fn is still unimplemented)

  * regex - factored out common replace logic for when replacement is
  a string and when it is a function

  * added tests

* Addressed review comments

* removed tinkering cruft; formatting

* addressed review comments
2022-07-19 08:47:57 +03:00
dependabot[bot] 2ffded778b build(deps): bump symphonia from 0.5.0 to 0.5.1
Bumps [symphonia](https://github.com/pdeljanov/Symphonia) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/pdeljanov/Symphonia/releases)
- [Commits](https://github.com/pdeljanov/Symphonia/compare/v0.5.0...v0.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-19 00:31:17 +03:00
relrelb 0e65617d4a avm2: Small cleanup in `RegExp::effective_replacement`
`char_indicies()` isn't really needed because the position is never
used.
So use the simpler `chars()` method instead.
2022-07-18 10:53:18 +03:00
Adrian Wielgosik 22d2810ef9 avm2: Migrate ContextMenu-related classes to AS 2022-07-17 11:05:37 -07:00
relrelb cad3cd8dbf avm2: Inline `Activation::run_stack_frame_for_script`
This reduces some complexity.
2022-07-15 17:15:14 -05:00
Aaron Hill af4f181856 avm2: Implement support for native methods in `playerglobal`
This commit adds support for marking methods as `native`
in ActionScript classes defined in playerglobal. The
`build_playerglobal` now checks for native methods, and
generates Rust code linking them to a corresponding Rust
function definition in the codebase.

To test this functionality, I've reimplemented several
functions as native methods (and moved related code to
pure ActionScript).
2022-07-15 11:43:49 -05:00
EmperorBale 95809f8a9b avm2: Make escape output for unicode characters, as well as characters that need padding 2022-07-15 15:29:55 +03:00
dowgird cfc9f51c5d avm2: implement $ patterns in regex replace 2022-07-13 15:48:25 -06:00
dependabot[bot] 90ecdfaff5 build(deps): bump serde from 1.0.138 to 1.0.139
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.138 to 1.0.139.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.138...v1.0.139)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-11 23:35:30 +03:00
Rafał Dowgird 80d1a8449a
avm2: implement string.split for regex (#7363)
* avm2: implement string.split for regex

* Compressed the testing for regexp and unwrapping thereof

* * Moved the split logic into the regex object

  * Factored out a method for utf-16 matching

  * Added tests

* formatting

* * replaced manual counting with storage.length()

* clippy cleanup

* Address review comments

  * fix import path for WString
  * remove redundant variable in return statement
  * error passing via '?' instead of unwrap()
2022-07-11 19:47:05 +03:00
relrelb 9856a03797 avm1: Inline `apply_to_display_object` 2022-07-10 07:29:38 +03:00
relrelb 78ebf06f55 avm2: Extract `MethodFlags` enum 2022-07-09 20:34:53 +03:00
relrelb f643048c1c core: Introduce `Request`
Which holds both a URL and what was `RequestOptions` formerly.
2022-07-09 09:43:42 +03:00
relrelb 115f15806e chore: Fix `needless_borrow` clippy lints
Though https://github.com/rust-lang/rust-clippy/pull/8355 has been
merged, it seems to still report false-positives on nightly channel.

For now just fix the instances reported by stable clippy, and keep
`needless_borrow` allowed.
2022-07-08 14:14:30 +03:00
relrelb 2f4e31c6be avm1: Avoid allocation of some static strings
Prefer creating a static `AvmString` over allocating an owned one.
2022-07-06 09:19:12 +03:00
relrelb 9c1a05aaaf avm2: Re-use code in `coerce_to_number`
Use `string_to_f64` and `string_to_int`, as [`MathUtils::convertStringToNumber`](858d034a3b/core/MathUtils.cpp (L453-L466))
in avmplus does.
2022-07-06 09:04:15 +03:00
dependabot[bot] 55e985da8c build(deps): bump serde from 1.0.137 to 1.0.138
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.137 to 1.0.138.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.137...v1.0.138)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-05 08:43:27 +03:00
dependabot[bot] 52bc7a39b4 build(deps): bump smallvec from 1.8.1 to 1.9.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.8.1 to 1.9.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.8.1...v1.9.0)

---
updated-dependencies:
- dependency-name: smallvec
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-04 23:32:26 +03:00
Mike Welsh 1963e47392 avm1: Increment register when preloading super (fix #7338)
The register index was not being increment when preloading the
`super` register which would cause issues when multiple registers
were preloaded.

Fixes #7338.
2022-07-03 12:51:07 -07:00
relrelb f0db6d8c60 avm1: Correct `parseFloat()`
Rewrite the implementation of `string_to_f64()` to match Flash behavior.
This affects `parseFloat()` as well as any `Value` to `f64` coercion.
2022-07-02 18:08:08 -07:00
relrelb 10af9435ae avm2: Minor `parseInt()/parseFloat()` tweaks
Alongside comment wordings, fix handling of non-`u8` characters by
replacing `as u8` conversions with `u8::try_from()`, that doesn't
wrap around, but rather fails gracefully.
2022-07-02 17:48:19 -07:00
relrelb 65be2adc63 wgpu: Bump to `0.13.0`
Based on the work in #6717, plus additional adaptions mentioned in
https://github.com/gfx-rs/wgpu/blob/master/CHANGELOG.md#wgpu-013-2022-06-30,
and more not-mentioned but required changes.

Also bump `wasm-bindgen` to `0.2.81` (along with its helper crates), as
required by the new `wgpu` version.

Note that I don't fully understand some of the required changes, notably:
* `wgpu::PresentMode::Mailbox` no longer works on my machine (Windows 11) -
The `wgpu` documentation says that `wgpu::PresentMode::Fifo` is the
only guaranteed to be supported, so I switched over to it instead.
* `self.staging_belt.recall()` doesn't return a `Future` anymore -
I assume it became synchronous so I simply removed the `executor`
from there.
2022-07-02 16:44:37 -07:00
Toad06 e219cb3b1c avm1: Fire `onData` function and event when calling `loadVariables` 2022-07-02 10:22:48 -07:00
relrelb 981fa0568c chore: `derive(Default)` for enums
It's available since stable Rust 1.62.0.
2022-07-02 09:23:04 -07:00
Aaron Hill b56eace008
avm2: Implement property type coercions
Properties can be declared with a type
(e.g. `var foo:MyClass = new MyClass();`). When
`set_property`/`init_property` is invoked for that property,
the VM will attempt to coerce the value to the provided type,
throwing an error if this fails. This can have observable behavior
consequences - if a property has type `integer`, for example, then
storing a floating point `Number` to that property will cause the
value to be coerced to an integer. Some SWFs (e.g. 'Solarmax') rely
on this behavior in order to implicitly coerce a floating point value
that's later used for array indexing.

This PR implements property type coercions in Ruffle. There are several
important considerations:

* The class lookup for property types needs to be done lazily, since
we can have a cycle between two classes (e.g. `var prop1:Class2;`
and `var prop2:Class1` in two different classes).
* The class lookup uses special rules (different from
  `resolve_definition`), and does *not* use `ScopeStack/`ScopeTree`
This means that a private class can specified as a property name -
the lookup will succeed without using a scope, even though
`flash.utils.getDefinitionByName` would fail with the same name
* The specialized 'Vector' classes (e.g "Vector$int") can be used
as property types, even though they cannot be lookup up normally.

Some Ruffle class definitions were previously using nonexistent
classes as property types (e.g. "BareObject") - these are fixed
in this PR.
2022-06-30 21:34:26 -07:00
Moulins c7bf11ece5 avm1: More accurate handling of preload/suppress flags in functions
- Handle the case where both preload aud suppress flags are
set for the same variable;
- Remove `arguments` field in `Activation`; instead use a normal
local definition;
- When `suppress_this` is set, inherit the `this` value from parent
activation. (This isn't entirely correct, as FP's `this` is mutable
and seems to be part of the scope chain, but this would require a
larger refactoring)
2022-06-29 16:02:13 -07:00
Moulins aa1e53e0e3 avm1: Refactor Executable::exec
- reduce rightwards drift by exiting early
- outline some code into separate methods on Avm1Function
2022-06-29 16:02:13 -07:00
Aaron Hill a79aa08f08
core: Free render backend resources on `BitmapData.dispose`
Currently, all three render backends hold on texture-related
resources indefinitely (`register_bitmap` pushes to a `Vec`,
and never removes anything). As a result, the resources used
by the render backend (which may include GPU memory) will grow
over time, even if the corresponding `BitmapData` has been deallocated.

This commit adds a new `unregister_bitmap` method, which is called from
`BitmapData.dispose`. All render backs are changed to now use an
`FnvHashMap<BitmapHandle, _>` instead of a `Vec`, allowing us to
remove individual entries.

Currently, we only call `unregister_bitmap in response to
`BitmapData.dispose` - when `BitmapData` is freed by the
garbage collector, `unregister_bitmap` is *not* called.
This will be addressed in a future PR.
2022-06-29 15:16:43 -07:00
Adrian Wielgosik 4d1bf7e00c avm2: Refactor AVM2 bare object creation 2022-06-29 15:12:39 -07:00
Adrian Wielgosik f31d4c2498 avm2: Remove SystemPrototypes. 2022-06-29 15:12:39 -07:00
Aaron Hill 1c5312d6c8 avm2: Declare 'dataFormat' property on URLLoader
This ensures that a sealed subclass can still access it.
2022-06-28 09:30:58 +03:00
dependabot[bot] 2fce315938 build(deps): bump gif from 0.11.3 to 0.11.4
Bumps [gif](https://github.com/image-rs/image-gif) from 0.11.3 to 0.11.4.
- [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.3...v0.11.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-28 00:51:23 +03:00
dependabot[bot] c043093f13 build(deps): bump quote from 1.0.19 to 1.0.20
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.19...1.0.20)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-28 00:09:48 +03:00
dependabot[bot] d6171f8a06 build(deps): bump smallvec from 1.8.0 to 1.8.1
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.8.0...v1.8.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-28 00:09:36 +03:00
dependabot[bot] 94e670c7c5 build(deps): bump indexmap from 1.9.0 to 1.9.1
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/bluss/indexmap/compare/1.9.0...1.9.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-28 00:09:12 +03:00
David Wendt 632052f49e core: Manually fire late `added`/`addedToStage` events on AVM2 roots 2022-06-26 19:50:35 -07:00
Aaron Hill 9f1cd4dea8 avm2: Don't try to set MovieClip child with default name
Flash Player only sets children with explicit names.
2022-06-26 19:34:21 -07:00
Aaron Hill 53cdba96d3 avm2: Convert flash.geom.Matrix to ActionScript
I've kept the rust `flash.geom` module, even though it's now empty,
since we'll need to add things like `flash.geom.Transform` native
methods in the future.
2022-06-24 12:34:12 -05:00
relrelb 48e4d80d0a avm2: Implement `flash.net.SharedObjectFlushStatus` 2022-06-24 18:28:33 +03:00
relrelb 13d8565b12 avm2: Implement `flash.net.URLRequestMethod` 2022-06-24 18:28:33 +03:00
relrelb 4e29df5796 avm2: Implement `flash.net.URLRequestHeader` 2022-06-24 18:28:33 +03:00
relrelb 8398dc4ae8 avm2: Port `flash.net.URLLoaderDataFormat` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 781954bd86 avm2: Implement `flash.display.TriangleCulling` 2022-06-24 18:28:33 +03:00
relrelb 32df3b762c avm2: Port `flash.display.StageScaleMode` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 29692b4a49 avm2: Port `flash.display.StageQuality` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 121d17dd94 avm2: Port `flash.display.StageDisplayState` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 1f1c2b91cd avm2: Port `flash.display.StageAlign` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 1a8f6ef6aa avm2: Port `flash.display.SpreadMethod` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 206aee3d28 avm2: Implement `flash.display.ShaderPrecision` 2022-06-24 18:28:33 +03:00
relrelb f51d20ca64 avm2: Implement `flash.display.ShaderParameterType` 2022-06-24 18:28:33 +03:00
relrelb 790880a508 avm2: Port `flash.display.Scene` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 5817c1761b avm2: Stub `Array` in ActionScript 2022-06-24 18:28:33 +03:00
relrelb 3745ab57db avm2: Port `flash.display.SWFVersion` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 14830adb54 avm2: Port `flash.display.PixelSnapping` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb d6e1b8bbc1 avm2: Implement `flash.display.PNGEncoderOptions` 2022-06-24 18:28:33 +03:00
relrelb f0a8ba9b87 avm2: Port `flash.display.LineScaleMode` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 8b8b320064 avm2: Port `flash.display.JointStyle` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb e5806bb3d4 avm2: Implement `flash.display.JPEGXREncoderOptions` 2022-06-24 18:28:33 +03:00
relrelb 53401cc51d avm2: Implement `flash.display.JPEGEncoderOptions` 2022-06-24 18:28:33 +03:00
relrelb 6779e406ce avm2: Port `flash.display.InterpolationMethod` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 7c992b4664 avm2: Implement `flash.display.GraphicsPathWinding` 2022-06-24 18:28:33 +03:00
relrelb 3655e85f6c avm2: Implement `flash.display.GraphicsPathCommand` 2022-06-24 18:28:33 +03:00
relrelb 033d4ba6ad avm2: Stub `int` in ActionScript 2022-06-24 18:28:33 +03:00
relrelb ad4b06917b avm2: Port `flash.display.GradientType` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb a119bfa102 avm2: Implement `flash.display.FocusDirection` 2022-06-24 18:28:33 +03:00
relrelb 3165e942d8 avm2: Implement `flash.display.ColorCorrectionSupport` 2022-06-24 18:28:33 +03:00
relrelb c7a391ec36 avm2: Implement `flash.display.ColorCorrection` 2022-06-24 18:28:33 +03:00
relrelb 1ad020566e avm2: Port `flash.display.CapsStyle` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 0081b03c6e avm2: Implement `flash.display.BlendMode` 2022-06-24 18:28:33 +03:00
relrelb 23e5b3f0bb avm2: Implement `flash.display.BitmapEncodingColorSpace` 2022-06-24 18:28:33 +03:00
relrelb c7664206b3 avm2: Implement `flash.display.BitmapDataChannel` 2022-06-24 18:28:33 +03:00
relrelb 761d746c38 avm2: Port `flash.display.ActionScriptVersion` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb c6e04dfd2a avm2: Implement `flash.text.TextLineMetrics` 2022-06-24 18:28:33 +03:00
relrelb 546662a4f7 avm2: Implement `flash.text.TextInteractionMode` 2022-06-24 18:28:33 +03:00
relrelb d24c03349e avm2: Port `flash.text.TextFormatAlign` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 6108be135e avm2: Port `flash.text.TextFieldType` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 976cf2da39 avm2: Port `flash.text.TextFieldAutoSize` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 11f6e4abfb avm2: Implement `flash.text.TextExtent` 2022-06-24 18:28:33 +03:00
relrelb dcfe158f6c avm2: Implement `flash.text.TextDisplayMode` 2022-06-24 18:28:33 +03:00
relrelb 613bd8924a avm2: Implement `flash.text.TextColorType` 2022-06-24 18:28:33 +03:00
relrelb 8d024f2140 avm2: Implement `flash.text.GridFitType` 2022-06-24 18:28:33 +03:00
relrelb d1a22cf083 avm2: Implement `flash.text.FontType` 2022-06-24 18:28:33 +03:00
relrelb 45aff8f7ef avm2: Implement `flash.text.FontStyle` 2022-06-24 18:28:33 +03:00