Commit Graph

1803 Commits

Author SHA1 Message Date
Mike Welsh 366e8aa926 Array: Fix Array single-param ctor
The Array constructor with a single param sets the length if the
parameter is a number (no coercion is done); otherwise, it is
creates an 1-length Array containing the parameter. Previously
we coerced the parameter to a float.
2020-09-26 14:13:06 -07:00
Mike Welsh 9e13058e04 avm1: Fix list of elements in Array ctor (fix #1195) 2020-09-26 14:13:06 -07:00
David Wendt 6bb6bcab7a core: Store rotations in degrees to avoid floating-point conversion discrepancies. 2020-09-26 14:12:49 -07:00
David Wendt 28bf84bd8b core: Store object scale as percentages to avoid floating point precision problems.
Fixes a specific pattern of preloader design where animations were handled by just making the box bigger every frame until it's 100. Of course, direct equality of f64 is a terrible idea, but it works in Flash, which apparantly must store scale in percentages. So we must, too.
2020-09-26 14:12:49 -07:00
David Wendt f6f084098e tests: Add a test for floating point errors in the AVM1 representation of `_xscale`, `_yscale`, and `_rotation`. 2020-09-26 14:12:49 -07:00
dependabot-preview[bot] c5135fc737 build(deps): bump syn from 1.0.41 to 1.0.42
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.41 to 1.0.42.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.41...1.0.42)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-26 14:11:01 -07:00
dependabot-preview[bot] 0dfac7b1ac build(deps): bump gif from 0.11.0 to 0.11.1
Bumps [gif](https://github.com/image-rs/image-gif) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/image-rs/image-gif/releases)
- [Changelog](https://github.com/image-rs/image-gif/blob/master/Changes.md)
- [Commits](https://github.com/image-rs/image-gif/compare/v0.11.0...v0.11.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-25 13:22:07 -07:00
Mike Welsh 802636fbbf chore: Bump to gif 0.11.0 2020-09-21 18:30:27 -07:00
Luca Weiss 8a8075ca99
avm1: Fix registered function names for Sound object (#1209)
The functions are just stubs currently so this shouldn't change any
behavior.
2020-09-19 16:21:50 -07:00
Nathan Adams 4a83641a6c core: Support \r newlines in texts - fixes #1071, #808 2020-09-19 16:18:35 -07:00
Luca Weiss d5cb396331 *: fix spelling mistakes 2020-09-19 16:17:58 -07:00
Mike Welsh 2f84d468ee text: Default text span color should be black
Previosuly color defaulted to 0% alpha, causing text to be
invisible if the text field did not specify a defualt color.
2020-09-18 18:58:09 -07:00
Mike Welsh 6f2655cf95 tests: Add test for SWF4 string ops 2020-09-17 16:03:51 -07:00
Mike Welsh 7eeba10bef avm1: Clean up SWF4 string ops
Clean up SWF4 string ops:
 * Operate on UTF-16 code units (in SWF6+)
 * StringExtract indices are 1-based
2020-09-17 16:03:51 -07:00
Mike Welsh 4f6c017bc0 avm1: Move utf16 util methods to string_utils 2020-09-17 16:03:51 -07:00
Nathan Adams ef3d5c1538 core: Apply a mask when rendering text, fixes parts of #1167 2020-09-17 16:03:16 -07:00
Nathan Adams e008603426 core: Add draw_rect to the render backend API 2020-09-17 16:03:16 -07:00
Mike Welsh 3cc43265bf core: Always recurse down into movieclips when mouse picking
Was only consdering the world bounds, but buttons can have separate
hit areas that don't actually affect the bounds of the parent clip.
(TODO: Could have keep track of a separate mouse_bounds instead.)

Fixes regression in Mini-Putt 2 (#1120).
2020-09-15 02:34:32 -07:00
Mike Welsh 4593320d36 tests: Add more tests to hittest_shapeflag test 2020-09-15 02:34:32 -07:00
Mike Welsh fe3bf5cb59 core: Implement hit_test_shape for MorphShape 2020-09-15 02:34:32 -07:00
Mike Welsh 4d26ebe9b4 core: Implement hit_test_shape for EditText 2020-09-15 02:34:32 -07:00
Mike Welsh e9a2ef5d82 core: DisplayObject::hit_test_shape now takes UpdateContext
Make default implementation the same as hit_test_bounds.
2020-09-15 02:34:32 -07:00
Mike Welsh 0d111ca92f avm1: _target of root should be /
Also, levels other than 0 should be appened in slash syntax, e.g
_level1/clip
2020-09-15 02:20:24 -07:00
David Wendt f2380d828a chore: Don't capitalize our type arguments. 2020-09-15 02:20:11 -07:00
David Wendt 7e91c45950 avm2: Move trait methods into the AS3 namespace.
`toString`, `toLocaleString`, and `valueOf` are still `public`, because they're not supposed to be trait methods at all.
2020-09-15 02:20:11 -07:00
David Wendt 27eda5cdf1 avm2: Remove `ArrayIterator` trait.
I originally added this with the anticipation that `impl` return syntax only allowed one trait plus OIBITs. This was prior experience in Rust but apparantly the compiler accepts this just fine, so I suppose my defensive coding practice was a bad/outdated idea.
2020-09-15 02:20:11 -07:00
David Wendt de0bc93839 Fix `hasOwnProperty` yielding false on populated non-hole array indicies. 2020-09-15 02:20:11 -07:00
David Wendt e581704559 avm2: `new Array()` should reject negative and `NaN` length arguments as errors. 2020-09-15 02:20:11 -07:00
David Wendt 582df3bd7d avm2: Misc perf fixes and nits in Array globals. 2020-09-15 02:20:11 -07:00
David Wendt 07e14463e2 avm2: Array `join` and `toString` treat `undefined` and `null` as empty strings. 2020-09-15 02:20:11 -07:00
David Wendt 3b7922d222 avm2: Implement `Array.sortOn` 2020-09-15 02:20:11 -07:00
David Wendt 0aa2c50118 avm2: Implement `Array.sort` 2020-09-15 02:20:11 -07:00
David Wendt bb19699739 avm2: Add convenience method for converting a `Value` into an `EnumSet`. 2020-09-15 02:20:11 -07:00
David Wendt a653a62a93 avm2: Add array sorting constants. 2020-09-15 02:20:11 -07:00
David Wendt ca4982029b avm2: Impl `Array.toLocaleString`. 2020-09-15 02:20:11 -07:00
David Wendt 2ae3b6445b avm2: Partially implement `toLocaleString` insamuch as is necessary to run Array tests on it.
This appears to work almost like it's own TObject method; you can run `Object.prototype.toLocaleString` on all sorts of things and it has separate behavior to what the class method for it might be. I have attempted to match Flash Player as best as I can.
2020-09-15 02:20:11 -07:00
David Wendt dbaef812fa avm2: Impl `Array.splice`. 2020-09-15 02:20:11 -07:00
David Wendt 53b564bb52 avm2: Implement `Array.slice`. 2020-09-15 02:20:11 -07:00
David Wendt 685fbc12e0 tests: `Array.reverse`'s test should also include a check for holes. 2020-09-15 02:20:11 -07:00
David Wendt 036f7cbb90 avm2: Implement `Array.shift` and `Array.unshift`.
This also updates `Array.push` to support it's ability to push multiple arguments at once.
2020-09-15 02:20:11 -07:00
David Wendt 879aff3669 avm2: Implement `Array.reverse` 2020-09-15 02:20:11 -07:00
David Wendt 1ce78388a3 avm2: Implement `Array.push` and `Array.pop` 2020-09-15 02:20:11 -07:00
David Wendt 0ece924877 avm2: Implement `indexOf` and `lastIndexOf` 2020-09-15 02:20:11 -07:00
David Wendt 7aa1ab82e4 avm2: Avoid locking the array when running user code.
The array being iterated is explicitly handed to all callbacks, and it is legal for the callback to mutate the array. Hence, we can't actually hold a `Ref` to the array storage when we call user code. Instead, we implement a custom `Iterator` which iterates over the object like user code would.

This actually can't be an `Iterator` impl due to limitations of the underlying trait. Hence, we have to `while let` instead of `for`.
2020-09-15 02:20:11 -07:00
David Wendt 832bbdd711 avm2: Implement `forEach`, `map`, `filter`, `every`, and `some` on `Array`.
This also comes with some refactoring: building the resulting array object and resolving holes is now done in helper methods.
2020-09-15 02:20:11 -07:00
David Wendt 0eeee72be6 avm2: Implement `Array.join`, `Array.toString`, and `Array.valueOf` (w/tests) 2020-09-15 02:20:11 -07:00
David Wendt 79df789028 tests: Add test for `Array.concat`. 2020-09-15 02:20:11 -07:00
David Wendt 75e6018607 tests: Add test for `newarray`. 2020-09-15 02:20:11 -07:00
David Wendt 505018c3b8 avm2: Implement `newarray`. 2020-09-15 02:20:11 -07:00
David Wendt 27793092c2 tests: Add `array_holes` test. 2020-09-15 02:20:11 -07:00