Commit Graph

3625 Commits

Author SHA1 Message Date
Adrian Wielgosik 21865edf9b avm2: Support const slots, fill some TODOs 2021-12-11 20:48:09 +01:00
Adrian Wielgosik b272d8722e avm2: Reword slot/disp_id assignment, remove Slot. 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 4d8999c012 avm2: Make all prototypes ScriptObjects; also cleanup vector enumeration, Proxy 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 3706db86d2 avm2: move properties from instances to vtable 2021-12-11 20:48:09 +01:00
relrelb d3fe4ea59a avm1: Split `XML` and `XMLNode` definitions
This reduces the file size of the previous `xml.rs` file, and makes
the code a bit more organized.
2021-12-11 20:28:37 +02:00
Adrian Wielgosik 6594d4159d avm2: Use Vec instead of HashMap for loaded constants 2021-12-11 10:03:29 +01:00
relrelb ca3b215561 chore: Appease clippy 2021-12-10 21:06:38 +02:00
relrelb 7966d850dd core: Normalize `\r` to `\n` in `avm_trace`
Fixes #3120.
2021-12-10 19:54:35 +02:00
relrelb eacf34d80a avm1: Remove `Function.prototype.toString`
`Function.prototype` doesn't have its own `toString` method, but
rather inherts it from `Object.prototype`. So remove `Function.prototype.toString`
and move its logic to `Object.prototype.toString`.
2021-12-10 11:36:39 +02:00
relrelb ce2eff8b25 render: Stub L16 JPEG pixel format
16-bit luminance (grayscale) images are very rare, so it's hard to
tell what the expected behavior should be.
2021-12-10 00:28:45 +02:00
dependabot[bot] 8007f21ffe build(deps): bump jpeg-decoder from 0.1.22 to 0.2.0
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.1.22 to 0.2.0.
- [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.1.22...v0.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-10 00:28:45 +02:00
Adrian Wielgosik d28dd3bd05 avm1: Fix up attributes of some builtins' protos 2021-12-10 00:28:21 +02:00
EmperorBale 0a25ebbc32 chore: Remove more explicit clones 2021-12-08 22:14:45 +01:00
EmperorBale d6b7d0c915 chore: Fix formatting 2021-12-08 22:14:45 +01:00
EmperorBale a192fbb113 chore: Remove explicit clones in avm2 2021-12-08 22:14:45 +01:00
EmperorBale 847a4fb61a chore: Remove explicit clones in value 2021-12-08 22:14:45 +01:00
EmperorBale 1709ea94e7 chore: Remove explicit clones in object 2021-12-08 22:14:45 +01:00
EmperorBale 8ea41bc151 chore: Remove explicit clones in slot 2021-12-08 22:14:45 +01:00
EmperorBale 15378bcfde chore: Remove explicit clones from vector 2021-12-08 22:14:45 +01:00
EmperorBale 2f71360c3b chore: Remove explicit clones from primitive_object 2021-12-08 22:14:45 +01:00
EmperorBale a7f86e679c chore: Remove explicit clones from uint 2021-12-08 22:14:45 +01:00
EmperorBale 0a8b964754 chore: Remove explicit clones from number 2021-12-08 22:14:45 +01:00
EmperorBale 8f27196356 chore: Remove explicit clones in int 2021-12-08 22:14:45 +01:00
EmperorBale a0bbc96b4a chore: Remove explicit clones in function 2021-12-08 22:14:45 +01:00
EmperorBale 7027046588 chore: Remove explicit clones in shape 2021-12-08 22:14:45 +01:00
EmperorBale 51f909691f chore: Remove explicit clones in movieclip 2021-12-08 22:14:45 +01:00
EmperorBale 96eb14fdab chore: Remove explicit clones in boolean 2021-12-08 22:14:45 +01:00
EmperorBale 60fc4cd0c0 chore: Remove explicit clones in activation 2021-12-08 22:14:45 +01:00
EmperorBale 002158a1b0 chore: Remove explicit clones in array 2021-12-08 22:14:45 +01:00
EmperorBale 7fce022293 avm2: Derive Copy for Value 2021-12-08 22:14:45 +01:00
Adrian Wielgosik 685911a77c swf: Box ShapeRecord::StyleChange variant 2021-12-08 22:14:17 +01:00
Moulins 3ff0c3d737 string: Correctly return None in `WStr::offset_in` for overlapping WStrs 2021-12-08 22:12:11 +01:00
relrelb da4b5986b1 chore: Appease clippy 2021-12-08 22:36:55 +02:00
relrelb 5de81d4729 html: Handle attribute errors gracefully
`quick-xml` returns an `Err` for invalid attributes (e.g. unquoted).
Handle such errors by ignoring the HTML completely and return an
empty string instead, as Flash does.

Fix #5789.
2021-12-05 08:40:04 +02:00
relrelb 7f7ecda8a9 core: Unify `define_bits_jpeg_3` and `define_bits_jpeg_4`
The only difference is the deblocking field, which is now read only
for DefineBitsJpeg4.
2021-12-04 21:32:16 +02:00
relrelb 00accf3e2a render: Rename `register_bitmap_jpeg_3` to `register_bitmap_jpeg_3_or_4`
It's actually used by both DefineBitsJpeg3 and DefineBitsJpeg4 tags.
2021-12-04 21:32:16 +02:00
dependabot[bot] 963fa78f29 build(deps): bump weak-table from 0.3.0 to 0.3.2
Bumps [weak-table](https://github.com/tov/weak-table-rs) from 0.3.0 to 0.3.2.
- [Release notes](https://github.com/tov/weak-table-rs/releases)
- [Changelog](https://github.com/tov/weak-table-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/tov/weak-table-rs/compare/0.3.0...v0.3.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-04 16:50:42 +02:00
relrelb 03aa31ec68 core: Fix a bug in `MorphShapeStatic::register_ratio`
The comparsion `start_change.move_to != end_change.move_to` doesn't
make sense, because even if they are identical, the positions need
to be updated.

Fix #2886.
2021-12-04 13:46:02 +02:00
relrelb fab4103932 chore: Appease clippy 2021-12-04 13:45:37 +02:00
David Wendt 54fcfde1cc core: String equality should short-circuit on pointer equality 2021-12-02 16:33:56 -07:00
David Wendt 29d2df5f07 core: Hash the whole (byte-oriented) WStr without iterating it. 2021-12-02 16:33:56 -07:00
David Wendt dbecd03110 core: When hashing `WString`, optimize for the common case (bytestrings) 2021-12-02 16:33:56 -07:00
David Wendt 9f30a9d4a6 avm2: When passing namespaces around, use a `SmallVec` of one element for memory savings. 2021-12-02 16:30:21 -07:00
David Wendt 1302ea9986 avm2: Pass everything around as `SmallVec`s. 2021-12-02 16:30:21 -07:00
David Wendt 5e03382f5d avm2: Smallvec the property maps. 2021-12-02 16:30:21 -07:00
David Wendt a18faeb047 avm2: Also put definition scripts in a `PropertyMap` and query them the same way we do objects 2021-12-02 16:30:21 -07:00
David Wendt 92697c9f1e avm2: Use FNV hashing for all other parts of the VM. 2021-12-02 16:30:21 -07:00
David Wendt 3329e2a965 avm2: Use FNV hashes for property lookup. 2021-12-02 16:30:21 -07:00
David Wendt 769c45add5 avm2: Make `QName` a copy type. 2021-12-02 16:30:21 -07:00
David Wendt d53abfebf4 avm2: Also preresolve all class traits, too. 2021-12-02 16:30:21 -07:00
David Wendt 44162ae698 avm2: Don't clone the multiname set on each lookup 2021-12-02 16:30:21 -07:00
David Wendt 3a7dd48c81 avm2: Build a flattened traits list per class and use that in lieu of a full trait lookup. 2021-12-02 16:30:21 -07:00
David Wendt 722dd6aabf avm2: Refactor multiname resolution to take advantage of the new value storage structure. 2021-12-02 16:30:21 -07:00
David Wendt c99231b610 avm2: Index the property map by local name and bucket all namespaces together into a single list. 2021-12-02 16:30:21 -07:00
David Wendt 0bc2ddfc7b avm2: Remove prototype lookups from `resolve_any` 2021-12-02 16:30:21 -07:00
David Wendt d83a7c909c avm2: Don't scan the prototype for each multiname check. 2021-12-02 16:30:21 -07:00
Moulins 6bd3c62195 avm1: Remove unnecessary clones in shared_object::recursive_deserialize_json 2021-12-02 07:12:22 +02:00
dependabot[bot] 7d1ac9d26b build(deps): bump syn from 1.0.81 to 1.0.82
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.81 to 1.0.82.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.81...1.0.82)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-29 23:04:42 +02:00
David Wendt fa179dc63f avm2: Unpublish a bunch of primclass methods 2021-11-28 18:40:21 -07:00
David Wendt 6d48126124 avm2: And, finally, `uint`. 2021-11-28 18:40:21 -07:00
David Wendt 640763bfda avm2: Also do the same for `int` 2021-11-28 18:40:21 -07:00
David Wendt 593158cb04 avm2: Also allow calling `Number` methods on the prototype in the `public` namespace. 2021-11-28 18:40:21 -07:00
David Wendt 6bfca1af5f avm2: Expose `Boolean` methods in the `public` namespace via prototypes. 2021-11-28 18:40:21 -07:00
David Wendt 3e8f13b70a avm2: `Number.MIN_VALUE` is the machine epsilon, not the lowest possible finite value. 2021-11-28 18:40:21 -07:00
David Wendt 7569994f1f avm2: Impl `Boolean.toString` and `Boolean.valueOf`. 2021-11-28 18:40:21 -07:00
David Wendt aa01a682e1 avm2: Implement `uint`'s various formatting methods, too. 2021-11-28 18:40:21 -07:00
David Wendt e43d18f7b0 avm2: Impl `int` versions of `toFixed`, `toString`, `toExponential`, and `toPrecision` 2021-11-28 18:40:21 -07:00
David Wendt cabfe5e20c avm2: All documented primitive class methods are in the AS3 namespace. 2021-11-28 18:40:21 -07:00
David Wendt 9e62b05157 avm2: Implement `Number.AS3::toString` and `Number.AS3::valueOf`.
This method has an odd flaw that we don't emulate yet. Actually, two:

1. Precision limits that are specific to the chosen radix
2. Occasional and intermittent corruption in the resulting 0 padding; usually manifesting as `x`, `W`, or `°` characters

The first could be emulated, but I've chosen not to... because the second thing listed not only isn't really possible to emulate, but actively prohibits approx-testing the results. So I'm marking the test as ignored and hoping no movies actually rely on the precision limits in `toString`.
2021-11-28 18:40:21 -07:00
David Wendt 4a09dfa3d0 avm2: Implement `Number.toFixed` and `Number.toPrecision` 2021-11-28 18:40:21 -07:00
David Wendt 55a7a1882d avm2: Implement `Number.toExponential` 2021-11-28 18:40:21 -07:00
David Wendt 16597e0d7b avm2: Fill out class constants for `uint`, `int`, and `Number`. 2021-11-28 18:40:21 -07:00
relrelb 2117ad8a4c html: Ignore <p>, <li> and <br> tags in non-multiline mode 2021-11-28 22:57:48 +02:00
relrelb 9cad582e8b html: Do not trim text in `FormatSpans::from_html`
Flash preserves spaces before and after text.

But since now `quick-xml` might emit empty `Text` events, those need
to be explicitly ignored in order to retain the same text format across
tags.
2021-11-28 22:57:48 +02:00
relrelb a027d932e4 html: Use `as_ref()` instead of `clone()`
This should improve performance a bit.
2021-11-28 22:57:48 +02:00
Varun Ramesh 7c87f35d8d
avm2: Implement `flash.display.PixelSnapping` (#5718)
* Add flash.display.PixelSnapping enum class

* Run 'cargo format --all'

* Add 'final' class attribute
2021-11-28 07:31:39 +02:00
Moulins 9701b817f5 core: Replace WStr<'_> and WStrMut<'_> by a single DST type WStr 2021-11-27 11:20:47 -07:00
Moulins fd8bdeb1a8 core: improve f64's FromWStr impl
This avoids converting the string to UTF8 if it can't possibly
be a float
2021-11-27 11:20:47 -07:00
Moulins ee326e31b7 core: Reduce allocations in AvmString::new_utf8
Also remove some useless back-and-forth conversions between
AvmString and String
2021-11-27 11:20:47 -07:00
Moulins fa30e1bc43 chore: rename AvmString::{new -> new_utf8, new_ucs2 -> new} 2021-11-27 11:20:47 -07:00
Moulins 45fe1e86ae core: remove AvmString::as_str, and the extra UTF8 String inside 2021-11-27 11:20:47 -07:00
Moulins e24af59197 core: remove last instances of AvmString::as_str 2021-11-27 11:20:47 -07:00
Moulins 824263d2bc core: adapt TextField, Font & Html handling code to use WStr 2021-11-27 11:20:47 -07:00
Moulins f149c9efce core: remove some AvmString::as_str calls 2021-11-27 11:20:47 -07:00
Moulins 053758d77c avm2: use WString in QName methods 2021-11-27 11:20:47 -07:00
Moulins 5ca911209b core: implement WStr::join 2021-11-27 11:20:47 -07:00
Moulins c496f81f13 avm1: remove AvmString::as_str usage in activation.rs and movie_clip.rs 2021-11-27 11:20:47 -07:00
Moulins 87400b829d core: use WStrings for display object's frame and scene labels 2021-11-27 11:20:47 -07:00
Moulins 84b4e33036 core: implement FromWStr for various enum types 2021-11-27 11:20:47 -07:00
Moulins b894d0c97f avm1: adapt parseInt, escape & unescape to use WStr API 2021-11-27 11:20:47 -07:00
Moulins c2349ae012 xml: use AvmString in xml code
This has the nice side-effect of reducing string cloning, because we can
just pass AvmStrings around instead.
2021-11-27 11:20:47 -07:00
Moulins 5db23ddbf3 avm2: use WStr in date parsing logic 2021-11-27 11:20:47 -07:00
Moulins f49ce49d28 core: add FromWStr trait and WStr::parse 2021-11-27 11:20:47 -07:00
Moulins 8863b54db0 avm1: don't use &str for activation's path & variable logic 2021-11-27 11:20:47 -07:00
Moulins 1d9d7e6942 avm1: don't use &str methods when parsing enum parameters in MovieClip 2021-11-27 11:20:47 -07:00
Moulins d850085d2b avm1: partially rewrite Value::primitive_as_number 2021-11-27 11:20:47 -07:00
Moulins 4a09088d42 avm2: rewrite regexp module to not rely on AvmString::as_str
This is a little tricky, because we have to map the utf8 indices
returned by the regex engine to utf16 indices usable by Ruffle.

To limit the impact on performance, the regex, the string we're
currently matching on, and the last known (utf8, utf16) positions
are cached, avoiding extra utf8 conversions in common use cases
where a single string is repeatedly searched with increasing
`lastIndex`.
2021-11-27 11:20:47 -07:00
Moulins 23cbe4c2fd core: Add `string::Pattern` trait, based on `std::str::Pattern`
This allows `Str::{find, rfind, split}` to accept multiple types
2021-11-27 11:20:47 -07:00
Moulins 110f568aa4 core: Remove some useless utf8<->utf16 conv. in {avm1,avm2}/activation.rs 2021-11-27 11:20:47 -07:00
Moulins 8885175550 core: Replace string::utils *_ignore_case functions by methods on WStr 2021-11-27 11:20:47 -07:00