Commit Graph

4092 Commits

Author SHA1 Message Date
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