Commit Graph

4050 Commits

Author SHA1 Message Date
TÖRÖK Attila 81749f900b avm2: Implement GradientType, InterpolationMethod, SpreadMethod in flash.display 2022-05-19 23:47:55 +02:00
Mike Welsh de99dcd37b core: Add `BitmapFormat::bytes_per_pixel` 2022-05-19 10:43:54 -07:00
Mike Welsh 48f7ff5f4d core: Add `Bitmap::to_rgba` 2022-05-19 10:43:54 -07:00
Mike Welsh e710f3fa0e core: Clean up `render::Bitmap`
* Make `BitmapFormat` a fieldless enum and move `data` to its own
   field for ease of use.
 * Make `Bitmap` fields private.
2022-05-19 10:43:54 -07:00
Mike Welsh 6615ed17f9 core: Verify bitmap length after decoding
Guarantee bitmap data after decoding has the expected length for
the given width+height+format. This eases the burden from backends
to worry about this. Pad or truncate the data if it doesn't have
the expected size.
2022-05-19 10:43:54 -07:00
Mike Welsh b88e77573d core: Handle greyscale PNGs
`render::decode_png` now handles greyscale or greyscale+alpha PNGs.
2022-05-19 10:43:54 -07:00
Toad06 b50f1201e1 avm1: `action_enumerate` can handle paths 2022-05-18 19:30:48 -07:00
dependabot[bot] 4dc9fd7adf build(deps): bump syn from 1.0.94 to 1.0.95
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.94 to 1.0.95.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.94...1.0.95)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-16 17:45:21 -07:00
David Wendt 1809ca611b avm2: Make dispatch list initialization lazy, so that it can run before constructors if necessary.
Due to various quirks of how timeline-initiated symbols interact with AVM2, it is possible for user code to gain a reference to uninitialized objects (especially `SimpleButton` which doesn't initialize until after `exitFrame`). It is still possible to attach event handlers to them that fire correctly, and movies expect to be able to.
2022-05-16 17:13:35 -07:00
dependabot[bot] fc4cd11959 build(deps): bump syn from 1.0.92 to 1.0.94
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.92 to 1.0.94.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.92...1.0.94)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-16 13:54:32 -07:00
Mike Welsh d1b65d9092 avm1: Pass ExecutionReason to `Object::call_method`
Internal function calls such as `toString` and event handlers
always used the base clip from the function itself, so add an
`ExecutionReason::InternalCall` to signify this and pass it along
to `call_method`.
2022-05-14 22:29:44 -07:00
Mike Welsh 4904b2cc97 avm1: Fix scope of function calls in SWFv5 vs. SWFv6+
Fix various scope behavior when executing a function:

 * For function calls in SWFv6+, functions are proper closures and
   close over the SWF version, base clip, and scope of their
   defining function.
 * Function calls in SWFv5 are not closures, and use the version,
   base clip, and scope of `this` when the function is called.

Fixes #5502.
2022-05-14 22:29:44 -07:00
Aaron Hill a453aa73af avm2: Don't consider declared return type for unchecked functions check
Testing under Flash shows that methods can be considered 'unchecked'
(allowing them to be called with more arguments than declared
parameters) even if they have a declared return type.

