Commit Graph

4353 Commits

Author SHA1 Message Date
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
relrelb 3abfac8ea6 avm2: Port `flash.utils.Endian` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 8228f7af6c avm2: Port `flash.utils.CompressionAlgorithm` to ActionScript 2022-06-24 18:28:33 +03:00
relrelb 801d95cdfa avm2: Implement `flash.geom.Orientation3D` 2022-06-24 18:28:33 +03:00
relrelb b38afb6c75 avm2: Implement `flash.geom.ColorTransform` 2022-06-24 18:28:33 +03:00
relrelb 668a25c404 avm2: Stub `uint` in ActionScript 2022-06-24 18:28:33 +03:00
Aaron Hill 6eb4b485f0
Merge pull request #7095 from adrian17/avm2-fix-bare-function-scope
avm2: Pull methods' scopes from vtable, not class
2022-06-23 00:10:17 -05:00
relrelb 017e35a82f avm2: Refactor `parseInt` implementation
Re-use some helper functions introduced in #7212, and fix some
minor inaccuracies.
2022-06-23 01:07:15 +03:00
Adrian Wielgosik 97cfaff347 avm2: Refactor a (class,scope,method) tuple to a ClassBoundMethod 2022-06-23 00:03:07 +02:00
Callum Thomson 1310f433f2
avm2: Implement escape() toplevel (#7281)
* AVM2: Implement escape()

* chore: Fix formatting

* avm2: Escape resolves non strings to null and use push to append

* chore: Fix nits

* avm2: Escape should coerce objects, add early returns
2022-06-22 08:43:22 +03:00
dependabot[bot] 87c3463510 build(deps): bump syn from 1.0.96 to 1.0.98
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.96 to 1.0.98.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.96...1.0.98)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 09:59:10 +03:00
relrelb 335ce09cb1 core: Remove `indexmap` version restriction
Seems like the cyclic package dependency has been resolved in `1.9.0`,
so bring it back as usual.
2022-06-21 09:26:10 +03:00
dependabot[bot] 678ff2420d build(deps): bump indexmap from 1.6.2 to 1.9.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.6.2 to 1.9.0.
- [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.6.2...1.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 09:26:10 +03:00
dependabot[bot] 65538839f5 build(deps): bump quote from 1.0.18 to 1.0.19
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.18...1.0.19)

---
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-21 08:54:07 +03:00
relrelb 0e0045425e avm2: Re-implement `parseFloat`
The AVM2 `parseFloat` implementation used to call into the AVM1 one,
which was not 100% accurate. De-couple it as a new implementation,
based on `MathUtils::convertStringToDouble` in `avmplus`:
https://github.com/adobe/avmplus/blob/master/core/MathUtils.cpp#L1229-L1439
2022-06-21 08:02:40 +03:00
relrelb 754579eb07 avm2: Port `AccessibilityProperties` to ActionScript 2022-06-18 20:00:56 +03:00
relrelb 786e8d92fb avm2: Introduce ActionScript entry-points
Previously all the `.as` files compiled into `playerglobal.swf`
were detected automatically using `walkdir`. While this might be
convenient, it can cause unexpected results when untracked `.as`
files exist. So instead, introduce two entry points - `stubs.as`
and `globals.as`, which include all stub ActionScript definitions,
and actual class implementations, respectively. This also simplifies
the `playerglobal.swf` build script a bit.
2022-06-18 18:26:57 +03:00
Aaron Hill 21eac9364f avm2: Use '.stub.as' suffix to indicate stub class
This removes the need for keeping an updating list in
'build_playerglobal', and made things easier for me
when porting classes to ActionScript.
2022-06-17 00:03:40 +03:00
relrelb 4e805bb109 avm2: Pass `-optimize` to `asc`
In order to reduce builtins size even further.
2022-06-16 23:09:36 +03:00
relrelb f9596543c6 avm2: Remove unused `Rectangle` and `Point` classes/prototypes
They are now both implemented in pure ActionScript, and no Rust code
ever references them.
2022-06-16 22:42:50 +03:00
relrelb a9915c71bc avm2: Port `flash.geom.Rectangle` to ActionScript
`flash.geom.Rectangle` is a good candidate, since it doesn't have
any native function, and it depends only on `flash.geom.Point`,
which was already been ported to ActionScript in #7071.
2022-06-16 22:42:50 +03:00
Aaron Hill f629a91e53
avm2: Allow implementing classes in ActionScript in custom `playerglobal`
This PR adds support for building a custom `playerglobal.swf`, which can be used
to implement builtin Flash classes in ActionScript. This file is embedded into Ruffle
using `include_bytes!`, and loaded during initialization.
As an example, the `Point` class is reimplemented
in ActionScript, and `flash.text.AntiAliasType` is added.

