Commit Graph

6930 Commits

Author SHA1 Message Date
EmperorBale d79c68bbcd core: Implement AvmString::new_utf8_bytes_lossy 2022-07-25 10:52:56 -07:00
TÖRÖK Attila aae862e108 chore: Run `cargo update` 2022-07-25 10:52:37 -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 afb9ecc4ab webgl: Avoid zeroing `renderbuffer_{width,height}`
This basically reverts #5737 and #6458 for the WebGL backend, which
regressed a bug where setting the style `display: none;` to a Ruffle
player logged many WebGL warnings to the console. This happened
because `renderbuffer_width` and `renderbuffer_height` were set to zero,
leading to problems when trying to pass them to WebGL APIs.

Avoid such situation by ensuring that `renderbuffer_width` and
`renderbuffer_height` are at least `1`, exactly as done before.
Also add a comment that explains why `.clamp()` isn't used.

Fixes #1264.
2022-07-24 23:37:54 +03: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 1accf2d8f9 web: Make `SourceAPI` a singleton
As a first step towards a simpler Web API, convert `SourceAPI` from
a class to a constant object, under the assumption that `SourceAPI`
isn't a public Ruffle API and as such is safe to be changed.

As a result the different `ruffle-core` users don't need to construct
a new `SourceAPI` instance before calling `PublicAPI.negotiate()`.
2022-07-23 10:37:33 -07: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
relrelb e78bf30d58 swf: Extract `Color` to a separate file 2022-07-23 08:43:02 +03: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
nosamu 01c8c38762 web: Hide loading screen when root movie download fails 2022-07-20 19:55:12 +03:00
dependabot[bot] 7336e7cbf7 build(deps): bump terser from 5.10.0 to 5.14.2 in /web
Bumps [terser](https://github.com/terser/terser) from 5.10.0 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-19 20:06:20 -07:00
Mike Welsh 6f142c21fa canvas: Fix transforming of gradient/bitmap strokes 2022-07-19 15:01:17 -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
Daniel Jacobs 56adcc5665
web: Add a loading screen (#7396)
* web: Add a loading screen

* web: Workaround sometimes overwitten remove method

* web: Completely remove exact px values from preloader

* web: Add meaningless loading animation to preloader

* web: Make preloader position relative

* web: Minor preloader CSS changes

* web: Don't change autoplay/unmuteOverlay showing logic

* demo: Use preloader-background for demo

* web: Don't fully remove preloader

* web: Hide preloader loading bar if there's no content-length

* web: Fix typo in load-ruffle

* web: Show/hide playButton and unmuteOverlay based on preloader state

* web: Address preloader feedback

* web: Revert ESLint change

* web: Remove unneeded optional chaining

* web: Change load option from hasPreloader to preloader

* web: Address some preloader feedback

* web: Change margin-bottom for preloader loading anim

* web: Simplify preloader conditional

* web: Show/hide full container when hiding/showing preloader

* web: Make preloader full-size
2022-07-19 22:20:53 +03: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 41bfc028d2 tests: Add test for special unicode characters and characters that need padding 2022-07-15 15:29:55 +03: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
nosamu 245b55a832 chore: Fix lint 2022-07-13 20:36:52 -07:00
nosamu 7c55a14c36 demo: Update swfs.json example 2022-07-13 20:36:52 -07:00
nosamu 320f84dc88 demo: Improve Sample SWF dropdown 2022-07-13 20:36:52 -07:00
dowgird cfc9f51c5d avm2: implement $ patterns in regex replace 2022-07-13 15:48:25 -06:00
relrelb 13a0eb3d92 scanner: Fix `path-slash` update
As mentioned in the [CHANGELOG.md](https://github.com/rhysd/path-slash/blob/master/CHANGELOG.md#v020---05-jul-2022),
`to_slash_lossy` now returns `Cow<'_, str>` instead of `String`.
2022-07-12 00:24:50 +03:00
dependabot[bot] c3a8d11e39 build(deps): bump path-slash from 0.1.5 to 0.2.0
Bumps [path-slash](https://github.com/rhysd/path-slash) from 0.1.5 to 0.2.0.
- [Release notes](https://github.com/rhysd/path-slash/releases)
- [Changelog](https://github.com/rhysd/path-slash/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rhysd/path-slash/compare/v0.1.5...v0.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-12 00:24:50 +03:00
dependabot[bot] 80dd295748 build(deps): bump lyon from 0.17.10 to 1.0.0
Bumps [lyon](https://github.com/nical/lyon) from 0.17.10 to 1.0.0.
- [Release notes](https://github.com/nical/lyon/releases)
- [Changelog](https://github.com/nical/lyon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nical/lyon/commits)

---
updated-dependencies:
- dependency-name: lyon
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-11 23:36:39 +03: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
nosamu a31dd2e101 Revert "web: Add a loading screen"
This reverts commit bec0710175.
2022-07-11 19:05:52 +02:00
nosamu 47d9c5220a Revert "web: Workaround sometimes overwitten remove method"
This reverts commit ed4f0b98b2.
2022-07-11 19:05:52 +02:00
nosamu 478c69f846 Revert "web: Completely remove exact px values from preloader"
This reverts commit 2c067fe5dd.
2022-07-11 19:05:52 +02:00
nosamu d79e45e49e Revert "web: Add meaningless loading animation to preloader"
This reverts commit c48ca2874b.
2022-07-11 19:05:52 +02:00
nosamu 7c522f2d66 Revert "web: Make preloader position relative"
This reverts commit ded77ab46a.
2022-07-11 19:05:52 +02: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
Daniel Jacobs ded77ab46a web: Make preloader position relative 2022-07-10 13:30:42 -07:00
Daniel Jacobs c48ca2874b web: Add meaningless loading animation to preloader 2022-07-10 13:30:42 -07:00
Daniel Jacobs 2c067fe5dd web: Completely remove exact px values from preloader 2022-07-10 13:30:42 -07:00
Daniel Jacobs ed4f0b98b2 web: Workaround sometimes overwitten remove method 2022-07-10 13:30:42 -07:00
Daniel Jacobs bec0710175 web: Add a loading screen 2022-07-10 13:30:42 -07: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