This is relied on by SteamBirds, which registers an event handler
which takes 0 parameters and an explicitly declared return type
2022-05-13 09:32:05 -07:00
Aaron Hill 8ff720dd9d
avm1: Allow new `unused_macro_rules` lint on `declare_properties`
This was recently added in https://github.com/rust-lang/rust/pull/96150
Some of the `__version` rules are currently unused, but I assume
that we still want to keep them for potential future use.
2022-05-13 09:31:46 -07:00
relrelb cab49ae6e1 swf: Introduce `Color::WHITE`
And use it where possible, to improve code readablity.
2022-05-12 12:12:06 -07:00
relrelb 0b0f8a1a7a swf: Introduce `Color::BLACK`
And use it where possible, to improve code readablity.
2022-05-12 12:12:06 -07:00
Aaron Hill 938d80146c avm2: Implement `TextField.background` getter/setter
There's already a `has_background` field on the underlying object
data, so we can just map this property to it.
2022-05-11 15:42:19 -07:00
Aaron Hill e39cfa8027 Define `String.fromCharCode` as both a public and AS3 method
This is relied on by SteamBirds
(https://www.kongregate.com/games/weasello/steambirds)
2022-05-11 15:42:19 -07:00
Mike Welsh f550abd18d web: Fix some warnings
Fix warnings caused by desktop-only code.
2022-05-09 22:28:43 -07:00
Mike Welsh 6547fcdf99 avm1: Remove `avm1::globals::display_object` module
This module is now mostly empty, so move the items up to `globals`.
`getDepth` was the only shared method, so declare this property
inline in each display object type. `Video` was also incorrectly
declaring `getDepth`.
2022-05-09 17:39:49 -07:00
Mike Welsh a97ae38008 avm1: Remove `toString` from display objects
`MovieClip` and others do not have a `toString`; instead, stage
objects are special cased to return their path when coerced to
string.
2022-05-09 17:39:49 -07:00
Mike Welsh 35d2f69396 avm1: Improve `StageObject::get_local_stored`
* Avoid an extraneous check to `ScriptObject::has_own_property`.
 * Avoid magic property branches if property name does not start
   with `_`.
2022-05-09 17:39:49 -07:00
Mike Welsh 2683686014 avm1: `_root`, `_parent`, `_global` are magic properties (fix #768)
Remove `_root`, `_parent` and `_global` from `MovieClip.prototype`.
Instead, these are "magic" properties similar to `_x` and `_y`.
Add `StageObject::resolve_path_property` to handle these, alongside
the `_levelN` property.

Fixes #768.
2022-05-09 17:39:49 -07:00
relrelb 781d091d42 swf: Return concrete data types in `Reader` methods
Where possible, return the specific data type instead of the generic
`Tag` type. Most reader methods do this already, so this brings the
rest in-line.
2022-05-09 14:59:38 -07:00
dependabot[bot] 7352aca3bc build(deps): bump jpeg-decoder from 0.2.5 to 0.2.6
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.5 to 0.2.6.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/compare/v0.2.5...v0.2.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 13:46:12 -07:00
relrelb bce4075c69 core: Remove `url_from_relative_path`
The remaining caller was `SwfMovie::from_path`, which is now changed
to be simpler, and a little stricter (panics if `Url::from_file_path`
fails, though it shouldn't happen with canonicalized paths).
2022-05-09 10:06:52 -07:00
nosamu f39537f984 docs: Correct issue number in code comment 2022-05-08 14:27:15 +03:00
relrelb b46134dc43 avm1: Tiny cleanup in `Activation::set_target`
Use `Option::filter`.
2022-05-07 22:46:35 -07:00
Mike Welsh f20f53f555 avm1: Grab SWF version from executing clip
Remove the `swf_version` parameter from `Activation` constructors,
because this was incorrectly using the global or root SWF version
most times.

Instead, grab the SWF version for the activation directly from the
base clip.
2022-05-07 10:25:10 -07:00
Mike Welsh 1e9c464d94 avm1: Add version to MovieClip properties 2022-05-07 10:25:10 -07:00
Mike Welsh 4fa4c6ca84 avm1: Implement property version checking
Check SWF version of AVM1 properties and return undefined if they
are gated to a later version.
2022-05-07 10:25:10 -07:00
Mike Welsh e6cadf7de4 avm1: Use u16 for Property::attributes 2022-05-07 10:25:10 -07:00
relrelb 401f423ffa xml: Remove `XmlAttributesObject`
Use a bare `ScriptObject` instead. This matches Flash's behavior in
many aspects:
* Attribute values can now store arbitrary AVM1 values, rather than
just strings. These are coerced to string lazily on demand (e.g.
when coercing the whole XML node to a string).
* Attributes iteration order is the same as their definition order,
not sorted by their name.

Also fix some bugs in `XmlNode::lookup_namespace_uri` (renamed from
`lookup_uri_for_namespace`):
* Iterate attributes by their definition order, so the first matching
one is returned.
* The empty prefix matches every attribute that starts with "xmlns"
(with/without a colon).

And inline `XmlNode::lookup_namespace_for_uri` into `get_prefix_for_namespace`,
and fix some bugs in there as well:
* Iterate attributes by their definition order, so the first matching
one is returned.
* Match any attribute that start with "xmlns" (with/without a colon).
2022-05-07 10:24:45 -07:00
Mike Welsh 5730c8db94 core: Clamp color values in DefineBitsJPEG3 (fix #6893)
The colors in a DefineBitsJPEG3 tag should be premultiplied alpha,
but in some SWFs they are incorrectly not premultiplied. Flash
Player clamps the color values to the alpha in this case to allow
these images to work more as expected.

Fixes #6893.
2022-05-07 09:46:44 -07:00
relrelb 87ce0f56b7 core: Remove `NavigatorBackend::resolve_relative_url`
The resolved URL only used by `NavigatorBackend::fetch`. So simply
inline `NavigatorBackend::resolve_relative_url` into `NavigatorBackend::fetch`,
per implementation.
2022-05-07 09:06:53 -07:00
relrelb ea665d91f2 core: Introduce and use `Response::url` 2022-05-07 09:06:53 -07:00
relrelb 2517d8de4b core: Introduce struct `Response`
Currently it's a trivial wrapper around `Vec<u8>`, but more fields
will be added in the future (e.g. response URL, HTTP status code).
2022-05-07 09:06:53 -07:00
Mike Welsh 82ed6fcba7 core: Cleanup PlaceObject comments 2022-05-06 11:33:52 -07:00
Mike Welsh 0833bd0d18 core: Clip events can only be set on initial placement 2022-05-06 11:33:52 -07:00
Mike Welsh 8bf0114fdf core: DisplayObject clip depth can only be set on initial placement 2022-05-06 11:33:52 -07:00
Mike Welsh 32252b2ed4 core: DisplayObject name can only be set on initial placement 2022-05-06 11:33:52 -07:00
Mike Welsh aa66c31d6c core: Add comment about rewind behavior of is_visible 2022-05-06 11:33:52 -07:00
Mike Welsh b46c07830e core: Stub DisplayObject::background_color 2022-05-06 11:33:52 -07:00
Mike Welsh f8698d1cc9 core: Stub DisplayObject::blend_mode 2022-05-06 11:33:52 -07:00
Mike Welsh 2cebd47ad2 core: Stub DisplayObject:is_bitmap_cached 2022-05-06 11:33:52 -07:00
relrelb f6153ff7c1 chore: Appease clippy 2022-05-06 10:36:38 -07:00
relrelb d1d6b56615 avm1: Remove a stale TODO
Forgotten in #6785.
2022-05-03 10:22:43 -07:00
relrelb beee6cb067 avm1: Correct and cleanup `Array.sort` and `Array.sortOn`
* Mimic Flash's quicksort algorithm, rather than using Rust's
`sort_unstable_by`.
* Rename `flags` to `options`, as they are named in AS2 reference.
* Organize different sorting options using 3 simple functions:
`sort_compare`, `sort_compare_custom` and `sort_on_compare`.
2022-05-03 09:47:38 -07:00
dependabot[bot] fcc199b0e5 build(deps): bump jpeg-decoder from 0.2.4 to 0.2.5
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.4 to 0.2.5.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/compare/v0.2.4...v0.2.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 14:48:42 -07:00
dependabot[bot] e68f88d37e build(deps): bump syn from 1.0.91 to 1.0.92
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.91 to 1.0.92.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.91...1.0.92)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 14:48:25 -07:00
dependabot[bot] 86e3f6c82a build(deps): bump serde from 1.0.136 to 1.0.137
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.136 to 1.0.137.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.136...v1.0.137)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 13:41:28 -07:00
Adrian Wielgosik b2f309fc35 avm1: Implement LocalConnection.domain() 2022-04-30 16:14:16 -07:00
relrelb babf49aaf9 chore: `.filter_map(..).next()` -> `.find_map(..)`
Per the rust-analyzer diagnostic: https://rust-analyzer.github.io/manual.html#replace-filter-map-next-with-find-map
2022-04-30 10:41:46 -07:00
Mike Welsh 1eb06908c8 core: Make PlayerBuilder::build infallible 2022-04-29 09:14:32 -07:00
Mike Welsh 3e15ca4cad core: Use `Arc::new_cyclic` in player initialization
Co-authored-by: relrelb <relrelbachar@gmail.com>

Change `UpdateContext::player` to not be an `Option`
2022-04-29 09:14:32 -07:00
Mike Welsh ddc28310f8 core: Clean up test_utils 2022-04-29 09:14:32 -07:00
Mike Welsh f48182ef3d core: Add various settings to PlayerBuilder 2022-04-29 09:14:32 -07:00
Mike Welsh 895508a0fb core: Remove Player::new
PlayerBuilder is effectively the Player constructor.
2022-04-29 09:14:32 -07:00
Mike Welsh e1e2b1008a core: Add PlayerBuilder 2022-04-29 09:14:32 -07:00
Mike Welsh 2453626dec core: Add MemoryStorageBackend::new 2022-04-29 09:14:32 -07:00
David Wendt 155672d482 core: Remove AS3-related `coerce_to_object` calls in `MovieClip` 2022-04-24 16:54:19 -07:00
David Wendt fe50e98f87 avm2: Remove `coerce_to_object` calls in `flash.text.TextField` 2022-04-24 16:54:19 -07:00
David Wendt afdae1f6c6 avm2: Remove `coerce_to_object` calls in `flash.media.Sound` 2022-04-24 16:54:19 -07:00
David Wendt 818526069e avm2: Remove `coerce_to_object` calls in `flash.events.MouseEvent` 2022-04-24 16:54:19 -07:00
David Wendt 5dc5ca06e3 avm2: Remove `coerce_to_object` calls in `flash.events.EventDispatcher` 2022-04-24 16:54:19 -07:00
David Wendt 4c736094c1 avm2: Remove `coerce_to_object` calls in `flash.display.Stage` 2022-04-24 16:54:19 -07:00
David Wendt cbc9937fcf avm2: Remove `coerce_to_object` calls in `flash.display.SimpleButton` 2022-04-24 16:54:19 -07:00
David Wendt 40ecae28d0 avm2: Remove `coerce_to_object` in `flash.display.MovieClip` 2022-04-24 16:54:19 -07:00
David Wendt 85b598a8da avm2: Remove `coerce_to_object` calls in `flash.display.DisplayObjectContainer` 2022-04-24 16:54:19 -07:00
David Wendt 7e7ee14d3b avm2: Remove `coerce_to_object` calls in `flash.display.DisplayObject`. 2022-04-24 16:54:19 -07:00
David Wendt 5f5f98ecdc avm2: Remove `coerce_to_object` calls in `flash.display.Bitmap` 2022-04-24 16:54:19 -07:00
David Wendt 5b5313bf95 avm2: Remove `coerce_to_object` calls in `String` impls 2022-04-24 16:54:19 -07:00
David Wendt e851b73570 avm2: Remove calls to `coerce_to_object` in `JSON` impls 2022-04-24 16:54:19 -07:00
David Wendt 88f4ebc2a3 avm2: Remove calls to `coerce_to_object` in `Function` impls 2022-04-24 16:54:19 -07:00
David Wendt 26e65368df avm2: Remove `coerce_to_object` calls in `Array` where possible, and replace with more descriptive error messages otherwise 2022-04-24 16:54:19 -07:00
David Wendt 1383901a94 avm2: Remove unnecessary usage of `coerce_to_object` in `avm2::globals`. 2022-04-24 16:54:19 -07:00
David Wendt 90b239f30d avm2: Add descriptive error messages for when `Vector` methods encounter `null`/`undefined`. 2022-04-24 16:54:19 -07:00
David Wendt e486efb4c6 avm2: Remove unnecessary usage of `coerce_to_object` in `ClassObject`. 2022-04-24 16:54:19 -07:00
David Wendt 0f2b77c138 avm2: Alter basic object operations to use more descriptive error messages. 2022-04-24 16:54:19 -07:00
David Wendt 4185acc5a8 avm2: Remove unnecessary usage of `coerce_to_object` in `avm2::events`. 2022-04-24 16:54:19 -07:00
David Wendt bb70086238 avm2: Replace a number of `coerce_to_object` calls with the previous commits' new messages as appropriate 2022-04-24 16:54:19 -07:00
David Wendt bea6744682 avm2: Add methods to `Value` and `Activation` for performing common coercions and returning a relevant error if they fail.
Those methods are:

 * `Value.coerce_to_receiver`: coerce to object for receivers
 * `Value.as_callable`: as_object for callables
 * `Activation.superclass_object`: get superclass of currently-called object
 * `Activation.resolve_class`: resolve scope value, unwrap `ClassObject`, and error out if either step fails

This accounts for ~80% of coercion-related errors in `Activation`.
2022-04-24 16:54:19 -07:00
David Wendt 2ec606c5cb avm2: Add utilities for formatting `Multiname`s and class instances' names. 2022-04-24 16:54:19 -07:00
relrelb 3dbde841df avm1: Remove `TObject::type_of`
It can be simply determined in `Value::type_of`.
2022-04-23 17:55:48 -07:00
Daniel Jacobs aa92c3c1bc core: scale_mode -> window_mode for set_window_mode 2022-04-22 19:31:23 +03:00
Mike Welsh e2e7ad0df2 avm2: Implement `flash.ui.Keyboard`
Add `Keyboard` key code constants and stub out other properties.
2022-04-21 21:40:04 -07:00
Mike Welsh 1cb3d389e8 core: Add some KeyCode variants 2022-04-21 21:40:04 -07:00
TÖRÖK Attila 7cbba5bc8f avm2: Stub flash.accessibility.AccessibilityProperties 2022-04-19 09:55:09 -07:00
relrelb 25d47da528 render: Improve CMYK to RGB conversion
Use integer arithmetic, which is more accurate and efficient.
2022-04-18 22:00:48 -07:00
Mike Welsh cdccc2a2db avm1: Array.sortOn does not inspect proto or virtual properties
`Array.sortOn` only looks at raw properties and does not inspect
the prototype chain or call virtual properties.
2022-04-18 08:34:04 -07:00
Mike Welsh 3305ac69c4 web: Support wmode parameter 2022-04-17 08:33:51 -07:00
relrelb 87e85e16da render: Make `rgb5_component` a lambda
This way the `compressed` parameter becomes implicit.
2022-04-16 13:52:59 -07:00
relrelb 8feeadf578 render: Use `std::borrow::Cow`
Also apply some nearby refactors.
2022-04-16 13:52:59 -07:00
relrelb eeaec947b3 render: Remove unneeded `pub`s
And remove the dead `glue_swf_jpeg_to_tables` function.
2022-04-16 13:52:59 -07:00
relrelb 9b4108444f render: Strip 16-bit PNG samples to 8-bit
PNGs with 16-bit samples were not being normalized to 8-bit, screwing up their
appearance.

Add the `STRIP_16` transformation using `Transformations::normalize_to_color8()`,
which is equivalent to `Transformations::EXPAND | Transformations::STRIP_16`.
Also warn in case `png` outputs a color type other than `Rgb` and `Rgba`.
Due to the `EXPAND` transformation, this may be only `Grayscale` or
`GrayscaleAlpha`. `Indexed` is converted to either `Rgb` or `Rgba`.

Fixes #6662.
2022-04-16 12:45:55 -07:00
Mike Welsh bce9398c0d avm1: Add Accessibility stub 2022-04-16 09:05:16 -07:00
Toad06 b2b1b5fa25 avm1: Correct `Add`, `Equals`, `Less` and `GetProperty` actions 2022-04-13 22:00:25 -07:00
Mike Welsh 146b8adc68 swf: Clean up LineStyle
* Remove LineStyle::color, instead using fill_style with
   FillStyle::Color to indicate solid color.
 * Store `flags` in the struct instead of separate bools/values.
 * Add getters/setters for ease of use.
 * Add builder-style methods for setting LineStyle properties.
 * Fix misnamed ALLOW_CLOSE flag to NO_CLOSE.
2022-04-11 22:50:40 -07:00
Mike Welsh c0dff98d84 chore: Fix len_zero warning in symphonia Mp3Decoder 2022-04-11 20:15:13 -07:00
Mike Welsh 24f00238a7 audio: Fix symphonia feature
This feature stopped building with the bump to symphonia 0.5, which
added a `Sync` bound to its traits.

 * Add `Sync` bounds to our own internal audio traits to match.
 * nellymoser::Decoder was also tweaked to add a Sync bound.
 * Lock the nellymoser dependency to a specific git commit.
2022-04-11 15:25:15 -07:00
dependabot[bot] a5f7fccca2 build(deps): bump quote from 1.0.17 to 1.0.18
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.17 to 1.0.18.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.17...1.0.18)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 13:51:20 -07:00
dependabot[bot] 5973ecc7d9 build(deps): bump flate2 from 1.0.22 to 1.0.23
Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases)
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.22...1.0.23)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 13:51:09 -07:00
Toad06 c6c1f553d5 avm1: Correct `Action::RandomNumber` 2022-04-11 11:02:08 -07:00
Toad06 e2528b04a7 avm1: Coerce booleans to `"1"` or `"0"` in SWFv4 2022-04-10 20:03:39 -07:00
Toad06 b221485288 avm1: Fix `Action::Divide` in SWFv4 2022-04-09 23:17:39 -07:00
Mike Welsh 91346f5fad avm1: Format floating-point numbers
Co-authored-by: Toad06 <gd.productions@laposte.net>
2022-04-09 22:40:59 -07:00
Mike Welsh 478f970fc8 chore: Appease clippy 2022-04-09 18:23:51 -07:00
Aaron Hill d7532ae654 avm2: Add stubs for `BitmapFilter`, `GlowFilter`, and `DisplayObject.filters`
This gets 'Rolling Hero' further in the startup process,
since it just tries to set a filter on an object.
2022-04-08 16:53:16 -07:00
relrelb ad42b9908f xml: Refactor `XmlNode` creation methods
Unify the previous 3 creation methods to a single `XmlNode::new`.
This allows supporting arbitrary `nodeType` values passed to the
`XMLNode` constructor.
2022-04-08 16:34:57 -07:00
relrelb 7497fb7008 core: Change `Player::set_root_movie` to accept a `SwfMovie`
Move the `Arc::new` to within the function.
2022-04-08 15:16:25 -07:00
Toad06 12737b8431 avm1: Fix `Number(String | Object)` in SWFv4 2022-04-08 10:41:21 -07:00
dependabot[bot] 1339d8b93a build(deps): bump syn from 1.0.90 to 1.0.91
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.90 to 1.0.91.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.90...1.0.91)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-08 10:40:43 -07:00
dependabot[bot] 860c2e313f build(deps): bump encoding_rs from 0.8.30 to 0.8.31
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.30 to 0.8.31.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.30...v0.8.31)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-08 10:40:26 -07:00
relrelb eeb5eb18f6 web: Bump wasm-bindgen to 0.2.80
As usual, also bump its helper crates (`js-sys`, `web-sys` and
`wasm-bindgen-futures`) to the latest versions.
2022-04-08 09:56:23 -07:00
dependabot[bot] e456fb3ed6 build(deps): bump jpeg-decoder from 0.2.3 to 0.2.4
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.3 to 0.2.4.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/compare/v0.2.3...v0.2.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 14:42:32 -07:00
Mike Welsh 6ec3049e02 desktop: Use floats for audio start/endpoints calculation (fix #6569)
Integer math was used when calculating a sound's start/endpoints,
because it was assumed that the sound sample rate was always an
even divisor of 44100Hz. However, some third party tools can embed
MP3s with other samples rates, such as #6569 which has a 16000Hz
MP3. This could also occur for dynamically loaded MP3s. This
results in the sound starting at an incorrect position.

Use floating point math to ensure the correct position is
caluclated.

Fixes #6569.
2022-04-03 15:50:43 -07:00
Mike Welsh 9687365885 core: Remove morph shape preloading
Remove the preload step that would pre-create the shapes for each
morph shape ratio on SWF load. Instead, lazily crate the shapes
when they are needed.
2022-04-03 13:50:09 -07:00
Mike Welsh b1879f4b99 core: Fix divide-by-zero in Video::seek (fix #6605) 2022-04-03 11:33:52 -07:00
Toad06 055e1d4dc1 avm1: Fix `loadVariablesNum` / `Action::GetUrl2` 2022-04-03 10:32:31 -07:00
Toad06 e93d39fdfe avm1: `DefineLocal` also accepts dot and slash paths 2022-04-02 14:30:56 -07:00
relrelb c8e7bdbce2 core: Fix loading of unknown data
Loading unknown data is not considered an error on Flash; Both
`onLoadProgress` and `onLoadComplete` events are dispatched. But,
`onLoadProgress` reports 0 bytes loaded.
2022-04-02 12:50:43 -07:00
relrelb e06506c2b9 render: Implement `CMYK32` jpeg pixel format 2022-04-02 01:17:38 +03:00
Aaron Hill 4f23500779 avm2: Implement most of `flash.external.ExternalInterface`
This re-uses the logic we have for handling AVM1's `ExternalInterface`.
For now, serialization/deserialization of non-array objects is
left unimplemented.
2022-03-31 22:40:09 -07:00
Mike Welsh 659db7facc avm1: Add2 calls valueOf for objects 2022-03-31 16:57:07 -07:00
Adrian Wielgosik a929a4becd avm2: Do not borrow Object's lock just to get the bound method 2022-03-31 16:56:55 -07:00
Adrian Wielgosik 7e8738d82e avm2: Add ContextMenuEvent stub 2022-03-30 21:42:48 +02:00
Adrian Wielgosik ef64413b8c avm2: Support ContextMenuItem fields 2022-03-30 21:42:48 +02:00
Adrian Wielgosik ea56902d80 chore: cargo fmt 2022-03-30 21:42:48 +02:00
Adrian Wielgosik 90b1d4722c avm2: Add ContextMenuItem stub 2022-03-30 21:42:48 +02:00
Adrian Wielgosik 2389422c99 avm2: Add ioErrorEvent stub 2022-03-30 21:42:48 +02:00
Adrian Wielgosik 388dc6fe31 avm2: Add customItems to ContextMenu stub 2022-03-30 21:42:48 +02:00
Mike Welsh d920dfa9b0 core: Add padding on autosized TextFields 2022-03-29 22:22:32 -07:00
Mike Welsh a671d2977b core: Pre-multiply alpha when loading PNG/GIF data (fix #6559)
When decoding PNG/GIF data, convert the image to premultiplied
alpha so that it plays nicely with the renderer.

This applies to both dynamically loaded images and to PNG/GIF data
embedded inside a DefineBitsJPEG tag. This is in contrast to
DefineBitsLossless and DefineBitsJPEG tags w/ alpha, which are
already premultiplied in the SWF.

Also remove unnecessary clamps now that Rust defines casts as
saturating.

Fixes #6559.
2022-03-29 13:41:04 -07:00
Mike Welsh 9c50770c1c avm1: Return Value from `abstract_lt`
All callers converted the result to `Value` anyway.
2022-03-28 19:07:12 -07:00
Mike Welsh 98ea2f81b6 avm1: {} < {} returns false
The Less2 op returns false if the `valueOf` of either parameter
results in an object. The exception is display objects:
`mc < mc` returns undefined.
2022-03-28 19:07:12 -07:00
dependabot[bot] fcb5eaec0e build(deps): bump syn from 1.0.89 to 1.0.90
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.89 to 1.0.90.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.89...1.0.90)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 00:09:22 +03:00
dependabot[bot] bf57d2c15a build(deps): bump jpeg-decoder from 0.2.2 to 0.2.3
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.2 to 0.2.3.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/compare/v0.2.2...v0.2.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 00:09:01 +03:00
David Wendt b9da107339 core: Refactor `MovieClipLoader` broadcast messages into separate `Loader` associated functions.
These are *not* methods, because we cannot borrow both the update context and the loader at the same time. At least not without making loaders free-standing objects (`GcCell`s), which I don't want to do yet.
2022-03-27 18:55:38 -07:00
David Wendt ac7bb84e08 core: Report unexpected content type errors better. 2022-03-27 18:55:38 -07:00
David Wendt 27697c6611 chore: No, loading an image does not replace the clip with a bitmap. 2022-03-27 18:55:38 -07:00
David Wendt e1d18be7fa core: First pass at image loading through `loadMovie` et all 2022-03-27 18:55:38 -07:00
Toad06 4ad0253076 avm1: `String(function)` returns `[type Function]` 2022-03-27 11:39:44 -07:00
Mike Welsh ac765bd187 chore: Update copyright
I (Michael R. Welsh) assign to Ruffle LLC all rights, title, and
interest to copyrights of my personal contributions to Ruffle,
effective March 26, 2022.
2022-03-26 18:13:14 -07:00
relrelb 1c576816b6 core: Refactor `LoadManager::load_form_into_load_vars`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
relrelb f3c22d930b core: Refactor `LoadManager::load_form_into_object`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
relrelb 83353e17c5 core: Refactor `LoadManager::load_movie_into_clip`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
relrelb 7e4b3c1003 core: Refactor `LoadManager::load_root_movie`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
Moulins 1bff5c517a Move back AvmString into ruffle_core::string
This allows removing the gc_arena dependency in ruffle_wstr
2022-03-26 13:42:57 -07:00
Moulins 1911aa9a6b Move core::string into separate ruffle_wstr crate. 2022-03-26 13:42:57 -07:00
relrelb 1230b5e713 swf: Use bitflags for `FontFlag` 2022-03-26 11:33:26 -07:00