The ActionScript compilation process is performed by `core/build.rs`.
See that file, along with `core/src/avm2/globals/README.md`, for
more details.
2022-06-15 22:00:17 +03:00
dependabot[bot] b8cdd59877 build(deps): bump bitstream-io from 1.3.0 to 1.5.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.3.0 to 1.5.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/compare/v1.3.0...v1.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-13 23:54:10 +03:00
relrelb bd88e5e95a render: Remove unused `unmultiply_alpha_rgba` 2022-06-11 08:28:24 +03:00
Aaron Hill 3d84eb7d45 Remove now-unused `lowest_depth` method 2022-06-11 00:59:18 +03:00
Aaron Hill 6d9d155b15 avm2: Use render_list instead of depth_list in most cases
The `render_list` for a container always contains all of the children
under both AVM1 and AVM2 - howver, the depth_list may not contain
some children under AVM2.

When we're not performing some AVM1-specific operation
(e.g. `getInstanceAtDepth`, or dumping out AVM1 variables),
we should be using the render list.
2022-06-11 00:59:18 +03:00
Aaron Hill cc90796d8a avm2: More filter-related stubs
This stubs out BlurFilter, adds properties to GlowFilter,
and make the getter for  DisplayObject.filters return
an empty array instead of Undefined.

This is all of the filter-related code that 'Solarmax'
needs in order to reach the main screen (combined with
other unrelated changes I have yet to submit)
2022-06-10 19:35:48 +03:00
Aaron Hill dde21a2a60 chore: Fix latest Clippy warnings 2022-06-08 07:19:56 +03:00
Aaron Hill 487017e7c5 avm2: Properly handle Dictionary enumerants
Previously, there was an off-by-one bug in `get_enumerant_name`,
which caused us to produce a spurious 'null' as a key.
However, the 'dictionary_foreach' test only checked that certain
keys were present, so the presence of an additional key didn't break
the test.

This commit makes Dictionary enumerants behave in the same way as
Array enumerants - all of the object-specific enumerants
(in this case, the non-primitive dicitonar keys) come first,
followed by 'base' enumerants from ScriptObject (in this case,
primtive/String keys). Additionally, `setPropertyIsEnumerable` is now
ignored for `Dictionary`, consistent with Flash's behavior.

The `dictionary_foreach` test is updated to print out all of
the keys when inspecting the dictionary. Since the enumeration
order is unstable (under both Flash and Ruffle) due to the dependency
on pointer hashing, the test sorts the keys before printing them.
This ensures that we get stable output which is consistent between
Ruffle and Flash.
2022-06-07 00:39:42 +02:00
Aaron Hill a4b3dbed79 avm2: Allow accessing `stage.loaderInfo.loaderURL`
Flash Player allows this, and returns the path to the root SWF file.
The test only checks that the returned path contains 'test.swf',
to avoid depending on a platform-specific path.
2022-06-06 22:08:54 +03:00
dependabot[bot] 63b11ad535 build(deps): bump syn from 1.0.95 to 1.0.96
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.95 to 1.0.96.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.95...1.0.96)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-06 20:25:25 +03:00
Aaron Hill 9e4d13f201 avm2: Make `Array.pop` actually pop from the back
The loop to search for a `non_hole` was missing
a `break;`, so it would actually find the *first*
non-hole, rather than than the last. This was not caught
by the test, since there was only one "real" element
in the array (the other one was set on 'Array.prototype')
2022-06-04 23:28:06 +03:00
relrelb 53ef80f514 render: Introduce `RenderBackend::register_bitmap`
Since all `RenderBackend::register_bitmap_*` implementations are
identical now, move them to the default implementation of `RenderBackend`.

Also, turn `RenderBackend::register_bitmap_raw` into `RenderBackend::register_bitmap`,
which accepts a single `Bitmap` parameter.
2022-06-02 15:27:29 -07:00
relrelb 4fb77edfb1 render: Move `srgb_to_linear` to `common_tess`
Since it's the only user of it. Also make it mutate the float array
parameter instead of returning a new one, just to simply things a
bit.
2022-05-31 21:48:11 +03:00
dependabot[bot] 3ce6412a2e build(deps): bump flate2 from 1.0.23 to 1.0.24
Bumps [flate2](https://github.com/rust-lang/flate2-rs) from 1.0.23 to 1.0.24.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases)
- [Commits](https://github.com/rust-lang/flate2-rs/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-30 23:36:08 +03:00
relrelb cec9850a33 core: Use `swf::Matrix::translate` in more places
Replace direct instatiations of `swf::Matrix` where only `tx` and
`ty` are specified, and other fields are default.

This results in a slightly more shorter, readable code.
2022-05-29 21:33:53 +03:00
Toad06 61fa38e70f avm1: Correct `Value::as_bool(String)` in SWFv6 and below 2022-05-27 23:05:55 +03:00
Adrian Wielgosik f169070106 avm2: Pull methods' scopes from vtable, not class 2022-05-26 20:53:41 +02:00
Aaron Hill 15cb9a9ce6 Use `instance_scope` when making `super` method call
A method called with `super` is always an instance method,
so we should be using `instance_scope` for consistency with
`call_property`. This fixes a bug where a method cannot
access static class members (via `getlex`) when called bia
`super.method()`
2022-05-24 18:49:47 -06:00
Aaron Hill fd2d14618d
core: Correctly calculate the length passed to `resize_to_reader`
In several places, we read some data from a tag, and then pass
the original tag length to `resize_to_reader`. This is incorrect -
the provided length is used an an offset from the current position
in the reader, so we will extend past the end of the current tag if
we've already read some bytes.

In practice, this doesn't appear to cause any problems - AVM bytecode
has internal length fields, which end up ensuring that we will never
try to read past where the slice *should* end. However, if a `DoAbc`
tag is the last tag in the file, then we'll end up trying to use
`resize_to_reader` with an offset past the end of the movie.

This commit subtracts the number of already-read bytes from `tag_len`,
to ensure that we always construct a correctly-sized `SwfSlice`
2022-05-24 11:46:16 -07:00
Toad06 580a499e56 core: Run `update_drag` in `Player::handle_event` 2022-05-23 19:05:35 -07:00
Mike Welsh 32bf7e1412 chore: Appease clippy 2022-05-22 02:34:18 -07:00
bbb651 cf820b4f95 desktop: Add fullscreen command line option 2022-05-20 19:51:22 -07:00
relrelb e3da0d2bfd avm1: Simplify `XML.xmlDecl`
Store just the XML declaration string itself, rather than the attributes
it consists of. Then simply return it in ActionScript's `XML.xmlDecl`
property, without using `quick_xml::Writer` at all. This also matches
Flash behavior by capturing the XML declaration as-is, preserving
whitespaces, quotes, casing etc.
2022-05-20 18:46:19 -07:00
Daniel Jacobs cddf5796a3 avm2: Add more Event classes' methods and properties 2022-05-20 18:42:07 -07:00
David Wendt e926af7796 core: Prevent recursive execution of frame scripts on the same movie clip.
To be clear, recursive execution of frame scripts between *different* movie clips is still allowed.
2022-05-20 18:37:42 -07:00
David Wendt 85d98d8c07 core: Always clear the `EXECUTING_AVM2_FRAME_SCRIPT` flag, even if we didn't actually execute frames.
Prior to this commit, executing frame scripts on a movie that doesn't have them for this frame, or didn't advance to a new frame, would cause the the movie to ignore all gotos until the next time it ran a frame script.
2022-05-20 18:37:42 -07:00
Aaron Hill eaeecfcfbc Adjust error message 2022-05-20 11:41:17 -07:00
Aaron Hill 613a255fb3 Use binary literal 2022-05-20 11:41:17 -07:00
Aaron Hill d3689de25d Use QName::dynamic_name 2022-05-20 11:41:17 -07:00
Aaron Hill 7a870ad10a Make some methods private 2022-05-20 11:41:17 -07:00
Aaron Hill 8d8a7600d8 avm2: Partially implement `URLLoader` and related classes
This PR implements the `URLLoader` class, allowing AVM2 scripts
to load data from a URL. This requires several other related
classes (`URLLoaderDataFormat`, `URLRequest`, `IOError`) to be
implemented as well.

Currently implemented:
* Fetching from URLs using the 'navigator' backend
* The `text` and `binary` data formats (which store data
in a `String` or `ByteArray` respectively)
* The `open`, `complete`, and `ioError` events
* The `bytesLoaded`, `bytesTotal`, and `data` properties

Not yet implemented:
* The HTTP and security events
* All of the properties of `IOError`
* The properties on `URLRequest` (besides `url`)
* The "variables" data format

This should be enough to get some basic uses of `URLLoader` working
(e.g. simple GET requests to a particular website).

Note that in Flash's `playerglobal`, the `URLLoader` class is just
a think wrapper around the more general `URLStream`. However,
implementing `URLStream` will require changes to `Navigator``
to support notifications when data arrives in the stream. When
that happens, we should be able to re-use a large amount of the
code in this PR.
2022-05-20 11:41:17 -07:00
Toad06 39e46e5bd3 avm1: Remove `Value::from_bool` 2022-05-19 20:24:53 -06:00
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
relrelb 71a1757d29 swf: Make `Glyph::advance` non-`Option`
Simply use `0` instead of `None`.
2022-03-26 11:33:26 -07:00
relrelb 984342abf3 swf: Avoid some `Vec::resize` usages
Use the `vec![]` macro instead.
2022-03-26 11:33:26 -07:00
dependabot[bot] f9e361ddae build(deps): bump bitstream-io from 1.2.0 to 1.3.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 10:52:26 -07:00
dependabot[bot] 0c4806854c build(deps): bump quote from 1.0.16 to 1.0.17
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.16 to 1.0.17.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.16...1.0.17)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 10:30:46 -07:00
relrelb 8f7b8c4b76 xml: Make `XmlNodeData` a struct
The difference between element nodes and text nodes is very minor.
So instead of representing them by two distinct enum members, make
`XmlNodeData` a single unified struct that can represent both. A new
`node_type` field is introduced, in order to still distinguish
between element and text nodes. Also, Ruffle made some incorrect
assumptions, which are now corrected, including:

* Nodes can have any arbitrary `u8` type. This is resolved by the
introduction of the `node_type` field which is a `u8`.
* Text nodes can have children. This is resolved by simply not checking
for text nodes in `append_child` etc.
2022-03-26 10:12:47 -07:00
relrelb 161071e8c4 core: Re-implement `NullExecutor`
Make it a thin abstraction layer over either the `futures` or `wasm-bindgen-futures`
crates, as already done in `render/wgpu/src/uniform_buffer.rs`,
instead of a hand-made single-thread executor.

Ideally this would also be usable on desktop, but I didn't manage to
get `LocalPool` working with `winit` (it needs to post a task to the
`EventLoopProxy` as a wake procedure).
2022-03-26 10:03:42 -07:00
Moulins bb63ac2de7 wstr: fix memory leak
WString's Drop impl didn't actually drop anything
2022-03-25 18:36:00 -07:00
Toad06 c1119fdc0b avm1: Apply autosize to a new `EditText` from an SWF `DefineEditText` tag 2022-03-21 20:00:06 -07:00
Aaron Hill a281db3af6 Add `define_indirect_properties` helper macro for property/slot pairs
In both `FrameLabel` and `Scene`, we define multiple
'public property / private slot' pairs.
The public property has a getter which delegates to the private
property. There is no setter for the property, ensuring that
the private slot can only be modified from within Ruffle itself.

This PR adds a macro `define_indirect_properties` to abstract over
this pattern. Currently, it only supports the read-only property
pattern - however, it could be extended in the future to generate
a setter that invokes a caller-provided callback function.

This needs to be a macro (rather than a method) so that we can
generate a function with the property name hard-coded into it.
Using a closure that references an upvar will not work, since
`Method::from_builtin` requires a function pointer.
2022-03-21 19:00:25 -07:00
relrelb b7a60384cf xml: Inline `update_id_map`
Move its logic to `from_start_event`, where `XmlNode`s are created.
2022-03-20 11:04:48 +02:00
relrelb 724f4165d6 avm1: Implement `nodeName` and `nodeValue` setters
These are actually handled by the same function.
2022-03-19 16:31:24 -07:00
relrelb f9dff4191b xml: Remove `XmlNodeData::DocumentRoot`
Document roots (a.k.a. `XML` objects) are very similar to regular
element nodes (a.k.a. `XMLNode` objects). The primary difference is
that `XML` objects return `null` for their `nodeName`. But this can
be changed too; Setting `xml.nodeName = "someName"` will make `XML`
objects behave much like `XMLNode`. Moreover, many checks in Ruffle
that refuse to operate on document roots were wrong, and actually
these should be accepted as normal element nodes.
Besides the functional corrections, this also simplifies the code.
2022-03-19 16:31:24 -07:00
relrelb fa70cc07ab xml: Inline `text_from_text_event` and `is_whitespace_text` 2022-03-19 15:08:16 -07:00
relrelb b31e826ee6 core: Simplify `SwfMovie` parsing in `Loader`
This also slightly changes behavior: Previously `SwfMovie::from_data`
errors were propagated as `FetchError` and `display_root_movie_download_failed_message`
was called, offering the user to sidestep CORS by opening the SWF
in a new tab. But that wouldn't help, obviously, because no network
error is involved. Now, these errors are propagated as `InvalidSwf`,
and `display_root_movie_download_failed_message` is not called.
2022-03-17 20:31:59 -07:00
relrelb ad944800be core: Perfer `Loader`'s `FetchError`
`NetworkError` and `NetworkUnavailable` were rarely used, and they
were very similar to `FetchError`.
2022-03-17 20:31:59 -07:00
relrelb bf32fc8576 core: Remove unused `Loader` types 2022-03-17 20:31:59 -07:00
dependabot[bot] d56377b166 build(deps): bump quote from 1.0.15 to 1.0.16
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.15 to 1.0.16.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.15...1.0.16)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-17 20:29:26 -07:00
dependabot[bot] 50bdb40914 build(deps): bump syn from 1.0.87 to 1.0.88
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.87...1.0.88)

---
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-17 01:00:16 +02:00
dependabot[bot] 7fc6a7c000 build(deps): bump syn from 1.0.87 to 1.0.88
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.87...1.0.88)

---
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-17 00:21:26 +02:00
relrelb 8a17d88c77 core: Remove `NavigatorBackend::time_since_launch`
`core` already depends on the `instant` crate which abstracts
`std::instant::Instant` and polyfills it on Web. Use it to replace
`NavigatorBackend::time_since_launch` in order to make `NavigatorBackend`
a little smaller and more simple.
2022-03-17 00:08:44 +02:00
relrelb 031126a1b8 core: Remove `LocaleBackend`
Previously there were 3 implementations of `LocaleBackend`:
`DesktopLocaleBackend`, `WebLocaleBackend` and `NullLocaleBackend`.

While `DesktopLocaleBackend`, `WebLocaleBackend` were identical,
`NullLocaleBackend` always returned a fixed date/time for tests
determinism.

Unify them in a single file, and use `cfg!(test)` and a new dedicated
`deterministic` feature to decide whether to mock date/time or not.
This should not cause any behavioral changes.
2022-03-16 19:57:53 +02:00
relrelb 1db29217eb chore: Appease clippy 2022-03-16 18:51:39 +02:00
Aaron Hill e87ad52deb avm2: Add initial implementation of `Matrix`
This implements the `a, b, c, d, tx, ty` properties,
as well as the constructor, `identity`, and `scale` methods.
2022-03-16 13:52:58 +02:00
dependabot[bot] 8d7000cd67 build(deps): bump syn from 1.0.86 to 1.0.87
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.86 to 1.0.87.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.86...1.0.87)

---
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-14 22:26:58 +02:00
relrelb f8f2764ac7 chore: Stop using traits available in prelude
This commit does the same as 36353df7f7,
cleaning up any leftovers and new code added since.
2022-03-14 01:16:00 +02:00
relrelb 9c9335dbb8 core: Small cleanup in `Font::measure` 2022-03-13 19:11:06 +02:00
relrelb 3d08f31fa7 avm1: Correct `StageObject::get_level_by_path`
Resolving `_levelN` had some inconsistencies with Flash:
1. `_flash` can be a prefix too.
2. The level ID parsing cannot fail; non-digit characters are ignored,
the value wraps around at `i32::MAX`, and negative values are valid.

This logic is relevant also for the `GetUrl` and `GetUrl2` opcodes.
For now only add TODOs for this.
2022-03-12 16:48:55 +02:00
relrelb b59638935f xml: Remove constant `process_entity` parameter 2022-03-12 16:11:39 +02:00
Aaron Hill 3bcb409bd8 Add more AVM2 'flash.' class stubs
This PR adds the following class stubs:

* 'flash.display.Loader'
* 'flash.net.URLRequest'
* 'flash.ui.Keyboard'
* 'flash.utils.Timer'

These are needed for 'This is the Only Level TOO' (though we'll need
actual implementations to get this game past the loading screen).
2022-03-12 15:09:41 +01:00
relrelb b0a73d5638 avm1: Remove `TransformObject::construct`
`constructor` in `core/src/avm1/globals/transform.rs` should do
the same, as in other built-in classes.
2022-03-12 15:59:05 +02:00
relrelb 5a1e417526 avm1: Simplify `TDisplayObject::avm1_root()`
Make it infailable.
2022-03-10 01:22:52 +02:00
dependabot[bot] 71758be08b build(deps): bump png from 0.17.4 to 0.17.5
Bumps [png](https://github.com/image-rs/image-png) from 0.17.4 to 0.17.5.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/compare/v0.17.4...v0.17.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-07 23:59:02 +02:00
Aaron Hill f4bb6fc43c Change property definition from `loaderUrl` to `loaderURL`
The actual property name is `loaderURL` - it looks like
a typo was made when this was originally defined in Ruffle.
2022-03-07 09:24:01 +02:00
relrelb 88f6856723 avm1: Fix `isFinite()` for SWF<7
Previously, `isFinite()` with no arguments on SWF<7 incorrectly
returned `true`, as `undefined` coerced to `f64` is `0.0`, which
is finite. Fix this by not defaulting to `undefined`, similarly to
the `isNaN()` implementation.
2022-03-06 23:15:18 +01:00
Aaron Hill 8d58c6974c Display `Muliname` when trying to lookup a non-public property
This will make these errors easier to debug.
2022-03-06 22:56:23 +01:00
Aaron Hill 4a534086b8 Make `Date` class prototype methods non-enumerable 2022-03-06 22:48:15 +01:00
Aaron Hill 2d1b3a2834 Also declare Date methods on class prototype 2022-03-06 22:48:15 +01:00
Aaron Hill 59ef987210 Declare AVM2 'Date' class methods in the AS3 namespace
We now declare these methods in the 'http://adobe.com/AS3/2006/builtin'
namespace. This corresponds to the 'AS3' namespace modifier shown on the
docs page: https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html

Previously, we would fail to lookup these methods, since the namespace
used by the SWF would not match the namespace defined by Ruffle.
2022-03-06 22:48:15 +01:00
relrelb 26f3d1e321 avm1: Fix typo 2022-03-06 23:10:09 +02:00
relrelb d0edffaed3 avm1: Remove unneeded `pub` 2022-03-06 23:10:09 +02:00
relrelb 6504dc8ffc avm1: Simplify `MovieClip::get_bounds`
The String and Object cases are already handled by `resolve_target_display_object`.
2022-03-06 23:10:09 +02:00
relrelb 2faabfb58e xml: Remove `Error`
Directly use `quick_xml::Error` instead.
2022-03-02 08:56:23 +02:00
relrelb e901999b4c xml: Silently fail in `insert_child`
Instead of returning a `Result` which is anyway always handled with
a `log::warn!()`, simply `log::warn!()` in place of errors. This
removes the last 3 remaining `Error` enum members besides `InvalidXml`.
2022-03-01 19:56:36 +02:00
relrelb 48d0737cd9 xml: Inline `adopt_child` into `insert_child`
There's no point in calling `adopt_child` alone. This makes 2 `Error`
enum members redundant.
2022-03-01 19:56:36 +02:00
Toad06 dcca61073b core: Display the appropriate mouse cursor after interacting with a button 2022-02-28 15:28:18 -07:00
dependabot[bot] b5f65463b6 build(deps): bump png from 0.17.3 to 0.17.4
Bumps [png](https://github.com/image-rs/image-png) from 0.17.3 to 0.17.4.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-28 22:31:11 +02:00
relrelb 7313913127 xml: Turn `remove_child` into `remove_node`
The 2 existing usages of `remove_node` always operated on a child and
its parent: One iterates over all of its children and removes each one,
and the other explicitly grabs the parent of a given node.

As a simplification, `remove_node` operates only on a child node,
without the need for the parent node in addition; it grabs the parent
from the child by itself. As such, it's non-failable.
2022-02-28 08:34:16 +02:00
relrelb 73c1be8dcc xml: Remove `Error::TextNodeCantHaveChildren`
Text nodes are guaranteed to not be parents, as `adopt_child`
refuses to adopt children into them. So instead of returning an
`Err(Error::TextNodeCantHaveChildren)` in case of a text node parent,
mark those code paths as `unreachable!()`. This makes `orphan_child`
non-failable.
2022-02-28 08:34:16 +02:00
Toad06 66c132017f avm1: Allow strings in `new Sound(target)` 2022-02-28 08:30:38 +02:00
relrelb 0401b3c447 avm2: Replace `json` with `serde_json`
The `json` crate seems unmaintained, and recently also causes compile
errors with stable Rust 1.59.0. On the other hand, `serde_json` is
very maintained and more popular.

However, from some reason a cyclic package dependency has introduced
by this change. For now use a workaround from: https://github.com/tkaitchuck/aHash/issues/95#issuecomment-903560879
2022-02-27 23:19:46 +02:00
relrelb fa459f7547 core: Require `serde` feature
Enable it unconditionally as a preparation for depending on `serde_json`,
which will need `serde::Serialize`.
2022-02-27 23:19:46 +02:00
relrelb 841d0f7efd avm1: Remove legacy JSON SharedObject deserialization
This is basically a revert of 61298b2be3.

`SharedObject`s used to be saved as JSON in Ruffle, but since #4238
they're saved in AMF to match Flash's behavior. The legacy JSON
deserialization remained for backwards-compatibility, but from what it
seems, it has never worked; cd1cde1708
changed `LocalStorageBackend` to store base64-encoded strings instead
of plain ones. Therefore, Ruffle attempts to base64-decode old JSON
data, and unsurprisingly fails.

In addition, this removes 1 out of 2 usages of the unmaintained `json`
crate, which recently also causes compile errors with stable Rust 1.59.0.
2022-02-27 23:19:46 +02:00
relrelb b645c01ce7 xml: Silently fail in `disown_parent`
Instead of returning a `Result` which is anyway always handled with
a `log::warn!()`, simply `log::warn!()` in place of error.
2022-02-24 18:02:52 +02:00
relrelb f7117824df xml: Silently fail in `set_{prev,next}_sibling`
Instead of returning a `Result` which is anyway always handled with
a `log::warn!()`, simply `log::warn!()` in place of errors.
2022-02-23 22:45:07 +02:00
relrelb ce6e90c027 avm1: Store `status` in `XmlObject`, instead of `ParseError`
The only use of `last_parse_error` was in the `XML.prototype.status`
property, where it was converted into a number. Avoid storing it by
storing just the number.
2022-02-21 23:21:14 +02:00
dependabot[bot] 40f356a385 build(deps): bump rand from 0.8.4 to 0.8.5
Bumps [rand](https://github.com/rust-random/rand) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/compare/0.8.4...0.8.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-14 22:34:09 +02:00
Toad06 5e8d8cc4d1 avm1: Add `trace` to globals 2022-02-14 14:50:33 +02:00
relrelb faa1f3d6b4 avm1: Refactor `XmlNodeObject::from_xml_node`
Revert some of e50aea864b for an even
better approach - Remove `XmlNodeObject::empty_node` entirely by
making `XmlNodeObject::from_xml_node` a suitable alternative. That is,
being able to accept a custom `proto` like before.

Also, make it return an `XmlNodeObject` instead of an `Object`, and
add a few `.into()` where needed.
2022-02-14 12:15:39 +02:00
dependabot[bot] db888ad739 build(deps): bump png from 0.17.2 to 0.17.3
Bumps [png](https://github.com/image-rs/image-png) from 0.17.2 to 0.17.3.
- [Release notes](https://github.com/image-rs/image-png/releases)
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-13 18:43:46 +02:00
relrelb dbddefb44d xml: Refactor `XmlNode::into_string`
* Don't use `quick_xml::Writer` for formatting the XML, being much
more simple.
* Return `WString` instead of `String`, reducing `to_utf8_lossy()`
calls except when the string needs to be escaped (attribute values
and text contents).
2022-02-13 18:11:50 +02:00
dependabot[bot] a3288fa20c build(deps): bump serde from 1.0.133 to 1.0.136
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.133 to 1.0.136.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.133...v1.0.136)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-13 18:10:43 +02:00
dependabot[bot] cc2df3e23c build(deps): bump syn from 1.0.85 to 1.0.86
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.85 to 1.0.86.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.85...1.0.86)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-13 16:55:17 +01:00
dependabot[bot] 036218ed01 build(deps): bump jpeg-decoder from 0.2.1 to 0.2.2
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.1 to 0.2.2.
- [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.1...v0.2.2)

---
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-02-13 16:47:13 +02:00
dependabot[bot] 5f630217c6 build(deps): bump smallvec from 1.7.0 to 1.8.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.7.0...v1.8.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-02-13 16:46:59 +02:00
dependabot[bot] 281c080295 build(deps): bump symphonia from 0.4.0 to 0.5.0
Bumps [symphonia](https://github.com/pdeljanov/Symphonia) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/pdeljanov/Symphonia/releases)
- [Commits](https://github.com/pdeljanov/Symphonia/compare/v0.4.0...v0.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-13 16:13:44 +02:00
dependabot[bot] 3bef5cadf6 build(deps): bump quote from 1.0.14 to 1.0.15
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.14 to 1.0.15.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.14...1.0.15)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-13 15:45:11 +02:00
Jean Marchand 9969e0ce5a avm2: Fix invalid option 2022-02-12 23:35:32 +02:00
relrelb ad2b8ea007 avm1: Merge `XmlDocument` into `XmlObject`
As `XmlDocument` and `XmlObject` had 1-to-1 relation, and `XmlDocument`
is already tightly coupled with AVM1, there's no good reason for them
being separate objects.

This brings us one step closer towards an XML implementation hosted
completely in AVM1.

A future PR will merge `XmlNode` into `XmlNodeObject` in a similar
manner.
2022-02-11 19:08:02 +02:00
relrelb aee98d81c8 avm1: Fix nightly build error 2022-02-11 18:45:32 +02:00
relrelb 360ad90a85 avm1: Call sort function with a primitive `this`
This is now possible thanks to #6108.
2022-02-11 18:45:32 +02:00
Toad06 b15806d9c2 avm1: Remove `random` from globals 2022-02-11 00:55:13 +02:00
relrelb 44fd13c654 avm1: Fix builtins' attributes
Fixes #5827.
2022-02-10 19:42:05 +02:00
relrelb b6c7cc1ca3 core: Cleanup `Avm1ConstructorRegistry`
Instead of storing shared pointers to `Avm1ConstructorRegistry` in
`MovieLibrary`, access the `PropertyMap` directly, without an extra
abstraction.

Also, move the constructor registries to `Avm1`, for better
encapsulation.
2022-02-10 07:58:30 +02:00
Toad06 fff9cd1d63 avm1: Change cursor to arrow when the `enabled` property is set to false 2022-02-09 16:26:50 -08:00
TÖRÖK Attila ed0aa3758c core: Extend the embedded fake device font with more characters
By also embedding the "Basic Latin", "Latin I", and "Latin Extended A" sections.
2022-02-09 20:09:52 +01:00
relrelb 6c4a10792d avm1: Remove `XmlIdMapObject`
Use a bare `ScriptObject` instead.
2022-02-07 22:24:42 +02:00
relrelb e50aea864b xml: Simplify `XmlNodeObject::from_xml_node`
Since it's always called with the same prototype (`XMLNode.prototype`),
this can be pulled into the function itself, greatly simplifying it.
2022-02-07 22:24:42 +02:00
relrelb 79d5a0e326 avm1: Avoid some calls to `XmlNode::introduce_script_object`
Instead call `XmlNode::script_object`, which internally calls
`XmlNode::introduce_script_object`. This is a preparation for changing
the signature of `XmlNodeObject::from_xml_node`.
2022-02-07 22:24:42 +02:00
relrelb 7e32f7b85d xml: Remove `tests.rs`
These are already covered by the SWF tests.
2022-02-07 22:24:42 +02:00
Adrian Wielgosik 562a205f3d chore: clippy 2022-02-07 00:49:00 +01:00
Adrian Wielgosik 2c4b260a8c chore: cargo fmt 2022-02-07 00:49:00 +01:00
Adrian Wielgosik c67579e236 avm2: Implement Object() 2022-02-07 00:49:00 +01:00
Adrian Wielgosik 0004b9e58e avm2: Implement RegExp() 2022-02-07 00:49:00 +01:00
Adrian Wielgosik c8fe2fcfb2 avm2: Implement Namespace() stub 2022-02-07 00:49:00 +01:00
Adrian Wielgosik 8402f6637b avm2: Implement Vector.<T>(array_like) 2022-02-07 00:49:00 +01:00
Adrian Wielgosik db8aa42db9 avm2: Support custom Class() implementations 2022-02-07 00:49:00 +01:00
Fernando Karchiloff 0c853082dd core: Fix bullet append with box_count check 2022-02-06 20:52:04 +02:00
Fernando Karchiloff b7273e038c core: fix bullet append from html 2022-02-06 20:52:04 +02:00
relrelb 48c43b731e avm1: Remove unused `is_defined` 2022-02-05 13:43:19 +02:00
Toad06 83cc9dc308 avm1: Fire `onReleaseOutside` event even when the button is invisible 2022-01-30 14:08:47 -08:00
Mike Welsh 601918a998 core: Fix drawing API stroke rendering order (fix #3186) 2022-01-29 20:05:04 -08:00
Mike Welsh 705588a2ec core: Fix incorrect fill and stroke rendering order (fix #6129) 2022-01-29 20:05:04 -08:00
Mike Welsh 55da3cd7d0 chore: Add .cargo/config.toml for workspace-level lint config
Currently it is not directly possible to configure lints for the
entire workspace via TOML, which forced us to repeat `#![allow]`
blocks in each crate.

embark pointed out this workaround to configure lints at the
workspace level via RUSTFLAGS:

https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395

Remove the common `#![allow]` blocks and switch to this method for
global lint config.

Temporarily allow `needless_borrow` lint, buggy pending this fix:
https://github.com/rust-lang/rust-clippy/pull/8355
2022-01-29 14:22:44 -08:00
relrelb 99b22b24dd avm1: Remove unused `FunctionObjectData::primitive` 2022-01-29 12:12:39 -08:00
Daniel Jacobs 1e5956c02a core: Fix get_text_format bullet return value 2022-01-27 22:35:18 -08:00
TÖRÖK Attila 43b21e5d4d chore: Bump approx to 0.5.1, remove clippy lint suppressions 2022-01-25 18:34:35 -08:00
Toad06 da50d44460 core: Fix detection of button events 2022-01-24 11:48:37 -08:00