Mike Welsh
dca97afdd7
chore: Remove puremp3 feature
...
Wasn't being used, remove the puremp3 dependency.
2021-05-02 19:31:01 -07:00
Adrian Wielgosik
8ca22c1f02
core: Support for custom context menu items on movie root
2021-05-02 15:28:00 -07:00
Chris Midgley
31911d24ab
tests: replace existing shared object test using mtasc
2021-05-01 17:40:01 -07:00
Chris Midgley
c03bc62074
fix: SharedObject data property is not deleteable
2021-05-01 17:40:01 -07:00
Mike Welsh
e8ec02418b
avm2: Fix Array.splice
...
Fix `Array.splice` in cases where elements are added but not
deleted, and when the starting index is larger than the length
of the array.
2021-04-30 13:48:27 -07:00
Mike Welsh
2a46c72bb2
avm1: Fix Array.splice
...
Clamp the index parameters to the length of the array. This fixes
`[].splice(1, 0, 'obj');` to add the object at the proper
position (0, because the start index 1 is larger than the length).
2021-04-30 13:48:27 -07:00
dependabot-preview[bot]
b57e1a14f0
build(deps): bump syn from 1.0.70 to 1.0.71
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.70 to 1.0.71.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.70...1.0.71 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-28 10:02:43 -07:00
David Wendt
041003f256
avm2: Slot lookups don't need the whole trait list, just the first one we find.
2021-04-28 00:01:47 -07:00
David Wendt
fd08a6ebf6
avm2: Instantiate slot traits on `get_slot`, `set_slot` etc.
...
Previously, we only instantiated slot traits when named as a property, which is only half the picture.
2021-04-28 00:01:47 -07:00
David Wendt
e35d1edbf0
avm2: Allow pulling traits by slot id
2021-04-28 00:01:47 -07:00
David Wendt
07db1786f1
tests: Add a test for AVM2 nested closures (which thus tests `newactivation`)
2021-04-28 00:01:47 -07:00
David Wendt
9318028b52
avm2: `newactivation` should return an object which implements the traits listed in the associated method `body`'s trait list
2021-04-28 00:01:47 -07:00
David Wendt
6c5098d3c7
avm2: Fix order in which `setslot` takes it's parameters
2021-04-28 00:01:47 -07:00
Adrian Wielgosik
5a6117722d
core: Also hide playback controls on single-frame SWFs
2021-04-27 16:42:02 -07:00
Adrian Wielgosik
a1737b5922
avm1: Respect menu.builtInItems, but on root clip only
2021-04-27 16:42:02 -07:00
Adrian Wielgosik
c3a16cb992
avm2: Support Stage.showDefaultContextMenu
2021-04-27 16:42:02 -07:00
Adrian Wielgosik
ce4d66e0f4
avm1: support Stage.showMenu
2021-04-27 16:42:02 -07:00
Adrian Wielgosik
41a126885c
web: Minimal context menu buttons for movie control
2021-04-27 16:42:02 -07:00
TÖRÖK Attila
61fddf530e
core/display_object: Correctly draw videos that have different bounds than the size of their actual frame data
2021-04-27 11:49:16 -07:00
Mike Welsh
1f8434aee6
tests: Add test for Stage.scaleMode/align
2021-04-26 01:15:42 -07:00
Mike Welsh
a57f227bda
core: Implement Stage resize events
2021-04-26 01:15:42 -07:00
Mike Welsh
251fd55567
core: Adjust stage size by DPI factor in NoScale scale mode
2021-04-26 01:15:42 -07:00
Mike Welsh
98befe678e
avm2: Add flash.display.StageScaleMode and Stage.scaleMode
2021-04-26 01:15:42 -07:00
Mike Welsh
80bcf68634
avm1: Add StageScaleMode and StageAlign properties to Stage
2021-04-26 01:15:42 -07:00
Mike Welsh
b4717130e3
core: Add StageScaleMode and StageAlign properties to Stage
2021-04-26 01:15:42 -07:00
David Wendt
a877fe8c67
tests: Add a new test for properties unique to the `Stage`
2021-04-26 01:15:42 -07:00
David Wendt
52c3b0f1bc
avm2: `Stage.color` yields background color alpha (always 0xFF) in the high bits of the u32
2021-04-26 01:15:42 -07:00
David Wendt
41fe51e9db
avm2: Impl `flash.display.StageQuality` enum
2021-04-26 01:15:42 -07:00
David Wendt
93d7f0b450
avm2: Stub `Stage.quality`
2021-04-26 01:15:42 -07:00
David Wendt
327a425fde
avm2: Stub `Stage.allowsFullScreen` and `Stage.allowsFullScreenInteractive`
2021-04-26 01:15:42 -07:00
David Wendt
cb167e0814
avm2: Impl `Stage.stageWidth`/`Stage.stageHeight`, sorta
2021-04-26 01:15:42 -07:00
David Wendt
1ee5bbf7ba
avm2: Impl `Stage.frameRate`
2021-04-26 01:15:42 -07:00
David Wendt
5d8f70d695
avm2: Implement `Stage.focus`
2021-04-26 01:15:42 -07:00
David Wendt
524f5fe57f
avm2: Impl `Stage.color`'s setter
2021-04-26 01:15:42 -07:00
David Wendt
6c6bd74af9
avm2: Impl `Stage.displayState`'s getter
2021-04-26 01:15:42 -07:00
David Wendt
ae080fd65f
avm2: Impl `flash.display.StageDisplayState`
2021-04-26 01:15:42 -07:00
David Wendt
b858f74139
avm2: Impl `Stage.contentsScaleFactor`
2021-04-26 01:15:42 -07:00
David Wendt
247f7e3de4
avm2: Impl `Stage.color`
2021-04-26 01:15:42 -07:00
David Wendt
d7a0d15fd8
avm2: Expose `Stage.browserZoomFactor`
2021-04-26 01:15:42 -07:00
David Wendt
0c6584ca03
core: Store the viewport's scale factor on the stage
2021-04-26 01:15:42 -07:00
David Wendt
98788ef194
avm2: Impl `flash.display.StageAlign`
2021-04-26 01:15:42 -07:00
David Wendt
2a30887660
avm2: Support the half-broken `loaderInfo` on the `Stage`
2021-04-26 01:15:42 -07:00
David Wendt
ef4db9ba16
avm2: Add overrides for every property that cannot be set on the `Stage`.
...
Yes, this includes properties that aren't implemented yet. They'll return a different error, but they'll still error out regardless, so I'm fine with this.
2021-04-26 01:15:42 -07:00
David Wendt
bc9affb09d
tests: Add tests for stage access and basic display object properties
2021-04-26 01:15:42 -07:00
David Wendt
716d492006
avm2: The stage's name should be `null`, not an empty string; and setting it should except.
2021-04-26 01:15:42 -07:00
David Wendt
01f74f6eb1
avm2: Add a convenience method for marking a builtin override trait.
2021-04-26 01:15:42 -07:00
David Wendt
8452e23382
avm2: Allow access to the `Stage`, both directly and indirectly
2021-04-26 01:15:42 -07:00
David Wendt
ba66c62947
core: Ensure `Stage` always has an AVM2 representation
2021-04-26 01:15:42 -07:00
David Wendt
81de112774
avm2: Add `Stage` class stub
2021-04-26 01:15:42 -07:00
David Wendt
7f4a99ca60
core: Add a `root_clip` method for `Stage` and make everything grabbing depth 0 off the stage use it
2021-04-26 01:15:42 -07:00
David Wendt
36e486b1d0
core: We don't need `CollectWrapper` anymore
2021-04-26 01:15:42 -07:00
David Wendt
f6fe0a84a2
core: Move the viewport and stage dimensions into the `Stage`.
2021-04-26 01:15:42 -07:00
David Wendt
c09bd0520c
core: Run all of the steps of a frame update on the `Stage`
2021-04-26 01:15:42 -07:00
David Wendt
b021d04345
core: Correct order of viewport bounds in render context
2021-04-26 01:15:42 -07:00
David Wendt
4e4f1dce26
core: `Stage` should render it's children
2021-04-26 01:15:42 -07:00
David Wendt
7341fa0554
core: Remove the explicit view bounding box and instead have all the culling code ask the `Stage` what it's bounding box is
2021-04-26 01:15:42 -07:00
David Wendt
67724bfc71
core: Move most of the player rendering code into the `Stage`'s render method.
2021-04-26 01:15:42 -07:00
David Wendt
44af21b398
core: `Letterbox` should be `Collect`
2021-04-26 01:15:42 -07:00
David Wendt
6bf3206d95
core: Replace `context.levels` with a root stage
2021-04-26 01:15:42 -07:00
David Wendt
0011753914
core: Add the ability to iterate over the depth list of any container
2021-04-26 01:15:42 -07:00
David Wendt
14430b9eb0
core: Add a `Stage` display object type
2021-04-26 01:15:42 -07:00
Mike Welsh
c422a66aa6
chore: Appease clippy
...
Fix `bool_assert_comparison` and `from_iter_instead_of_collect` lints.
2021-04-24 21:42:30 -07:00
Mike Welsh
d43b033caa
tests: Add tests for BitmapData max size
2021-04-24 16:16:24 -07:00
relrelb
bab0ae8f30
avm1: Limit width and height of BitmapData
2021-04-24 16:16:24 -07:00
relrelb
c78501f2bd
avm1: Fix panic in BitmapData.loadBitmap
...
BitmapData.loadBitmap is not subject to the size limit. That is,
it can load larger bitmaps than the BitmapData constructor.
Fix panic for large bitmaps by not invoking the BitmapData constructor
directly. This should also improve performance.
Do the same for BitmapData.clone.
2021-04-24 16:16:24 -07:00
relrelb
2d3a4910fc
avm1: Correct BitmapData constructor
...
* Extract is_size_valid, which respects 3 different limits:
SWF<=9, SWF10 and SWF>=11.
* Delay is_size_valid check after all arguments coercing.
* Swap the transparency and fill_color parameters of init_pixels.
2021-04-24 16:16:24 -07:00
Mike Welsh
d34b72cc47
web: Expose SWF metadata to JavaScript
...
Add `RufflePlayer.metadata` that exposes the SWF header fields to
JavaScript.
Add `RufflePlayer.readyState` and fire a `loadedmetadata` event
once the metadata is available, mimicking the HTML5 media APIs.
2021-04-23 16:58:24 -07:00
Mike Welsh
33a73c5262
tests: Bump test script timeout
2021-04-23 16:57:28 -07:00
Mike Welsh
d58bc9b5c5
core: Disable script timeout in debug builds
2021-04-23 16:57:28 -07:00
David Wendt
f33976f4c0
avm2: Store symbol / class relationships using the class constructor, not the prototype.
2021-04-23 00:26:10 -07:00
David Wendt
0ee9e0f820
tests: Add a test for constructing symbol classes in AVM2
2021-04-23 00:26:10 -07:00
David Wendt
aa6dc600c0
avm2: Treat construction of symbol classes as symbol instantiation.
2021-04-23 00:26:10 -07:00
David Wendt
815d0fb540
core: Add `DisplayObject` method for setting the AVM2 side of a display object
2021-04-23 00:26:10 -07:00
David Wendt
9b19cc1570
Store the movie associated with a given symbol being constructed.
2021-04-23 00:26:10 -07:00
David Wendt
282508a281
core: Make the AVM2 constructor registry global
2021-04-23 00:26:10 -07:00
David Wendt
b1be111a4e
core: Store constructor prototypes in the constructor registry when defining symbols
2021-04-23 00:26:10 -07:00
David Wendt
555d97006a
core: Add an AVM2 constructor registry
2021-04-23 00:26:10 -07:00
David Wendt
68c270e7c0
avm2: Impl `Eq`, `Hash` for `Object` using ptr values
2021-04-23 00:26:10 -07:00
TÖRÖK Attila
3f583088a2
core/avm1: Coerce Rectangle and Point parameter fields to f64 first
2021-04-21 18:46:03 -07:00
TÖRÖK Attila
22306cc8d9
core/avm1: Switch to i32 in BitmapData.merge(), clamp *_mult parameters
2021-04-21 18:46:03 -07:00
TÖRÖK Attila
40eedb6405
core/avm1: Implement BitmapData.merge()
2021-04-21 18:46:03 -07:00
dependabot-preview[bot]
63e8c0c88a
build(deps): bump syn from 1.0.69 to 1.0.70
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.69 to 1.0.70.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.69...1.0.70 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-21 18:31:39 -07:00
Adrian Wielgosik
8176e0a633
avm2: minor changes to domain memory
...
* Do not use as_bytearray_mut when we don't need mutability
* Set default domain memory size to 1024b.
2021-04-21 15:08:13 -07:00
CUB3D
9812fab9f8
chore: Format and fix clippy lints
2021-04-21 00:33:11 -07:00
CUB3D
7c4eb0d7ff
avm2: Implement ApplicationDomain.domainMemory
2021-04-21 00:33:11 -07:00
CUB3D
b3b1e69fc2
avm2: Store ByteArrayObject in Domain rather than ByteArrayStorage
2021-04-21 00:33:11 -07:00
CUB3D
4dc1210b37
avm2: Use try_into for converting slice->array
2021-04-21 00:33:11 -07:00
CUB3D
98d9bd06b6
avm2: Remove more unused code from test
2021-04-21 00:33:11 -07:00
CUB3D
d6a3b5bfda
avm2: Remove unused code from test
2021-04-21 00:33:11 -07:00
CUB3D
397ceed33c
avm2: Dont panic when domain memory not available
2021-04-21 00:33:11 -07:00
CUB3D
136add866a
chore: Fix clippy lints
2021-04-21 00:33:11 -07:00
CUB3D
63120806bf
avm2: Correct Sxi8 and Sxi16
2021-04-21 00:33:11 -07:00
CUB3D
6d2339b151
avm2: Add tests for Op::Sxi1
2021-04-21 00:33:11 -07:00
CUB3D
f34579926c
chore: Format
2021-04-21 00:33:11 -07:00
CUB3D
99edb5ab2b
avm2: Implement Op::Sxi1
2021-04-21 00:33:11 -07:00
CUB3D
9ffa4f1f50
avm2: Implement Op::Lf64
2021-04-21 00:33:11 -07:00
CUB3D
b4736413fa
avm2: Implement Op::Sf64
2021-04-21 00:33:11 -07:00
CUB3D
2b4becf41f
avm2: Implement Op::Lf32
2021-04-21 00:33:11 -07:00
CUB3D
509392db8e
avm2: Implement Op::Sf32
2021-04-21 00:33:11 -07:00
CUB3D
dce2626482
avm2: Use from/to_le_bytes
2021-04-21 00:33:11 -07:00
CUB3D
35d7c5a7e3
chore: Format
2021-04-21 00:33:11 -07:00
CUB3D
ae9d5fd328
avm2: Implement Op::Li32
2021-04-21 00:33:11 -07:00
CUB3D
951d557a90
avm2: Implement Op::Si32
2021-04-21 00:33:11 -07:00
CUB3D
96ad0e3d00
avm2: Implement Op::Li16
2021-04-21 00:33:11 -07:00
CUB3D
aaaf6ace3e
avm2: Implement Op::Si16
2021-04-21 00:33:11 -07:00
CUB3D
f437539f73
avm2: Some domain memory is available by default and error when range invalid
2021-04-21 00:33:11 -07:00
CUB3D
5a0cdf60bc
avm2: Implement Op::Si8 and Op::Li8 badly
2021-04-21 00:33:11 -07:00
CUB3D
12a198f671
avm2: Implement Op::Coerce and add tests
2021-04-21 00:33:11 -07:00
CUB3D
c2969895b2
avm2: Add domain memory tests
2021-04-21 00:33:11 -07:00
CUB3D
89c01dca18
swf: Add support for AVM2 domain memory opcodes
2021-04-21 00:33:11 -07:00
TÖRÖK Attila
46ddc31254
avm2: Call the super initializer of LoaderInfo after construction
2021-04-19 18:16:47 -07:00
Mike Welsh
cbe685f8d5
tests: Update transform test to verify color transform rounding
2021-04-19 15:47:52 -07:00
Mike Welsh
0552d26551
core: Use Fixed8 and i16 for ColorTransform
...
Use the proper types for ColorTransform:
* Fixed8 (8.8) format for multiplicative component
* i16 format for additive component
This matches the behavior of Flash (for example, alpha only changes
in units of 1/256).
2021-04-19 15:47:52 -07:00
dependabot-preview[bot]
9c466c65da
build(deps): bump syn from 1.0.67 to 1.0.69
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.67 to 1.0.69.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.67...1.0.69 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-18 23:54:37 -07:00
relrelb
cd8ab813a4
avm1: Return an unboxed undefined in `TransformObject` constructor
...
This is now possible thanks to #2415 .
2021-04-17 09:27:29 -07:00
relrelb
6d68460196
tests: Expand funky_function_calls
2021-04-17 09:25:24 -07:00
relrelb
95cffdc2f9
avm1: Pass undefined this for CallMethod with non-string method_name
...
This isn't the most accurate behavior, since it should be an unboxed
Value, but currently it's not possible due to #843 .
2021-04-17 09:25:24 -07:00
relrelb
6a34070e76
tests: Expand sound
...
Check Sound.duration and Sound.getDuration() for detached sounds.
Check rounding behavior of Sound.duration and Sound.getDuration()
behind a comment because NullAudioBackend doesn't respect durations.
TODO: Uncomment it once NullAudioBackend returns real durations.
2021-04-17 09:11:50 -07:00
relrelb
e3478248ac
avm1: Implement Sound.getDuration() and Sound.setDuration()
...
These seem to be undocumented.
Looks like Sound.getDuration() behaves exactly as Sound.duration,
and Sound.setDuration() does nothing.
2021-04-17 09:11:50 -07:00
relrelb
6310e31023
avm1: Sound.duration should return undefined when no sound is attached
...
Previously it returned 0.
2021-04-17 09:11:50 -07:00
relrelb
4d41297b04
avm1: Remove reduntant new_ret_no_self annotation
...
Per https://rust-lang.github.io/rust-clippy/master/#new_ret_no_self ,
`new_ret_no_self` applies only to functions named `new`.
`TObject::create_bare_object` used to be named `new`, but was renamed
in 79af3ffe44
.
2021-04-16 15:25:22 -07:00
relrelb
1f934c5fc6
avm1: Remove redundant newlines
2021-04-16 15:25:22 -07:00
relrelb
dac60da936
avm1: ValueObject::boxed -> coerce_to_object
2021-04-16 15:25:22 -07:00
relrelb
0f8f0986e9
chore: Use matches!(...) in more places
2021-04-16 15:25:22 -07:00
relrelb
9dc63a7831
core: Remove redundant tuple
2021-04-16 15:25:22 -07:00
relrelb
a2e162be0d
avm1: Add Value::is_primitive
...
This provides a more convenient and readable way compared to
using matches!(Value::Object(_)).
2021-04-16 15:25:22 -07:00
relrelb
2ba6cada5b
avm1: Reserve arguments capacity
...
This prevents unnecessary re-allocations.
2021-04-16 15:25:22 -07:00
Chris Midgley
d89f0bbbfe
fix: looks like contentType is ignored (at least in FP6)
2021-04-16 12:36:49 -07:00
Chris Midgley
ba185418b9
chore: fmt
2021-04-16 12:36:49 -07:00
Chris Midgley
6c619495f4
chore: fix warnings
2021-04-16 12:36:49 -07:00
Chris Midgley
8e6bba1525
avm1: implement send_and_load
2021-04-16 12:36:49 -07:00
Chris Midgley
f1b07bd75b
avm1: set contentType on xml; fix initial contentType on load_vars.
2021-04-16 12:36:49 -07:00
dependabot-preview[bot]
f90d58703a
build(deps): bump pretty_assertions from 0.7.1 to 0.7.2
...
Bumps [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions ) from 0.7.1 to 0.7.2.
- [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases )
- [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md )
- [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/compare/v0.7.1...v0.7.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-15 14:30:00 -07:00
Mike Welsh
a45a5c2bcb
avm1: _levelN should shadow children instances with the same name
...
If a child clip is named `_level0`, accessing `_level0` should
return the level and not the child clip.
Move `DisplayObject::get_level_by_path` to `StageObject`, and
change it to return an `Option<Value>`, and return
`Some(Value::Undefined)` if the path is a valid level path but
the level is not occupied. This causes get/set of `_levelN` to
be swallowed, even if the level isn't populated.
2021-04-15 13:49:17 -07:00
Mike Welsh
34886933e5
avm1: Adjust precedence of children in StageObject::get
...
Children instances should shadow display object magic properties.
For example, a child named "_x" will be returned instead of the
parent's _x position in GetMember.
2021-04-15 13:49:17 -07:00
Mike Welsh
9224e85a2d
avm1: Delete2 returns true only if a property was actually deleted
...
This was incorrectly returning true for children instances
(`delete "clip"`).
2021-04-15 13:49:17 -07:00
Mike Welsh
d04989cf49
tests: Update stage_object_children test
...
Add a few tests for shadowing of child instances vs. display
object magic properties (for example, when a child clip is named
"_x" or "_level0").
2021-04-15 13:49:17 -07:00
desuwa
0d6c548be4
tests: Add tests for Player::run_actions at timer callbacks.
2021-04-15 13:48:27 -07:00
desuwa
3030f2098a
avm1: Run Player::run_actions after every timer callback.
2021-04-15 13:48:27 -07:00
EmperorBale
04d80e5e4e
chore: Fix more typos
2021-04-15 00:02:40 -07:00
EmperorBale
0ea02919b3
chore: Fix typo
2021-04-15 00:02:40 -07:00
EmperorBale
d227c6cbce
chore: Fix formatting
2021-04-15 00:02:40 -07:00
EmperorBale
153da75304
tests: Add test for IsType
2021-04-15 00:02:40 -07:00
EmperorBale
cbf8d77006
avm2: Fix IsType
2021-04-15 00:02:40 -07:00
EmperorBale
e4ba4b074a
tests: Add test for AsType
2021-04-15 00:02:40 -07:00
EmperorBale
ca2709f594
avm2: Implement AsType
2021-04-15 00:02:40 -07:00
EmperorBale
17acebb108
chore: Fix formatting
2021-04-15 00:02:40 -07:00
EmperorBale
f459e18b1a
tests: Update regression tests
2021-04-15 00:02:40 -07:00
EmperorBale
1d0c2b78b2
tests: Add test for AsTypeLate
2021-04-15 00:02:40 -07:00
EmperorBale
c0a56b14c0
avm2: Implement AsTypeLate
2021-04-15 00:02:40 -07:00
Mike Welsh
b9d84c0a82
chore: Appease clippy
...
Honor the branches-sharing-code lint.
2021-04-15 00:02:27 -07:00
Mike Welsh
d87be39e3c
avm2: Don't parse "inf" as Infinity
2021-04-14 21:51:48 -07:00
Mike Welsh
b6945395a8
avm1: Don't parse "inf" as Infinity
...
Rust nightly 4/13 allows f64::parse to handle "infinity", case
insensitive. This broke cases such as `Number("Infinity")`, which
should return `NaN` in AVM1.
Additionally, Rust will now print "-0" for negative zero, when
previously it would print "0".
* Return NaN for inf cases ("inf", "-Infinity", "+INF", etc.)
* Add a test for `Number("inf")` (this was also incorrect before
the latest nightly)
* Add a special case for zero in `f64_to_string` to ensure
that -0.0 gets coerced to "0".
For more info, see:
https://github.com/rust-lang/rfcs/issues/1074
2021-04-14 21:51:48 -07:00
Adrian Wielgosik
b2bed7a18d
avm1: Add missing clearTimeout() ( fix #4003 )
2021-04-14 11:02:04 -07:00
Moulins
f9bbe96812
core: Remove extra Option/Results from XmlNode getters
...
This removes some special cases and simplifies the code.
2021-04-11 14:16:48 -07:00
Moulins
ae1a01d181
avm1: Allow XMLNode reparenting ( closes #3962 )
...
`XMLNode.{appendChild, insertNode}` can now be used to move
child nodes from a parent to another.
There are two special cases:
- if the node is already a child of the destination, nothing happens
- if moving the node would create a cycle, nothing happens
2021-04-11 14:16:48 -07:00
relrelb
20d6fcc128
chore: Remove unnecessary type annotations
2021-04-10 18:39:16 -07:00
Mike Welsh
11f40384da
tests: Add test for loading into _root
2021-04-10 13:48:05 -07:00
Mike Welsh
aa0707411c
avm1: Update movie parameters when loading into _root/_level0
...
The movie framerate and dimensions should be changed when a movie
is loaded into _root or level 0.
2021-04-10 13:48:05 -07:00
David Wendt
7a781179aa
core: Move all of the remaining AVM2 object allocation and/or construction into the `construct_frame` step.
2021-04-09 22:24:22 -07:00
David Wendt
dc5b30e460
core: Remove "constructor ran" flag now that we can handle that with a local bool
2021-04-09 22:24:22 -07:00
David Wendt
27d09084fb
core: Use the library's AVM type to determine how to name the root.
...
We cannot check it's constructed AVM value anymore because it is now named before construction.
2021-04-09 22:24:22 -07:00
David Wendt
ebc5c3dd64
avm2: Ensure that objects are only *ever* constructed at frame construction time.
...
This ensures that root movie classes see their children in their constructor.
2021-04-09 22:24:22 -07:00
desuwa
e8de3a5a20
tests: Add tests for `MovieClip.hitTest()` with shapeflag and masks.
2021-04-09 22:11:07 -07:00
desuwa
4f90b9d161
avm1: Support masks when mouse-picking.
2021-04-09 22:11:07 -07:00
relrelb
f8b589fc24
core: Fix panic in remove_invalid_jpeg_data
...
`data` could be shorter than 4 bytes.
2021-04-09 14:47:19 -07:00
desuwa
755409673b
avm2: Add tests for set_width / set_height setting the scale to non-finite values.
2021-04-07 17:42:28 -06:00
desuwa
3c2d467a5f
avm1: Add tests for set_width / set_height setting the scale to non-finite values.
2021-04-07 17:42:28 -06:00
desuwa
fa1fde7083
core: Ensure the new scale is finite when setting the width / height of display objects.
2021-04-07 17:42:28 -06:00
desuwa
b7bf8334b2
core: Run `update_drag` earlier in the update cycle. Fix #1511
2021-04-06 15:48:06 -06:00
relrelb
732efb27c4
render: Fix RGB15 bitmaps decoding
...
Each row should be padded to 2.
2021-04-05 20:10:35 -06:00
David Wendt
5d198952e8
chore: Fix merge conflict mis-resolution
2021-04-05 16:18:37 -06:00
David Wendt
5cba07111e
avm2: Impl `LoaderInfo.parameters`
2021-04-05 16:18:37 -06:00
David Wendt
de1b0d4d0c
core: Add support for an explicit loader URL (though nothing sets it yet) and expose it in `LoaderInfo`.
2021-04-05 16:18:37 -06:00
David Wendt
4eee8be911
avm2: Impl `SWFVersion` enumeration
2021-04-05 16:18:37 -06:00
David Wendt
4c314a47cc
avm2: Impl `LoaderInfo.bytes`
2021-04-05 16:18:37 -06:00
David Wendt
a9328b228f
avm2: Allow writing to `ByteArrayStorage`
2021-04-05 16:18:37 -06:00
David Wendt
f61ea0b290
chore: Clippy beta/nightly compliance
2021-04-05 16:18:37 -06:00
David Wendt
46bf1b33c4
avm2: Impl `LoaderInfo.width`
2021-04-05 16:18:37 -06:00
David Wendt
28a1cb4308
avm2: Impl `LoaderInfo.url`
2021-04-05 16:18:37 -06:00
David Wendt
5941d6cf66
avm2: Impl `LoaderInfo.swfVersion`
2021-04-05 16:18:37 -06:00
David Wendt
6814fb9c22
avm2: Stub `LoaderInfo.isURLInaccessible`
2021-04-05 16:18:37 -06:00
David Wendt
b6e31d8be5
avm2: Impl `LoaderInfo.height`
2021-04-05 16:18:37 -06:00
David Wendt
e795da0358
avm2: Impl `LoaderInfo.frameRate`
2021-04-05 16:18:37 -06:00
David Wendt
cbd167fd6c
avm2: Stub `LoaderInfo.contentType`
2021-04-05 16:18:37 -06:00
David Wendt
76c563146d
tests: Grab `contentType` on frame two
2021-04-05 16:18:37 -06:00
David Wendt
7b7d250ce9
avm2: This is a getter, not a method
2021-04-05 16:18:37 -06:00
David Wendt
2a01260f52
avm2: `bytesLoaded` etc reports the compressed file length, not the uncompressed length
2021-04-05 16:18:37 -06:00
David Wendt
d0ad894f70
avm2: Impl `LoaderInfo.content`
2021-04-05 16:18:37 -06:00
David Wendt
b4cb01d2c9
avm2: Impl `LoaderInfo.bytesTotal`, and `.bytesLoaded`
...
`bytesLoaded` is currently aliased to `bytesTotal` as we do not yet support streaming loads
2021-04-05 16:18:37 -06:00
David Wendt
55e448ebaa
avm2: Impl `LoaderInfo.applicationDomain`
2021-04-05 16:18:37 -06:00
David Wendt
c156cd2a16
tests: Add tests for properties that are only accessible on frame 2
2021-04-05 16:18:37 -06:00
David Wendt
12dcfe7c62
avm2: Impl `LoaderInfo.actionScriptVersion`
2021-04-05 16:18:37 -06:00
David Wendt
1a7b33a1af
avm2: Impl `ActionScriptVersion`
2021-04-05 16:18:37 -06:00
David Wendt
a492c4db4d
tests: Add a test for `LoaderInfo`'s properties
2021-04-05 16:18:37 -06:00
David Wendt
fc26c26d1d
avm2: Allow access to `loaderInfo` on root movies
2021-04-05 16:18:37 -06:00
David Wendt
60c92dde49
avm2: Add Loader Info class & object type
2021-04-05 16:18:37 -06:00
CUB3D
e2f124ee34
avm2: Rename current_position -> instruction_start
2021-04-03 16:37:47 -06:00
CUB3D
c22ebc1de3
chore: Format on stable
2021-04-03 16:37:47 -06:00
CUB3D
d5c2e5559b
avm2: Don't mutably borrow for pos()
2021-04-03 16:37:47 -06:00
CUB3D
96f89a1643
avm2: Implement Op::LookupSwitch
2021-04-03 16:37:47 -06:00
relrelb
2d37f4d23e
avm1: Migrate `search_prototype` to primitive prototype
2021-04-03 12:40:05 -06:00
relrelb
bbded90697
avm1: Rename proto_value to proto
2021-04-01 17:06:07 -06:00
relrelb
89679bba65
avm1: Delete proto and set_proto
...
In favor of the new proto_value and set_proto_value pair.
In the next commit proto_value and set_proto_value will be renamed
to proto and set_proto.
2021-04-01 17:06:07 -06:00
relrelb
2c1dfea3ce
avm1: Migrate Player to proto_value
2021-04-01 17:06:07 -06:00
relrelb
76d80061a7
avm1: Migrate Object to proto_value
2021-04-01 17:06:07 -06:00
relrelb
e712a4fd59
avm1: Migrate FunctionObject to proto_value
2021-04-01 17:06:07 -06:00
relrelb
dc174b9d9f
avm1: Migrate StageObject to proto_value
2021-04-01 17:06:07 -06:00
relrelb
be60aa5941
avm1: Migrate XmlIdMapObject to proto_value
2021-04-01 17:06:07 -06:00
relrelb
ea52562d06
avm1: Migrate XmlAttributesObject to proto_value
2021-04-01 17:06:07 -06:00
relrelb
161db474a2
avm1: Migrate SuperObject to proto_value
2021-04-01 17:06:07 -06:00
relrelb
766a5db31c
avm1: Migrate ScriptObject to proto_value
2021-04-01 17:06:07 -06:00
relrelb
18a32424bd
amv1: Migrate custom_object.rs to proto_value
2021-04-01 17:06:07 -06:00
CUB3D
209b9cec36
chore: Format
2021-03-31 18:36:24 -06:00
CUB3D
ecbf6118bb
avm2: Update tests
2021-03-31 18:36:24 -06:00
CUB3D
9453743f9f
avm2: Add test for Op::EscXElem
2021-03-31 18:36:24 -06:00
CUB3D
0ea564f75c
avm2: Implement Op::EscXAttr and Op::EscXElem
2021-03-31 18:36:24 -06:00
relrelb
e453cbf0ef
tests: Expand object_prototypes
2021-03-31 18:04:52 -06:00
relrelb
e5660bc0c7
avm1: Allow primitive prototypes
...
Prototypes can be primitive, not just objects. However, TObject's
proto() and set_proto() work with Object and not Value. To allow
easier and more incremental migration from Object to Value, this
commit introduces a new pair of proto_value/set_proto_value functions
in TObject, preserving the existing proto/set_proto functions.
Both pairs have default implementations, so it's enough to implement
only one pair in each TObject implementation.
For now only ScriptObject uses the new pair, which fixes the behavior
of incorrectly coercing __proto__ to object.
Follow-up migration plan:
1. Replace all old proto/set_proto implementations by the new
proto_value/set_proto_value in all TObject implementations on a
one-by-one basis.
2. After proto/set_proto become unused, delete them and rename
proto_value/set_proto_value to proto/set_proto for more concise code.
2021-03-31 18:04:52 -06:00
relrelb
014e85b1f0
tests: Expand funky_function_calls
2021-03-31 17:59:58 -06:00
relrelb
5beb0164dd
tests: Cleanup funky_function_calls
2021-03-31 17:59:58 -06:00
relrelb
a3727e0727
avm1: Fix "this" argument conversion in Function.prototype.{call,apply}
...
The "this" argument should fall-back to the global object only for
undefined or null. Other primitives should be coerced to an object
rather than falling-back to the global object.
As a drive-by replace `Vec::new` by `Vec::with_capacity` in
`Function.prototype.apply` to minimize unnecessary reallocations.
2021-03-31 17:59:58 -06:00
CUB3D
8d68dcb562
avm2: Update tests
2021-03-29 20:46:02 -06:00
CUB3D
68527c13da
avm2: Implement flash.utils.getTimer
2021-03-29 20:46:02 -06:00
dependabot-preview[bot]
23af83f923
build(deps): bump syn from 1.0.64 to 1.0.65
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.64 to 1.0.65.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.64...1.0.65 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-27 01:40:26 -07:00
relrelb
7e1acce150
core: Fix build without default features
...
Previously `cargo build --no-default-features` failed because then
neither implementation of `Mp3Decoder` is chosen.
Fix that by not handling mp3 sounds at all in that case.
2021-03-27 01:40:11 -07:00
Mike Welsh
f96a414036
avm2: Lazily initialize Graphics object
...
Initialize a Sprite/Shape's Graphics object on the first access,
so that `shape.graphics == shape.graphics` is `true`.
2021-03-24 13:18:06 -07:00
Mike Welsh
040da925e4
avm2: Fix incorrect color in drawing API
2021-03-24 13:18:06 -07:00
Mike Welsh
9a08b9ae4f
avm2: flash.display.Graphics is final
2021-03-24 13:18:06 -07:00
David Wendt
df466dfba1
core: Start with an empty drawing when a `Shape` is converted into a `Drawing`.
2021-03-24 13:18:06 -07:00
David Wendt
b739b8d786
core: Retain the original `swf::Shape` until dynamic behavior is needed, upon which we switch to using a `Drawing`.
2021-03-24 13:18:06 -07:00
David Wendt
ff028de8de
core: `Drawing` should accept a SWF movie to pull bitmaps from
2021-03-24 13:18:06 -07:00
David Wendt
4238d8bd2a
tests: Add another test for drawing on `MovieClip`
2021-03-24 13:18:06 -07:00
David Wendt
1d57eee369
tests: Add a test for shape drawing
2021-03-24 13:18:06 -07:00
David Wendt
1d64f38bb7
avm2: Impl `drawRect`
2021-03-24 13:18:06 -07:00
David Wendt
60f4f2c534
core: `Graphic` should expose it's `Drawing` for external access
2021-03-24 13:18:06 -07:00
David Wendt
85ee005c0f
core: `Graphic` should always use it's stored `Drawing`'s bounds
2021-03-24 13:18:06 -07:00
David Wendt
e3f2d0f213
avm2: Allow constructing new `Shape`s.
2021-03-24 13:18:06 -07:00
David Wendt
62a779444d
avm2: `graphics` is a `Sprite` property, not a `MovieClip` property
2021-03-24 13:18:06 -07:00
David Wendt
5e7327d041
avm2: Allow drawing on `Shape`s.
2021-03-24 13:18:06 -07:00
David Wendt
e8b6d1a52a
core: Migrate clip drawing commands to exposing the internal `Drawing` to mutation
2021-03-24 13:18:06 -07:00
David Wendt
1a6f401f1f
avm2: Implement `Graphics.moveTo`
2021-03-24 13:18:06 -07:00
David Wendt
15d3a1e99d
avm2: Implement `Graphics.lineTo`
2021-03-24 13:18:06 -07:00
David Wendt
9464a8800a
avm2: Implement `CapsStyle`
2021-03-24 13:18:06 -07:00
David Wendt
f7f98cc69e
avm2: Implement `LineScaleMode`
2021-03-24 13:18:06 -07:00
David Wendt
582d2447cd
avm2: Implement `JointStyle`
2021-03-24 13:18:06 -07:00
David Wendt
6396b90890
avm2: Implement `Graphics.lineStyle`
2021-03-24 13:18:06 -07:00
David Wendt
41ad756792
avm2: Implement `Graphics.endFill`
2021-03-24 13:18:06 -07:00
David Wendt
3dfeeacfcc
avm2: Implement `Graphics.curveTo`
2021-03-24 13:18:06 -07:00
David Wendt
71b6bca100
avm2: Implement `Graphics.clear`
2021-03-24 13:18:06 -07:00
David Wendt
f1febe33b9
avm2: Implement `Graphics.beginFill`
2021-03-24 13:18:06 -07:00
David Wendt
124e144d02
avm2: Add a class for `graphics`
2021-03-24 13:18:06 -07:00
dependabot-preview[bot]
20b2e55171
build(deps): bump gif from 0.11.1 to 0.11.2
...
Bumps [gif](https://github.com/image-rs/image-gif ) from 0.11.1 to 0.11.2.
- [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.1...v0.11.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-23 10:03:59 -07:00
dependabot-preview[bot]
19d57941ee
build(deps): bump serde from 1.0.124 to 1.0.125
...
Bumps [serde](https://github.com/serde-rs/serde ) from 1.0.124 to 1.0.125.
- [Release notes](https://github.com/serde-rs/serde/releases )
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.124...v1.0.125 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-23 10:03:17 -07:00
Adrian Wielgosik
c084d575f4
tests: Speed up builds of regression tests
2021-03-20 14:50:57 -07:00
Adrian Wielgosik
2d1c60e02e
avm1: Fix binary operators not returning signed values
...
Also enabled AVM2 test that was forgotten before.
2021-03-20 14:49:55 -07:00
EmperorBale
ac9d27b2fd
avm1: Avoid panic when setMask called with no arguments ( fix #3298 )
2021-03-19 17:25:58 -07:00
Chris Midgley
aa94f6570e
avm1: fix String.substr behaviour for negative lengths ( fix #3626 )
2021-03-19 14:32:04 -07:00
David Wendt
05dc538a25
avm2: Use the actual `FromIterator` trait
2021-03-19 12:39:57 -07:00
David Wendt
1baadb93c2
chore: cargo fmt is fickle
2021-03-19 12:39:57 -07:00
David Wendt
a40755154d
avm2: `TextField` and `TextFormat` are sealed (non-dynamic) classes
2021-03-19 12:39:57 -07:00
David Wendt
6deebf0733
tests: approx the `leading` and `font_size` tests, and increase the epsilon on `autosize` by 1px.
2021-03-19 12:39:57 -07:00
David Wendt
a05423d48c
avm2: Setting a given text property also sets or resets the `html` mode (since it's not a separate property like in AS2)
2021-03-19 12:39:57 -07:00
David Wendt
f5268198b0
avm2: Don't round text metrics (`textWidth` and `textHeight`)
2021-03-19 12:39:57 -07:00
David Wendt
f908eb65fc
tests: Port AS2 edittext tests to AS3.
2021-03-19 12:39:57 -07:00
David Wendt
f188306f4f
avm2: `setTextFormat` is range-checked
2021-03-19 12:39:57 -07:00
David Wendt
78c519cce0
avm2: Don't except when creating a dynamic TextField.
2021-03-19 12:39:57 -07:00
David Wendt
4ef01000a8
avm2: Impl `TextField.setTextFormat`
2021-03-19 12:39:57 -07:00
David Wendt
a115db49ba
avm2: Impl `TextField.setSelection`
2021-03-19 12:39:57 -07:00
David Wendt
7902914aa4
avm2: Impl `TextField.replaceText`
2021-03-19 12:39:57 -07:00
David Wendt
c22f30fdf0
avm2: Impl `TextField.replaceSelectedText`
2021-03-19 12:39:57 -07:00
David Wendt
b4d97ca183
avm2: Impl `TextField.getTextFormat`
2021-03-19 12:39:57 -07:00
David Wendt
f45c9d1889
avm2: Impl `TextField.appendText`
2021-03-19 12:39:57 -07:00
David Wendt
42f717deb8
avm2: Impl `TextField.wordWrap`
2021-03-19 12:39:57 -07:00
David Wendt
4bfc3cfda4
avm2: Impl `TextField.type`
2021-03-19 12:39:57 -07:00
David Wendt
1c2ef3154a
avm2: Impl `TextFieldType`
2021-03-19 12:39:57 -07:00
David Wendt
da563266d5
avm2: Impl `TextField.textHeight` and `TextField.textWidth`
2021-03-19 12:39:57 -07:00
David Wendt
8165aa5c4a
avm2: Impl `TextField.textColor`
2021-03-19 12:39:57 -07:00
David Wendt
c0a2547be3
avm2: Impl `TextField.text`
2021-03-19 12:39:57 -07:00
David Wendt
dee937ac3a
avm2: Impl `TextField.selectable`
2021-03-19 12:39:57 -07:00
David Wendt
b6a1bf80c1
avm2: Impl `TextField.multiline`
2021-03-19 12:39:57 -07:00
David Wendt
053b6bd4cc
avm2: Impl `TextField.length`
2021-03-19 12:39:57 -07:00
David Wendt
1ce868c51e
avm2: Impl `TextField.htmlText`
2021-03-19 12:39:57 -07:00
David Wendt
89c131bf52
avm2: Impl `TextField.embedFonts`
...
This assumes `embedFonts` is the opposite of device fonts, which sounds reasonable.
2021-03-19 12:39:57 -07:00
David Wendt
62ec106afb
avm2: Impl `TextField.displayAsPassword`
2021-03-19 12:39:57 -07:00
David Wendt
fa5145b884
avm2: Impl `TextField.defaultTextFormat`
2021-03-19 12:39:57 -07:00
David Wendt
3d8bf90794
core: Also allow converting `TextFormat` back into an AVM2 object.
2021-03-19 12:39:57 -07:00
David Wendt
3d2d2072af
avm2: Impl `TextFormatAlign`
2021-03-19 12:39:57 -07:00
David Wendt
e10726ef1c
core: Add utilities for converting an AVM2 object into a `TextFormat`
2021-03-19 12:39:57 -07:00
David Wendt
50f992b9e6
avm2: Implement `TextField.borderColor`
2021-03-19 12:39:57 -07:00
David Wendt
8913297514
avm2: Fix type of `TextField.backgroundColor`
2021-03-19 12:39:57 -07:00
David Wendt
8d1e0992b5
avm2: Impl `TextField.border`
2021-03-19 12:39:57 -07:00
David Wendt
436b3b2ed3
avm2: Impl `TextField.backgroundColor`
2021-03-19 12:39:57 -07:00
David Wendt
a84acd55c3
avm2: Impl `TextFieldAutoSize`
2021-03-19 12:39:57 -07:00
David Wendt
e35f66fafe
avm2: Impl `TextField.autoSize`
2021-03-19 12:39:57 -07:00
David Wendt
b6adc18c9c
avm2: Impl `flash.text.TextFormat`
2021-03-19 12:39:57 -07:00
David Wendt
f44e54246d
avm2: Text fields on AVM2 movies should have AVM2 objects.
2021-03-19 12:39:57 -07:00
David Wendt
9e739f8ceb
avm2: Ensure constructed text fields have a DisplayObject side
2021-03-19 12:39:57 -07:00
David Wendt
b71286f1c4
avm2: Stub `flash.text.TextField`
2021-03-19 12:39:57 -07:00
relrelb
cdb2c279c0
avm2: Implement Nop
2021-03-19 12:39:23 -07:00
relrelb
72626825d3
tests: Expand bitmap_data
2021-03-18 22:04:39 -07:00
relrelb
3b6f0f0ced
avm1: Fix color_bounds_rect
2021-03-18 22:04:39 -07:00
Aaron Hill
d3744d28df
Derive `Collect` for `ActionQueue`
2021-03-18 21:56:04 -07:00
dependabot-preview[bot]
069096e3e7
build(deps): bump syn from 1.0.63 to 1.0.64
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.63 to 1.0.64.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.63...1.0.64 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-18 18:33:14 -07:00
Callum Thomson
a570d96433
avm2: Implement flash.geom.Point ( #3681 )
2021-03-18 12:03:04 -07:00
Adrian Wielgosik
1aa77b04fe
avm1: Reduce frequency of timeout checks by 10+ times
2021-03-13 01:19:58 -08:00
relrelb
d16d142c60
chore: Appease clippy
2021-03-13 00:56:04 -08:00
relrelb
e594f602b6
chore: Twips::new(0) -> Twips::zero()
2021-03-13 00:56:04 -08:00
dependabot-preview[bot]
934f95cd52
build(deps): bump syn from 1.0.62 to 1.0.63
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.62 to 1.0.63.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.62...1.0.63 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 12:25:56 -08:00
dependabot-preview[bot]
8bd13203a1
build(deps): bump pretty_assertions from 0.6.1 to 0.7.1
...
Bumps [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions ) from 0.6.1 to 0.7.1.
- [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases )
- [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md )
- [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/compare/v0.6.1...v0.7.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 12:25:47 -08:00
relrelb
866e143073
chore: Cleanup bounds related code
2021-03-08 14:34:26 -08:00
EmperorBale
4d7b2fa1b9
avm1: Fix #3446
...
Thanks!
2021-03-08 00:52:35 -08:00
TÖRÖK Attila
339d0330a2
avm1: Fix seeking
...
The problem was most likely with negative relative offsets
2021-03-08 00:49:16 -08:00
relrelb
8f21c17683
chore: Rename MutationContext parameters to gc_context
2021-03-06 23:30:06 -08:00
relrelb
8318d4d0ed
chore: Remove unnecessary context parameters
2021-03-06 23:30:06 -08:00
relrelb
fff6eb2ffd
chore: Use bitflags set method
2021-03-06 23:30:06 -08:00
dependabot-preview[bot]
d8c140fce1
build(deps): bump syn from 1.0.61 to 1.0.62
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.61 to 1.0.62.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.61...1.0.62 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-06 23:28:38 -08:00
dependabot-preview[bot]
c4af8114d0
build(deps): bump serde from 1.0.123 to 1.0.124
...
Bumps [serde](https://github.com/serde-rs/serde ) from 1.0.123 to 1.0.124.
- [Release notes](https://github.com/serde-rs/serde/releases )
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.123...v1.0.124 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-05 22:29:54 -08:00
EmperorBale
b68eeeae26
avm2: Implement ByteArray
2021-03-05 15:01:02 -08:00
desuwa
0d98fe8b7c
core: Clear masker/maskee properties when unloading objects
2021-03-05 14:15:25 -08:00
dependabot-preview[bot]
b586c7f74e
build(deps): bump indexmap from 1.6.1 to 1.6.2
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.6.1...1.6.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-05 14:10:36 -08:00
dependabot-preview[bot]
b6559214b8
build(deps): bump syn from 1.0.60 to 1.0.61
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.60 to 1.0.61.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.60...1.0.61 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-05 10:31:55 -08:00
TÖRÖK Attila
873736950e
core/avm1: Implement BitmapData.paletteMap()
2021-03-03 05:26:24 -08:00
paq
922998b4a2
tests: Add test for RegExp's exec
2021-03-03 03:37:34 -08:00
paq
71588b32f1
tests: Add test for RegExp's test
2021-03-03 03:37:34 -08:00
paq
ae2de6315d
tests: AVM2 RegExp constructor and flags
2021-03-03 03:37:34 -08:00
paq
d866f73c5e
avm2: Implement RegExp
2021-03-03 03:37:34 -08:00
paq
b8c1f1627a
chore: Add `regress` crate for implementing RegExp class.
2021-03-03 03:37:34 -08:00
David Wendt
999100a332
avm2: Only track broadcast lists for events that are actually broadcasts.
2021-03-03 03:08:01 -08:00
David Wendt
540a68fb68
avm2: Grant each event it's own, separate broadcast list.
2021-03-03 03:08:01 -08:00
David Wendt
8e8de09f63
core: Ensure absolutely nothing runs in frame scripts unless the object is AVM2.
2021-03-03 03:08:01 -08:00
David Wendt
d90ad1ab08
core: Account for the fact that AVM2 constructs objects far earlier than the frame number advances.
...
This is most certainly *not* the correct behavior; though it does work. If I track the frame number in event handlers we can see it change before `enterFrame` is broadcast. However, when I tried to do that, all hell broke loose and every AVM1 and AVM2 test failed (gating the behavior to AVM2 did *not* help).
2021-03-03 03:08:01 -08:00
David Wendt
a5b4e168d3
avm2: Stub `flash.display.Shape`.
2021-03-03 03:08:01 -08:00
David Wendt
d157a9995b
core: When a programmatic goto happens, *all* frame scripts run immediately.
2021-03-03 03:08:01 -08:00
David Wendt
452d878cd9
core: When triggered by ActionScript, clip gotos should trigger AS3 frame lifecycle events.
...
For some reason, only *some* of the events actually trigger; notably programmatic gotos do not trigger `enterFrame`.
Implicit gotos (like looping around to frame 1) also do not trigger frame scripts; they instead run at the usual time.
2021-03-03 03:08:01 -08:00
David Wendt
c9b68f600c
core: Avoid skipping queued script frames in the case where a frame script queues up additional frame scripts via gotos
2021-03-03 03:08:01 -08:00
David Wendt
f3a8eb821f
core: Gotos still trigger new frame scripts
2021-03-03 03:08:01 -08:00
David Wendt
e9f8636fe5
core: Frame scripts should run immediately and not queue
2021-03-03 03:08:01 -08:00
David Wendt
dc499a13a2
core: Gotos do not issue frame progression events on their own.
2021-03-03 03:08:01 -08:00
David Wendt
69e8a33a8e
Debug event dispatches.
2021-03-03 03:08:01 -08:00
David Wendt
a2d56016cb
avm2: Don't except when dispatching events on unconstructed objects.
2021-03-03 03:08:01 -08:00
David Wendt
50546512fe
core: Add a separate construct step before running display objects.
...
This appears to only be in use for AVM2. Objects placed on a given frame are constructed before anything else happens with it's parent - even it's constructor being called. This involves splitting AVM2 up into a bunch of steps that really don't make sense for AVM1 content. Hence, `construct_frame` is a no-op for AVM1 and pre-running the first frame when instantiated is AVM1 exclusive now.
2021-03-03 03:08:01 -08:00
David Wendt
a91273530f
tests: Display events tests should log construction events
2021-03-03 03:08:01 -08:00
David Wendt
a308b9d4f9
Re-dispatch the added event after post-instantiating an object since the automatic dispatch happens too early
2021-03-03 03:08:01 -08:00
David Wendt
ac6a206257
Fire `exitFrame`, `enterFrame`, and `frameConstructed` events as broadcasts.
2021-03-03 03:08:01 -08:00
David Wendt
d1ffa3254b
Store a list of every constructed event dispatcher so we can broadcast events on them.
2021-03-03 03:08:01 -08:00
David Wendt
731c18ad80
avm2: Issue (or attempt to issue) events for entering, exiting, and constructing, a frame.
2021-03-03 03:08:01 -08:00
David Wendt
2e38caafff
tests: Add further tests for various timeline interaction scenarios and events
2021-03-03 03:08:01 -08:00
David Wendt
3df97d8da2
avm2: Stub `System.gc`.
...
Our current garbage collector design precludes the ability to actually collect garbage during player updates, so this is a no-op.
2021-03-03 03:08:01 -08:00
David Wendt
464f388324
avm2: Unstaged display objects are treated as unrooted.
2021-03-03 03:08:01 -08:00
David Wendt
279f2d0652
core: Re-allow reinsertions into the same parent (but still gate off the extra events it would otherwise use)
2021-03-03 03:08:01 -08:00
David Wendt
cea65f95db
avm2: Dispatch `addedToStage` and `removedFromStage` events
2021-03-03 03:08:01 -08:00
David Wendt
7f78bfa51d
core: Add a utility method to check if a display object is rooted to the current stage
2021-03-03 03:08:01 -08:00
David Wendt
5acaf0bd01
core: `iter_render_list` returns a non-locking iterator and should be documented as such.
2021-03-03 03:08:01 -08:00
David Wendt
094563e28f
tests: Add a (currently failing) test for the execution order of various events in the presence of programmed display tree manipulations.
2021-03-03 03:08:01 -08:00
David Wendt
df5520f3e0
avm2: Dispatch `added` and `removed` events
2021-03-03 03:08:01 -08:00
David Wendt
76ef0d4740
avm2: Event phase should be counted from 1 in `valueOf`.
2021-03-03 03:08:01 -08:00
David Wendt
c4a5c6f4d3
avm2: Constructed events start in phase 2, not 3
2021-03-03 03:08:01 -08:00
David Wendt
4521c2b599
avm2: Manually-constructed movie clips (and their subclasses) should be accessible from the display object tree.
2021-03-03 03:08:01 -08:00
David Wendt
63af38be9a
avm2: Add convenience method for natively-dispatched events.
2021-03-03 03:08:01 -08:00
Adrian Wielgosik
14e0980226
avm1: Implement getInstanceAtDepth
2021-03-01 15:31:30 -08:00
Mads Marquart
24780003e7
swf: Deduplicate different read methods
2021-02-27 17:04:42 -08:00
Mads Marquart
dad21d4398
swf: Make avm2 Reader operate directly with byte slices
2021-02-27 17:04:42 -08:00
Tempy111
00e1f36984
core: Add missing support for Tab keycode
2021-02-27 16:44:39 -08:00
Mike Welsh
3099914374
chore: Appease clippy
2021-02-27 16:10:46 -08:00
dependabot-preview[bot]
8500a676cf
build(deps): bump quick-xml from 0.20.0 to 0.22.0
...
Bumps [quick-xml](https://github.com/tafia/quick-xml ) from 0.20.0 to 0.22.0.
- [Release notes](https://github.com/tafia/quick-xml/releases )
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md )
- [Commits](https://github.com/tafia/quick-xml/compare/v0.20.0...v0.22.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-26 11:44:48 -08:00
Aaron Hill
ff1aff607a
avm1: Explicitly drop `obj` when it is no longer needed
...
Explicitly drop `obj` when it is no longer needed to avoid borrow errors, and add a test case similar to #3169 .
Co-authored-by: Mike Welsh <mwelsh@gmail.com>
2021-02-19 03:30:21 -08:00
dependabot-preview[bot]
75fca8f6b6
build(deps): bump url from 2.2.0 to 2.2.1
...
Bumps [url](https://github.com/servo/rust-url ) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/servo/rust-url/releases )
- [Commits](https://github.com/servo/rust-url/compare/v2.2.0...v2.2.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-18 14:22:06 -08:00
Aaron Hill
6050dd8204
Replace most manual `Collect` impls with `#[derive(Collect)]`
...
* Replace most unsafe impls with Collect.
* Switch to local gc-arena fork.
2021-02-17 18:38:55 -08:00
desuwa
809d0a9245
avm1: Implement useHandCursor
2021-02-17 18:29:32 -08:00
Adrian Wielgosik
916bd8a9b8
core: Make EditText.border and EditText.background independent
2021-02-17 17:55:17 -08:00
Aaron Hill
f745c39a42
chore: Remove `Collect` impls from `Activation` and `UpdateContext`
...
Neither of these impls are actually used.
As a result of this change, several fields in `avm2::Activation` became
unused. I assumed that these fields will become used as more of avm2 is
implemented, so I suppressed the warnings for now
2021-02-16 20:35:26 -08:00
CUB3D
b93e556f89
avm2: Implement Op::Typeof and dummy XML/XMLList
2021-02-16 20:21:40 -08:00
David Wendt
df5e97481c
core: Adjust documentation
2021-02-16 19:03:48 -08:00
David Wendt
5e9d91710d
core: Future-proof the non-keyframe seek for other stream types.
2021-02-16 19:03:48 -08:00
TÖRÖK Attila
b3992dbc1a
core/video: Loop to frame modulo num_frames. Fixes z0r.de/1843
2021-02-16 19:03:48 -08:00
TÖRÖK Attila
2e6d3eae18
core/video: Make seeking to non-keyframes possible.
2021-02-16 19:03:48 -08:00
David Wendt
8709bb2489
chore: Clippy wants this too
2021-02-16 19:03:48 -08:00
David Wendt
0bc101dbde
chore: Spelling matters
2021-02-16 19:03:48 -08:00
David Wendt
5fcdb79528
core: Rename the video dependency enums to better describe their meaning.
2021-02-16 19:03:48 -08:00
David Wendt
4d0b73feeb
core: Seeks before instantiation are valid and should be cached for later execution
2021-02-16 19:03:48 -08:00
David Wendt
4905e9a83d
avm2: `Video` is a sealed class.
2021-02-16 19:03:48 -08:00
David Wendt
d9541e1ea6
core: Fix various documentation errors in video
2021-02-16 19:03:48 -08:00
David Wendt
c5fa9eb4a8
chore: Clippy compliance for stub video backend
2021-02-16 19:03:48 -08:00
David Wendt
964b1c4359
video: Frames with no data associated are treated as empty Pframes.
2021-02-16 19:03:48 -08:00
David Wendt
93ef62bac0
video: Snap seeks to nearest keyframe
2021-02-16 19:03:48 -08:00
David Wendt
02b94649c3
avm2: Stub the `Video` class.
2021-02-16 19:03:48 -08:00
David Wendt
aa98fad126
avm1: Stub impl the `Video` class.
2021-02-16 19:03:48 -08:00
David Wendt
828ff39802
video: Warn if duplicate video frames are encountered
2021-02-16 19:03:48 -08:00
David Wendt
0e2b328073
video: Warn if we are missing a frame to render.
2021-02-16 19:03:48 -08:00
David Wendt
c6a9e27916
video: Report what frame gave an error
2021-02-16 19:03:48 -08:00
David Wendt
5b546bf2d8
video: Always decode the first frame
2021-02-16 19:03:48 -08:00
David Wendt
368c1cf3c5
video: Implement a very basic video decoding loop
2021-02-16 19:03:48 -08:00
David Wendt
6dc96f5d58
core: Allow instantiation of videos
2021-02-16 19:03:48 -08:00
David Wendt
50d61b07f2
video: Stub seeking.
...
`PlaceObject`'s `ratio` field is treated as a seek parameter for video streams.
2021-02-16 19:03:48 -08:00
David Wendt
b78baeb41d
core: Add software video backend, separate from the null backend, to store software decoders.
2021-02-16 19:03:48 -08:00
David Wendt
57dab4327e
core: Further adjustment to video backend type
2021-02-16 19:03:48 -08:00
David Wendt
1e3cc60f05
core: Also implement `VideoFrame` tag.
...
This is far more awkward and copy-heavy than it needs to be.
2021-02-16 19:03:48 -08:00
David Wendt
9b161889f8
core: Parse `DefineVideoStream` and use it to put videos into the character library.
2021-02-16 19:03:48 -08:00
David Wendt
34577057e4
core: Add video display object
2021-02-16 19:03:48 -08:00
David Wendt
80bceeacab
core: Add `VideoBackend` to host video decoders
2021-02-16 19:03:48 -08:00
bunnyhero
6b58afa408
avm1: Make disabled MovieClips handle more events
...
Fixes #3250 .
2021-02-15 09:48:18 -08:00
Mike Welsh
ecd873eb39
tests: Add test for TextField.autoSize/background
2021-02-13 06:34:20 -08:00
Adrian Wielgosik
df6aa85948
text: Implement TextField.background, disable it by default
2021-02-13 06:34:20 -08:00
Adrian Wielgosik
26ffbdfe23
text: Improve autoSize logic for non-wrapping text layout
2021-02-13 06:34:20 -08:00
Mads Marquart
8ba4fdbbbe
core: Enable logging in tests, which makes it easier to spot mistakes
2021-02-13 03:49:12 -08:00
relrelb
bb89391f3a
chore: Avoid deprecated constants
...
The Rust documentation considers numeric constants prefixed with std::
as deprecated.
For example: https://doc.rust-lang.org/std/u16/constant.MAX.html .
2021-02-12 06:36:17 -08:00
Mike Welsh
e5fb1f09e7
chore: Appease clippy
...
* #[derive(Collect)] should be before #[collect]
* Replace redunant `&buf[..]` with `buf`
* Changes most cases of UPPERCase to UpperCase
* Allow upper_case_acronym on most SWF types, as they are from
SWF spec/more annoying to change.
2021-02-12 06:32:42 -08:00
dependabot-preview[bot]
2fbbbe81b8
build(deps): bump quote from 1.0.8 to 1.0.9
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.8 to 1.0.9.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.8...1.0.9 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-12 02:32:42 -08:00
Adrian Wielgosik
da86f7fc5a
avm1: Don't mutably borrow display_properties for reading
...
Fixes #3199 .
2021-02-11 13:41:03 -08:00
Mike Welsh
16bd7fade6
web: Use case-insensitive check for detecting javascript scheme
2021-02-08 03:41:16 -08:00
paq
5cca3884d6
avm2: Implement `Array.length`'s setter
2021-02-07 23:49:52 -08:00
paq
8aaead90de
avm2: Implement String.charCodeAt
2021-02-07 16:11:24 -08:00
paq
c7c025277f
avm2: Implement String.charAt
2021-02-07 16:11:24 -08:00
paq
2ec21bdd07
avm2: Implement String.length
2021-02-07 16:11:24 -08:00
paq
4a87d707f0
avm2: Implement String constructor
2021-02-07 16:11:24 -08:00
David A Roberts
6af18c1c4d
avm1: Implement MovieClip.setMask - #17 #263
2021-02-05 13:53:54 -08:00
Mike Welsh
937393ce07
core: Fix panic from negative array indices in SharedObject ( fix #3094 )
2021-02-04 19:56:29 -08:00
Mike Welsh
cfbb5751e8
tests: Add test for local SharedObject
2021-02-04 19:56:29 -08:00
Adrian Wielgosik
1454e0d126
core: Don't copy Glyphs around; make Font methods take &self
2021-02-04 11:54:17 -08:00
dependabot-preview[bot]
dd4860c469
build(deps): bump encoding_rs from 0.8.26 to 0.8.28
...
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs ) from 0.8.26 to 0.8.28.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases )
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.26...v0.8.28 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-04 11:22:31 -08:00
Adrian Wielgosik
d78e4e5e00
Core: Avoid framerate dropping down 5x if frames can't be handled in time.
2021-02-03 17:04:03 -08:00
Adrian Wielgosik
ac47b56fef
chore: Revert "build(deps): bump quick-xml from 0.20.0 to 0.21.0"
...
This reverts commit 0c6c339a64
.
2021-02-03 14:36:13 -08:00
dependabot-preview[bot]
0c6c339a64
build(deps): bump quick-xml from 0.20.0 to 0.21.0
...
Bumps [quick-xml](https://github.com/tafia/quick-xml ) from 0.20.0 to 0.21.0.
- [Release notes](https://github.com/tafia/quick-xml/releases )
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md )
- [Commits](https://github.com/tafia/quick-xml/compare/v0.20.0...v0.21.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-03 11:09:26 -08:00
Mike Welsh
47f0f980b8
core: Handle PlaceObject tags with malformed clip actions
...
Some SWFs in the wild have PlaceObject tags with ending ClipActions
that are 2 bytes instead of the required 4 bytes (see #2899 ).
Swallow the error in this case so that the tag can run.
2021-02-02 23:56:48 -08:00
paq
48d59c0340
chore: Minor refactor names.rs
2021-02-02 10:16:41 -08:00
relrelb
074731e1a4
audio: Add Nellymoser support
2021-02-02 00:41:01 -08:00
Adrian Wielgosik
2c2a9367ae
avm1: Respect case-(in)sensitivity in text bindings
...
Fixes #3031 .
2021-02-01 18:09:32 -08:00
Mike Welsh
02d99c3686
core: CSMTextSettings tag alters text hit testing
...
Normally, a hit test on static text will consider the text glyphs.
However, a CSMTextSettings tag can change the text to use the
"advanced rendering engine", which causes hit tests to only consider
the bounds. This is toggled by the "Anti-alias for readibility"
setting in the Flash IDE.
Wire up the CSMTextSettings tag and adjust hit test behavior based
on this flag.
Fixes #2987 .
2021-02-01 17:17:41 -08:00
Mads Marquart
1990e51639
avm2: Add UiBackend::display_unsupported_message
...
To allow displaying rich content when unsupported ActionScript 3 content is encountered.
2021-01-31 23:04:20 -08:00
Brian Gontowski
31dd2729e2
web: Add an onFSCommand callback into JavaScript
2021-01-31 18:03:31 -08:00
EmperorBale
4122e8a1b0
core: Implement TextField.password property
2021-01-31 12:26:58 -08:00
relrelb
7431cd9b10
core: Merge InputBackend into UiBackend
2021-01-30 16:36:45 -08:00
CUB3D
206ac43703
avm1: Correct ToInteger for undefined, null and object inputs
2021-01-29 19:44:32 -08:00
relrelb
02dfb23c67
core: Remove unneeded pub
2021-01-29 13:05:37 -08:00
relrelb
eaf0441f9a
avm1: Small refactors
2021-01-29 13:05:37 -08:00
relrelb
beff73b815
core: Small refactor
2021-01-29 13:05:37 -08:00
dependabot-preview[bot]
67f793549e
build(deps): bump flate2 from 1.0.19 to 1.0.20
...
Bumps [flate2](https://github.com/rust-lang/flate2-rs ) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases )
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.19...1.0.20 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-29 11:43:05 -08:00
dependabot-preview[bot]
6f14490f84
build(deps): bump jpeg-decoder from 0.1.21 to 0.1.22
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.21 to 0.1.22.
- [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.21...v0.1.22 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-29 11:42:19 -08:00
Mike Welsh
477fa06daf
avm1: Fix off-by-one error in String.lastIndexOf
...
Fixes #2873 .
Co-authored-by: Toad06 <gd.productions@laposte.net>
2021-01-29 02:59:14 -08:00
Mike Welsh
92e4d781e7
tests: Add test for #2870
2021-01-28 16:36:42 -08:00
Mike Welsh
008f0f596c
core: Clip event slices are from parent movie in PlaceObject
...
Since 19034b7
, clip event scripts are returned as slices from the
SWF. This caused a panic when a movie was loaded into a clip,
because the loaded clip's `movie` would be used as the source for
clip events. However, clip events are placed by the parent's
PlaceObject tags, so the movie in this case should be the parent's
movie.
Fixes #2870 .
2021-01-28 16:36:42 -08:00
Mads Marquart
39aa7536df
core: Remove unsafe NonZeroU32 creation in shape utils
2021-01-28 14:39:35 -08:00
Mike Welsh
0f5bab3e78
core: Use dirty flag for updating sound transforms
2021-01-27 15:25:04 -08:00
Mike Welsh
7eb5389630
core: Avoid vec allocation in AudioManager::update_sounds
2021-01-27 15:25:04 -08:00
Mike Welsh
a4699a3ca5
audio: Sound transforms apply to stream sounds
...
This unifies the code path for event sounds and stream sounds.
Both `AudioBackend::start_stream` and `start_sound` return a
`SoundHandle`. `stop_stream` is removed (`stop_sound` can be
used for both cases).
Also removes references to `CharacterId` from the `AudioBackend`
(instead, an increasing ID is returned to identiy streams while
loading).
2021-01-27 15:25:04 -08:00
Mike Welsh
4c33464115
tests: Add test for Sound
2021-01-27 15:25:04 -08:00
Mike Welsh
95ce2abf17
audio: Remove AudioBackend::stop_sounds_with_handle/is_sound_playing_with_handle
2021-01-27 15:25:04 -08:00
Mike Welsh
da2dd3b36c
core: Implement sound transforms and Sound.setPan
2021-01-27 15:25:04 -08:00
Mike Welsh
98e6c54c3b
avm1: Implement Sound.onSoundComplete
2021-01-27 15:25:04 -08:00
Mike Welsh
34f60b127a
core: Add AudioManager to handle actively playing sounds
...
Add an AudioManager struct to handle this list of actively playing
sounds. This will maintain information for each sound instance,
such as the owning display object, AVM1 object, etc.
This will allow us to implement the awkward AVM1 Sound API in a
fairly backend-agnostic way.
2021-01-27 15:25:04 -08:00
TÖRÖK Attila
a89eb6b9b8
avm1: Implement BitmapData.perlinNoise()
2021-01-27 11:53:05 -08:00
Adrian Wielgosik
937b371e30
core: Support grayscale JPEGs
2021-01-26 17:14:27 -08:00
dependabot-preview[bot]
8172ddb1ba
build(deps): bump rand from 0.8.2 to 0.8.3
...
Bumps [rand](https://github.com/rust-random/rand ) from 0.8.2 to 0.8.3.
- [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/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-26 08:52:20 -08:00
dependabot-preview[bot]
7856cdd3d7
build(deps): bump serde from 1.0.122 to 1.0.123
...
Bumps [serde](https://github.com/serde-rs/serde ) from 1.0.122 to 1.0.123.
- [Release notes](https://github.com/serde-rs/serde/releases )
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.122...v1.0.123 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-25 14:14:33 -08:00
Mike Welsh
306d2ead7f
core: Avoid panic in EditText::on_changed ( fix #2809 )
2021-01-24 19:52:30 -08:00
dependabot-preview[bot]
64983cde22
build(deps): bump serde from 1.0.121 to 1.0.122
...
Bumps [serde](https://github.com/serde-rs/serde ) from 1.0.121 to 1.0.122.
- [Release notes](https://github.com/serde-rs/serde/releases )
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.121...v1.0.122 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-24 17:26:09 -08:00
dependabot-preview[bot]
32fd3fb71b
build(deps): bump syn from 1.0.59 to 1.0.60
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.59 to 1.0.60.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.59...1.0.60 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-24 14:23:03 -08:00
paq
e9ad1587a4
chore: Rename Namespace::public_namespace to Namespace::public
2021-01-24 11:53:43 -08:00
paq
b58fcf3b05
chore: Use Namespace::public_namespace() instead of Namespace::package("")
2021-01-24 11:53:43 -08:00
dependabot-preview[bot]
239ccb3511
build(deps): bump jpeg-decoder from 0.1.20 to 0.1.21
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.20 to 0.1.21.
- [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/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-24 11:52:39 -08:00
dependabot-preview[bot]
86b4c20809
build(deps): bump serde from 1.0.120 to 1.0.121
...
Bumps [serde](https://github.com/serde-rs/serde ) from 1.0.120 to 1.0.121.
- [Release notes](https://github.com/serde-rs/serde/releases )
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.120...v1.0.121 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-23 14:12:08 -08:00
Adrian Wielgosik
0a64c34e73
Make avm11::Value Copy
2021-01-23 12:04:47 -08:00
Adrian Wielgosik
2065812d1a
Preallocate AVM1 Values when preparing constant pool
2021-01-23 12:04:47 -08:00
relrelb
19662503ca
swf: Convert ButtonActionCondition to bitflags
2021-01-23 11:59:24 -08:00
relrelb
7f4845d777
swf: Convert ButtonState to bitflags
2021-01-23 11:59:24 -08:00
paq
c088c18517
chore: Remove Flash's recovery file and add it to .gitignore
2021-01-23 00:29:25 -08:00
dependabot-preview[bot]
c0ac8a4a77
build(deps): bump syn from 1.0.58 to 1.0.59
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.58 to 1.0.59.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.58...1.0.59 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-23 00:29:02 -08:00
CUB3D
0cf3a4abed
core: Invert pixel fill order for BitmapData.noise
2021-01-22 13:16:19 -08:00
CUB3D
d57fd172f9
core: More special casing for noise
2021-01-22 13:16:19 -08:00
CUB3D
00fe7b6468
avm1: Generate correct values for negative seeds for BitmapData.noise()
2021-01-22 13:16:19 -08:00
CUB3D
9ba38784ef
avm1: Properly implement BitmapData.noise() for positive seeds
2021-01-22 13:16:19 -08:00
Mike Welsh
82fd9dfd4e
chore: Appease clippy
2021-01-21 18:52:43 -08:00
Mike Welsh
78f85d96f0
chore: Remove some debug spew
2021-01-21 18:22:42 -08:00
Aaron Hill
b2f5f807de
avm2: Print full multiname for "Property does not exist" errors ( #2740 )
...
This makes it easy to see when the error is a result of something in the
"flash" package being unimplemented.
2021-01-21 17:52:17 -08:00
relrelb
b05c6540e1
chore: Migrate from enumset to bitflags
2021-01-21 16:35:46 -08:00
relrelb
ab92bc1b98
tests: Add tests for target clip in SWF6
2021-01-21 14:52:52 -08:00
relrelb
286bf7ac3f
tests: Add tests for target clip in SWF5
2021-01-21 14:52:52 -08:00
Toad06
9866a4baef
web: Use enum instead of arbitrary values
2021-01-21 14:52:52 -08:00
Mike Welsh
60a95f3ea0
core: Gracefully handle tag length past EOF
2021-01-21 14:04:46 -08:00
Mike Welsh
34e0763cfe
avm1: Don't unwrap in ColorTransform methods
2021-01-21 11:48:26 -08:00
Mike Welsh
6e7e5395aa
tests: Add test for subclassing a native type
2021-01-21 11:48:26 -08:00
Mike Welsh
5582da9f8a
avm1: create_bare_object should properly wire up proto
...
When a native class was extended, most native types were grabbing
their normal prototype instead of using the user's supplied prototype.
e.g. `class MyColorTransform extends ColorTransform`.
2021-01-21 11:48:26 -08:00
Mike Welsh
a6ea28d9b4
avm1: Create proper underlying type when extending native objects ( fix #2682 )
2021-01-21 11:48:26 -08:00
Mike Welsh
e8efe22dee
tests: Add test for SWF5 string encoding
2021-01-20 15:02:31 -08:00
Mike Welsh
66256dd3be
swf: SwfStr no longer contains encoding
...
SwfStr is now an unsized slice analogous to `str` or `bstr`.
The desired encoding must be supplied when converting to String.
2021-01-20 15:02:31 -08:00
Mike Welsh
61628a74fc
swf: Rename and organize some util methods
...
* SwfRead -> SwfReadExt
* SwfWrite -> SwfWriteExt
* read_swf_header -> decompress_swf
* read_swf -> parse_swf
2021-01-20 15:02:31 -08:00
Mike Welsh
1d9c11e145
swf: Add SwfStr type to handle encodings in SWF<6
2021-01-20 15:02:31 -08:00
Mike Welsh
19034b76e4
swf: Return slices in swf::Reader
...
Avoid copies by returning slices of the decompressed input.
2021-01-20 15:02:31 -08:00
klemens
9488a3fb97
spelling fixes
2021-01-18 22:07:39 -08:00
Mike Welsh
da1e2801a2
chore: Appease clippy
2021-01-18 21:23:50 -08:00
relrelb
c284a2e47e
tests: Add export_assets
2021-01-15 11:48:29 -08:00
relrelb
abfa08c964
core: Allow exports to be overridden
...
Per SWF19 p.54, the latter export name is used.
2021-01-15 11:48:29 -08:00
TÖRÖK Attila
a01ea70514
core/avm1: Implement BitmapData.copyPixels()
2021-01-14 13:02:55 -08:00
cheezeygeek
1911708ad1
avm1: Fix onChange firing, remove unwraps, revert as_broadcaster
2021-01-13 15:47:20 -08:00
cheezeygeek
b3cd9b0f89
avm1: Implement listeners and onChanged for TextField ( close #2297 )
2021-01-13 15:47:20 -08:00
Mike Welsh
df82194823
tests: Add test for case insensitive Object.registerClass in SWF6
2021-01-13 15:38:38 -08:00
Mike Welsh
3c31336c93
chore: Rename some getters
2021-01-13 15:38:38 -08:00
Moulins
26a2b6e4f7
core: Add test for `Object.registerClass` return values
2021-01-13 15:38:38 -08:00
Moulins
f394953331
core: Reimplement `Object.registerClass`.
...
Maintain an external mapping from symbol names to registered
constructors to properly handle `registerClass` being called on
not-yet-available symbols.
SWFs v6 and v7+ each have a separate global mapping, with
different case sensitivities.
Also returns the correct boolean value to the AVM.
Fixes #2343 and #1864 .
2021-01-13 15:38:38 -08:00
Mike Welsh
9bb36885bb
web: Add backgroundColor option and support bgcolor attribute
...
Add `backgroundColor` setting to the config options, allowing
a user to override the background color of an SWF. The polyfill
will now look for the `bgcolor` HTML attribute on the embed
and fill in this setting appropriately.
2021-01-13 11:57:19 -08:00
Mike Welsh
4820d5b044
core: Change Player::background_color to an Option
...
Player::background_color is now an Option. SetBackgroundColor will
change the background color of the player only when this is None,
i.e. only if no background color has yet been set.
This matches the behavior of the offical Flash Player, for example,
if a parent SWF is missing a SetBackgroundColor tag and loads a
child SWF, the child SWF's SetBackgroundColor tag takes effect.
This is anticipating adding a `bgcolor` option to the web builds,
allowing the HTML embed to override the bgcolor.
2021-01-13 11:57:19 -08:00
Adrian Wielgosik
7242bfb5f0
avm1: In ASSetPropFlags, don't crash on flags > 7
2021-01-13 11:55:35 -08:00
dependabot-preview[bot]
a73e85ea6d
build(deps): bump rand from 0.8.1 to 0.8.2
...
Bumps [rand](https://github.com/rust-random/rand ) from 0.8.1 to 0.8.2.
- [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.1...0.8.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-13 04:17:41 -08:00
Mike Welsh
63f2b4f02f
avm1: Remove Error::ConstructorFailed
...
Not necessary now that native constructors can return differing
types. `new BitmapData` can return undefined.
2021-01-12 09:13:24 -08:00
Mike Welsh
cd68d4f76a
avm1: Properly implement Object constructor
2021-01-12 09:13:24 -08:00
Mike Welsh
e93f3b5d3b
tests: Add test for Object constructor
2021-01-12 09:13:24 -08:00
Mike Welsh
df500282cd
avm1: Use the return value of built-in ctors as `this`
...
* Built-in constructors now return the newly constructed object,
which will be used as `this`. This allows for constructors such
as `new Object` which can return differing types.
* Adjust `FunctionObject::constructor` to take both a constructor
and a function. Add `constructor_to_fn!` macro to turn most
simple native constructors into a function that discards the
return value.
* Change `TObject::construct` to return `Value` instead of `Object`.
This is necessary for constructors that return primitive values.
2021-01-12 09:13:24 -08:00
Mike Welsh
4e27818952
core: Don't recreate objects when switching button states
...
When switching button states, previously we cleared all children
and recreated children for the new state. Now any children that
exist in both states are persisted and not recreated.
Fixes #2354 .
2021-01-11 14:06:22 -08:00
Mike Welsh
6b2b0eb2c6
core: Allow mouse picking of children inside buttons
...
Particularly fixes cases of button-inside-button (#2354 ).
2021-01-11 14:06:22 -08:00
Toad06
7480e836ec
web: Changes from review
2021-01-11 13:16:00 -08:00
TÖRÖK Attila
cce3a8199d
web: Add a config option to disable the message about unsupported content
2021-01-10 16:02:23 -08:00
Mike Welsh
484ac03ca8
tests: Test removeMovieClip on non-movieclips
2021-01-09 18:31:04 -08:00
Mike Welsh
bab88ede8c
fix
2021-01-09 18:31:04 -08:00
MrCheeze
ff15b67192
avm1: Allow RemoveSprite/removeMovieClip on any display object
2021-01-09 18:31:04 -08:00
Mike Welsh
6638aebde8
tests: Add test verifying proper getBytesTotal value
2021-01-09 14:29:19 -08:00
MrCheeze
5915f2a841
core: Return uncompressed length for getBytesLoaded/Total
2021-01-09 14:29:19 -08:00
Adrian Wielgosik
828dbcb00c
Don't panic on invalid JPEG sizes in DefineBitsJpeg*
2021-01-08 13:38:41 -08:00
dependabot-preview[bot]
f80d74a3d7
build(deps): bump smallvec from 1.6.0 to 1.6.1
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.6.0...v1.6.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-08 12:09:49 -08:00
relrelb
030ff398ef
desktop: Handle fullscreen keyboard shortcut in its own case
2021-01-08 11:59:08 -08:00
relrelb
abe608fd4d
desktop: Add fullscreen keyboard shortcut
2021-01-07 12:49:36 -08:00
Mike Welsh
44e9185a5f
core: Adjust culling area based on letterbox setting
2021-01-07 11:46:07 -08:00
Mike Welsh
01aca9f861
web: Remove upgrade_to_https param from Ruffle::new
...
Grab it from the `config` directly instead of using an extra param.
2021-01-07 11:46:07 -08:00
Mike Welsh
bacb66b97b
core: Move Letterbox to config module
2021-01-07 11:46:07 -08:00
Mike Welsh
8728804f28
web: Add letterbox config option
2021-01-07 11:46:07 -08:00
Mike Welsh
e9da6a13f0
core: Add letterbox setting
...
Player::set_letterbox can be used to control the letterbox behavior.
* Letterbox::Off => no letterbox (flash behavior)
* Letterbox::Fullscreen => letterbox only in fullscreen (web default)
* Letterbox::On => always letterbox (desktop default)
2021-01-07 11:46:07 -08:00
Mike Welsh
03b5edd4d1
render: Remove RenderBackend::draw_letterbox
...
Move letterbox draw logic to `Player`, using renderer.draw_rect
2021-01-07 11:46:07 -08:00
CUB3D
063c8a1234
chore: Fix formatting
2021-01-06 18:06:30 -08:00
CUB3D
01557fba5a
core: Add flash.filters.GradientGlowFilter
2021-01-06 18:06:30 -08:00
CUB3D
0cab167e4c
core: Add flash.filters.GradientBevelFilter + refactor existing filters
2021-01-06 18:06:30 -08:00
Moulins
02c591958e
core/avm1: don't run onLoadInit handler if movie loading failed
...
Replace Loader::Movie::loader_complete flag by an enum to distinguish
between success and failure.
Fixes #2123
2021-01-06 16:00:58 -08:00
relrelb
468b2ca487
core: Ignore SetBackgroundColor in child movie clips
2021-01-06 16:00:11 -08:00
Callum Thomson
75081c8149
avm1: Implement flash.filters.ConvolutionFilter avm1 built-in
2021-01-04 18:26:11 -08:00
relrelb
9a8edda8a6
chore: Update lyon to 0.17.1
2021-01-04 18:08:14 -08:00
relrelb
de761f5b7c
chore: Update bitstream-io to 1.0.0
2021-01-04 15:23:36 -08:00
TÖRÖK Attila
21e071384d
core/avm1: Handle object aliasing in BitmapData.copyChannel by cloning
2021-01-04 15:10:01 -08:00
dependabot-preview[bot]
51641dad60
build(deps): bump rand from 0.8.0 to 0.8.1
...
Bumps [rand](https://github.com/rust-random/rand ) from 0.8.0 to 0.8.1.
- [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.0...0.8.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-04 15:08:40 -08:00
Mike Welsh
fae1d6fd6a
chore: Appease clippy
2021-01-04 13:17:26 -08:00
Adrian Wielgosik
de38bb48eb
core: Fake passage of time to fool busy-loop frame limiters
2021-01-04 12:19:20 -08:00
Kamil Gierada
49a69c8109
core: ADPCM decoder produces less artifacts
2021-01-02 16:44:28 -08:00
Mike Welsh
4c12f27e46
tests: Add tests for #1671
2021-01-02 16:19:08 -08:00
Mike Welsh
146d41c971
avm1: Bail out of swapDepths on dead clips
2021-01-02 16:19:08 -08:00
paq
72be136fb9
avm1: Implement unescape
2021-01-02 14:37:03 -08:00
dependabot-preview[bot]
219f4664d6
build(deps): bump minimp3 from 0.5.0 to 0.5.1
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-02 14:22:38 -08:00
CUB3D
03e69c5c0b
core: Update DisplacementMapFilter tests
2021-01-02 03:12:07 -08:00
CUB3D
631d185014
core: Implmement flash.filters.DisplacementMapFilter
2021-01-02 03:12:07 -08:00
TÖRÖK Attila
3b14437b25
core/avm1: Implement BitmapData.scroll
2021-01-01 19:44:56 -08:00
dependabot-preview[bot]
83c32e8693
build(deps): bump syn from 1.0.56 to 1.0.57
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.56 to 1.0.57.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.56...1.0.57 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-01 13:46:35 -08:00
Mike Welsh
a5b5ba46ba
avm1: Unspecified arguments should be set to undefined ( fix #2166 )
...
Unspecified arguments should be set to undefined to prevent
assignments from leaking to the parent scope, for example:
```
function f(arg0) {
arg0 = "BAD"; // Previously could set _root.arg0
}
f();
```
2020-12-31 20:01:05 -08:00
Mike Welsh
22ab8df8f5
tests: Add test for #2166
2020-12-31 20:01:05 -08:00
dependabot-preview[bot]
6a3b9f9f53
build(deps): bump smallvec from 1.5.1 to 1.6.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.5.1...v1.6.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-31 14:37:38 -08:00
Mike Welsh
9b6295f33a
render: Pass library to RenderBackend::register_shape ( fix #2037 )
...
Pass the movie library to `register_shape` methods so that bitmap
charcter IDs can be resolved immediately on the proper SWF.
This fixes #2037 , which cause incorrect bitmaps to be used when
multiple movies were loaded.
2020-12-31 13:10:21 -08:00
Adrian Wielgosik
2b2a7c3c27
Remove redundant SystemPrototypes from UpdateContext.
2020-12-31 13:09:59 -08:00
Mike Welsh
ea3b6f59df
avm1: Implement XML.ignoreWhite
2020-12-30 16:00:39 -08:00
Mike Welsh
caa2d8e383
tests: Add test for XML.ignoreWhite
2020-12-30 16:00:39 -08:00
Mike Welsh
d736293425
avm1: Fix method calls with null/empty string name
...
`f[null]` should call `f["null"]`.
`f[undefined]`, `f[""]`, `f[o]` where o.toString returns the empty
string should call `f` directly.
2020-12-30 13:35:36 -08:00
CUB3D
5fb15c8f80
core: Support CallMethod with non-string method_name ( fix #2160 )
2020-12-30 13:35:36 -08:00
paq
4f980becb2
avm1: Implement escape
2020-12-30 12:42:03 -08:00
Mike Welsh
3ce4406434
core: Fix memory leak caused by unbound text variables
...
Text fields without variables would return as unbound in
EditText::try_bind_text_field_variable, causing them to be added
to the unbound textfield list even though they had no variable
setting. Return successful bidning by default to avoid adding
these textfields to the unbound list.
2020-12-29 14:18:07 -08:00
Mike Welsh
802aa9b7a7
avm1: Allow SharedObject creation even if URL is unknown ( fix #2150 )
...
Allow SharedObjects to be created even in the case that the movie
URL is None (for example, loading an SWF from bytes). Use a dummy
"localhost" URL.
2020-12-29 14:17:57 -08:00
Mike Welsh
ff5ecf9754
avm1: Fix incorrect name used for SharedObject cache ( fix #2149 )
2020-12-29 14:17:57 -08:00
Callum Thomson
7b202bd2e7
avm1: Implement flash.filters.ColorMatrixFilter avm1 built-in
2020-12-29 03:10:46 -08:00
paq
8c86434e38
avm1: Implement Matrix.deltaTransformPoint
2020-12-28 01:17:00 -08:00
paq
8baa36e801
avm2: Implement isFinite
2020-12-27 23:02:39 -08:00
paq
ce2d7efac3
avm2: Implement isNaN
2020-12-27 23:02:39 -08:00
Mike Welsh
7bdbb6c37d
text: Fix masking of text area ( fix #1496 , #1554 )
2020-12-27 23:01:24 -08:00
Mike Welsh
8d707bc6ab
core: onKeyUp/Down method handlers fire only if clip has focus ( fix #2120 )
2020-12-27 16:08:27 -08:00
paq
7bfe3f7177
avm1: Implement Matrix.transformPoint (ruffle-rs#303)
2020-12-27 14:27:04 -08:00
Mike Welsh
8222d3095b
desktop: Add --timedemo benchmark
...
Add --timedemo for benchmarking, which will run the given SWF as
quickly as possible for 5000 frames or the end of the root
timeline, whichever comes first. The total duration will be output
upon completion.
2020-12-26 23:59:12 -08:00
jmckiern
a3b4074fc4
core: Fix multiline selection bug
2020-12-26 23:18:02 -08:00
jmckiern
208a69d715
core: Move caret to start or end of selection if shift is not held
...
Previously pressing left with a selection would set `selection.to = selection.start() - 1`, now it sets it to `selection.to = selection.start()`. The same is true for right/selection.end()
2020-12-26 23:18:02 -08:00
jmckiern
464f2b63a9
chore: Fix spelling mistake
2020-12-26 23:18:02 -08:00
jmckiern
c277c1083b
core: Render selected text as white with black background
2020-12-26 23:18:02 -08:00
jmckiern
0269c31dbc
core: Change caret color to text color
2020-12-26 23:18:02 -08:00
dependabot-preview[bot]
1b4c8265b7
build(deps): bump syn from 1.0.55 to 1.0.56
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.55 to 1.0.56.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.55...1.0.56 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-26 14:01:15 -08:00
Sam Morrow
38bdb8b39a
web/desktop: Add basic dialog handling ( closes #1978 )
2020-12-23 19:08:18 -08:00
Mike Welsh
367404ddd8
core: SharedObjects are bucketed by domain
...
Key SharedObjects on the domain and path where the SWF is hosted,
and implement the localPath and secure parameters.
Fix #855 .
2020-12-22 14:18:06 -08:00
Callum Thomson
e38d559b1e
avm1: Implement flash.filters.DropShadowFilter
...
Implements the AVM object for DropShadowFilter. Actual rendering is still TODO.
2020-12-22 14:17:12 -08:00
David Wendt
b848e4c5ff
avm2: Get rid of `RufflePrivate` and just use regular private namespaces scoped to our own domain.
2020-12-21 21:47:29 -08:00
David Wendt
30d8dc21be
avm2: Remove weird `into` constructor on `EventHandler`
2020-12-21 21:47:29 -08:00
David Wendt
7baa3cc06d
avm2: Seal the `EventDispatcher` class
2020-12-21 21:47:29 -08:00
David Wendt
3ff9b87261
avm2: `RufflePrivate` namespaces should be treated as private namespaces.
2020-12-21 21:47:29 -08:00
David Wendt
19219ad0c1
avm2: Implement `dispatchEvent`.
...
Event dispatch is a surprisingly complicated procedure, so this makes sure to test:
1. Event dispatch on bare dispatchers
2. Event dispatch on hierarchial dispatchers (movieclips)
3. Event cancellation (which is reported by `dispatchEvent`)
4. The implicit `this` on unbound event handlers. I'm not yet sure if this is a special property of event dispatch or if all unbound functions inherit their global scope as `this`.
5. The execution order of handlers on both bare and hierarchial dispatchers
6. Delegation to hierarchial dispatchers
7. Modification of the dispatch list during dispatch of an event. Surprisingly enough, you can add handlers to the event you're handling and expect them to execute, *if* you added them to a further object in the order *or* you added a bubble handler in the capture phase.
2020-12-21 21:47:29 -08:00
David Wendt
f33e5f893a
avm2: Allow builtins to get at the global scope.
2020-12-21 21:47:29 -08:00
David Wendt
8efaed40a0
avm2: `event.eventPhase` is enumerated from 1
2020-12-21 21:47:29 -08:00
David Wendt
87ff679898
avm2: Implement `EventDispatcher.willTrigger`
2020-12-21 21:47:29 -08:00
David Wendt
a071800117
avm2: `EventDispatcher` should supercall, too.
2020-12-21 21:47:29 -08:00
David Wendt
e8163e43ab
avm2: Builtin constructors should supercall.
2020-12-21 21:47:29 -08:00
David Wendt
be4e37a55c
avm2: Implement `addEventListener`, `removeEventListener`, and `hasEventListener`.
2020-12-21 21:47:29 -08:00
David Wendt
2faf5259ca
avm2: Add a representation for event dispatch lists.
...
For various reasons, we store the dispatch list for an object on a separate property of an `EventDispatcher` rather than dictating that all children of `EventDispatcher` use a specific object type. This is because `EventDispatcher` is a very general class with lots of object representations it needs to cover. So instead, we introduce a new object representation for a *property* and store it in a Ruffle private namespace that is as isolated from user code as alternate object representations are.
2020-12-21 21:47:29 -08:00
David Wendt
b02897637f
avm2: Add a new namespace type to store runtime-internal properties we don't want user code being able to access ever.
2020-12-21 21:47:29 -08:00
dependabot-preview[bot]
606fd28b3b
build(deps): bump quote from 1.0.7 to 1.0.8
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.7 to 1.0.8.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.7...1.0.8 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-20 15:54:45 -08:00
Callum Thomson
69ab12fcc3
avm1: Add flash.filters.GlowFilter
2020-12-20 15:31:09 -08:00
dependabot-preview[bot]
820572f204
build(deps): bump syn from 1.0.54 to 1.0.55
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.54 to 1.0.55.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.54...1.0.55 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-20 15:19:11 -08:00
Mike Welsh
8a0e55d74a
chore: Bump to rand 0.8
2020-12-19 14:33:12 -08:00
Mike Welsh
9d6e711006
tests: Add test for #2030
2020-12-19 02:14:27 -08:00
Mike Welsh
60d7c0a742
core: Fix incorrect bounds for Bitmap ( fix #2030 )
2020-12-19 02:14:27 -08:00
Mike Welsh
981a4de9c9
tests: Uncomment arguments.caller avm1 test
2020-12-19 01:46:20 -08:00
Mike Welsh
0dd8b24fec
avm1: Implement arguments.caller
2020-12-19 01:46:20 -08:00
Mike Welsh
a3f18b80b6
tests: Add test for TextField.replaceSel
2020-12-19 00:35:26 -08:00
Mike Welsh
62a3729b55
avm1: Implement TextField.replaceSel
2020-12-19 00:35:26 -08:00
Mike Welsh
042e9a444b
tests: Add parseFloat tests
2020-12-18 02:50:09 -08:00
Mike Welsh
80d5d9cd0a
avm1: Initial implementation of parseFloat
2020-12-18 02:50:09 -08:00
Mike Welsh
326a5b6212
core: Move device font to Library ( fix #1995 )
2020-12-17 23:20:22 -08:00
Mike Welsh
a58073cabd
core: Fix Collect impl for BitmapData ( fix #2009 )
2020-12-17 19:35:26 -08:00
Mike Welsh
72a24b9800
tests: Add tests for #1906
2020-12-17 18:07:01 -08:00
Mike Welsh
25cd4ee375
avm1: Color.setTransform/setRGB sets transformed-by-AS flag ( fix #1906 )
2020-12-17 18:07:01 -08:00
Mike Welsh
7cf217a911
swf: Use lzma-rs for LZMA SWFs ( fix #405 )
...
Pure Rust decoder that functions on desktop and wasm.
Enable lzma feature by default.
TODO: Switch to lzma-rs streaming API when stable on crates.io.
Currently decodes entire stream at once.
2020-12-17 16:40:21 -08:00
jmckiern
beed570475
core: Add string_utils char boundary functions
2020-12-17 16:15:24 -08:00
jmckiern
b81cb1a3eb
core: Extend text input to deal with multibyte chars
2020-12-17 16:15:24 -08:00
David Wendt
09f9e99fbb
avm2: Implement `rest` parameters in function calls.
2020-12-17 13:21:44 -08:00
David Wendt
453e013c2c
avm2: Implement `arguments`.
2020-12-17 13:21:44 -08:00
David Wendt
217890f4a6
avm2: Implement `Function.apply`
2020-12-17 13:21:44 -08:00
Mike Welsh
369c5bda56
render: Implement Bitmap smoothing property
2020-12-15 00:04:51 -08:00
CUB3D
3556ffd778
chore: Fixes after rebase
2020-12-15 00:04:51 -08:00
CUB3D
a92b8ffded
core: All other changes from review
2020-12-15 00:04:51 -08:00
CUB3D
ccd08f14d9
core: Fix naming and safety issues
2020-12-15 00:04:51 -08:00
CUB3D
e483d0959f
core: Remove unwraps
2020-12-15 00:04:51 -08:00
CUB3D
6f91352d41
chore: Fix clippy lints
2020-12-15 00:04:51 -08:00
CUB3D
eea45d6ae6
core: Tidy up loadBitmap
2020-12-15 00:04:51 -08:00
CUB3D
23a9c7143a
core: Support failiable constructors
2020-12-15 00:04:51 -08:00
CUB3D
b3dd5c0c0b
core+renderer: Fix corner cases
2020-12-15 00:04:51 -08:00
CUB3D
666c3db9c6
core: Refactor bitmapData
2020-12-15 00:04:51 -08:00
CUB3D
74ab728cff
core: Format
2020-12-15 00:04:51 -08:00
CUB3D
22a7b1d340
core: Add handling of invalid arguments for getColorBoundsRect/colorTransform
2020-12-15 00:04:51 -08:00
CUB3D
353d5a268b
core: Add better handling of invalid arguments to BitmapData
2020-12-15 00:04:51 -08:00
CUB3D
9d46d67588
core+web+renderer: Add load/attach Bitmap and handling for invalid args with BitmapData
2020-12-15 00:04:51 -08:00
CUB3D
3c12fa6ee5
core: Implement BitmapData.floodFill and correct getPixel for invalid coordinates
2020-12-15 00:04:51 -08:00
CUB3D
3afd20063f
core: Implement get/set pixel(32) functions
2020-12-15 00:04:51 -08:00
CUB3D
e45e942a1f
core: Start implementation for flash.display.BitmapData
2020-12-15 00:04:51 -08:00
dependabot-preview[bot]
843bc74292
build(deps): bump indexmap from 1.6.0 to 1.6.1
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.6.0...1.6.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-14 17:49:16 -08:00
David Wendt
acadcb8fc0
avm2: `Event` is a sealed class.
2020-12-14 16:46:33 -08:00
David Wendt
f7f51dcde2
avm2: `EventPhase` and `PropagationMode` should be `Eq`
2020-12-14 16:46:33 -08:00
David Wendt
6caaf0d222
avm2: Implement all of the `Event` class constants.
...
I'm not writing tests for these, my wrists hurt enough as is.
2020-12-14 16:46:33 -08:00
David Wendt
8a787e6153
avm2: Implement `Event.toString` (which matches it's valueof behavior)
2020-12-14 16:46:33 -08:00
David Wendt
dc32d7894c
avm2: Remove redundant event phase accessor
2020-12-14 16:46:33 -08:00
David Wendt
ec63ff55cb
avm2: Implement `Event.stopPropagation` and `Event.stopImmediatePropagation`.
...
These aren't testable yet.
2020-12-14 16:46:33 -08:00
David Wendt
d393a5f4f8
avm2: Implement `Event.preventDefault` and `Event.isDefaultPrevented`
2020-12-14 16:46:33 -08:00
David Wendt
8b9a804ae9
avm2: Implement `Event.formatToString`.
2020-12-14 16:46:33 -08:00
David Wendt
584c6c8b11
avm2: Implement `Event.clone`
2020-12-14 16:46:33 -08:00
David Wendt
3d12929914
avm2: Expose `Event.target`, `currentTarget`, and `eventPhase`.
...
These have no tests because these properties can only be updated by an event broadcaster.
2020-12-14 16:46:33 -08:00
David Wendt
90da20579c
avm2: Implement `Event.bubbles`, `cancelable`, and `type`.
2020-12-14 16:46:33 -08:00
David Wendt
58f4470dc5
avm2: Add `Event` class, object type, and native representation
2020-12-14 16:46:33 -08:00
jmckiern
709561a255
avm1: Use ? on set_text_color so errors are raised
2020-12-14 12:45:45 -08:00
jmckiern
ec1ff0be3a
avm1: Use ? instead of match Ok()'s so errors are raised
2020-12-14 12:45:45 -08:00
jmckiern
a09ac58ebd
chore: Remove TODO
2020-12-14 12:45:45 -08:00
jmckiern
cfd003de7a
avm1: Implement TextField.backgroundColor
2020-12-14 12:45:45 -08:00
jmckiern
61e3214d0a
avm1: Implement TextField.borderColor
2020-12-14 12:45:45 -08:00
Sam Morrow
c4d7b24629
web: Fix cors issues with http (close ruffle-rs#1486)
2020-12-14 05:51:28 -08:00
Zeh Fernando
8e9de8e16b
core: Implement MovieClip._lockroot in avm1
...
This also enables the (previously ignored) _lockroot tests.
2020-12-13 15:34:42 -08:00
Mike Welsh
ee74197a00
avm1: Move TextField properties to prototype
...
Remove TextField::attach_virtual properties, as properties are
on the prototype, not the textfield itself.
Use the `with_text_field_props` macro for these properties.
Also remove `get_` prefix from most getters to match naming
conventions.
2020-12-09 14:45:20 -08:00
David Wendt
ed4d51dfc1
avm1: Don't panic if we encounter an invalid display object hierarchy for AS2. Instead, yield a runtime error.
2020-12-09 14:00:06 -08:00
David Wendt
afd033898c
avm2: Implement `hitTestObject`
2020-12-09 14:00:06 -08:00
David Wendt
d9172780c5
avm2: Implement `hitTestPoint`.
2020-12-09 14:00:06 -08:00
David Wendt
b18b87e566
avm2: Implement `mouseX` and `mouseY`.
...
Note that we cannot write a reproducible test for this.
2020-12-09 14:00:06 -08:00
David Wendt
06ba2f898a
avm2: Implement `visible`.
2020-12-09 14:00:06 -08:00
David Wendt
d489aca377
avm2: Expose `DisplayObject.root`
2020-12-09 14:00:06 -08:00
David Wendt
4b9deb7106
core: Don't crash on rootless display objects.
...
Instead, crash if AVM1 ever sees a rootless display object.
2020-12-09 14:00:06 -08:00
David Wendt
0069d51dad
swf: `pushshort` should be read as a `u30` and then cast to an `i16` as it's parsed representation.
2020-12-09 14:00:06 -08:00
David Wendt
1b2a4708d6
avm2: Implement `DisplayObject.parent`.
2020-12-09 14:00:06 -08:00
David Wendt
852f26bdeb
tests: Fix name test breaking with our half-working execution order
2020-12-09 14:00:06 -08:00
David Wendt
c053f2c87c
avm2: Expose DisplayObject `name` property
2020-12-09 14:00:06 -08:00
David Wendt
ea7efe8740
core: Avoid double-borrow when moving clips between parents
2020-12-09 14:00:06 -08:00
David Wendt
a7b4f7fbd0
core: Add instantiated by timeline flag as AVM2 appears to track that
2020-12-09 14:00:06 -08:00
David Wendt
6080585d73
core: Assign `rootN` format names to top-level AVM2 movie clips.
2020-12-09 14:00:06 -08:00
David Wendt
19f9e99954
avm2: Expose and test `rotation`.
2020-12-09 14:00:06 -08:00
David Wendt
29f96e76ab
tests: Activate alpha test (since it seems to work fine)
2020-12-09 14:00:06 -08:00
David Wendt
200581e1e3
avm2: Expose `x` and `y` properties.
2020-12-09 14:00:06 -08:00
David Wendt
4784dc3c03
tests: Add more stringent height/width test that we're only accurate to within 1 twip.
2020-12-09 14:00:06 -08:00
David Wendt
abca120628
avm2: Expose `width` to AS3 code.
2020-12-09 14:00:06 -08:00
David Wendt
3225cd40e2
core: Avoid panic when display objects are manipulated in clearly invalid ways.
2020-12-09 14:00:06 -08:00
David Wendt
990401a09c
core: Allow percentages (e.g. scalex/y) to be specified, stored, and cached at either [0..1] or [0..100] scale.
2020-12-09 14:00:06 -08:00
David Wendt
6da658a845
avm2: `pushshort` has an undocumented coercion step
2020-12-09 14:00:06 -08:00
David Wendt
90e203b004
avm2: `this.height` ignores negative values
2020-12-09 14:00:06 -08:00
David Wendt
bd00bea744
avm2: Expose `alpha`, `height`, `scaleY`, and `scaleX` to script code.
2020-12-09 14:00:06 -08:00
David Wendt
69db45131b
tests: Add inactive tests for `alpha`, `height`, `rotation`, `width`, `x`, and `y`.
2020-12-09 14:00:06 -08:00
dependabot-preview[bot]
d1c79a5dd5
build(deps): bump png from 0.16.7 to 0.16.8
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.7 to 0.16.8.
- [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 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-08 21:13:22 -08:00
jmckiern
3cab11d18e
avm1: Implement TextField.textColor ( close #1863 )
2020-12-07 15:09:36 -08:00
dependabot-preview[bot]
17eb651682
build(deps): bump syn from 1.0.53 to 1.0.54
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.53 to 1.0.54.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.53...1.0.54 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-07 13:08:20 -08:00
Mike Welsh
9901738249
chore: Appease rustfmt
2020-12-07 10:35:40 -08:00
relrelb
989bfb8f3e
avm1: Improve loops treatment in Sound.start
...
The second argument of Sound.start, loops, can be greater than
std::u16::MAX, but previously greater values were treated as 1.
Ideally, the solution is to respect those values, but since SoundInfo
holds a u16, a short-term solution is to treat them as std::u16::MAX
instead.
2020-12-06 14:22:38 -08:00
Mike Welsh
16b9c77d02
core: Remove panic in morph shape lerp
2020-12-05 00:19:30 -08:00
dependabot-preview[bot]
f45fa80e29
build(deps): bump smallvec from 1.5.0 to 1.5.1
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.5.0...v1.5.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-04 17:54:47 -08:00
bbb651
92bd0874e1
Fixed "Swap" only working for i32
2020-12-03 15:51:37 -08:00
bbb651
8baf35e7af
Added AVM2 op "Swap"
2020-12-03 15:51:37 -08:00
Mike Welsh
758a32f5f0
core: Remove unimplemented! in decode_define_bits_lossless
2020-12-02 23:58:03 -08:00
Zeh Fernando
c018ac065c
tests: Add test for MovieClip._lockroot in avm1
2020-12-02 11:59:01 -08:00
Mike Welsh
a0d56aad44
core: Don't panic on DefineFont4
2020-12-01 23:01:35 -08:00
Mike Welsh
25e7ec99a0
core: Handle serializing arrays in SharedObjects
2020-11-30 22:15:34 -08:00
Mike Welsh
ad5028817a
core: Remove unnecssary parameter from Button::set_state
2020-11-30 01:15:43 -08:00
Mike Welsh
0d79d85d83
avm1: Fix MovieClip properties being attached to Object.prototype
2020-11-30 01:15:43 -08:00
Mike Welsh
aedddd29ab
avm1: Implement Button.enabled and MovieClip.enabled
2020-11-30 01:15:43 -08:00
dependabot-preview[bot]
827a8ee18d
build(deps): bump syn from 1.0.52 to 1.0.53
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.52 to 1.0.53.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.52...1.0.53 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-29 22:46:08 -08:00
Mike Welsh
ab200b6dc0
avm1: Don't fire button events when invisible ( fix #1521 )
2020-11-29 12:47:36 -08:00
Mike Welsh
dafe7e5027
avm1: Implement Key.getAscii
2020-11-29 02:31:10 -08:00
Mike Welsh
18addef831
core: Don't run stream sounds when stopped ( fix #1719 )
2020-11-27 21:11:15 -08:00
dependabot-preview[bot]
3d9ebbde9c
build(deps): bump syn from 1.0.51 to 1.0.52
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.51 to 1.0.52.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.51...1.0.52 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-27 15:46:54 -08:00
David Wendt
a978b649b9
core: Also gate the `set_parent` change on `remove_range` just in case
2020-11-27 13:23:34 -08:00
David Wendt
0f1d4d5248
core: Always remove children from their old render list positions regardless of what depth list position they had
2020-11-27 13:23:34 -08:00
David Wendt
e69e6fcc5e
core: Fix regression on Super Mario 63
2020-11-27 13:23:34 -08:00
David Wendt
6e565d4da2
core: Fix compliation error caused by the `TDisplayObjectContainer` refactor
2020-11-27 13:23:34 -08:00
David Wendt
5a2f17a642
core: Consistently refer to render list positions as an `index` for consistency with Rust naming conventions
2020-11-27 13:23:34 -08:00
David Wendt
c011c028de
avm2: Correctly coerce render list indicies as `i32`, not `u32`.
2020-11-27 13:23:34 -08:00
David Wendt
01539baf5d
core: Move `render_children` into `TDisplayObjectContainer`.
2020-11-27 13:23:34 -08:00
David Wendt
ba311dd5b4
core: Remove previous changes to make certain `DisplayObject` methods take `&mut self`, which noises up the PR
2020-11-27 13:23:34 -08:00
David Wendt
6d992e239a
core: Re-fix #1580 as it's fix didn't make it into the `DisplayObjectContainer` refactor the first time
2020-11-27 13:23:34 -08:00
David Wendt
8764831533
chore: cargo 1.47 changed the formatting algorithm
2020-11-27 13:23:34 -08:00
David Wendt
365601f2d9
core: New-depth children should always be placed before higher children, not after lower ones.
...
We will call this the "before-above" rule, to contrast with the previous "after-below" behavior. The main difference is how off-depth-list children are handled, which more closely matches AVM2.
The previous implementation of after-below wouldn't work unless we made the fallback case of not having a below child put it to the *end* of the list. This gave us test pass but broke animations. The first one I tried, Cirno's Perfect Math Class, prepends the entire depth list, which with the half-broken after-below behavior wound up appending to the render list.
There isn't an inverse problem with before-below and the end of the list, since we cover that case and we don't have to put weird exceptions.
2020-11-27 13:23:34 -08:00
David Wendt
74b50f2586
core: AVM2-locked children should still be removable from the depth list.
2020-11-27 13:23:34 -08:00
David Wendt
3769d24715
core: Fix incorrect placement of clips where depth placements intended to place objects at the bottom of the list instead placed them at the top.
2020-11-27 13:23:34 -08:00
David Wendt
35bc43cce2
avm2: Swapping children should lock them from depth manipulation.
2020-11-27 13:23:34 -08:00
David Wendt
c8cd4a9192
avm2: Remove outdated documentation on some internal functions.
2020-11-27 13:23:34 -08:00
David Wendt
6cb3ff9632
avm2: Stub `getObjectsUnderPoint` and `areInaccessibleObjectsUnderPoint` as we do not yet support the `Point` class
2020-11-27 13:23:34 -08:00
David Wendt
fec4e3c0a9
core: Replace direct container manipulation with `TDisplayObjectContainer` methods wherever possible.
...
The purpose of this refactor is twofold:
1. Ensure `TDisplayObjectContainer` holds all the container methods we need
2. Ensure that future adjustments to trait methods automatically apply to the display object's own use of the container, in case we want to do things in those methods that can't be done in a borrowed container
There are two places where we cannot use the new trait methods:
1. `Button.set_state` as it holds a borrow at the point we want to clear the container
2. `MovieClipData.goto_remove_object`, since it's a method on the data and thus cannot access trait methods
This particular commit generates a lot of noise as several `DisplayObject` methods were incorrectly marked as non-mutating.
2020-11-27 13:23:34 -08:00
David Wendt
9dde91e0fd
core: Store named children on AVM2 movieclips as object properties
2020-11-27 13:23:34 -08:00
David Wendt
86e1037940
avm2: Implement `stopAllMovieClips`
2020-11-27 13:23:34 -08:00
David Wendt
3cac03857c
chore: Clippy beta compliance
2020-11-27 13:23:34 -08:00
David Wendt
cad2c4ecee
tests: Add a button child execution order test.
2020-11-27 13:23:34 -08:00
David Wendt
e2e598edde
avm2: Implement `swapChildren` and `swapChildrenAt`.
2020-11-27 13:23:34 -08:00
David Wendt
71cdbd7194
avm2: Implement `setChildIndex`
2020-11-27 13:23:34 -08:00
David Wendt
cf0ab2d82f
avm2: Implement `removeChildren`.
...
This also changes the underlying `DisplayObjectContainer` method to accept any type of range. Turns out enum trait objects aren't actually trait objects and don't need to worry about object safety!
2020-11-27 13:23:34 -08:00
David Wendt
38fd29ae5f
avm2: Implement `removeChildAt`
2020-11-27 13:23:34 -08:00
David Wendt
c97ff2b024
core: Implement remove-by-range functionality
2020-11-27 13:23:34 -08:00
David Wendt
495dcf9d05
core: Remove direct execution list head manipulation and the `replace_at_depth` flag that indicates that it has occured.
...
Depending on how I'm reading the old code I replaced, it appeared to be constructing execution lists backwards. I have no idea if this was intended behavior or not. If so, then I'll need to add reverse-add capability to `replace_at_depth`.
2020-11-27 13:23:34 -08:00
David Wendt
80d7409fc5
core: Separate off container management into a separate `DisplayObjectContainer` trait
2020-11-27 13:23:34 -08:00
David Wendt
fed28a7b46
chore: Add `Default` for `ChildContainer` as per clippy
2020-11-27 13:23:34 -08:00
David Wendt
759a590d76
avm2: Implement `getChildIndex`
2020-11-27 13:23:34 -08:00
David Wendt
2454287342
tests: Enable the `removeChild` test that tests timeline manipulation.
2020-11-27 13:23:34 -08:00
David Wendt
85fa8f327d
avm2: Impl `contains` w/ test
2020-11-27 13:23:34 -08:00
David Wendt
e4b5a3f8fc
core: When removing a child from it's parent, make sure it's marked as having no parent.
2020-11-27 13:23:34 -08:00
David Wendt
a2d876bc8c
core: Remove double-ended support for `ChildIter` as it's unnecessary and wastes time
2020-11-27 13:23:34 -08:00
David Wendt
1f2c194ffd
avm2: Remove unnecessary execution list accesses and debugging statements from `DisplayObjectContainer`.
2020-11-27 13:23:34 -08:00
David Wendt
bcef9ef415
tests: Add a whole number of tests of depth/render list interaction from the AS3 side
2020-11-27 13:23:34 -08:00
David Wendt
ab4dd984e8
core: Refactor display list management into a separate `ChildContainer` struct.
...
`ChildContainer` is responsible for maintaining child lists for all display objects that can hold children. Currently, this is just `Button` and `MovieClip` since those are the only objects in AVM1 that can have children, but this will be extended to other objects in future commits.
The number of lists managed has also increased from two to three. The execution list is unchanged save for it's migration into the `ChildContainer` struct. The render list has been split in two to support AS3. Specifically, the render list is now a `Vec`. Render children are still rendered in order but they are now referenced by AS3 `id`s rather than depths. The old `BTreeMap` that served as a render list is now the depth list and serves to maintain compatibility with SWF tags and AVM1 code that refers to things on the timeline by depth.
2020-11-27 13:23:34 -08:00
David Wendt
a5f09d3c09
avm2: Implement `removeChild`.
2020-11-27 13:23:34 -08:00
David Wendt
a5ea9795f6
avm2: Implement `addChild` and `addChildAt`, with tests
2020-11-27 13:23:34 -08:00
David Wendt
c7199ff83f
core: Add a utility for placing a display object at a particular relative position (rather than a static depth) on the render list.
...
For example, let's say we had two objects on the clip at depths 5 and 6. AS3 would see them as children IDs 0 and 1. Adding something at ID 1 translates to putting something between depth 5 and 6. To do this, we shift all higher-depth children up one depth to make room for the incoming clip, producing a new order of depths 5, 6, and 7.
2020-11-27 13:23:34 -08:00
David Wendt
52efbd98a8
core: Remove child's sibling pointers when removing the child from the parent's exec list.
...
This fixes a hang in as-of-yet uncommitted AS3 tests that reused display objects, where repeated removals and additions to the same MovieClip caused the construction of a cyclic render list.
2020-11-27 13:23:34 -08:00
David Wendt
cfd6965b2c
avm2: Use order in the render list (but NOT depths) rather than the execution list for `get_child_by_id`
2020-11-27 13:23:34 -08:00
David Wendt
b263b52bca
avm2: Correctly instantiate timeline clips whose AVM2 constructor isn't specified as a `flash.display.MovieClip`.
2020-11-27 13:23:34 -08:00
David Wendt
4817e92992
avm2: `getChildAt` works in reverse execution list order, not by depth
2020-11-27 13:23:34 -08:00
David Wendt
f3ae65df93
core: Add flag for display objects which were placed by AS3.
...
In AS3. objects placed by scripts *cannot* be removed by `RemoveObject` tags. This enforces that in Ruffle.
2020-11-27 13:23:34 -08:00
David Wendt
8c9f8520b3
avm2: Implement `DisplayObjectContainer.numChildren`
2020-11-27 13:23:34 -08:00
David Wendt
f748576927
avm2: Implement `getChildByName`
2020-11-27 13:23:34 -08:00
David Wendt
827567bb58
avm2: `toString` of stage objects should work the same way as other objects
2020-11-27 13:23:34 -08:00
David Wendt
dc629af177
avm2: `getChildById` indexes by zero, but it gives me the child at depth one.
2020-11-27 13:23:34 -08:00
David Wendt
d04f131cfe
avm2: Implement `DisplayObjectContainer.getChildAt`.
...
This test doesn't work yet because it needs `avm2-domainscope` to get merged in.
2020-11-27 13:23:34 -08:00
relrelb
1d648a1d55
core: Use encoding_rs in load_vars_loader
...
This adds support for BOM.
2020-11-26 15:41:50 -08:00
Nathan Adams
d8728bbf25
avm1: Made firstChild and lastChild ignore non-node children
2020-11-26 11:18:00 -08:00
Nathan Adams
c8bb54977b
core: Fix panic loading 'invalid-ish' html in text fields - fixes #1193
2020-11-26 11:17:00 -08:00
Mike Welsh
aff34a4233
core: Seed RNG with timestamp
2020-11-26 00:07:59 -08:00
Mike Welsh
53212f192c
chore: Appease clippy, squelch unnecessary_wraps lint
2020-11-24 18:59:42 -08:00
Mike Welsh
e655cf0c08
web: Add Ruffle::audio_context getter
2020-11-24 16:36:33 -08:00
Mike Welsh
8db4482fcf
core: Avoid panic on truncated SWF ( fix #1583 )
2020-11-24 00:29:28 -08:00
dependabot-preview[bot]
6b60fbe432
build(deps): bump syn from 1.0.50 to 1.0.51
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.50 to 1.0.51.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.50...1.0.51 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-23 17:21:29 -08:00
Mike Welsh
d9ac9fa076
avm1: Array.reverse should return itself
2020-11-22 13:50:49 -08:00
Mike Welsh
7ac53be24f
avm1: Implement TextField.removeTextField
2020-11-22 01:55:46 -08:00
Mike Welsh
03ab4e28d1
chore: Bump quickxml to 0.20
2020-11-22 01:55:01 -08:00
Mike Welsh
a61d2b54ae
avm1: Implement TextField.type
2020-11-21 16:58:19 -08:00
dependabot-preview[bot]
22d695421f
build(deps): bump syn from 1.0.48 to 1.0.50
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.48 to 1.0.50.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.48...1.0.50 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-21 15:20:54 -08:00
Mike Welsh
8d78ee5172
avm1: Use f64 when calculating scale/rotation ( fix #1622 )
2020-11-21 11:39:41 -08:00
MrCheeze
5ea3814097
core: Fix issue where unloaded buttons can still trigger mouse rollout events ( close #1603 )
2020-11-21 11:36:21 -08:00
David Wendt
5d542680ae
avm1: Remove bounds checks from `ActionDefineFunction`, `ActionWith`, `ActionDefineFunction2`, and `ActionTry`.
2020-11-20 00:28:56 -08:00
David Wendt
8ff085b464
avm1: Allow execution of opcodes before the start of an action or function.
2020-11-20 00:28:56 -08:00
Mike Welsh
2d463629e2
core: Avoid borrow panic when text is removed ( fix #1580 )
2020-11-19 18:42:31 -08:00
Mike Welsh
d3265bfd60
avm1: Add allow_empty param to Activation:resolve_target_display_object
...
In some cases, the empty string path "" should resolve to the
starting clip. In other cases, it should be considered invalid.
Add a parameter to control this behavior, and set this to false
for MovieClip::hit_test to prevent `clip.hitTest("")` from
returning true.
2020-11-18 17:58:42 -08:00
Mike Welsh
4c01022a38
avm1: Allow string paths in hitTest ( fix #1559 )
2020-11-18 17:58:42 -08:00
dependabot-preview[bot]
6bfa3144c3
build(deps): bump smallvec from 1.4.2 to 1.5.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.4.2 to 1.5.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.2...v1.5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-18 16:30:15 -08:00
relrelb
2e0509694c
docs: Miscellaneous spelling corrections
2020-11-12 13:34:05 -08:00
Mike Welsh
48ee47d88a
tests: Add test for AVM2 Math
...
Also allow specifying relative epsilon for swf_tests_approx.
2020-11-12 04:24:47 -08:00
Mike Welsh
3ce8bc3c4b
avm2: Implement Math
2020-11-12 04:24:47 -08:00
Mike Welsh
b927acb2c2
avm2: trace accepts multiple arguments
2020-11-10 17:05:56 -08:00
Mike Welsh
2e73eba6c9
tests: Add test for unload clip event
2020-11-09 17:26:19 -08:00
Mike Welsh
15d0d814a7
avm1: Exclude unload clip event from continue_if_base_clip_exists
...
Unload event handlers should not halt if their clip is removed
(because it is already removed when an unload handler starts).
This will probably get cleaner if #1535 is fixed (unload clips
stay alive for one frame).
Fixes #447 .
2020-11-09 17:26:19 -08:00
Mike Welsh
fe6ff77889
tests: Add test for initialize clip event
2020-11-09 10:43:18 -08:00
Mike Welsh
3905837679
avm1: Fire initialize clip event
...
This event fires for new clips before any construct clip events.
Split the action queue up into separate priorities, giving
initialize the highest priority.
2020-11-09 10:43:18 -08:00
Mike Welsh
316bc4e920
chore: Appease clippy
2020-11-09 01:52:57 -08:00
relrelb
930d6ebe59
core: Correct MovieClip method names in error messages
...
They all were MovieClip.attachMovie probably becuase of copy-pasting.
2020-11-06 12:33:05 -08:00
David A Roberts
1a978600c6
avm1: Swap rendering order of MovieClip
...
Renders drawing API behind siblings in the same clip.
2020-11-06 12:31:56 -08:00
dependabot-preview[bot]
fcf665fbe9
build(deps): bump url from 2.1.1 to 2.2.0
...
Bumps [url](https://github.com/servo/rust-url ) from 2.1.1 to 2.2.0.
- [Release notes](https://github.com/servo/rust-url/releases )
- [Commits](https://github.com/servo/rust-url/compare/v2.1.1...v2.2.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-06 00:45:35 -08:00
Mike Welsh
4fe5fc44a6
tests: Bump script timeout to 200 secs
2020-11-03 16:02:53 -08:00
Nathan Adams
6c270d8c3a
core: Fix double borrow in button post_init - fixes #1450 and #1190
2020-11-03 15:15:47 -08:00
Nathan Adams
8f064eea6e
core: Strip newlines when loading editboxes that contain them and are marked singleline. This appears to be the correct behaviour - they're never stripped anywhere else but on load
2020-11-02 11:43:10 -08:00
Nathan Adams
f285c990c0
avm1: _root should be allowed in text variable bindings
2020-11-02 11:43:10 -08:00
Nathan Adams
51f986e274
core: Propagate text variable bindings when text is typed
2020-11-02 11:43:10 -08:00
Nathan Adams
3b15babec6
core: Show caret on empty edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
a067170afd
core: Rename EditText::get_selection to ::selection
2020-11-02 11:43:10 -08:00
Nathan Adams
c520ff1f50
core: Only show carets for editable text
2020-11-02 11:43:10 -08:00
Nathan Adams
e6d39658b9
core: Change text input to be a match statement
2020-11-02 11:43:10 -08:00
Nathan Adams
8abf5a5be8
core: Limit text input to only editable text
2020-11-02 11:43:10 -08:00
Nathan Adams
e856968f75
core: Allow arrow keys in edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
5592a6ca9d
core: Perform delete & backspace in edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
cefa42fae0
tests: Add an avm1 test for Selection
2020-11-02 11:43:10 -08:00
Nathan Adams
c910824de8
core: Fix caret position in multi layout text
2020-11-02 11:43:10 -08:00
Nathan Adams
9893972710
core: Allow typing of text in edit boxes
2020-11-02 11:43:10 -08:00
Nathan Adams
881bf3789e
core: Clicking on text will place the caret at the position clicked
2020-11-02 11:43:10 -08:00
Nathan Adams
8a43eb9972
core: Display a caret when the text selection isn't a highlight
2020-11-02 11:43:10 -08:00
Nathan Adams
01c34b97f3
core: Show highlighted text in a slightly different colour (todo: background)
2020-11-02 11:43:10 -08:00
Nathan Adams
163e9fd21b
core: Clicking on (selectable) texts will make that text focused
2020-11-02 11:43:10 -08:00
Nathan Adams
1a230bda09
core: Remove focus when the focused object is removed
2020-11-02 11:43:10 -08:00
Nathan Adams
a4a2cd00b2
avm1: Implement Selection index getters & setSelection - #271
2020-11-02 11:43:10 -08:00
Nathan Adams
3f2057b53e
core: Edit boxes are always focusable, regardless of settings
2020-11-02 11:43:10 -08:00
Nathan Adams
171e23e9e1
avm1: Implement Selection.getFocus and setFocus - #271
2020-11-02 11:43:10 -08:00
Nathan Adams
efbab816e7
avm1: Implement MovieClip.focusEnabled - #263
2020-11-02 11:43:10 -08:00
Nathan Adams
b61a72166f
avm1: Stubbed out Selection - #271
2020-11-02 11:43:10 -08:00
Nathan Adams
93acb07374
core: Introduce a focus tracker, to keep track of one (and only one) focused object
2020-11-02 11:43:10 -08:00
Nathan Adams
f72310be43
core: Change the cursor to an IBeam on selectable text
2020-11-02 11:43:10 -08:00
Nathan Adams
f6b46cb615
core: Implement EditBox.selectable - #280
2020-11-02 11:43:10 -08:00
dependabot-preview[bot]
f04f4ef961
build(deps): bump flate2 from 1.0.18 to 1.0.19
...
Bumps [flate2](https://github.com/rust-lang/flate2-rs ) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/rust-lang/flate2-rs/releases )
- [Commits](https://github.com/rust-lang/flate2-rs/compare/1.0.18...1.0.19 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 10:52:04 -08:00
Mike Welsh
93e7f657f1
tests: Update Array.concat test to print out entire array
2020-10-31 02:42:34 -07:00
Mike Welsh
ff74f67db8
avm1: Fix Array.concat incorrectly creating arrays
2020-10-31 02:42:34 -07:00
relrelb
e74e115cd0
core: Fix bug in PcmDecoder::next
...
It looks like the mono and stereo cases were mistakenly swapped
for 8-bit sounds. This commit simply swaps them to the correct
order.
2020-10-30 12:39:57 -07:00
Mike Welsh
0f4219610d
core: Properly handle masker-inside-masker ( fix #1347 )
...
If a masker is placed inside a masker, the inner mask is inactive
and instead renders as normal art, masked by the outer mask. Properly
handle this case by only pushing new masks if we are not currently
drawing the mask stencil.
Maskee inside maskee still functions as expected. (i.e., a clip
using a mask is masked itself).
2020-10-25 20:41:31 -07:00
dependabot-preview[bot]
55d16c200a
build(deps): bump approx from 0.3.2 to 0.4.0
...
Bumps [approx](https://github.com/brendanzab/approx ) from 0.3.2 to 0.4.0.
- [Release notes](https://github.com/brendanzab/approx/releases )
- [Commits](https://github.com/brendanzab/approx/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-25 12:07:13 -07:00
Mike Welsh
bc31c33f65
avm1: Test for removed clip after a function call
...
0482d1c
made it so that a stack frame halts if its base clip gets
removed (e.g. from a goto). It actually seems like this check
only occurs after a function/method call (see #1370 ). So
and gotoAndPlay method call can cause the stack frame to pop, but
a GotoFrame action cannot.
Only check if the base clip has been removed in CallFunction,
CallMethod, NewObject, NewMethod ops.
Fixes #1370 .
2020-10-24 17:36:38 -07:00
Mike Welsh
e55346a211
tests: Test for removed clip after a function call
2020-10-24 17:36:38 -07:00
dependabot-preview[bot]
05edb73d72
build(deps): bump syn from 1.0.46 to 1.0.48
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.46 to 1.0.48.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.46...1.0.48 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-24 17:20:21 -07:00
Mike Welsh
21818a896d
text: Draw white background for bordered text fields
2020-10-23 16:13:36 -07:00
relrelb
083e2a2ff5
core: Implement getBytes{Loaded,Total} (simpler approach)
2020-10-23 13:13:00 -07:00
relrelb
14a71b69cc
core: Implement getBytes{Loaded,Total}
2020-10-23 13:13:00 -07:00
Nathan Adams
bac4d8c2bf
avm1: Ratelimit timeout check to help ease performance
2020-10-23 13:03:47 -07:00
Mike Welsh
c2d4d56f88
avm1: Allow this in GetVariable/SetVariable paths
2020-10-22 17:23:22 -07:00
Mike Welsh
8da1eeafcb
tests: Add test for this in GetVariable action
2020-10-22 17:23:22 -07:00
Mike Welsh
41f77fade1
avm1: Export names are case insensitive
...
Fixes capital letters not appearing in #1346
2020-10-21 17:09:31 -07:00
Mike Welsh
e093f05656
tests: Add case insensitivity test for attachMovie
2020-10-21 17:09:31 -07:00
dependabot-preview[bot]
3e5457f712
build(deps): bump syn from 1.0.45 to 1.0.46
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.45 to 1.0.46.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.45...1.0.46 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-21 17:08:57 -07:00
Colin Berry
c51a31fde8
desktop: Support URL paths and Proxy options
2020-10-20 23:31:23 -07:00
dependabot-preview[bot]
2fdb378e4f
build(deps): bump syn from 1.0.44 to 1.0.45
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.44 to 1.0.45.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.44...1.0.45 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-17 13:00:00 -07:00
Nathan Adams
a2d53df49c
render: Store immutable part of wgpu rendering as a reusable object, to speed up exporting
2020-10-17 04:16:24 -07:00
David Wendt
6f659db342
tests: Fix the lazyinit test so that it actually passes on Ruffle
2020-10-17 03:32:09 -07:00
David Wendt
50d6ffb510
avm2: Prevent circularly referential scripts from causing stack overflows or double-borrows.
2020-10-17 03:32:09 -07:00
David Wendt
a484861f79
tests: Add a test for lazy initialization load order.
2020-10-17 03:32:09 -07:00
David Wendt
d27360b282
avm2: Enable lazy initialization for ABCs that request it.
2020-10-17 03:32:09 -07:00
David Wendt
0d1676afda
avm2: Create a separate domain for each loaded movie and pull symbols out of each.
2020-10-17 03:32:09 -07:00
David Wendt
cdab885979
avm2: Implement `ApplicationDomain` and all methods that don't require `Vector` or domain memory
2020-10-17 03:32:09 -07:00
David Wendt
1aceb7776d
avm2: Superclasses should resolve out of the current scope stack.
2020-10-17 03:32:09 -07:00
David Wendt
00fcc5ffa4
avm2: Reference the current domain at the bottom of the scope stack.
2020-10-17 03:32:09 -07:00
David Wendt
f2caf60d3e
avm2: Scripts should run in a child of the global domain.
2020-10-17 03:32:09 -07:00
David Wendt
1792939212
avm2: Script scopes should hold the domains they are a part of.
...
Also, this means we have a `TObject` representation for domains now.
2020-10-17 03:32:09 -07:00
David Wendt
6a736b0d2b
avm2: Wrap all player globals in a separate appdomain and script.
...
This entirely abolishes the "global scope object" in AVM2. I even had to redefine several global object functions to work with the bottom of the scope stack, which seems to be where ASC likes to stick the script scope.
2020-10-17 03:32:09 -07:00
David Wendt
add7c4d43d
avm2: Collect all script definition names and associated scripts into a `Domain`.
2020-10-17 03:32:09 -07:00
David Wendt
02e05e3d7f
Add separate scope object for each script.
2020-10-17 03:32:09 -07:00
Mike Welsh
4558be948e
render: Fix masking issues on wgpu/webgl backends
...
Change the usage of the stencil buffer to avoid running out of
stencil bits when too many nested masks are active.
This also cleans things up on wgpu which requires us to make
pipeline states in advice; now we only need a few stencil states
for masking as opposed to hundreds.
2020-10-17 02:42:56 -07:00
Mike Welsh
97a3ef73a3
tests: Add tests for issue #893
2020-10-15 00:10:55 -07:00
Mike Welsh
e66b71817b
avm1: Stop execution if base clip is removed ( fix #893 )
...
Stop execution of the current stack frame if the base clip was
removed (for example, due to a goto).
2020-10-15 00:10:55 -07:00
Nathan Adams
6d9155477c
core: Add flashvars support - #312
2020-10-12 15:28:16 -07:00
Mike Welsh
a6b952e44e
core: Switch from libflate to flate2
2020-10-12 13:47:35 -07:00
Mike Welsh
2c2aa82730
chore: Remove debug message
2020-10-12 13:30:03 -07:00
Nathan Adams
fd6431f724
core: Don't use std Instant as it doesn't work for web, use a wrapper
2020-10-11 13:34:15 -07:00
Nathan Adams
4abd02e2f7
core: Implement a timeout for script execution, defaulting to 15 seconds. Fixes #554
2020-10-11 13:34:15 -07:00
Mike Welsh
137ac2887e
core: Don't mouse pick children when invisible ( fix #1242 )
2020-10-11 04:10:25 -07:00
Mike Welsh
2c9cf6802d
core: Squelch false AS3 error before initial SWF loads
2020-10-10 19:28:01 -07:00
Mike Welsh
5c3dd25638
avm1: Avoid unwrap in Sound constructor
...
At least avoid the panic in this case, but it can possibly fail
(see #701 ).
2020-10-10 18:13:08 -07:00
dependabot-preview[bot]
2c2a70e714
build(deps): bump syn from 1.0.43 to 1.0.44
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.43 to 1.0.44.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.43...1.0.44 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-10 16:35:50 -07:00
Mike Welsh
23660e49c9
core: Avoid panic due to invalid style IDs
...
If the shape converter encountered a fill/line style with an
ID > the number of styles, Ruffle would panic as it tried to grab
the non-existent style. This could occur if we mis-parsed some
shape data, or the SWF contained incorrect data. Now we the invalid
style is gracefully ignored.
2020-10-10 16:35:37 -07:00
Mike Welsh
10aaae9247
chore: Appease nightly clippy
2020-10-10 00:03:25 -07:00
dependabot-preview[bot]
4af9632761
build(deps): bump syn from 1.0.42 to 1.0.43
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.42 to 1.0.43.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.42...1.0.43 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-09 12:22:43 -07:00
David Wendt
5abebd5433
avm2: Yield an error if the caller specifies a label/scene pair and the label is not present within the scene.
2020-10-06 06:03:22 -07:00
David Wendt
1a10f1e004
avm2: Lock old movies (SWFv8 and earlier) to always use AVM1
2020-10-06 06:03:22 -07:00
David Wendt
693e56dc67
core: Always instantiate a new movie's library before creating it's root movieclip.
2020-10-06 06:03:22 -07:00
David Wendt
7c719bfb0c
Only the first tag in a SWF file should be trusted to deliver file attributes.
2020-10-06 06:03:22 -07:00
David Wendt
ddccede9d3
avm2: Make VM type non-optional.
...
This has the side effect of forcing the AVM check to happen at the time of library construction, which is already very early on in movie loading.
2020-10-06 06:03:22 -07:00
David Wendt
ef665acaec
avm2: Movie clips not explicitly granted a `symbol_class` should be constructed using the `MovieClip` class directly
2020-10-06 06:03:22 -07:00
David Wendt
12cf8022cd
core: Remove useless uses of `matches!`.
2020-10-06 06:03:22 -07:00
David Wendt
007d54b389
avm2: Remove redundant implementations of `prev_frame` and `next_frame`
2020-10-06 06:03:22 -07:00
David Wendt
4c44ca8e77
avm2: Non-integer numbers should be handled as strings and integer-parsible strings should be handled as numbers.
2020-10-06 06:03:22 -07:00
David Wendt
e2f21d0a7d
avm2: Retire old references to the "VM tendency" nomenclature
2020-10-06 06:03:22 -07:00
David Wendt
896a5b37a5
avm2: Implement `new MovieClip()`.
2020-10-06 06:03:22 -07:00
David Wendt
d399811eb8
avm2: Allow `MovieClip` to be constructed by users.
2020-10-06 06:03:22 -07:00
David Wendt
50dd9a6733
avm2: Implement the programmatically-playing flag that governs `isPlaying` behavior.
2020-10-06 06:03:22 -07:00
David Wendt
035c841eb5
tests: Add tests for `gotoAndStop` and rename the `gotoAndPlay` one
2020-10-06 06:03:22 -07:00
David Wendt
1f29497b8c
tests: Add test for AS3 movieclip play
2020-10-06 06:03:22 -07:00
David Wendt
8152400a39
avm2: Implement `MovieClip.scenes`.
2020-10-06 06:03:22 -07:00
David Wendt
c682868205
avm2: Implement `MovieClip.currentScene`
2020-10-06 06:03:22 -07:00
David Wendt
2483201bcd
avm2: Store the lengths of each scene in a movie.
2020-10-06 06:03:22 -07:00
David Wendt
8a13d5fe10
avm2: Implement `Scene` object.
2020-10-06 06:03:22 -07:00
David Wendt
5e31c44b81
All objects should default to `toString`ing with their own classname.
2020-10-06 06:03:22 -07:00
David Wendt
de186ed5f3
avm2: Implement `MovieClip.currentLabels`
2020-10-06 06:03:22 -07:00
David Wendt
77a86aef9b
avm2: Implement `FrameLabel`.
2020-10-06 06:03:22 -07:00
David Wendt
86b07c0007
tests: Add tests for `prevScene` and `nextScene`.
2020-10-06 06:03:22 -07:00
David Wendt
542147d657
avm2: Run all AVM2 frame scripts on the action queue.
...
This is the same way that AVM1 actions run and it appears that frame scripts work exactly the same way. It fixes all outstanding bugs with movie clip navigation in AVM2 and allows me to remove a lot of weird workarounds I was writing for the old, incorrect behavior.
I'm also removing the "last run script frame" rule as `run_frame_internal` already had rules to prevent stopped clips from rerunning actions.
2020-10-06 06:03:22 -07:00
David Wendt
996d7528d5
avm2: Implement `prevScene` and `nextScene`.
2020-10-06 06:03:22 -07:00
David Wendt
864c6a37f9
avm2: Dynamic properties should be retrievable before they are actually set.
2020-10-06 06:03:22 -07:00
David Wendt
6d0befad97
avm2: Implement `prevFrame` and `nextFrame`, with tests.
2020-10-06 06:03:22 -07:00
David Wendt
bcf08b5bf7
avm2: Frame scripts should run when the frame number has changed, regardless of playhead state.
2020-10-06 06:03:22 -07:00
David Wendt
97048fb8bd
avm2: Implement `stop` and `play`, with tests for the former.
2020-10-06 06:03:22 -07:00
David Wendt
c8cd4d09cd
core: Don't run frame scripts on stopped movie clips.
2020-10-06 06:03:22 -07:00
David Wendt
556c951b1c
avm2: Implement `gotoAndPlay`/`gotoAndStop`, with test.
2020-10-06 06:03:22 -07:00
David Wendt
3513918149
avm2: Allow typechecking by prototype, rather than just by constructor.
2020-10-06 06:03:22 -07:00
David Wendt
e837840bba
core: Always skip frames after the current frame when getting the current scene or label.
2020-10-06 06:03:22 -07:00
David Wendt
5b83f6b4cc
avm2: Add test for movieclip-specific properties.
2020-10-06 06:03:22 -07:00
David Wendt
3b6f8cff4e
avm2: Implement `framesLoaded`, `isPlaying`, and `totalFrames`.
2020-10-06 06:03:22 -07:00
David Wendt
7ca34452a1
avm2: Implement `currentFrameLabel` and `currentFrame`.
2020-10-06 06:03:22 -07:00
David Wendt
6124ed468f
core: Add `current_label` for getting the current label on a given clip.
...
This also fixes `current_scene` as well.
2020-10-06 06:03:22 -07:00
David Wendt
c1b14b7639
avm2: Implement `currentFrame`.
2020-10-06 06:03:22 -07:00
David Wendt
7756fd530d
core: Allow grabbing the movieclip's current scene, if scene labels are defined.
2020-10-06 06:03:22 -07:00
David Wendt
d747ef7914
core: Store scene and frame labels generated by the `DefineSceneAndFrameLabelData` tag.
2020-10-06 06:03:22 -07:00
David Wendt
55fec14a1c
tests: Add tests for timeline scripts.
2020-10-06 06:03:22 -07:00
David Wendt
c04bf7d53c
`addFrameScript` indexes by zero, not by one.
2020-10-06 06:03:22 -07:00
David Wendt
ab45b9084d
avm2: Parse `SymbolClass` package paths correctly.
2020-10-06 06:03:22 -07:00
David Wendt
a1a21500d8
core: Warn when a movie clip is AVM2-constructed without an accompanying symbol class.
2020-10-06 06:03:22 -07:00
David Wendt
8c67260e68
core: Special-case ID 0 as the current movie timeline.
...
Note: This relies on the fact that SWF files do not stick `SymbolClass` declarations in child movieclips. If this isn't the case, then it will fail horribly, and we would then need to actually store clip 0 in the library somehow.
2020-10-06 06:03:22 -07:00
David Wendt
f2c3466026
avm2: The AVM2 constructor should be an actual Class, not it's prototype.
2020-10-06 06:03:22 -07:00
David Wendt
e915a07d4f
core: ABC files should resolve at the time of discovery, not on the action queue.
2020-10-06 06:03:22 -07:00
David Wendt
7e898457b0
avm2: Implement `addFrameScript`.
2020-10-06 06:03:22 -07:00
David Wendt
d991c49774
Implement `addFrameScript`.
2020-10-06 06:03:22 -07:00
David Wendt
664152d739
avm2: Mark `EventDispatcher` as implementing `IEventDispatcher`.
...
This doesn't actually implement any of it's methods yet, which *would* cause an error *if* we were verifying that.
2020-10-06 06:03:22 -07:00
David Wendt
e72c9776ec
avm2: Implement `IEventDispatcher`.
2020-10-06 06:03:22 -07:00
David Wendt
c899b3080a
avm2: Add function to unwrap a `StageObject` as it's underlying `DisplayObject`.
2020-10-06 06:03:22 -07:00
David Wendt
a70e1be466
Add code to instantiate AVM2 movie clips correctly.
...
This also includes several bits to build an effective VM barrier.
2020-10-06 06:03:22 -07:00
David Wendt
247e79e61a
core: Track the VM each movie has pledged to execute on.
...
This uses a "VM tendency" system wherein the presence of `DoAction` or `DoInitAction` tags defaults the movie to AVM1, while the presence of `DoABC` defaults to AVM2. The presence of a `FileAttributes` tag allows setting the VM tendency in the same manner using it's AS3 bit.
Particularly malformed SWFs may cause execution issues if Flash Player uses a dramatically different system from this.
2020-10-06 06:03:22 -07:00
David Wendt
3128bbcda6
core: Implement `SymbolClass` tag.
2020-10-06 06:03:22 -07:00
David Wendt
edd31c4b83
core: Allow pulling the AVM2 Object out of a participating movie clip.
2020-10-06 06:03:22 -07:00
David Wendt
f85319aa4c
core: Allow `DisplayObject` to hold AVM2 objects.
...
This requires the use of an intermediary enum called `AvmObject` which can hold either object representation. Currently, it's mostly just being unwrapped as AVM1 objects, which we will need to fix.
2020-10-06 06:03:22 -07:00
David Wendt
63f411d231
avm2: Add `StageObject` object implementation for holding display objects in AVM2.
2020-10-06 06:03:22 -07:00
David Wendt
3fb186e5c0
avm1: Remove fscommand debug code
2020-10-01 13:53:00 -07:00
David Wendt
1a77874e04
avm1: For good measure, also unload on empty URL in `ActionGetURL`.
2020-10-01 13:53:00 -07:00
David Wendt
bb5c367e91
chore: Remove dbg statement in loaders
2020-10-01 13:53:00 -07:00
David Wendt
e73cdd7987
avm1: Actually unload movies when we get an empty URL in `GetURL2` and the target is a sprite.
2020-10-01 13:53:00 -07:00
CUB3D
f0a02f00b5
core: Changes from review
2020-09-29 11:06:56 -07:00
CUB3D
110b9ec551
core: Fix edge cases and implement rest of bevel filter
2020-09-29 11:06:56 -07:00
CUB3D
2c3ee4d94b
core: Add flash.filters.BevelFilter
2020-09-29 11:06:56 -07:00
Sean-Thomas
5701312527
desktop: Implement play/pause for CPAL backend
...
- removed default implementations for `play()` and `pause()` methods for AudioBackend trait
- Implemented `play()` and `pause()` methods for CPAL audio backend
- Implemented empty block for `play()` and `pause()` methods for NULL audio backend
2020-09-29 11:05:23 -07:00
Sean-Thomas
a9538f81d0
web: Renamed "prime_audio" and "suspend_audio"
...
Renamed "prime_audio" and "suspend_audio" to "play" and "pause" respectfully.
2020-09-29 11:05:23 -07:00
Sean-Thomas
6b54cc4311
web: Add pause method for web player
...
Adds a suspend_audio method to compliment prime_audio on WebAudioBackend, as well as logic in player.rs on the set_is_playing method to suspend audio when is_playing is set to false. Exposes pause method for the ruffle player in JavaScript with logic to display the play button when paused.
2020-09-29 11:05:23 -07:00
Mike Welsh
ead845ff33
chore: Appease clippy
2020-09-26 18:19:37 -07:00
Mike Welsh
98d2651e62
tests: Add tests for Array single-param ctor
2020-09-26 14:13:06 -07:00
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
David Wendt
3d37fda1ef
tests: Add tests for `deleteproperty` on arrays.
2020-09-15 02:20:11 -07:00
David Wendt
04828663e8
avm2: `deleteproperty` should only ever yield `false` when attempting to delete unknown properties on a sealed class object.
2020-09-15 02:20:11 -07:00
David Wendt
6d9b9c9218
avm2: Attempts to get unknown properties on dynamic objects should yield `undefined`.
2020-09-15 02:20:11 -07:00
David Wendt
966dfc3902
avm2: Add method to get at the `Class` of non-class objects with a prototype.
...
The only unclassed objects should be bare objects, which are hard to get at.
2020-09-15 02:20:11 -07:00
David Wendt
cac1717780
avm2: Add utility method `is_sealed` for `Class`.
2020-09-15 02:20:11 -07:00
David Wendt
1a8f041b77
tests: Add `array_storage` test.
2020-09-15 02:20:11 -07:00
David Wendt
34ba1643dd
tests: Add test for reading properties of an array
2020-09-15 02:20:11 -07:00
David Wendt
5a29b781ec
avm2: Ensure `ArrayObject` offers access to it's array properties for reading and writing.
2020-09-15 02:20:11 -07:00
David Wendt
e054456286
avm2: Add method to check if a particular namespace is the public namespace.
2020-09-15 02:20:11 -07:00
David Wendt
1d3f5d80be
tests: Add test for `new Array`'s arguments.
2020-09-15 02:20:11 -07:00
David Wendt
a09ba9d263
avm2: Implement `length`.
2020-09-15 02:20:11 -07:00
David Wendt
aaf586e3a7
avm2: `define_instance_trait` should actually define instance traits.
2020-09-15 02:20:11 -07:00
David Wendt
45c95cae02
avm2: Impl `Array.concat`
2020-09-15 02:20:11 -07:00
David Wendt
1092bf2bc5
avm2: Add the ability to wrap an already-constructed array in an object.
2020-09-15 02:20:11 -07:00
David Wendt
bd35ebb793
avm2: Impl `Array` constructor
2020-09-15 02:20:11 -07:00
David Wendt
bedd5fa007
avm2: Add a method for mutating the array storage of an object.
2020-09-15 02:20:11 -07:00
David Wendt
d92d3023e7
avm2: Restore `as_number`.
...
This is for the sake of methods that want to change behavior based on if they're working with a number or some other kind of value. It should not be used otherwise.
2020-09-15 02:20:11 -07:00
David Wendt
16e1a1bdf3
avm2: Add Array class.
...
This code also ensures that the prototypes of each system object are created in the appropriate `TObject` impl. This ensures that, for example, `new Array` hands you back an actual array.
2020-09-15 02:20:11 -07:00
David Wendt
88fc9b1538
avm2: Implement base types for array-shaped objects.
2020-09-15 02:20:11 -07:00
dependabot-preview[bot]
f0976cffc7
build(deps): bump syn from 1.0.40 to 1.0.41
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.40 to 1.0.41.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.40...1.0.41 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-14 12:02:03 -07:00
Nathan Adams
3ff399ca6b
core: Trace only to the log backend, but have the default log backend trace to the log crate
2020-09-13 13:51:39 -07:00
Nathan Adams
319efabb47
tests: Make tests capture trace output through new backend
2020-09-13 13:51:39 -07:00
Nathan Adams
e25e03a841
core: Log to new avm_trace method where we want things to show up
2020-09-13 13:51:39 -07:00
Nathan Adams
de009c7673
core: Add Log backend, for capturing trace output specific to a movie
2020-09-13 13:51:39 -07:00
dependabot-preview[bot]
491526cc93
build(deps): bump bitstream-io from 0.8.5 to 0.9.0
...
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io ) from 0.8.5 to 0.9.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases )
- [Commits](https://github.com/tuffy/bitstream-io/compare/v0.8.5...v0.9.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 21:17:24 -07:00
Adrian Wielgosik
0fe88f23bb
avm1: Use fnv hash in PropertyMap
2020-09-09 10:44:52 -07:00
CUB3D
8a5434c956
core: Switch to enum for differentiating callable values from uncallable ones
2020-09-07 13:14:48 -07:00
CUB3D
efa7e862fd
core: Propagate this through scope and get_variable
2020-09-07 13:14:48 -07:00
CUB3D
91d5e0f74b
core: Update tests
2020-09-07 13:14:48 -07:00
CUB3D
136a5664b0
core: Pass the correct this for CallFunction when in a with scope
...
fixes #805 , #945 , #1018
2020-09-07 13:14:48 -07:00
Mike Welsh
a18e80baf2
chore: Fix clippy lints
2020-09-07 12:18:41 -07:00
dependabot-preview[bot]
08f1299595
build(deps): bump syn from 1.0.39 to 1.0.40
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.39 to 1.0.40.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.39...1.0.40 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:14:14 -07:00
dependabot-preview[bot]
07a6075765
build(deps): bump indexmap from 1.5.2 to 1.6.0
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.5.2...1.6.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 11:13:54 -07:00
David Wendt
35b589b2ac
avm2: `in` should only ever query non-namespaced/public properties.
2020-09-07 11:07:07 -07:00
David Wendt
3b5411547a
avm2: Implement `in`
2020-09-07 11:07:07 -07:00
David Wendt
11b8354905
avm2: `resolve_any` should resolve prototype properties.
2020-09-07 11:07:07 -07:00
Mike Welsh
64679e8796
avm1: typeof button/text should be object ( fix #1110 )
2020-09-04 11:33:40 -07:00
Nathan Adams
b2dc564628
avm1: Fix String.lastIndexOf(undefined)
2020-09-04 11:32:16 -07:00
Nathan Adams
ea7a9758c4
avm1: Fix String.indexOf(undefined)
2020-09-04 11:32:16 -07:00
Mike Welsh
86ab300ee8
core: Call post_instantiate on initial empty root ( fix #946 )
...
The `fake_root` did not have an object, which could cause the
player to panic if the SWF was not completely loaded when playing.
Calling `post_instantiate` ensures that this dummy root has an
object.
2020-09-04 11:31:04 -07:00
Mike Welsh
3a813f1f15
tests: Test for #1104
2020-09-03 19:09:48 -07:00
Mike Welsh
5ea06b0ce6
swf: Use Option for more PlaceObject parameters
...
There is a difference between empty/default (change value to default)
and none (don't modify), so make this explicit for some PlaceObject
parameters where it wasn't.
Fixes #1104 .
2020-09-03 19:09:48 -07:00
Mike Welsh
151b13a424
avm1: ExternalInterface properties are read only
2020-09-03 18:17:44 -07:00
Nathan Adams
b5531a48d0
web: Allow reentrant ExternalInterface callbacks
2020-09-03 18:17:44 -07:00
Nathan Adams
a49e8d8587
web: Implement two-way communication with ExternalInterface
2020-09-03 18:17:44 -07:00
Nathan Adams
687c912067
core: Allow for reentry from ExternalInterface methods
2020-09-03 18:17:44 -07:00
Nathan Adams
32de953822
core: Allow passing arguments and returning values to/from ExternalInterface
2020-09-03 18:17:44 -07:00
Nathan Adams
e1b3ac79d6
core: Add ability to call out to ExternalInterfaceProviders
2020-09-03 18:17:44 -07:00
Nathan Adams
502ea98ed4
core: Add ability to call in to ExternalInterface callbacks from outside of the player (+ test)
2020-09-03 18:17:44 -07:00
Nathan Adams
169c61bf96
tests: Added ability for tests to have a before_start and before_end, and added basic ExternalInterface test that uses it
2020-09-03 18:17:44 -07:00
Nathan Adams
3784f411b4
core: Add ExternalInterface::addCallback
2020-09-03 18:17:44 -07:00
Nathan Adams
b66e9f8d16
avm1: Add ExternalInterface with only 'available' property right now
2020-09-03 18:17:44 -07:00
Nathan Adams
8f11141426
core: Add initial ExternalInterface structs
2020-09-03 18:17:44 -07:00
Nathan Adams
c5ac707fb5
avm1: Iterating xmlnode attributes should list every attribute
2020-09-03 17:03:43 -07:00
Nathan Adams
bcb64b9a62
avm1: Fix calling Function() as a function - fixes #1074
2020-09-03 17:01:20 -07:00
Nathan Adams
40cdb84656
tests: Add test for avm1 Function(foo)
2020-09-03 17:01:20 -07:00
Mike Welsh
ce2b360ab7
core: Provide default impl for DisplayObject:hit_test_bounds
2020-09-02 17:51:55 -07:00
Mike Welsh
b0c9795cad
core: Graphic::from_swf_tag takes ownership of Shape
2020-09-02 17:51:55 -07:00
Mike Welsh
f2f70cc882
core: Mouse picking for buttons uses shape hit tests
2020-09-02 17:51:55 -07:00
Mike Welsh
d7a186b2cd
avm1: Implement shape hit testing
2020-09-02 17:51:55 -07:00
Mike Welsh
2da3c0d319
tests: Add hitTest shapeflag test
2020-09-02 17:51:55 -07:00
Nathan Adams
ec407a9514
avm1: Don't blanket impl From<i64> for Value, convert it explicitly where we know it's okay
2020-09-02 17:12:31 -07:00
Nathan Adams
0b5713557b
desktop: Implement LocaleBackend for desktop
2020-09-02 17:12:31 -07:00
Nathan Adams
f50b29151c
avm1: If a NaN is provided to new Date(timestamp), fail immediately
2020-09-02 17:12:31 -07:00
Nathan Adams
9dfc20e1ba
avm1: Implement Date.UTC
2020-09-02 17:12:31 -07:00
Nathan Adams
86eb6f2e50
avm1: Implement Date - #249
2020-09-02 17:12:31 -07:00
Nathan Adams
3d30ec67e2
test: Add more cases to registerClass tests
2020-09-02 15:18:59 -07:00
Nathan Adams
2178beec87
core: When constructing objects for DisplayObjects, make sure frames are run at the right moment
2020-09-02 15:18:59 -07:00
Mike Welsh
537cca7c38
tests: Add test for #1086
2020-09-02 13:25:53 -07:00
Mike Welsh
bc08971066
core: Return version from MovieClip::swf_version ( fix #1086 )
...
MovieClip was not returning the proper SWF version, causing it to
default to the newest SWF version in some cases when it shouldn't.
2020-09-02 13:25:53 -07:00
dependabot-preview[bot]
03dcdcd494
build(deps): bump indexmap from 1.5.1 to 1.5.2
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.5.1...1.5.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-02 12:39:18 -07:00
CUB3D
e95c1ff758
core: Make blurX and blurY floating point
2020-09-02 10:59:00 -07:00
CUB3D
143ba03754
core: Fix clippy lints and format
2020-09-02 10:59:00 -07:00
CUB3D
a2c151677b
core: Add blurFilter and test
2020-09-02 10:59:00 -07:00
CUB3D
d1ad095bad
core: Add tests for bitmap_filter
2020-09-02 10:59:00 -07:00
CUB3D
34f485ca21
core: Add basic flash.filters.(BlurFilter|BitmapFilter)
2020-09-02 10:59:00 -07:00
Nathan Adams
cb2461920b
core: HTTP request values need to preserve order
2020-08-28 11:53:32 -07:00
dependabot-preview[bot]
4137a1cac0
build(deps): bump minimp3 from 0.4.0 to 0.5.0
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-27 13:20:14 -07:00
dependabot-preview[bot]
9db07eb997
build(deps): bump minimp3 from 0.3.5 to 0.4.0
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.3.5 to 0.4.0.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-26 09:57:40 -07:00
Mike Welsh
f55bac2014
text: HTML tags and attributes are case insensitive ( fix #1021 )
...
Use eq_ignore_ascii_case when parsing HTML tags. Different versions
of Flash may export HTML tags with different cases, so this will
work a little better; however, we'll need a true HTML parser to
handle this robustly (for opening and closing tags with different
cases, for example).
2020-08-24 11:27:14 -07:00
Mike Welsh
febada8a8e
text: Fix duplicated characters when parsing HTML entities ( fix #1026 )
2020-08-24 11:27:14 -07:00
Mike Welsh
e8178c35a3
core: Add MouseWheel player event
2020-08-23 13:38:59 -07:00
kmeisthax
559bc05b6a
avm2: Implement avm2 math opcodes (merge #1037 )
...
* Implement `add`, with tests.
* Implement `add_i`.
There's no test, because for whatever reason, I can't figure out how to emit this from Animate CC 2020.
* avm2: Implement `bitand` with tests.
* Implement `bitnot` with tests.
* Implement `bitor` with tests.
* avm2: Implement `bitxor`
* avm2: Implement `declocal`, `declocal_i`, `decrement`, and `decrement_i`.
* tests: `swf_approx` tests should be allowed to print NaNs.
* avm2: Implement `divide`.
* avm2: Implement `inclocal`, `inclocal_i`, `increment`, and `increment_i`.
* avm2: Implement `lshift`.
* Implement `modulo`.
* avm2: Implement `multiply` and `multiply_i` (no tests for the latter)
* avm2: Implement `negate` and `negate_i` (no tests for the latter)
* avm2: Implement `rshift`
* avm2: Implement `subtract` and `subtract_i` (the latter without tests)
* avm2: Implement `urshift`.
2020-08-23 13:38:38 -07:00
Mike Welsh
ba05894901
avm1: Don't mutably borrow self in TObject
2020-08-23 02:19:53 -07:00
Mike Welsh
2a84d924bb
chore: Don't mutably borrow self in TDisplayObject
2020-08-22 11:56:19 -07:00
dependabot-preview[bot]
5d2ba7fee6
build(deps): bump syn from 1.0.38 to 1.0.39
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.38 to 1.0.39.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.38...1.0.39 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-21 12:54:02 -07:00
Mike Welsh
06b6d14367
avm1: Fix removeMovieClip depth range
...
removeMovieClip should only function on objects within a certain
depth range, usually to prevent removing timeline clips. However,
this wasn't working properly in some cases because the depth was
being biased incorrectly (removeMovieClip never takes a depth
parameter, so we should not bias the depth).
2020-08-21 00:55:35 -07:00
Mike Welsh
528b52ac7c
tests: Activate unused remove_movie_clip test
2020-08-21 00:55:35 -07:00
Mike Welsh
1e6a053c56
avm1: Implement TargetPath
2020-08-20 18:14:01 -07:00
Mike Welsh
bbc5e01009
tests: Add test for targetPath action
2020-08-20 18:14:01 -07:00
Mike Welsh
e9f9cda34d
tests: Rename target_path test to string_path
2020-08-20 18:14:01 -07:00
Mike Welsh
b8f5a405b9
tests: Add test for flash.geom.Transform
2020-08-20 17:29:04 -07:00
Mike Welsh
ca3ed34c2c
avm1: Implement flash.geom.Transform
2020-08-20 17:29:04 -07:00
Mike Welsh
0a81dae7bb
avm1: toString for display objects
2020-08-18 01:18:15 -07:00
Mike Welsh
cefc0ce5c1
core: Add button children to execution list
...
Children of buttons were not getting linked up into the execution
list, which would cause certain methods to be incorrect (such as
button._width).
2020-08-18 01:18:15 -07:00
Mike Welsh
d2c49c0f33
core: Remove some mut from TDisplayObject methods
2020-08-18 01:18:15 -07:00
Mike Welsh
544c1becc2
tests: Add test for button children
2020-08-18 01:18:15 -07:00
Mike Welsh
59ebd0167e
core: Fix priority of conflicting instance names
2020-08-18 01:18:15 -07:00
Mike Welsh
b5c7e1dab0
tests: Add test for conflicting instance names
2020-08-18 01:18:15 -07:00
Mike Welsh
13b4b6bbbb
chore: Fix unused variable warning in url_from_relative_path
2020-08-16 18:44:57 -07:00
Floens
95acc14190
avm1: fix array unshift
...
update array_trivial test for it
2020-08-16 04:27:09 -07:00
Mike Welsh
f782ea8020
avm2: AVM2 built-in class suport (merge #802 )
...
Initial support for defining built-ins in AVM2
2020-08-16 03:45:02 -07:00
David Wendt
4c824fcefe
Rename `trait.rs` to `traits.rs` to avoid the use of reserved keyword syntax.
2020-08-14 21:20:41 -04:00
David Wendt
7b7f0b20e6
Consolidate all of our copied `CollectWrapper`s.
2020-08-14 20:52:09 -04:00
Albert Safin
e03373bceb
avm1: parseInt
2020-08-13 00:40:20 -07:00
Mike Welsh
cbd448522a
chore: Allow unknown clippy lints
...
same_item_push was added on nightly, but is currently throwing
a false negative. I added an allow for it, but this causes a
warning on stable for an unknown lints, so allow unknown lints for
now.
2020-08-12 23:51:12 -07:00
Mike Welsh
6c89869210
chore: Fix clippy lints
2020-08-12 19:04:14 -07:00
dependabot-preview[bot]
9b6dd45439
build(deps): bump smallvec from 1.4.1 to 1.4.2
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.1...v1.4.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-12 11:13:33 -07:00
David Wendt
825eb34c67
avm1: `Button` should not hold write locks on itself when instantiating children.
...
This fixes a bug where a nested textfield within a button with variable linkages would panic in Ruffle.
2020-08-12 11:08:27 -07:00
David Wendt
354b194b69
avm1: Add test for nested text fields in buttons.
2020-08-12 11:08:27 -07:00
David Wendt
32aad6176b
`FunctionObject::from_builtin_constr` should pull the scope and class off of it's given prototype and copy it onto the constructor function it returns.
2020-08-11 00:04:13 -04:00
David Wendt
11ddccfa6a
Remove the two-step initialization process and construct an ES4 class for `Object`, `Function`, and `Class`.
...
This has some particularly annoying consequences for initialization order: notably, we can't actually create any ES4 classes using the standard machinery until after the three objects I just mentioned get created. Ergo, we have to create them through lower-level means, handing prototypes around, and then initialize AVM2's system prototypes list for it.
When we start adding more system prototypes, we'll also have to fill the extras with blank objects and then slot them in as we create them.
2020-08-11 00:02:12 -04:00
David Wendt
16d8c85d20
Load player globals as soon as possible.
...
We're about to massively change the initialization process, and we really don't want to create another situation where the player can get caught with it's pants down.
2020-08-10 23:35:37 -04:00
David Wendt
a8e267ed16
Allow system prototypes to be initialized after the fact.
2020-08-10 23:35:37 -04:00
David Wendt
b1bcceaa78
Allow accessing the `Class` off of a constructor or prototype that references it.
2020-08-10 23:35:33 -04:00
David Wendt
22ec96b85e
`install_trait` and `install_foreign_trait` should return the value of the thing they installed.
2020-08-10 23:23:35 -04:00
David Wendt
df95482eb1
Allow setting `slot_id` or `disp_id` (depending on kind).
2020-08-10 23:23:34 -04:00
David Wendt
4ed5050f56
Add function to change trait attributes.
2020-08-10 23:23:34 -04:00
David Wendt
a5b62e833e
Add trait attributes, similar to that of class attributes
2020-08-10 23:23:31 -04:00
David Wendt
60d42fa558
Allow creating slot/const traits.
2020-08-10 23:19:22 -04:00
David Wendt
3ca8dfd21a
Allow constructing traits for getters, setters, and unbound free functions.
2020-08-10 23:19:22 -04:00
David Wendt
d366ceab0e
Allow setting the protected namespace of a builtin class.
2020-08-10 23:19:21 -04:00
David Wendt
9dc6cbe1ce
Allow creating builtin traits from methods.
2020-08-10 23:19:21 -04:00
David Wendt
5e932bcb75
Allow implementing interfaces in built-in classes.
2020-08-10 23:19:20 -04:00
David Wendt
94d5170277
When manually instantiating classes for globals, make sure that the classes get the global scope object when instantiated.
2020-08-10 23:19:15 -04:00
David Wendt
3585cf983b
Convert our stub implementations of all non-ECMA classes into `Class`es.
...
This was surprisingly tricky - due to the need to look up superclasses, class trait instantiation requires an active `Activation` and `UpdateContext`. We can't get those during VM instance creation, since the player needs the VM first before it can give it a context to work with. Ergo, we have to tear the global scope initialization in two. At the first possible moment, the player calls a new `load_player_globals` method that initializes all class traits in global scope.
2020-08-10 23:16:07 -04:00
David Wendt
6f284f60eb
Allow constructing a trait from a class.
2020-08-10 23:09:16 -04:00
David Wendt
b0b6cec117
Allow expanding a `QName` into a `Multiname` that selects exactly the `QName` and no more.
2020-08-10 23:09:15 -04:00
David Wendt
f09c35c4b9
`From<NativeMethod<'gc>>` doesn't always work, but using an explicit non-trait method sometimes does.
...
I have no idea why this is necessary - I was in a context where what *should* have been a `NativeMethod<'gc>` was instead being interpreted as some different function type with all the same lifetimes, but with an extra `'gc` lifetime as well. Funneling this through a non-trait method bypasses whatever is going on with the trait solver, and then at that point the trait solver knows what to do. Consider this an extra level of conversion.
2020-08-10 23:09:15 -04:00
David Wendt
4a2a456666
`Class::new` should also take the superclass name.
2020-08-10 23:09:13 -04:00
David Wendt
d96596fd8a
Add a function to manually change attributes.
2020-08-10 23:07:16 -04:00
David Wendt
44b8e5d9c7
Wrap up the existing sealed/final/interface bits in a `ClassAttributes` enumset.
2020-08-10 23:07:13 -04:00
David Wendt
bf6ccfeee1
Add some convenience functions for defining native classes.
2020-08-10 23:02:42 -04:00
David Wendt
c2cdc302c3
Remove further unnecessary primitive comparison checks
2020-08-10 16:38:04 -07:00
David Wendt
993f56798e
Extract all of the numerical conversions into a separate module and leverage them where appropriate in AVM2
2020-08-10 16:38:04 -07:00
David Wendt
566b262d60
Move all our custom object implementations into a separate module, and use a macro to implement them.
2020-08-10 16:38:04 -07:00
David Wendt
5bcd1be270
Remove another instance of `abs` for zero-checks.
2020-08-10 16:38:04 -07:00
David Wendt
2f55c08e37
`pushbyte` should generate signed integers rather than `Number`s.
2020-08-10 16:38:04 -07:00
David Wendt
7f479f24b9
Adjust `coerce_to_string` to be less silly.
2020-08-10 16:38:04 -07:00
David Wendt
a12f51903f
Non-finite covers everything here.
2020-08-10 16:38:04 -07:00
David Wendt
2e8acfe6f7
Apparantly, Rust already does not care about negative zero, so we don't need to, either.
2020-08-10 16:38:04 -07:00
David Wendt
1bb6f84beb
Avoid hitting `coerce_to_number` for integer comparison cases.
2020-08-10 16:38:04 -07:00
David Wendt
4e92352813
Don't promote to `f64` in strict-equality comparisons if we can promote to `i64` instead.
2020-08-10 16:38:04 -07:00
David Wendt
a211698464
Handle strict and abstract equality of our various number subtypes as if they were all the same type.
...
ECMA-262 3rd ed. doesn't mention anything about different number types, so the standard as-if rule applies. If we are going to distinguish number types, we have to treat them as if they were the same type, promoting to `f64` as necessary to facilitate the conversion. I took a cursory look at an ECMA-262 4th ed. draft and it appears to do the same, although it calls everything `GeneralNumber` and has some really confusing psuedo-Pascal syntax for some reason.
I am extremely glad AVM2 does not provide access to 64-bit integer types (for now, at least).
2020-08-10 16:38:04 -07:00
David Wendt
f3e47cb596
Further adjustments due to the massive refactor of `Activation`, `AvmX`, and `UpdateContext`.
2020-08-10 16:38:04 -07:00
David Wendt
ea4c42a6d1
Split `Value::Number` into separate floating-point, integer, and unsigned representations to match the three numerical classes provided by AS3.
2020-08-10 16:38:04 -07:00
David Wendt
a0895e843c
Fix `matches!` lint in nightly Rust being tripped.
2020-08-10 16:38:04 -07:00
David Wendt
b779dccdc1
Allow objects to provide a coercion hint for cases where a more obvious one is not available.
2020-08-10 16:38:04 -07:00
David Wendt
d14fa845c2
Remove `Value::Namespace`.
...
Namespaces as values adds a bunch of extra special cases to the coercion and equality rules that don't really belong there. Namespace itself just returns it's URI as a string, so we can just make `NamespaceObject` do that and then treat it the same way we treat boxed primitives.
2020-08-10 16:38:04 -07:00
David Wendt
e6aac48ae2
Add `NamespaceObject` to hold `Namespace`s.
...
The reason for this will become very apparent, very shortly.
2020-08-10 16:38:04 -07:00
David Wendt
aeb1752d0f
`PrimitiveObject`'s `toString` and `valueOf` should always yield their boxed values.
2020-08-10 16:38:04 -07:00
David Wendt
65b4392642
Remove `as_number`.
...
The only code that used it was the enumeration operations in AVM2.
2020-08-10 16:38:04 -07:00
David Wendt
4906c5a3f1
Remove uses of `as_string` in various places.
...
These include:
* Name resolution in `newobject`
* All runtime & late-bound multinames
* `Object.hasOwnProperty`
* `Object.propertyIsEnumerable`
* `Object.setPropertyIsEnumerable`
2020-08-10 16:38:04 -07:00
David Wendt
c040997be2
*Actually* fix the conversion.
...
So, I overlooked this reading the 1.45 documentation, but the first thing they did is completely change f64 conversions. Apparantly, what I was doing (and what JavaScript spec dictates) is actually considered UB in LLVM, and my ability to actually write a concise wrapping u32 conversion is actually a soundness hole in Rust. Ergo, I'm now emulating the wrapping and sign calculation, which makes this both passing it's tests again and free of soundness holes and UB.
2020-08-10 16:38:04 -07:00
David Wendt
473414e167
Explicitly request `u64` be involved with `u32` coercions.
...
I don't know why I'm doing this - tests are failing in CI but not locally, and I can only assume that the most obvious conversion is broken in some way on whatever other architecture GitHub Actions uses. This will explicitly mask the integer result as a u64, and then convert it down to u32. A not-broken compiler should treat this code identically.
2020-08-10 16:38:04 -07:00
David Wendt
962f6aa54c
Remove `as_object`.
...
AVM2 is based on ES4, which as far as I'm aware, does not distinguish between "primitive values" and "objects". Thus, it is expedient to interpret any statement requiring something to be an Object to mean "not null or undefined".
Since we internally represent register values with primitive types, it is important that the VM always coerces to object before doing any other sort of type checking. Hence, something like `as_object` is unhelpful as it accidentally enforces a primitive/object distinction that ES4 attempted to remove.
2020-08-10 16:38:04 -07:00
David Wendt
8de063a916
Implement automatic primitive boxing via `coerce_to_object`.
2020-08-10 16:38:04 -07:00
David Wendt
f12f67650b
Stub all primitive type classes.
2020-08-10 16:38:04 -07:00
David Wendt
cb0f1e9099
Add a new object variant for boxed primitives.
2020-08-10 16:38:04 -07:00
David Wendt
6ec1d453b8
Add tests for `greaterequals`, `greaterthan`, `lessequals`, and `lessthan`.
2020-08-10 16:38:04 -07:00
David Wendt
b7dfce51b8
Implement `greaterequals`, `greaterthan`, `lessequals`, and `lessthan`.
2020-08-10 16:38:04 -07:00
David Wendt
f88f2e225a
Add tests for `>`, `<`, `<=`, and `>=`.
...
Note that this does NOT completely test the full range of if instructions for abstract relational comparison. Notably, the Adobe Animate CC compiler compiles each operator into it's negated equivalent, e.g. `<` becomes `ifnlt`.
I do not know how to get it to emit `ifge` or the like, which differ only by how they handle `NaN`s.
2020-08-10 16:38:04 -07:00
David Wendt
730c47cf29
Implement `ifge`, `ifgt`, `ifle`, `iflt`, `ifnge`, `ifngt`, `ifnle`, and `ifnlt`.
2020-08-10 16:38:04 -07:00
David Wendt
70a27ccb81
Implement ECMA abstract relational comparison
2020-08-10 16:38:04 -07:00
David Wendt
2ef03c6019
Allow no-hint primitive coercion
2020-08-10 16:38:04 -07:00
David Wendt
76ab8570e4
Implement and test `equals`.
...
The test is also far more in-depth than the `if_eq`/`if_ne` tests, which use the same set of vectors as the strict-equality tests from a while ago. Interestingly, this test passed on first run
2020-08-10 16:38:04 -07:00
David Wendt
5da4e2f118
Test for `iseq` and `isne`
2020-08-10 16:38:04 -07:00
David Wendt
29d5ae9989
Implement `ifeq` and `ifne`.
2020-08-10 16:38:04 -07:00
David Wendt
ccc478e7dd
Implement ECMA-262 abstract equality.
2020-08-10 16:38:04 -07:00
David Wendt
0125a14d1f
Partially implement `ToObject` coercion.
...
Implementation is limited to generating exceptions on `null` or `undefined`. I'm not sure if primitive values don't exist in AVM2 or if this is supposed to box them like ES3, so I have decided to handle neither at this time.
2020-08-10 16:38:04 -07:00
David Wendt
86965eb674
Test for `coerce_s`.
...
I cannot yet figure out how to generate tests that use `convert_s`, so it's not covered.
2020-08-10 16:38:04 -07:00
David Wendt
0138300b5a
Implement `coerce_s` and `convert_s`.
2020-08-10 16:38:04 -07:00
David Wendt
90d2964adf
Properly handle all cases of ECMA-262 string coercions.
...
This code is slightly over/under-precise compared to AVM2. This is because we handle precision limiting in binary floats rather than as part of the float printing process. Flash Player may also be rounding differently than us. However, I'm pretty sure ECMA-262 allows us to slightly differ here.
2020-08-10 16:38:04 -07:00
David Wendt
35f939cb15
Add and test for `convert_u` using `ToUint32` from ECMA-262
2020-08-10 16:38:04 -07:00
David Wendt
6eb41035cf
Add & test ECMA-262 ToInt32 and `convert_i` opcode.
...
The ECMA-262 documentation is awfully overwrought for something that boils down to "chop off the non-whole part, wrap to 32 bits, then reinterpret as signed". Bitwise operations are *hell* to describe mathematically, and such descriptions are even harder to understand.
2020-08-10 16:38:04 -07:00
David Wendt
351fe026e9
Add a test for all the above numerical coercions.
2020-08-10 16:38:04 -07:00
David Wendt
4c1489a814
Promote bytes to signed representation before pushing.
...
For whatever reason, `pushbyte` appears to be processed as a *signed* byte, despite the clear wording of "*byte_value* is an unsigned byte" in avm2overview.pdf. I guess it's supposed to be manually converted and promoted in this manner.
2020-08-10 16:38:04 -07:00
David Wendt
736a94a244
Implement numerical coercions according to ECMA-262 3rd Edition spec.
2020-08-10 16:38:04 -07:00
David Wendt
24fd30652d
Allow tracing numbers to the console.
2020-08-10 16:38:04 -07:00
David Wendt
60f9613365
Implement and test for `convert_b`.
2020-08-10 16:38:04 -07:00
David Wendt
6cf48eb543
Implement and test `not`.
2020-08-10 16:38:04 -07:00
David Wendt
b972c24f7e
Oh look, I figured out how to emit `istrue`, so that's tested, too.
2020-08-10 16:38:04 -07:00
David Wendt
850ebc88a2
Add test for truthiness.
...
As compiled by Adobe Animate CC 2020, this test appears to only use `iffalse`. However, both `op_is_false` and `op_is_true` coerce in the same manner, so I'm not entirely sure this is a problem for now.
2020-08-10 16:38:04 -07:00
David Wendt
e5c8c5b340
Expose `Infinity` to AS3.
2020-08-10 16:38:04 -07:00
David Wendt
5bb8c1836f
Replace `as_bool` with `coerce_to_bool`.
...
Functions that need to assert Boolness without coercion should either:
1. Ensure their function declaration requires a Boolean. (We don't enforce type errors on ES4 typehints yet, but we should.)
2. Check the value type themselves and raise their own errors if necessary.
As it stands the only users of `as_bool` either needed to check the type themselves or use `coerce_to_bool`. Notably, `setPropertyIsEnumerable` doesn't appear to coerce *or* throw an error: it instead fails silently if you hand it a non-`Boolean` value.
2020-08-10 16:38:04 -07:00
dependabot-preview[bot]
04b146ffc4
build(deps): bump enumset from 1.0.0 to 1.0.1
...
Bumps [enumset](https://github.com/Lymia/enumset ) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/Lymia/enumset/releases )
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md )
- [Commits](https://github.com/Lymia/enumset/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-09 13:15:38 -07:00
dependabot-preview[bot]
178178d9dd
build(deps): bump indexmap from 1.5.0 to 1.5.1
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.5.0...1.5.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-08 13:37:32 -07:00
dependabot-preview[bot]
53d32d4dac
build(deps): bump num_enum from 0.5.0 to 0.5.1
...
Bumps [num_enum](https://github.com/illicitonion/num_enum ) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/illicitonion/num_enum/releases )
- [Commits](https://github.com/illicitonion/num_enum/compare/0.5.0...0.5.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 16:00:27 -07:00
dependabot-preview[bot]
0c7edda6c2
build(deps): bump syn from 1.0.37 to 1.0.38
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.37 to 1.0.38.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.37...1.0.38 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-05 15:59:02 -07:00
unknown
47a8eb6f3e
avm1: Copy broadcast functions for MovieClipLoader
2020-08-04 07:02:14 -07:00
dependabot-preview[bot]
f8aa185c3e
build(deps): bump syn from 1.0.36 to 1.0.37
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.36 to 1.0.37.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.36...1.0.37 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-03 16:57:45 -07:00
David Wendt
8cb6e4af39
Further adjustments that fell through before.
2020-08-01 16:11:11 -04:00
David Wendt
4dbd26807e
Remove useless lifetime in `notify_system_listeners`
2020-08-01 15:49:29 -04:00
David Wendt
8ebf5405e2
Move AVM2 into the UpdateContext.
2020-08-01 15:49:29 -04:00
David Wendt
bfa5f8ae35
Further compilation fixes necessary to get the refactor to compile again.
...
Notably, all of the `Avm1` "run stack frame" functions can no longer take a self parameter as the update context they will be getting also has that same parameter. Ergo, they're associated functions that get the moral equivalent of self from the update context.
This also introduces a new `Activation::from_stub` which creates a stub frame that runs everything on the main movie in layer 0. This significantly reduces boilerplate code elsewhere in the project.
2020-08-01 15:49:28 -04:00
David Wendt
9b089ae1d7
Convert `array.rs` to the new activation-only format.
...
This also removes the function parameter on `sort_compare_numeric`. As it was only being used for string comparisons, and it was causing unfixable lifetime issues, I have instead had it take the case-sensitivity flag and call the two functions it would have been passed anyway. This fixes the lifetime issue.
2020-08-01 15:49:26 -04:00
David Wendt
a19595c8b4
Embed `UpdateContext` in `Activation` directly.
...
The process of constructing an `Activation` now involves calling `UpdateContext.reborrow`, which "sheds" a lifetime by copying all of the borrows into a new "owned" context with that lifetime.
Likewise, to call out to functions that don't need an `Activation`, just borrow the context out of the current activation. You can also construct child-frame activations by reborrowing the parent activation's context.
2020-08-01 15:49:19 -04:00
David Wendt
7c7b019087
Move AVM1 inside UpdateContext.
2020-08-01 13:44:04 -04:00
David Wendt
14bfbc358f
wip: Move UpdateContext into Activation
2020-08-01 13:33:04 -04:00
David Wendt
9f76a7b964
Ensure that `Player` always has a movie in level zero, even if no movie has been queued up yet.
...
There is a race condition inadvertently caused by allowing movies to be fetched in slot 0: it is possible for the player to be caught mid-load without a root movie. A lot of code assumes level 0 always exists (e.g. `levels.get(0).unwrap()`), while our initialization methods assumed no Player methods would be called until the root movie is installed. This is an unreasonable assumption, as among other things users can trigger the race condition by just playing the movie too quickly.
2020-08-01 02:35:00 -07:00
Nathan Adams
26b14bd904
avm1: Undone some __constructor__ setting on objects that don't actually construct
2020-08-01 02:33:14 -07:00
Nathan Adams
db4f5007f3
avm1: TObject::create_bare_object doesn't use or need args
2020-08-01 02:33:14 -07:00
Nathan Adams
79af3ffe44
avm1: Rename TObject::new to TObject::create_bare_object
2020-08-01 02:33:14 -07:00
Nathan Adams
2131f7860b
avm1: Change Object::construct to create and return a new object, instead of requiring the caller to do that first
2020-08-01 02:33:14 -07:00
Nathan Adams
e74d4f0abb
avm1: Make FunctionObject::allocate_function require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
fb7fb6f99a
avm1: Make FunctionObject::functional require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
9123d92513
avm1: Make FunctionObject::constructor require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
691e3b6804
avm1: Make FunctionObject::function_and_constructor require prototype, it's not optional
2020-08-01 02:33:14 -07:00
Nathan Adams
88a31cc5a9
avm1: Ensure we call movie constructors through Function::construct, not manually, to set __constructor__
2020-08-01 02:33:14 -07:00
Nathan Adams
69a4d10338
avm1: Replace manual constructor calling with Function::construct, to ensure we set __constructor__
2020-08-01 02:33:14 -07:00
Nathan Adams
2faf35d43e
avm1: Set __constructor__ in Function::construct
2020-08-01 02:33:14 -07:00
unknown
d6eeb723dc
avm1: Fix panic in broadcastMessage
2020-07-29 15:24:23 -07:00
unknown
1d17910b6d
chore: Remove an unnecessary file
2020-07-29 15:24:23 -07:00
unknown
ef4240e95d
chore: Satisfy rustfmt and clippy
2020-07-29 15:24:23 -07:00
unknown
a14f19e9e5
avm1: Call the respective listeners
2020-07-29 15:24:23 -07:00
unknown
795cd72dce
avm1: Broadcasting functions are now copied from AsBroadcaster
2020-07-29 15:24:23 -07:00
unknown
b72dbcae96
chore: Assert his inside of listeners
2020-07-29 15:24:23 -07:00
unknown
df50cbb27f
avm1: Fix the behavior of addListener and removeListener
2020-07-29 15:24:23 -07:00
unknown
20989ef03d
avm1: Initialize now copies the functions from AsBroadcaster
2020-07-29 15:24:23 -07:00
unknown
3a0af11e34
chore: Run rustfmt
2020-07-29 15:24:23 -07:00
unknown
890dc0ea13
avm1: Implement AsBroadcaster
2020-07-29 15:24:23 -07:00
Nathan Adams
32be19da6d
avm1: Allow gotoAndStop/gotoAndPlay with frame numbers in paths - #915
2020-07-29 13:53:57 -07:00
Mike Welsh
5d08956152
tests: Add typeof and labels for Object() test
2020-07-29 13:52:51 -07:00
CUB3D
0fe3a23fd6
core: Correct handling of Object function without args
2020-07-29 13:52:51 -07:00
CUB3D
49bee3fe5c
core: Implement Object() function
2020-07-29 13:52:51 -07:00
CUB3D
fa8b2bca8b
chore: Fix formatting
2020-07-27 12:50:31 -07:00
CUB3D
c1771d7d4e
core: Split function and constructor, tests, fix bug with constructor
2020-07-27 12:50:31 -07:00
CUB3D
4217138d1a
chore: Update comment
2020-07-27 12:50:31 -07:00
CUB3D
7792487181
chore: Fix clippy lints
2020-07-27 12:50:31 -07:00
CUB3D
afb1d6b42f
core: Add global Array() function
2020-07-27 12:50:31 -07:00
CUB3D
22db5ab76a
core: Populate function when creating a constructor
2020-07-27 10:38:50 -07:00
CUB3D
01b7e73459
core: Fix build
2020-07-27 10:38:50 -07:00
CUB3D
adb9af5a62
core: Update arguments
2020-07-27 10:38:50 -07:00
CUB3D
7b66968ebb
core: Cleanup
2020-07-27 10:38:50 -07:00
CUB3D
5f87b1361b
core: Update NewMethod action and update globals to use constructor
2020-07-27 10:38:50 -07:00
CUB3D
e83dbf7327
core: Split construct and call for function objects
2020-07-27 10:38:50 -07:00
Nathan Adams
337e3292dd
avm1: Treat MovieClipLoader _listeners as an array, not an object
2020-07-27 05:36:28 -07:00
dependabot-preview[bot]
ed07ea6db2
build(deps): bump syn from 1.0.35 to 1.0.36
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.35 to 1.0.36.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.35...1.0.36 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 05:17:11 -07:00
Nathan Adams
17344613e3
core: Lock variable dumping behind avm_debug
2020-07-27 04:13:31 -07:00
Nathan Adams
e98b953088
avm1: Use avm_warn and avm_error in all of avm1
2020-07-27 04:13:31 -07:00
Nathan Adams
10a739f714
avm1: Always assign function names (where possible) when running in avm_debug, not just when spamming output
2020-07-27 04:13:31 -07:00
Nathan Adams
810e231b8b
avm1: Add macros for more advanced log/error printing when avm_debug is on
2020-07-27 04:13:31 -07:00
Mike Welsh
e5480ee9b2
chore: Use matches! to fix clippy lint
2020-07-27 04:13:11 -07:00
Nathan Adams
f1f04e0e7a
avm1: Fixed a bunch of cases where we're using _level0 instead of current object ( fixes #926 )
2020-07-27 01:40:28 -07:00
Nathan Adams
cf61f8a4d3
avm1: Add failing test for registerClass in a loaded movie
2020-07-27 01:40:28 -07:00
Mike Welsh
8ac2ad9b40
avm1: Store movie URL on load and implement _url (merge #912 )
2020-07-27 01:38:28 -07:00
David Wendt
acd7ceb706
Fix missing import on web.
2020-07-25 22:20:30 -04:00
David Wendt
153b7b78a5
Add a web version of `url_from_relative_path` that just yields an error.
...
This allows us to remove the conditionals on implementations of `from_path` that need to call this function, as the function is now always guaranteed to be there, even if it's just a no-op/`Err` generator.
2020-07-25 19:48:32 -04:00
Mike Welsh
07122dc931
avm1: Implement Key listeners
2020-07-24 14:32:41 -07:00
Mike Welsh
85d9caef56
avm1: All properties of _global are DontEnum
2020-07-23 22:58:58 -07:00
Mike Welsh
794dc69809
avm1: Implement isFinite
2020-07-23 22:58:58 -07:00
David Wendt
aed47d458d
Level loads in GetURL2 should also propagate origin information.
2020-07-23 23:09:08 -04:00
David Wendt
a34e81a704
`_url` on desktop should always return a file URL for file-loaded movies.
2020-07-23 23:02:56 -04:00
David Wendt
f0e2c77c1f
URLs from paths is a desktop-only feature.
2020-07-23 23:02:55 -04:00
David Wendt
9b9d4076fe
Expose movie URL to ActionScript.
2020-07-23 23:02:55 -04:00
David Wendt
a8877ab63c
Yield the correct error when the root movie load fails.
2020-07-23 23:02:55 -04:00
David Wendt
d172441663
Also make absolute URLs for all movie loads passed through the load manager.
2020-07-23 23:02:54 -04:00
David Wendt
5d15f5bfe3
When loading a movie from the filesystem outside of the core, ensure that the URL is properly made absolute.
2020-07-23 23:02:54 -04:00
David Wendt
c926da8888
Refactor URL relativization into two utility methods that backends can provide base URLs and paths to.
2020-07-23 23:02:54 -04:00
David Wendt
7433bfe28f
Add a `NavigatorBackend` method to resolve relative URLs.
2020-07-23 23:02:53 -04:00
David Wendt
4813942fe7
The player should always change the audio backend's framerate itself.
2020-07-23 23:02:52 -04:00
David Wendt
f56d16a68d
Separate player creation from root movie setup, and allow users of Ruffle to load in movies synchronously or asynchronously.
...
During the small period of time when a player is created but has no root movie, a temporary empty movie is installed with an assumed stage size and framerate of 550x400@12fps. This is Flash default for new projects, so it seemed appropriate. User ActionScript cannot see these values, and I'm not even sure JavaScript can, either.
2020-07-23 23:02:51 -04:00
David Wendt
6998dafdb9
Store an origin URL on every movie that is loaded.
2020-07-23 23:02:50 -04:00
Nathan Adams
7f7281493f
core: Allow toggling avm_debug output on and off with ctrl+alt+d, defaults to off
2020-07-23 19:14:32 -07:00
Mike Welsh
efa059ff8d
tests: Add test for LoadVars
2020-07-23 03:00:19 -07:00
Mike Welsh
1709e76409
avm1: Implement LoadVars
2020-07-23 03:00:19 -07:00
Mike Welsh
74cb8609c1
avm1: Support loading into _level in GetURL2
...
Calling loadMovieNum with a variable parameter compiles into a
GetURL2 call with a `_level` window target parameter. Previously
this triggered Ruffle to try to navigate to the SWF. Now it
properly loads the SWF inside the current movie.
2020-07-23 02:08:48 -07:00
Nathan Adams
f0980301da
avm1: Implement arguments.callee
2020-07-22 15:57:45 -07:00
Nathan Adams
4a56cb1062
avm1: Make virtual properties store Object instead of Executable, so we can refer to the callee
2020-07-22 15:57:45 -07:00
Nathan Adams
f4ab57d6e0
avm1: Make property watchers take Object, not Executable, so we can track the callee
2020-07-22 15:57:45 -07:00
Nathan Adams
9ae10b6387
avm1: Made AvmString debug actually show contents of the string
2020-07-22 13:23:57 -07:00
Nathan Adams
3b2b7c226c
avm1: Fix gc unsoundness with missing collects in SystemPrototypes
2020-07-21 09:43:07 -07:00
Nathan Adams
0e0be34e17
avm1: Fix compile error when using avm_debug flag
2020-07-21 09:42:41 -07:00
Nathan Adams
d5deeee1b7
avm1: Properly implement the arguments object, it's an array
2020-07-21 07:49:00 -07:00
dependabot-preview[bot]
aa966fbfb6
build(deps): bump syn from 1.0.34 to 1.0.35
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.34 to 1.0.35.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.34...1.0.35 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-20 14:24:56 -07:00
Mike Welsh
1a5d7fe452
avm2: Initial AVM2 interpreter (merge #404 )
...
Initial work on the AVM2 interpreter.
2020-07-19 19:59:05 -07:00
David Wendt
7adabc8166
Use `unwrap_or_default`
2020-07-18 17:28:07 -04:00
David Wendt
44b924d7b4
`Script` should not hold write locks when probing it's internal caches.
2020-07-18 17:26:11 -04:00
Mike Welsh
034c125b80
core: Support radial gradients in morph shapes
...
Radial gradients were not accounted for in morph shapes.
Clean up the interpolation code and add support for radials.
Fixes #591 .
2020-07-18 14:12:04 -07:00
David Wendt
575a9b091a
Use FnvHashMap for the translation unit pools.
2020-07-18 17:02:52 -04:00
David Wendt
262bb148f1
Rename `a2me` to `entry` (or `method` in one case where it lets me simplify a struct declaration)
2020-07-18 17:02:32 -04:00
David Wendt
c415190376
Zero-index multinames should generate a validation error in `QName::from_abc_multiname`.
2020-07-18 16:48:10 -04:00
David Wendt
dc962f2abd
Add AVM2 equivalent of `PropertyMap` for further expansion.
2020-07-18 16:41:35 -04:00
David Wendt
37b6b89d26
Add a stub AVM2 string representation to allow for both VMs' strings to diverge.
2020-07-18 16:20:58 -04:00
David Wendt
ccacc540bf
Remove dead code on all now-in-use structs and methods.
2020-07-18 16:12:24 -04:00
dependabot-preview[bot]
0bd7f07649
build(deps): bump png from 0.16.6 to 0.16.7
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.6 to 0.16.7.
- [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.16.6...v0.16.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-18 12:36:46 -07:00
Mike Welsh
ae7db80ea3
avm1: Move getURL to MovieClip.prototype ( fix #804 )
...
For example, _root.getURL should work.
2020-07-18 01:03:47 -07:00
dependabot-preview[bot]
ee2222a425
build(deps): bump indexmap from 1.4.0 to 1.5.0
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.4.0...1.5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 20:51:05 -07:00
Mike Welsh
8ecae5a87f
avm1: duplicateMovieClip copies clip events
...
Clip events should be copied from the source clip to the newly
created clip. Fixes objects remaining onscreen in #815 .
2020-07-17 20:49:05 -07:00
Mike Welsh
8c1ec01d75
tests: Test clip events copying in duplicateMovieClip
...
duplicateMovieClip should also copy any clip events on the source
clip to the newly created movie clip.
2020-07-17 20:49:05 -07:00
Mike Welsh
7c52a1bcc4
avm1: Accept path strings in ActionCall ( fix #832 )
2020-07-14 23:34:21 -07:00
Mike Welsh
b43fdca4ad
avm1: resolve_text_field_variable -> resolve_variable_path
2020-07-14 23:34:21 -07:00
Mike Welsh
f9b1c586d1
tests: Add test for paths in ActionCall
2020-07-14 23:34:21 -07:00
David Wendt
e354c53075
Remove any remaining uses of `abc_ref`.
...
Holding a `Ref` on a garbage-collected object inherently extends any borrow locks on that object. Since ABC files are references already, taking a `Ref` to them only helps to skip the refcount update. This is less useful than expected: in most situations, using `abc_ref` causes double-borrow panics. The few methods that can use it are going to be fragile in the face of future refactors, so I'm nipping the problem in the bud now.
2020-07-14 20:14:23 -04:00
David Wendt
f4c5075086
Run all string constant retrieval through the `TranslationUnit`, preventing us from making multiple copies of the same string.
...
For good measure, most of the other methods in `value` for retrieving pool primitives now also use `TranslationUnit` instead of `AbcFile`. This is the result of a handful of cascading changes throughout the project, and itself caused a few more.
2020-07-14 20:05:25 -04:00
David Wendt
70e9e7e9e9
Add support for cached/interned pool strings in the `TranslationUnit`.
2020-07-13 23:42:07 -04:00
David Wendt
e1b9b823fc
Remove `abc_string` and replace it with `abc_string_copy`. All code that pulls strings from the ABC file now uses `AvmString`s.
2020-07-13 23:41:46 -04:00
David Wendt
61a3ff8ae6
Replace `String` or `&str` references with `AvmString` everywhere in the AVM2 runtime.
2020-07-13 22:21:18 -04:00
David Wendt
2021cec9d3
Impl `Copy`, `Eq`, `PartialOrd`, `Ord`, and `Hash` for `AvmString`.
2020-07-13 22:09:34 -04:00
David Wendt
508fcd6e9e
`pool_string` should return a `Ref<str>` just like `value::abc_string`.
2020-07-13 17:45:12 -04:00
David Wendt
a406bdada2
Don't attempt to log debugging information if we're not in a debug build.
2020-07-13 17:45:12 -04:00
David Wendt
ae26615bb4
`coerce_string` may return a static string, which we shouldn't clone.
2020-07-13 17:45:12 -04:00
David Wendt
f0c633fe81
Allow borrowing string values from an ABC file instead of cloning everything.
2020-07-13 17:45:11 -04:00
David Wendt
64e5b46259
Add tests for `instanceof` and `is` operators.
2020-07-13 17:45:10 -04:00
David Wendt
39a4566f20
Instances should be listed as their prototypes (empty as they are)
2020-07-13 17:45:10 -04:00
David Wendt
c917b3d411
Implement `istype`, `istypelate`, and `instanceof`.
2020-07-13 17:45:10 -04:00
David Wendt
a0cb052795
Add `is_instance_of` trait method to `TObject`
2020-07-13 17:45:09 -04:00
David Wendt
3fae8b3832
Read the interface list when instantiating classes, resolve them, and stick them in the prototype for later use.
2020-07-13 17:45:09 -04:00
David Wendt
cce68dbc21
Add trait methods for getting and setting the interfaces list.
2020-07-13 17:45:08 -04:00
David Wendt
563a515189
Add a test for loading interfaces into the AVM2.
...
This test will fail if the AVM2 implementation does not support bodyless methods or bare classes properly.
2020-07-13 17:45:07 -04:00
David Wendt
8f2d3315f3
Allow the construction of classes with no base class.
...
This is primarily used for interfaces, in case you can't guess by the previous commit.
2020-07-13 17:45:07 -04:00
David Wendt
5d89d4ed85
Allow methods to not hold a body.
...
Interface methods are specifically not allowed to be called: as a result, they don't get a method body. Existing code assumed a 1:1 relationship between methods and bodies, which causes spurious errors.
2020-07-13 17:45:07 -04:00
David Wendt
090fe56bd3
Wrap `BytecodeMethod` (and the bytecode half of `Executable`) in a `Gc`.
...
This is inspired by Dinnerbone's similar PR on the AVM1 side, where the Action half of that VM's `Executable` was reduced from 128 bytes to 16 by shoving it in a `Gc`. This won't be as dramatic but should still save some memory.
In fact, it should save a *lot* of memory in bytecode execution, where thanks to the previous commit's rebase, we now need to clone the current method once *for each instruction executed*. That is terrible, but should stop now.
2020-07-13 17:45:06 -04:00
David Wendt
97e005622b
Invert the role of `Avm2` and it's `Activation`, similar to what was done with `Avm1` and it's `Activation`.
...
This also results in a far reduced role for `ReturnValue`, since I also took the liberty of removing most of it's use. Furthermore, I also made it apply equally to native and AVM2 code, which ensures all native implementations of methods don't double-borrow.
In AVM1, `ReturnValue` was actually removed entirely, because it's not needed. I attempted to do the same, but the fact that we're currently embedding `ScriptObjectData` in native objects means that we need it for virtual properties. Otherwise, virtual property implementations will see locked objects, which is bad.
2020-07-13 17:45:06 -04:00
David Wendt
5b5bf0719e
Remove `Avm2Function` as it is no longer used.
2020-07-13 17:45:05 -04:00
David Wendt
098b034de0
Refactor method-related structs into a separate method module.
...
This also renames `NativeFunction` and `Avm2MethodEntry` to `NativeMethod` and `BytecodeMethod`, respectively.
2020-07-13 17:45:05 -04:00
David Wendt
b6e05519cd
Remove `Avm2ClassEntry`. It is no longer used.
2020-07-13 17:45:05 -04:00
David Wendt
12fc13da7f
Clippy compliance for the last batch of commits.
2020-07-13 17:45:05 -04:00
David Wendt
041cb0b5c3
Resolve multiname constant zero as an error rather than a panic.
...
While some code that references pool multinames has zero as a valid index, we cannot validate exactly what the zero index is for a given index. Hence, callers instantiating multinames must check for zero and substitute the correct zero-value interpretation for their given type. If zero is an invalid value, it should ideally throw a different error than what's provided here.
2020-07-13 17:45:04 -04:00
David Wendt
0d2235d2e0
Resolve all remaining compilation issues with this refactor.
2020-07-13 17:45:04 -04:00
David Wendt
7684736bf7
`table_class` should resolve `Class`es straight from the current translation unit.
2020-07-13 17:45:04 -04:00
David Wendt
232c29dc5e
Fix remaining problems with method loading using `callstatic`
2020-07-13 17:45:03 -04:00
David Wendt
eaebd3c63c
Make `Avm2MethodEntry` hold it's `TranslationUnit` rather than an `AbcFile`.
2020-07-13 17:45:03 -04:00
David Wendt
4467bc3193
Make `TranslationUnit` a GC-mandatory type (only referred to by `GcCell`).
2020-07-13 17:45:03 -04:00
David Wendt
60f3ae3ba7
Remove `Avm2ScriptEntry`. It is now obsolete and unused.
2020-07-13 17:45:02 -04:00
David Wendt
f549d0146e
Fix compilation bugs involved with automatic script initializer execution.
2020-07-13 17:45:02 -04:00
David Wendt
b4f944b37b
Wrap ABC loading inside of a `TranslationUnit`.
2020-07-13 17:45:01 -04:00
David Wendt
70e9030072
Decouple the entire trait machinery from ABC-provided traits.
...
This commit breaks the build: we still need to tell `Avm2` how to turn ABC traits into our own internal `Trait<'gc>`, `Class<'gc>`, and `Method<'gc>` types. We also need something to track which traits have already been instantiated, because `callstatic` would otherwise reinstantiate the trait in a different scope. (In fact, I think it *does* do exactly that right now...)
2020-07-13 17:45:01 -04:00
David Wendt
15a62d31cb
Add an internal representation of `Trait`, separate from `swf::avm2::types::Trait`, which is specific to the ABC file format.
...
The intention is to completely replace all usage of `Avm2XYZEntry` with `Class`, `Trait`, and `Method`. This will allow runtime-provided global class traits to coexist with those provided by user code.
2020-07-13 17:45:01 -04:00
David Wendt
4cd30455de
Excise `ReturnValue<'gc>` from all `TObject` methods.
...
Inspired by Dinnerbone's PR doing the exact same thing to AVM1.
On AVM2 we have a bit of a subtle issue: the base implementation of `set_property_local` and `init_property_local` *must* return `ReturnValue`s to avoid double-borrows. Each implementation of `TObject` must resolve them before returning.
2020-07-13 17:45:00 -04:00
David Wendt
3362ec09e8
chore: Clippy conformance
2020-07-13 17:45:00 -04:00
David Wendt
fe283e6770
Silence this warning about occupied slots being an unused variant.
...
I don't know if I'm missing something, but I'm pretty sure this variant is reachable via `TObject::install_slot`.
2020-07-13 17:45:00 -04:00
David Wendt
6117288fe2
Add tests for `ifstricteq`, `ifstrictne`, and `strictequals`.
2020-07-13 17:44:59 -04:00
David Wendt
34ab8c8ce6
`NaN` is not special-cased in AS3.
2020-07-13 17:44:59 -04:00
David Wendt
34b3bbae63
*Correctly* implement `ifstricteq` and `ifstrictne`.
...
The previous implementation suffered from copypasta and was attempting to assert that both of it's values were `bool`.
2020-07-13 17:44:59 -04:00
David Wendt
ecfd16cec9
Add global constants `undefined`, `null`, and `NaN`.
2020-07-13 17:44:58 -04:00
David Wendt
03a240ebcd
Add tests for `valueOf`.
2020-07-13 17:44:58 -04:00
David Wendt
b4d907bf2e
Implement `strictequals`.
2020-07-13 17:44:58 -04:00
David Wendt
3b52dfe2ba
Since we have an `es3_inheritance` test now, rename the existing inheritance test to `es4_inheritance`.
2020-07-13 17:44:57 -04:00
David Wendt
cf6714d33c
Implement and test `toLocaleString`.
...
This function has vague documentation about enabling locale-specific formatting in subclasses. As far as I can tell, none of the objects I implemented so far do anything different than `toString`, so I just have it use the same `TObject` property I set up for `toString`.
2020-07-13 17:44:57 -04:00
David Wendt
3558c3afa0
Add test of `Function.prototype.call`
2020-07-13 17:44:56 -04:00
David Wendt
16774aa055
Add a test for legacy / ES3 inheritance.
...
This was originally something *way* more evil: mixed inheritance between ES3 and ES4 classes. It didn't pan out due to fundamental limitations of the two object models. How the hell did Brendan Eich/Adobe/TC-39 expect ES4 classes to be adopted in already-existing codebases?!
2020-07-13 17:44:56 -04:00
David Wendt
4b66af8dc3
ES4 classes, while superficially similar to functions, are not functions and should not inherit from the `Function` prototype.
...
We still reuse the `FunctionObject` machinery internally. If necessary, we may want to split this into a separate `ClassObject` if some internal `TObject` method needs replacing for classes.
2020-07-13 17:44:55 -04:00
David Wendt
8b36751fbb
Several built-in functions are not `public`, but instead live in the `AS3` namespace. This moves those functions there.
...
In practice not many movies will care about this, because the `AS3` namespace is open by default. You could opt-out of that, and I suppose that was there for using existing ES3 code in AS3 projects. ES4 would have had a similar ES4 namespace, which "JavaScript 2.0" code would need to opt into. Of course, ES4/JS2 never happened, so we just have this weird historical quirk here.
2020-07-13 17:44:55 -04:00
David Wendt
37cdcb3bce
Add tests for `toString` on objects, functions, and classes.
2020-07-13 17:44:54 -04:00
David Wendt
f493cf954f
Make `toString` and `valueOf` methods of `TObject`, called `to_string` and `value_of` respectively.
...
The reason for this is that, in AVM2, `toString` and `valueOf` are not defined on the classes or prototypes of `Function` or `Class`. Instead, they use the `Object.prototype` versions of those functions. Ergo, string and primitive coercion are inherent object methods (the ones that get `[[DoubleSquareBrackets]]` in the ECMA standards). In Ruffle, our equivalent to `[[DoubleSquareBrackets]]` methods are methods on the `TObject` trait, so we're adding them there.
This mechanism will make implementing boxed value types (ala AVM1's `BoxedObject`) easier, too.
We also add some reasonable defaults for `ScriptObject` and `FunctionObject` which will appear on objects, functions, and classes.
2020-07-13 17:44:53 -04:00
David Wendt
ba2c1f5750
Add test for `setPropertyIsEnumerable`
2020-07-13 17:44:39 -04:00
David Wendt
f13e2ea3c4
Implement `setPropertyIsEnumerable`
2020-07-13 17:44:37 -04:00
David Wendt
dc0cb00a03
Add a test for `propertyIsEnumerable`.
2020-07-13 17:44:37 -04:00
David Wendt
2afbcf450a
Impl `propertyIsEnumerable`
2020-07-13 17:44:36 -04:00
David Wendt
a0ca5891e4
Prevent instance traits from being accessible directly from prototypes.
2020-07-13 17:44:36 -04:00
David Wendt
307a95e5c4
`callproperty` and `callpropvoid` should *never* get callables from `base_proto`.
2020-07-13 17:44:35 -04:00
David Wendt
42cb8f57c8
Add a test for `has_own_property` in various class instance scenarios.
2020-07-13 17:44:35 -04:00
David Wendt
6e2508a79d
Fix `any` name resolution, at least enough for the `has_own_property` test to work.
...
Private names now return `false`, and we run any names through trait lookups. This also means any namespace resolution can fail now, in case we need to throw a `VerifyError`.
2020-07-13 17:44:34 -04:00
David Wendt
8677804ea0
Actually enable the `isPrototypeOf` test.
2020-07-13 17:44:34 -04:00
David Wendt
c6265bb50c
Allow tracing booleans.
...
This requires implementing *some level* of coercions, even though this isn't the way to do it.
2020-07-13 17:44:34 -04:00
David Wendt
00186f7602
Free functions always have a `prototype`, this is a holdover from ES3.
2020-07-13 17:44:33 -04:00
David Wendt
0e89cb2175
Impl `Object.isPrototypeOf` w/ test
2020-07-13 17:44:33 -04:00
David Wendt
d29f3dc1d0
Add `as3_object_enumeration` and `as3_class_enumeration` tests.
...
The former tests iterating normal objects and the latter tests iterating objects with prototypes.
2020-07-13 17:44:33 -04:00
David Wendt
c014b40109
Implement `hasnext`, `hasnext2`, `nextname`, `nextvalue`, and the underlying enumeration machinery that powers it.
...
I have... significant reservations with the way object enumeration happens in AVM2. For comparison, AVM1 enumeration works like this: You enumerate the entire object at once, producing a list of property names, which are then pushed onto the stack after a sentinel value. This is a properly abstract way to handle property enumeration.
In AVM2, they completely replaced this with index-based enumeration. What this means is that you hand the object an index and it gives you back a name or value. There's also an instruction that will give you the next index in the object.
The only advantage I can think of is that it results in less stack manipulation if you want to bail out of iteration early. You just jump out of your loop and kill the registers you don't care about. The disadvantage is that it locks the object representation down pretty hard. They also screwed up the definition of `hasnext`, and thus the VM is stuck enumerating properties from 1. This is because `hasnext` and `hasnext2` increment the index value before checking the object. Code generated by Animate 2020 (which I suspect to be the final version of that software that generates AVM2 code) initializes the index at hero, and then does `hasnext2`, hence we have to start from one.
I actually cheated a little and added a separate `Vec` for storing enumerant names. I strongly suspect that Adobe's implementation has objects be inherently slot-oriented, and named properties are just hashmap lookups to slots. This would allow enumerating the slots to get names out of the object.
2020-07-13 17:44:32 -04:00
David Wendt
73189b6449
Properly unwind errors thrown from the AVM2 reader.
2020-07-13 17:44:32 -04:00
David Wendt
1cc8954747
Impl `pop`, which is the opposite of `dup`; and also the opposite of all the `push` instructions.
...
Confusingly, this one isn't documented in the AVM2 spec at all, but it's method of operation is fairly obvious.
2020-07-13 17:44:31 -04:00
David Wendt
9496fbde0a
Remove `DontEnum`, `is_enumerable` and attribute mutation. They won't be needed.
2020-07-13 17:44:31 -04:00
David Wendt
67b7fbb593
Implement `label`, which is a no-op designed specifically to silence verifier errors about unreachable code.
2020-07-13 17:44:31 -04:00
David Wendt
da6a7c0723
Implement `kill`, at least a little.
...
I'm sure there's some other part of AVM2 that cares about killed registers, but I couldn't find it yet.
2020-07-13 17:44:30 -04:00
David Wendt
7253c091a2
Add tests for control flow instructions that use booleans or strict equality.
...
Other comparisons will have to wait until we have ECMA-compliant abstract comparison and coercion.
2020-07-13 17:44:30 -04:00
David Wendt
9c5ea1d30c
Implement `jump`, `iftrue`, `iffalse`, `ifstricteq`, and `ifstrictne`.
2020-07-13 17:44:30 -04:00
David Wendt
b33c246713
Implement `is_property_overwritable`.
2020-07-13 17:44:29 -04:00
David Wendt
ddc9aa4cca
Add a test for ES4 method binding of `this`.
2020-07-13 17:44:29 -04:00
David Wendt
915b2da42b
Allow binding a reciever to a function, and make all method traits bind themselves to the object they were constructed on.
...
Our already odd `super` handling throws up another subtlety regarding bound recievers. Since we have to construct an instance of a parent class in order to get traits on it, we also have to make sure that we initialize traits with the correct reciever. I'll demonstrate here:
```let mut base = base_proto.construct(avm, context, &[])?;
let name = base.resolve_multiname(&multiname).unwrap();
let value = base.get_property(object, &name, avm, context)?.resolve(avm, context)?```
In this case, if `name` is the name of a method, getter, or setter trait, then `get_property` will instantiate that trait on `base` but bound to `reciever`. This is correct behavior for this case, but more generally, trait instantiation is permenant and therefore there's potential for confusing shenanigans if you `get_property` with the wrong reciever.
To be very clear, `reciever` should *always* be the same object that is getting `get_property` et. all called on it. In the event that you need to instantiate traits with a different `reciever`, you should construct a one-off object and retrieve prototypes from that.
2020-07-13 17:44:28 -04:00
David Wendt
f042e453a3
Add a test for interactions between prototype and class-trait properties.
...
This is the test that broke the old object model's back, please see parent commit's description for more details.
2020-07-13 17:44:27 -04:00
David Wendt
2f95a7a81b
Completely overhaul the way traits are defined on objects.
...
Previously, we were treating ES4 classes like syntactic sugar over a prototype chain (like ES6 classes); e.g. each declared trait was set in the given prototype and then property look-ups happened as normal.
This already caused problems with virtual properties, which could be partially-defined in subclasses and required careful checks to make sure we stopped checking the prototype chain on the *correct* half of the property.
However, this is a hint of a larger problem, which is that ES4 classes don't actually define anything on the prototype chain. Instead, the instance itself constructs class properties and methods on itself. This allows things like methods automatically binding `this`, which isn't included in this commit but will be implemented really soon.
The prototype chain still exists even on pure ES4 classes, due to the need for backwards compatibility with ES3 code. Object, for example, still defines it's methods as prototype methods and thus there needs to be a prototype chain to reach them. I actually could have gotten away with using the prototype chain if AS3 *hadn't* retained this "legacy" detail of ES3 allowing this class/prototype distinction to leak out into upcoming tests.
We still actually use the prototype chain for one other thing: trait resolution. When we look for a trait to install onto an object, we pull traits from the prototype chain using a special set of `TObject` methods. This happens in opposite order from normal prototype lookups so that subclassing and verification can proceed correctly.
`super` somehow became even harder to implement: we now actually construct the parent class so we can get traits from it, which is going to complicate method binding as mentioned above.
2020-07-13 17:44:27 -04:00
David Wendt
353017576a
`ScriptObject` now holds a reference to a class and allows retrieving traits from it.
2020-07-13 17:44:27 -04:00
David Wendt
f10920adc0
Implement `Object.prototype.hasOwnProperty` and resolution of `Namespace::Any`.
2020-07-13 17:44:26 -04:00
David Wendt
67744650f1
Pass the ABC name and lazy init flag to the AVM2.
2020-07-13 17:44:25 -04:00
David Wendt
6cc3f7ecc3
Add a test for stored properties as well.
...
This test passed with no errors.
2020-07-13 17:44:24 -04:00
David Wendt
5abc78d3bd
Add test of AVM2 virtual properties.
...
This tests:
* Getter invocation
* Setter invocation
* Properties with one or the other, but not both
* Inheritance
* Superproperty getters and setters
* Getters with inherited setter
* Setters with inherited getter
2020-07-13 17:44:24 -04:00
David Wendt
c5e3af2053
When resolving `get_property`, skip over virtual properties that do not have a defined getter.
2020-07-13 17:44:23 -04:00
David Wendt
54b792ef3a
Ensure that called setters are properly resolved so that errors in setters propagate up the Rust stack correctly.
...
The previous system for handling setters would execute the setter and then return a value to indicate whether or not the caller needed to resolve a stack frame. However, no caller of `Property.set` actually did this. Ergo, errors in setters and getters would not resolve up the stack at the correct time.
This problem also exists in AVM1 but is far less noticable as AVM1 only has two very uncommon runtime errors and very few movies use `throw`.
2020-07-13 17:44:23 -04:00
David Wendt
b8106d24d2
Ensure virtual setters are run when defined on a prototype.
...
Normally, `set_property` only affects the object it was called on, which makes sense: otherwise, we couldn't override values that originate from a class prototype without accidentally monkey-patching the prototype. However, virtual setters only exist in prototypes and need to be accessible from child objects.
The solution to this is to have a specific method to check if a virtual setter exists. Virtual setters are then resolved through the prototype chain. If no virtual setter exists, then the reciever object is handed the value.
Note that we always use the `reciever` object rather than `self` so that `setsuper` can work correctly. In `setsuper`, we resolve the base class, and then set properties on it with the actual object in question as it's reciever. If a virtual setter is called, it will get the actual object it should be manipulating; and otherwise, prototypes will not be modified or consulted.
2020-07-13 17:44:22 -04:00
David Wendt
665d7a4342
Implement `getsuper` and `setsuper`.
...
This required the reintroduction of dedicated reciever parameters to `Object.get_property_local` and `Object.set_property`, which I had removed from the AVM1 code I copied it from. It turns out being able to change the reciever was actually necessary in order to make super set/get work.
2020-07-13 17:44:22 -04:00
David Wendt
785832b7f3
Add `as3_inheritance` test, which is primarily designed to test method calls, constructor execution, and usage of `super`.
2020-07-13 17:44:22 -04:00
David Wendt
e8fbac6cf2
Refactor the base_proto system to more accurately record what prototype methods come from.
...
The previous system primarily relied on `Executable` to automatically start and continue a super chain. This works, but only for class hierarchies without *override gaps* - methods that override another method not defined by the direct superclass of the method. In that case, the override method would be called twice as the `base_class` was moved up one prototype at a time, which is wrong.
The new system relies on the call site to accurately report the prototype from which the current method was retrieved from. Super calls then start the resolution process *from the superclass of this prototype*, to ensure that the already-called method is skipped.
It should be noted that the proper `base_class` for things like `callmethod`, `callstatic`, `call`, `get`/`set` methods, and other call opcodes that don't use property look-up are best-effort guesses that may need to be amended later with better tests.
To facilitate `base_proto` resolution, a new `Object` method has been added. It's similar to `get_property`, but instead returns the closest prototype that can resolve the given `QName`, rather than the actual property's `ReturnValue`. Call operations use this to resolve the `base_proto`, and then resolve the method being called in `base_proto`. The existing `exec_super` method was removed and a `base_proto` method added to `exec` and `call`.
2020-07-13 17:44:21 -04:00
David Wendt
43da7ac952
`resolve_multiname` should actually return it's prototype's return value.
2020-07-13 17:44:20 -04:00
David Wendt
ab5a95c05b
Add a test for various types of class methods.
2020-07-13 17:44:19 -04:00
David Wendt
1c3b9c50fe
Implement prototype awareness for `get_property`, `has_property`, and `resolve_multiname`.
...
Furthermore, implement `has_own_property`.
2020-07-13 17:44:19 -04:00
David Wendt
fa4369da72
Execute static class initializers.
...
This also fixes the lack of function prototype on classes.
2020-07-13 17:44:18 -04:00
David Wendt
687a82f643
Constructors should also inherit closure scope.
2020-07-13 17:44:18 -04:00
David Wendt
73966f1b31
Make sure that we actually call the super constructor, not our own constructor.
2020-07-13 17:44:17 -04:00
David Wendt
1b67bb94c8
Impl `callsuper`, `callsupervoid`, and `constructsuper`.
...
This works primarily by retaining the current superclass prototype in the activation object and then using it to retrieve the super method.
For constructors, we implement the `constructor` property, which is probably not the correct way to do this.
2020-07-13 17:44:15 -04:00
David Wendt
f3dee5c310
Add (currently failing) test for constructors.
2020-07-13 17:44:14 -04:00
David Wendt
a77f676279
`construct` and `constructprop` should push the object that was just constructed.
2020-07-13 17:44:13 -04:00
David Wendt
0fc9b9a287
`construct` and `constructprop` should take their args in reverse-order like the call functions do.
2020-07-13 17:44:13 -04:00
David Wendt
9431e02802
The class function should use the *instance* initializer as it's callable, not the class initializer.
2020-07-13 17:44:13 -04:00
David Wendt
bedf5cb459
Add a basic test for function calls.
2020-07-13 17:44:13 -04:00
David Wendt
38868fbdfe
Args are pushed onto the stack in normal order, so we need to pop them off in reverse order.
2020-07-13 17:44:12 -04:00
David Wendt
a2dfffc56e
Add our first AVM2 regression test: hello world!
2020-07-13 17:44:09 -04:00
David Wendt
7d576203c9
Impl `coerce_a`.
...
This currently treats `coerce_a` as a no-op. Strictly speaking, this is for type verification purposes, but we currently don't type-verify ABC code. Ergo, this requires no VM support at this time.
2020-07-13 17:43:50 -04:00
David Wendt
a0ab978bed
Impl `callmethod`, `callproperty`, `callproplex`, `callpropvoid`, and `callstatic`.
...
Also, implement a method table that method traits can optionally add themselves to.
Also also, add the ability to invoke a method without a `this` object. This required a non-trivial refactoring of the activation machinery, and changes to the signature of `NativeFunction`, and all native AVM2 functions.
2020-07-13 17:43:49 -04:00
David Wendt
68cf9e8869
Upon encountering an `Err`, dispose of the current AVM2 stack.
...
In the future, the `unwrap_stack_frame` mechanism should be expanded upon to allow running exception handlers and recovering from a Rust error - but not today.
2020-07-13 17:43:49 -04:00
David Wendt
a7ff2de476
Don't spam the test log with `Resolving Multiname` messages for each scope that gets checked
2020-07-13 17:43:48 -04:00
David Wendt
dd6b0a8728
Remove unused reference to slot property fields
2020-07-13 17:43:48 -04:00
David Wendt
bf45f7f161
Fix crash when reading or writing a property that redirects to a slot.
2020-07-13 17:43:48 -04:00
David Wendt
7792fd5581
Impl `trace`, which is a free function rather than an opcode this time.
2020-07-13 17:43:48 -04:00
David Wendt
a557867c71
Add the entire class hierarchy of `MovieClip` and `Sprite`.
2020-07-13 17:43:47 -04:00
David Wendt
f6e2ca1fe5
Clean up the current set of builtins to accurately reflect the namespace hierarchy.
2020-07-13 17:43:47 -04:00
David Wendt
38b1524a49
Fix the error messages for `findpropstrict` and `getlex` to be more informative.
2020-07-13 17:43:47 -04:00
David Wendt
843de29460
Impl `newobject`
2020-07-13 17:43:46 -04:00
David Wendt
7201f6c4fe
Impl `debug`, `debugfile` and `debugline`.
2020-07-13 17:43:46 -04:00
David Wendt
1d1bad1ab4
Impl `getglobalscope`
2020-07-13 17:43:46 -04:00
David Wendt
074ba94c17
Impl `newfunction` and `newclass`.
...
Notably, this also removes `new_closure_scope` as it is not needed. AVM1 does not capture `with` scopes in closures, but AVM2 (as well as modern ECMAScript) does.
2020-07-13 17:43:46 -04:00
David Wendt
1fe73b3329
Impl `dup`
2020-07-13 17:43:45 -04:00
David Wendt
0ff1c04697
Impl `initproperty`
2020-07-13 17:43:45 -04:00
David Wendt
5042fc1bc7
Debug all multiname resolutions
2020-07-13 17:43:44 -04:00
David Wendt
5c0e095ab5
`getlex` does not support runtime multinames according to spec.
2020-07-13 17:43:44 -04:00
David Wendt
9e120c216b
Propagate arguments into local registers when calling AVM functions.
2020-07-13 17:43:44 -04:00
David Wendt
5b00c1fd96
Ensure that `this` is properly populated into local registers.
2020-07-13 17:43:44 -04:00
David Wendt
b2f5307213
Add `flash.display.Sprite` because Flash Builder tests demand it.
2020-07-13 17:43:42 -04:00
David Wendt
4ab9a46515
Impl `getscopeobject`
2020-07-13 17:43:41 -04:00
David Wendt
5f98a198cb
Remove dead code in Activation
2020-07-13 17:43:41 -04:00
David Wendt
279d90ec22
Remove `define_value` from AVM2 objects.
...
We already have a menagerie of `install_*` functions for adding static properties to a an object; and we don't have to support any kind of asinine nonsense liks `ASSetPropFlags` here. Ergo, we don't need this.
2020-07-13 17:43:39 -04:00
David Wendt
cbce8660bc
Implement `deleteproperty`.
2020-07-13 17:43:37 -04:00
David Wendt
d19d9ef90e
Clean up unused variables
2020-07-13 17:43:35 -04:00
David Wendt
8b56973d29
Remove scope methods that aren't necessary.
...
In AVM1, these are necessary because `ActionGetVariable` et. all directly interface with the scope chain. In AVM2, you `findpropstrict` up the scope chain, which gives you a normal object that you can interact with as you like. Ergo, the scope chain doesn't need set/get property methods.
2020-07-13 17:43:34 -04:00
David Wendt
fd275bdcf3
Implement constant slots and traits.
...
Class and Function traits now generate const slots, too.
2020-07-13 17:43:33 -04:00
David Wendt
412c3d8489
Implement `Function` traits.
2020-07-13 17:43:29 -04:00
David Wendt
af70024f62
Implement slot traits.
2020-07-13 17:43:28 -04:00
David Wendt
200c10b4a2
Classes can fit in slots, so let's stick them in there.
2020-07-13 17:43:27 -04:00
David Wendt
d42b16f021
Add stub impl of `flash.display.MovieClip`.
2020-07-13 17:43:27 -04:00
David Wendt
ebcfee4676
Add specific error messages for unresolvable super classes
2020-07-13 17:43:27 -04:00
David Wendt
362294181f
Implement constant pool default values (index 0).
...
All constant pools in an ABC file are actually numbered starting from one; there's an implicit 0 entry not stored in the file that the runtime is expected to retrieve when pulling constants from the pool.
The AVM2/ABC spec only mentions this in passing.
2020-07-13 17:43:27 -04:00
David Wendt
e1916519dd
Add debug for trait installs
2020-07-13 17:43:26 -04:00
David Wendt
cfe0e333be
Fix invalid script index when loading an ABC file.
2020-07-13 17:43:26 -04:00
David Wendt
bc0bdf8496
The public namespace appears to just be an unnamed package namespace, not a regular namespace.
2020-07-13 17:43:25 -04:00
David Wendt
04879fc419
Implement class traits.
...
This allows the AVM to declare classes, which necessitated some refactoring to avoid double-borrows or having to do something "magic" that would dodge virtual properties.
2020-07-13 17:43:25 -04:00
David Wendt
ecfd5abb41
Impl `construct` and `constructprop`.
2020-07-13 17:43:24 -04:00
David Wendt
1ab4091050
Implement slots and related opcodes.
2020-07-13 17:43:24 -04:00
David Wendt
88957b2b3d
Add stub builtins for Object and Function. These are more-or-less identical to the way we did it in AVM1 (e.g. no fancy player globals file)
2020-07-13 17:43:24 -04:00
David Wendt
1945f36dc0
When running the initial script, also install it's traits onto the global scope.
2020-07-13 17:43:23 -04:00
David Wendt
35c36a807b
Always execute the last script when loading an ABC file
2020-07-13 17:43:23 -04:00
David Wendt
560900e708
ABC files are always pre-loaded.
...
Frame actions are handled as syntactic sugar on top of a `MovieClip` subclass and event handlers. ABC scripts do not live on the normal timeline.
2020-07-13 17:43:23 -04:00
David Wendt
502936f0fe
Implement non-slot trait properties (Method, Getter, and Setter)
2020-07-13 17:43:22 -04:00
David Wendt
12e9fbbffb
Impl virtual property slots
2020-07-13 17:43:22 -04:00
David Wendt
eb0c9dcaec
Allow constructing a function around a particular class definition.
...
I'm writing all this code assuming that classes and traits are syntactic sugar around ES3-style prototype chains on function objects. Hence, `FunctionObject` is still our workhorse object type for implementing typing.
2020-07-13 17:43:21 -04:00
David Wendt
cf490bedfb
Unstub `proto`.
2020-07-13 17:43:20 -04:00
David Wendt
b12c6e0ff1
Implement closure scope stacks.
2020-07-13 17:43:20 -04:00
David Wendt
7d75255a1a
Add global scope which is automatically included on all new activations.
2020-07-13 17:43:20 -04:00
David Wendt
984e701142
Swap out `has_property`'s stub impl.
2020-07-13 17:43:19 -04:00
David Wendt
e5142e85e9
Replace `get_property` and `set_property` with slightly-less-stub impls.
2020-07-13 17:43:17 -04:00
David Wendt
d56db06447
Implement `resolve_multiname`, sort of.
2020-07-13 17:43:16 -04:00
David Wendt
78a1c9a7e3
Implement `pushscope`, `popscope`, and `pushwith`.
2020-07-13 17:43:16 -04:00
David Wendt
5e6fc79f42
Implement `getproperty`, `setproperty`
2020-07-13 17:43:15 -04:00
David Wendt
60c16b0a60
Implement `findproperty`, `findpropstrict`, and `getlex`; which are necessary for interacting with global scope.
2020-07-13 17:43:15 -04:00
David Wendt
3c8035f871
clippy pls
2020-07-13 17:43:14 -04:00
David Wendt
12223d524a
Add support methods in `Scope` to support opcodes that traverse the scope chain.
2020-07-13 17:43:14 -04:00
David Wendt
0ff1ba7120
Multiname resolution is another object method.
2020-07-13 17:43:14 -04:00
David Wendt
376d1a8ca6
Add scope support
2020-07-13 17:43:13 -04:00
David Wendt
3b476cba9e
Implement `pushnamespace` since that's a value type now
2020-07-13 17:43:13 -04:00
David Wendt
1a6acb9440
Implement late binding and runtime qualifications for names.
2020-07-13 17:43:12 -04:00
David Wendt
2f3a3aff6f
Add exact type assertion methods for strings and namespace values.
2020-07-13 17:43:11 -04:00
David Wendt
6d8dc6e63d
Pull ABC constant pool methods out of Avm2 and into Value.
...
The old methods still exist and do the same thing, but the Value methods
accept arbitrary AbcFile references.
2020-07-13 17:42:51 -04:00
David Wendt
c65d93d063
Implement multinames, sans runtime namespace support.
2020-07-13 17:42:50 -04:00
David Wendt
6bd94d6bc9
`from_abc_namespace` should accept a namespace index and retrieve it from the file's constant pool itself.
2020-07-13 17:42:50 -04:00
David Wendt
43f1080fab
Implement namespaces as a value type
2020-07-13 17:42:49 -04:00
David Wendt
52ac7a6583
Implement call/return for bare functions
2020-07-13 17:42:49 -04:00
David Wendt
115f0393aa
Add `call` method to the object trait. Only functions are callable in AVM2, all others error out.
2020-07-13 17:42:48 -04:00
David Wendt
d1aeae8e02
Add support for local registers in the interpreter.
2020-07-13 17:42:47 -04:00
David Wendt
4d000e1ce0
Implement `pushxyz` opcodes for all value types that we currently support.
2020-07-13 17:42:46 -04:00
David Wendt
5600ac477c
Always execute any AVM2 code that may have been queued as a result of loading ABC files.
2020-07-13 17:42:45 -04:00
David Wendt
7f60fab1e5
Add the bare minimum necessary to get opcodes out of an ABC and into an interpreter loop.
...
Surprisingly enough, the "bare minimum" includes a stack, object model, and values already.
2020-07-13 17:42:45 -04:00
David Wendt
e80c887261
Add a very basic object model to the AVM2 interpreter.
2020-07-13 17:42:44 -04:00
David Wendt
b7f257e7c8
Add a path to get from the movie clip to the Avm2.
2020-07-13 17:42:43 -04:00
David Wendt
a852a6939a
Add an extremely trivial implementation for the AVM2 interpreter state.
2020-07-13 17:42:31 -04:00
Nathan Adams
fba8ccda81
avm1: Rename Avm1String to AvmString
2020-07-13 10:12:54 -07:00
Nathan Adams
d8f043fa1a
avm1: Value::coerce_to_string returns an Avm1String, as it can avoid a clone-and-reallocate
2020-07-13 10:12:54 -07:00
Nathan Adams
f0ef68cb16
avm1: Reenabled paused string-value tests during string refactor
2020-07-13 10:12:54 -07:00
Nathan Adams
c60b2cf4fc
avm1: Implement From<&'static str> for Value
2020-07-13 10:12:54 -07:00
Nathan Adams
e03e3f6c4e
avm1: Allow Avm1String to contain &'static str
2020-07-13 10:12:54 -07:00
Nathan Adams
ad733f2f21
avm1: Add Avm1String which wraps Gc<String>
2020-07-13 10:12:54 -07:00
Nathan Adams
016b9db3c5
avm1: Change Value::String(String) to Value::String(Gc<String>)
2020-07-13 10:12:54 -07:00
CUB3D
0591c0fe4b
core: Add functions to prototypes
2020-07-12 15:25:58 -07:00
CUB3D
ab022b66e9
chore: Format and cleanup clippy lints
2020-07-12 15:25:58 -07:00
CUB3D
83cca044ad
core: Add tests for ContextMenu and ContextMenuItem
2020-07-12 15:25:58 -07:00
CUB3D
46cd8eb507
core: Add ContextMenuItem
2020-07-12 15:25:58 -07:00
CUB3D
04ca652f98
core: ContextMenu fully implemented
2020-07-12 15:25:58 -07:00
CUB3D
73a98c7f78
core: Implement copy() for ContextMenu
2020-07-12 15:25:58 -07:00
CUB3D
f3aa6f7f01
core: Add stub of ContextMenuItem
2020-07-12 15:25:58 -07:00
CUB3D
c8fefc56b5
core: Add stubs for context menu
2020-07-12 15:25:58 -07:00
dependabot-preview[bot]
aaf42d1948
build(deps): bump syn from 1.0.33 to 1.0.34
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.33 to 1.0.34.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.33...1.0.34 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-12 15:01:43 -07:00
Nathan Adams
180891c58e
avm1: Add impl_custom_object!() macro to simplify custom object types
2020-07-10 16:48:05 -07:00
Nathan Adams
eb94cc54b2
chore: Move avm1 objects to their own module, we have plenty of them now
2020-07-10 16:48:05 -07:00
Mike Welsh
3322c2d916
avm1: Implement updateAfterEvent
2020-07-10 14:38:48 -07:00
Mike Welsh
8715589f50
tests: Add setInterval test
2020-07-10 14:38:48 -07:00
Mike Welsh
98e7da7d93
avm1: Implement setInterval
2020-07-10 14:38:48 -07:00
Mike Welsh
a1ff80bb18
avm1: Object.watch is case insensitive on SWFv6
2020-07-10 12:02:26 -07:00
Nathan Adams
8a0430d744
avm1: Implement Object.watch & Object.unwatch ( #268 )
2020-07-10 12:02:26 -07:00
Nathan Adams
ecbab536b5
avm1: Respect ScriptLimits for recursion depth, and use that in infinite_recursion_function
2020-07-08 14:47:38 -07:00
Nathan Adams
2b30fd32b7
avm1: Activation depth can be up to u16.
2020-07-08 14:47:38 -07:00
Nathan Adams
51ec5739c6
avm1: Throw errors when functions (user-called, or special) go too deep
2020-07-08 14:47:38 -07:00
Nathan Adams
aa98c2c24f
avm1: Track the reason for executions, if it's a function call vs
...
something special, like a getter
2020-07-08 14:47:38 -07:00
Nathan Adams
65396ba87a
avm1: All errors are ignored during getters or setters
2020-07-08 14:47:38 -07:00
Nathan Adams
3ee1902117
avm1: Don't log errors at every Activation, only at the "root" frames
2020-07-08 14:47:38 -07:00
Nathan Adams
8218e14824
avm1: Remove unused field is_executing from Activation
2020-07-08 14:47:38 -07:00
dependabot-preview[bot]
a3bdb20cf1
build(deps): bump smallvec from 1.4.0 to 1.4.1
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.4.0...v1.4.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-06 20:30:41 -07:00
Mike Welsh
2cbbe32412
tests: Add test for GetVariable/SetVariable on _x, etc.
2020-07-05 15:15:31 -07:00
Mike Welsh
804385347f
tests: Add test for virtual properties on prototype
2020-07-05 15:15:31 -07:00
Mike Welsh
fec8cf5e52
tests: Add tests for with from issue #792
2020-07-05 15:15:31 -07:00
Mike Welsh
bd7f986594
avm1: Allow overwriting _parent
2020-07-05 15:15:31 -07:00
Mike Welsh
ad6e2ceed4
avm1: Remove TObject::is_property_overwritable
...
Local virtual properties take precedence over prototype/parent
scopes, even for read-only propreties.
2020-07-05 15:15:31 -07:00
Mike Welsh
1240c79f70
avm1: StageObject::has_property should return true for _x, etc.
2020-07-05 15:15:31 -07:00
Mike Welsh
6feb266576
avm1: with(undefined) or with(null) is ignored
2020-07-05 15:15:31 -07:00
CUB3D
00d55b05a0
chore: Fix formatting
2020-07-05 13:49:59 -07:00
CUB3D
64eed4def9
chore: Cleanup
2020-07-05 13:49:59 -07:00
CUB3D
ab58cff8b3
core: Add tests for ColorTransform and cleanup code
2020-07-05 13:49:59 -07:00
CUB3D
0dcbd05f5d
chore: Fix formatting
2020-07-05 13:49:59 -07:00
CUB3D
68eb6a6342
core: Fix ColorTransformObject virtual prototype setters
2020-07-05 13:49:59 -07:00
CUB3D
73e9dc1a82
core: Refactor ColorTransform
2020-07-05 13:49:59 -07:00
CUB3D
26ae182584
core: Update to reflect avm changes
2020-07-05 13:49:59 -07:00
CUB3D
431cc532be
core: ColorTransform no longer passed through engine ColorTransform object
2020-07-05 13:49:59 -07:00
CUB3D
a8b1be2afa
core: Remove useless to_owned in color_transform
2020-07-05 13:49:59 -07:00
CUB3D
c0315dce3f
chore: Format
2020-07-05 13:49:59 -07:00
CUB3D
a8f7638d99
core: Implement ColorTransform
2020-07-05 13:49:59 -07:00
dependabot-preview[bot]
328246dc10
build(deps): bump jpeg-decoder from 0.1.19 to 0.1.20
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.19 to 0.1.20.
- [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.19...v0.1.20 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-04 15:29:45 -07:00
Mike Welsh
7b4045f32b
core: Remove some unneccessary `take` calls in tag functions
2020-07-03 18:52:26 -07:00
Mike Welsh
08569ae979
core: Limit tag parsing to slice of tag data
2020-07-03 18:52:26 -07:00
Nathan Adams
c50c835790
avm1: Made Executable::Action take in a Gc to Avm1Function, reducing the size of the struct significantly
2020-07-03 18:47:34 -07:00
Nathan Adams
c4980d0bf5
core: Make XMLName::node_name return Cow<str>. It's not always owned, and we don't always need it to be.
2020-07-03 17:30:59 -07:00
Nathan Adams
c036e2cf88
avm1: Made f64_to_string return Cow<str> instead of String, as we sometimes return static values
2020-07-03 17:30:59 -07:00
Nathan Adams
938d644d7d
core: Made PropertyMap::insert take &str instead of String, as ownership isn't always needed
2020-07-03 17:30:59 -07:00
Nathan Adams
fb84999778
core: Made VacantEntry store a &str instead of a String, avoiding allocation until insertation is requested
2020-07-03 17:30:59 -07:00
Nathan Adams
f4921fad45
core: Made PropertyMap::entry take &str instead of String. We often don't need ownership here.
2020-07-03 17:30:59 -07:00
Nathan Adams
b5c06be8a2
avm1: Anonymous function names for debugging when not in debug mode
2020-07-03 17:24:20 -07:00
Nathan Adams
51321713b5
avm1: Show stack frame with the avm_debug feature
2020-07-03 17:24:20 -07:00
Nathan Adams
c976cf8efb
avm1: Replace action.avm() with activation.avm to help with borrow checker in next commit
2020-07-03 17:24:20 -07:00
Mike Welsh
07814fdf53
tests: Add test for Error
2020-07-02 20:58:01 -07:00
Jon Pacheco
48c65f02a1
avm1: Implement Error object (see #251 )
2020-07-02 20:58:01 -07:00
Adrian Wielgosik
301d696670
Add a fast path for ASCII case conversions
2020-07-02 12:48:50 -07:00
Mike Welsh
3a4d432645
tests: Edit textfield_variable test for #777
2020-07-02 01:29:41 -07:00
Mike Welsh
dd32acd8fc
avm1: Empty text field does not initialize variable binding
...
If a text field with a variable binding is placed on the stage,
usually the variable is initialized with the initial text. However,
if the text field is empty, the variable remains undefined.
Fixes #777 .
2020-07-02 01:29:41 -07:00
Mike Welsh
b05da5ef0f
avm1: CastOp fails for primitive values
2020-07-01 17:30:56 -07:00
Nathan Adams
d86761db5d
avm1: Implement try {..} catch {..} finally {..} - #731
2020-07-01 17:30:56 -07:00
Nathan Adams
7c0b0a7a57
avm1: Fix instanceof checks with primitives
2020-07-01 16:36:54 -07:00
Nathan Adams
d1732dd3d6
avm1: Returning from with{} should return from the parent activation
2020-07-01 16:21:43 -07:00
Mike Welsh
4b4370b90d
avm: Refactor Avm1, move execution to StackFrame (merge #767 )
...
AVM1 refactoring: moving execution from Avm1 to StackFrame
2020-07-01 15:56:09 -07:00
Nathan Adams
8bc3eedc43
avm1: Rename StackFrame to Activation now that they're merged
2020-07-02 00:09:43 +02:00
dependabot-preview[bot]
41e262d745
build(deps): bump libflate from 1.0.1 to 1.0.2
...
Bumps [libflate](https://github.com/sile/libflate ) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/sile/libflate/releases )
- [Commits](https://github.com/sile/libflate/compare/1.0.1...1.0.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-01 11:43:31 -07:00
Nathan Adams
9b66b496d0
avm1: Fix double-borrow when calling a getter that calls another method
2020-07-01 18:53:16 +02:00
dependabot-preview[bot]
aa9100395f
build(deps): bump downcast-rs from 1.1.1 to 1.2.0
...
Bumps [downcast-rs](https://github.com/marcianx/downcast-rs ) from 1.1.1 to 1.2.0.
- [Release notes](https://github.com/marcianx/downcast-rs/releases )
- [Changelog](https://github.com/marcianx/downcast-rs/blob/master/CHANGELOG.md )
- [Commits](https://github.com/marcianx/downcast-rs/compare/v1.1.1...v1.2.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-30 17:32:47 -07:00
Nathan Adams
987375299b
avm1: Replace 'run_in_avm' with just building a StackFrame object, letting Rust borrowchecker do our stack management for us
2020-06-30 21:57:51 +02:00
Nathan Adams
47a806a5ee
avm1: Removed errors that are no longer possible to run into
2020-06-30 21:28:32 +02:00
Nathan Adams
a989aa235a
avm1: We don't need to lock StackFrames anymore, the borrow checker will steer us right
2020-06-30 21:26:57 +02:00
Nathan Adams
2288919663
avm1: We don't need to store data in StackFrame, it's only used when actually running data
2020-06-30 21:24:46 +02:00
Nathan Adams
45c3967deb
avm1: Merge Activation into StackFrame
2020-06-30 21:08:42 +02:00
Nathan Adams
d889b98043
avm1: Merge Activation::from_function and Activation::from_action as they're identical
2020-06-30 20:34:05 +02:00
Nathan Adams
6e4dd506da
avm1: Activation doesn't need to be in a GcCell
2020-06-30 20:31:49 +02:00
Nathan Adams
4d24bc7f09
avm1: Removed pc from Activation, it's no longer needed
2020-06-30 19:42:18 +02:00
Nathan Adams
3e9c380ba1
avm1: Remove is_function from Activation, it's no longer needed
2020-06-30 19:40:21 +02:00
Nathan Adams
ec4affcf10
avm1: Use child activations when already running from another activation
2020-06-29 10:13:59 +02:00
Nathan Adams
aaa082fb60
avm1: Replace run_with_stack_frame with run_in_avm
2020-06-29 10:13:57 +02:00
Nathan Adams
0dd2ece371
avm1: Introduce parents to StackFrame, and move run_activation from avm1 to StackFrame
2020-06-29 10:12:17 +02:00
Nathan Adams
9b630bd305
avm1: Remove ReturnValue, it's no longer needed
2020-06-29 10:12:16 +02:00
Nathan Adams
ab4304d634
avm1: Properly and more explicitly work around the double-borrow issue in setters
2020-06-29 10:10:38 +02:00
Nathan Adams
a2103d906d
avm1: Remove dead code from Avm1
2020-06-29 10:10:24 +02:00
Nathan Adams
f85684fec0
avm1: Move current_swf_version and is_case_sensitive from avm1 to stackframe
2020-06-29 10:10:11 +02:00
Nathan Adams
d470c52aea
avm1: Move root_object, target_clip_or_root, target_clip and base_clip from avm1 to StackFrame
2020-06-29 10:09:57 +02:00
Nathan Adams
ca305684db
avm1: Removed unused return_value on Activation
2020-06-29 10:09:40 +02:00
Nathan Adams
da8ca1379f
avm1: Change from 'avm, context' to 'activation, context' and restructured to support this
2020-06-29 10:09:38 +02:00
Nathan Adams
a841743962
avm1: Make current_stack_frame return a Result for easy chaining
2020-06-29 10:07:48 +02:00
Nathan Adams
cdfd58d619
avm1: Move register get/setting from avm1 to StackFrame
2020-06-29 10:07:31 +02:00
Nathan Adams
63e66c29eb
avm1: We already have our stack frame, don't refetch it in actions
2020-06-29 10:07:14 +02:00
Nathan Adams
3a093dddbd
avm1: Run activations immediate, not queued up for some-time-later
2020-06-29 10:07:12 +02:00
Nathan Adams
10b8f4abaf
avm1: Handle stack poping in avm
2020-06-29 08:55:50 +02:00
Nathan Adams
84a5fae43f
avm1: Only perform stack-frame adjustments in one place, not scattered throughout actions
2020-06-29 08:51:34 +02:00
Nathan Adams
9109d89daa
avm1: Allow for frame control in StackFrame from any action
2020-06-29 08:51:34 +02:00
Nathan Adams
329716bfe7
avm1: Don't refetch activation.data every action
2020-06-29 08:51:33 +02:00
Nathan Adams
af72f68f0f
avm1: Run entire stack frames at once
2020-06-29 08:51:33 +02:00
Nathan Adams
c6b9de883f
avm1: Add Activation to StackFrame, removing lots of get-and-unwraps
2020-06-29 08:51:33 +02:00
Nathan Adams
4d76e8b24d
avm1: Move all actions from Avm1 to a new StackFrame
2020-06-29 08:51:33 +02:00
Mike Welsh
3bc3d4acb2
text: Fix bindings being incorrectly cleared in StageObject
...
Call to `Vec::retain` was backwards, causing bindings to be
incorrectly cleared/not cleared when a text field was removed.
2020-06-28 23:38:58 -07:00
Mike Welsh
93cf7a1386
text: Use retire_stack_frame after firing text bindings
2020-06-28 23:37:50 -07:00
Mike Welsh
ed82d984d2
text: Properly set text field position when created dynamically
2020-06-28 18:36:10 -07:00
Mike Welsh
7eeda7d93e
chore: clippy
2020-06-28 18:36:10 -07:00
Mike Welsh
ef31a6bea4
text: Don't override TextField::set_matrix and other layout changes
...
Don't override set_matrix and set_x for TextFields, and leave the
bounds intact.
TODO: There are still some wrapping issues in the tests, but
this allows the simple case of single-line texts to render
correctly.
2020-06-28 18:36:10 -07:00
Mike Welsh
b40f9d4c1a
avm1: Implement TextField.html
2020-06-28 18:36:10 -07:00
Mike Welsh
d97a515330
tests: Add text field variable test
2020-06-28 18:36:10 -07:00
Mike Welsh
618fa11acb
avm1: Implement text field variable binding
2020-06-28 18:36:10 -07:00
Mike Welsh
51d66c53f0
core: Edit text sets variables on instantiation
2020-06-28 18:36:10 -07:00
Mike Welsh
12fca71b21
avm1: Move StageObjectData behind a GC pointer
2020-06-28 18:36:10 -07:00
Mike Welsh
a922fd559f
avm1: Add EditText variable property
...
Add `EditText::variable` as well as `TextField.variable` property.
This commit only adds the getter/setter and does not yet add the
binding functionality.
2020-06-28 18:36:10 -07:00
Mike Welsh
dd50071240
core: Move frame and goto methods from MovieClipData to MovieClip
2020-06-28 18:36:10 -07:00
Mike Welsh
8da0f43412
tests: Add test for DefineLocal and issue #760
2020-06-28 15:15:45 -07:00
Mike Welsh
52fbb77e99
avm1: DefineLocal respects virtual properties and prototype chain ( fix #760 )
...
DefineLocal will call a virtual setter if the property already exists
on the local object, including the local object's prototype chain.
DefineLocal2 will also not overwrite a property if it already exists
on the local object, including the local object's prototype chain.
2020-06-28 15:15:45 -07:00
Mike Welsh
905f9d7ac6
core: Clear mouse down flag even if there is no hovered object
2020-06-27 23:34:19 -07:00
Mike Welsh
a846d92d8c
core: Don't fire rollOut events if clip is removed
...
Allows the inventory to work in The Room Tribute.
2020-06-27 21:24:49 -07:00
Mike Welsh
0833c15e25
tests: Add test for enumerating array indices
2020-06-27 20:25:45 -07:00
Mike Welsh
478d88b22d
tests: Test hasOwnProperty for array indices in array_properties
2020-06-27 20:25:45 -07:00
Mike Welsh
8e3b96f1b1
tests: Add tests for non-string params in hasOwnProperty:
2020-06-27 20:25:45 -07:00
Mike Welsh
ccf33eedf6
avm1: Array indices are enumerable
2020-06-27 20:25:45 -07:00
Mike Welsh
ecc54d01f7
avm1: Disallow setting "" property
...
object[""] has no effect.
2020-06-27 20:25:45 -07:00
Mike Welsh
ef82fc472e
avm1: Object.hasOwnProperty should coerce_to_string
2020-06-27 20:25:45 -07:00
Mike Welsh
b37b74e0b6
tests: Add test for __constructor__ being DontEnum
2020-06-27 18:54:01 -07:00
Mike Welsh
054194026e
avm1: Mark __constructor__ and constructor as DontEnum
2020-06-27 18:54:01 -07:00
dependabot-preview[bot]
63beea22a2
build(deps): bump weak-table from 0.2.3 to 0.3.0
...
Bumps [weak-table](https://github.com/tov/weak-table-rs ) from 0.2.3 to 0.3.0.
- [Release notes](https://github.com/tov/weak-table-rs/releases )
- [Changelog](https://github.com/tov/weak-table-rs/blob/master/release.toml )
- [Commits](https://github.com/tov/weak-table-rs/compare/0.2.3...0.3.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-27 16:08:52 -07:00
dependabot-preview[bot]
82a86d6139
build(deps): bump png from 0.16.5 to 0.16.6
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.5 to 0.16.6.
- [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 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-27 16:08:11 -07:00
Nathan Adams
463b79f063
avm1: Implement Action::Throw
2020-06-25 02:03:15 -07:00
Nathan Adams
70e4a40f01
avm1: Allow for user errors inside avm1::error::Error
2020-06-25 02:03:15 -07:00
Mike Welsh
81d75c6256
text: Text formatting for EditText fields (merge #615 )
...
First implementation of HTML parsing and formatting for text fields.
2020-06-24 23:06:11 -07:00
Mike Welsh
5d9701313e
text: Fix TextField.embedFonts setter
2020-06-24 22:46:59 -07:00
Mike Welsh
b2c96336fd
text: Cull text field if offscreen
2020-06-24 22:46:54 -07:00
David Wendt
74af7b345c
Adjust `BoxBounds` to use `Copy` instead of `Clone`.
2020-06-24 23:40:27 -04:00
David Wendt
d7a257f93f
Adjust `LayoutContext` and `LayoutBox` to construct a `Vec` of boxes rather than an intrusive, garbage-collected linked list.
2020-06-24 23:34:38 -04:00
David Wendt
d281452fe1
Expose the device font flag to AVM1 code.
2020-06-24 22:55:50 -04:00
David Wendt
453cf6c0f1
Remove *extremely* out of date documentation on `BoxBounds`.
2020-06-24 22:36:36 -04:00
David Wendt
2723c3f6d9
Rename `Collec` to `CollectWrapper`
2020-06-24 22:34:04 -04:00
David Wendt
5b36522258
Remove out-of-date doccomment on `LayoutBox`.
2020-06-24 22:19:16 -04:00
David Wendt
0b8d0e8c85
Move the internal padding to a separate constant.
2020-06-24 21:53:58 -04:00
David Wendt
e4d4d996f9
Don't push each line of text down with the leading adjustment.
...
We already adjust the cursor with the same adjustment, so we don't need to move the text down.
2020-06-24 21:32:59 -04:00
David Wendt
bfb150ec05
Remove hardcoded 3px margin.
...
This was originally intended to correctly position text within the border, but it appears borders are weird and this doesn't jive with what unbordered text does.
2020-06-24 21:32:59 -04:00
Mike Welsh
0f794489a4
text: Don't create underline drawing if no underline exists
2020-06-24 12:53:51 -07:00
Mike Welsh
3558e42c34
text: Always fallback to Noto Sans if text field is set to use device fonts
2020-06-24 12:19:06 -07:00
Mike Welsh
f591e1dafc
text: process_html_entity returns a Cow
2020-06-24 11:56:20 -07:00
Mike Welsh
5a7012923b
avm1: Move TextField methods into functions
2020-06-24 11:11:00 -07:00
Mike Welsh
d2702464a5
avm1: TextField properties are emumerable and deletable
2020-06-24 11:02:21 -07:00
Mike Welsh
b47e84b131
text: Derive Default for TextFormat
2020-06-24 10:44:34 -07:00
CUB3D
a5b0a196cc
core: Update to use updated value conversion functions
2020-06-24 01:57:15 +01:00
CUB3D
f03093528c
core: Add shared object cache and saving on exit
...
On the desktop player, shared objects will now be flushed on quit.
Attempting to retrieve an existing shared object will now return a
reference to the existing one.
2020-06-24 01:46:42 +01:00
CUB3D
166cb60d89
chore: Clean up useage of unwrap
2020-06-24 01:46:07 +01:00
CUB3D
62834fd690
chore: Remove unnecessary comment
2020-06-24 01:46:07 +01:00
CUB3D
fce8e8b7de
chore: Fix build
2020-06-24 01:46:07 +01:00
CUB3D
8a65ac764b
chore: Clean up comments
2020-06-24 01:46:07 +01:00
CUB3D
8e28bab159
chore: Fix clippy lints, refactor storage to use data_local_dir
2020-06-24 01:46:07 +01:00
CUB3D
0122d65a09
core: Refactor SharedObject
2020-06-24 01:46:07 +01:00
CUB3D
1b130ccd47
chore: Refactor storage access
2020-06-24 01:46:06 +01:00
CUB3D
4e286b43ae
chore: Format
2020-06-24 01:46:06 +01:00
CUB3D
0c6a7b3b4c
core: Add SharedObject object type
2020-06-24 01:46:05 +01:00
CUB3D
752ffc5cca
chore: Fix clippy lints and tests
2020-06-24 01:44:07 +01:00
CUB3D
eff06d3d4d
core: Add stub listener methods for SharedObject
2020-06-24 01:43:25 +01:00
CUB3D
d3ae6a3a40
core: Fix data property of SharedObject
2020-06-24 01:43:25 +01:00
CUB3D
48693e4a7a
core: Add inital storage backend implementation
...
Currently SharedObjects are encoded and decoded from JSON via the
StorageBackend, also provided is a basic in-memory implementation
2020-06-24 01:43:23 +01:00
CUB3D
539b4b0f63
core: Add stub for SharedObject
2020-06-24 01:42:19 +01:00
David Wendt
12495de91e
Generate `LI`s when newlines are encountered with bullets on.
2020-06-22 19:45:39 -04:00
David Wendt
ed5f3cdd0e
Don't attempt to use non-embedded fonts. Instead, replace all of them with Noto (like EditText used to do).
2020-06-22 19:02:32 -04:00
David Wendt
40ea58c1c0
Since we cannot parse `<br>` properly yet, replace them and `<sbr>` with newlines before parsing so that we don't get spurious parse errors.
2020-06-22 18:00:51 -04:00
dependabot-preview[bot]
0a166af8ac
build(deps): bump syn from 1.0.32 to 1.0.33
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.32 to 1.0.33.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.32...1.0.33 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-22 10:15:50 -07:00
Nathan Adams
cea2c9520d
chore: Ignore new 'unnested_or_patterns' clippy lint as we the suggested behaviour doesn't exist outside of nightly
2020-06-21 04:18:44 -07:00
David Wendt
7a9796a2f9
Restore BR parsing.
...
Note that this won't actually work since we're behind an XML parser that chokes on implicitly self-closing HTML tags.
2020-06-20 20:15:00 -04:00
David Wendt
c1ad37a0f6
Implement text span raising, sans list items.
...
During the raising process, we maintain a list of pointers to the lowest-most `textformat`, `p`, `font`, `a`, `b`, `i`, and `u` in the document that we are appending to. When we get a new one of any of those elements, we clear the rest off the stack. This forces us to add HTML in the same order Flash does.
LIs are not yet supported because they require us to process text line-by-line which doesn't mesh with this model.
There's also a test but the XML DOM generates HTML strings with the wrong attribute order, so the test fails spuriously.
2020-06-20 20:14:57 -04:00
David Wendt
e036d6594b
Add some entity support to HTML parsing.
2020-06-20 20:08:22 -04:00
David Wendt
88fcb98913
Allow disabling entity processing when parsing XML.
...
This necessitated a change to edittext_bullet, which turns out is accidentally an entity test, too. It now no longer uses entities so that it won't spuriously fail due to an entity related problem.
2020-06-20 20:06:21 -04:00
David Wendt
65f4d2cf1e
Add regression tests for `underline`.
...
We're within 4px in every case.
2020-06-20 19:56:01 -04:00
David Wendt
f097a6584e
Implement underlines.
2020-06-20 19:56:01 -04:00
David Wendt
d63b3f23e9
Add support for inserting arbitrary drawings into the layout.
2020-06-20 19:56:00 -04:00
David Wendt
a2d69a69a3
Add a test for bullets.
...
As usual with most newline related things, we're 3px off no matter how many or how few lines we have.
2020-06-20 19:56:00 -04:00
David Wendt
1c371c3a95
Render bullets.
...
Bullets are implemented by rendering U+2022 as if it were normal text, but always placed 18px from the left of the line. This appears to be sort of what Flash does.
2020-06-20 19:55:59 -04:00
David Wendt
a3dfa8c21f
Bulleted lists get 35px of additional left-margin and do not respect alignment at all.
2020-06-20 19:55:59 -04:00
David Wendt
fa2da492a7
Allow ActionScript to control text field borders.
2020-06-20 19:55:58 -04:00
David Wendt
2aa7d9770f
Draw a border around text if requested.
2020-06-20 19:55:58 -04:00
David Wendt
8628261dc8
Add a bunch of necessary fixes to default text formatting and HTML format extraction.
...
This also replaces the `edittext_html_defaults` test with a more robust test that checks the default format and global format of SWF-based, text, and HTML test vectors.
2020-06-20 19:55:57 -04:00
David Wendt
4f3d4c82fb
For some reason, Flash does not respect `<br>` at all, so we won't, either.
...
It *does*, however, respect `<sbr>` (which does the exact same thing), as well as `\n` (which makes absolutely no sense in HTML, normally that would get stripped out).
2020-06-20 19:55:57 -04:00
David Wendt
efc6236cb5
Treat the end of each paragraph as a newline.
2020-06-20 19:55:56 -04:00
David Wendt
d5fc2709fc
Don't use a slice to hold an index.
...
Fixes clippy on beta and nightly Rust.
2020-06-20 19:55:56 -04:00
David Wendt
58a039a6aa
Nulls in font names are ignored.
2020-06-20 19:55:56 -04:00
David Wendt
d8a38d06bb
Collect font height, letter spacing and the kerning flag into a single `EvalParameters` structure.
2020-06-20 19:55:55 -04:00
David Wendt
1f6d6018dc
Use a char pattern here for clippy's sake
2020-06-20 19:55:55 -04:00
David Wendt
1966ec5cb1
Implement `sbr` tags.
...
No, I don't know what they are either, but at least one movie exists which treats them like `br`, so we'll treat them like that, too.
2020-06-20 19:55:54 -04:00
David Wendt
9e56f10fd0
Approx the align and margins text by up to 3 pixels.
...
These tests currently have visual bugs in all cases, and measurement bugs in the justification case that require me to approx them.
2020-06-20 19:55:54 -04:00
David Wendt
f746ac5539
Implement `justify`, mostly.
...
This implementation has a few bugs which appear to have something to do with alignment. It's not only justify, but justify is the only test that's flagged as failing.
If you look at the margins test, you'll see what I mean: right-aligned and justified text doesn't quite make it to the right edge of the box even though it should. I'm not sure why.
This also restricts text rounding further: `measure` now only rounds when wrapping text, since Flash Player appears to account for fractional pixels in all other cases.
2020-06-20 19:55:54 -04:00
David Wendt
670c4723e3
Add support for the `kerning` flag, which turns on and off the kerning information on fonts.
2020-06-20 19:55:53 -04:00
David Wendt
3c9a43ea72
Add a regression test for newlines.
...
This test includes tests for HTML newlines, which causes the XML parser in Ruffle to throw errors. Hence why it's currently ignored.
2020-06-20 19:55:53 -04:00
David Wendt
180ef3b423
Recognize `<br>` as a line break.
...
This code is currently unreachable as `<br>` will actually trigger an AVM1 error due to our overly-strict XML parser.
2020-06-20 19:55:52 -04:00
David Wendt
045a81e79e
Implement `html` and `htmlText`... sort of.
...
There are several problems, first off:
1. I'm not entirely sure what I'm supposed to be changing on the text field when someone writes `html`.
2. We're using the XML parser for HTML (both `htmlText` and SWF tag parsing) which causes problems. Notably, `<br>` issues an AVM1 error (!!!) because the XML parser doesn't like unclosed tags.
3. Reading `htmlText` should not return the same HTML tree (at least, not until we implement stylesheets). It should instead regenerate an HTML tree from text spans.
2020-06-20 19:55:52 -04:00
David Wendt
2452124631
Break individual words at the start of lines that are too big to fit on the line.
2020-06-20 19:55:51 -04:00
David Wendt
6c44418b10
Add a test for tab_stops.
...
This test is currently inaccurate by up to 5 pixels, this is due to some behavior with really, really wide tabstops and word breaks that I don't entirely get yet.
2020-06-20 19:55:51 -04:00
David Wendt
2ad216cab4
Don't continue comparing tab stops after we find one that fits.
2020-06-20 19:55:50 -04:00
David Wendt
b6c12b1e23
Use current font height times 2.7 as the natural tab stop, as that seems to match Flash... for now.
2020-06-20 19:55:50 -04:00
David Wendt
0e45dc12e9
Recompile the letter spacing test 'cause I spotted an errant `s` in the FLA
2020-06-20 19:55:49 -04:00
David Wendt
2caaa6875d
Add support for explicit tabs and newlines.
2020-06-20 19:55:49 -04:00
David Wendt
153ab675e9
When aligning a line, actually consider all the boxes within the line.
2020-06-20 19:55:49 -04:00
David Wendt
3d094ed689
Add margins test.
...
This test is also approx'd to 1px due to the same issue where heights are off by one.
2020-06-20 19:55:48 -04:00
David Wendt
db0398d2ee
Left and right margins and indents should not be included in `textWidth`.
2020-06-20 19:55:48 -04:00
David Wendt
74d4c25133
Add a test for letter spacing.
...
This test is approximate because the 0.5px test is off by 1px in terms of height.
2020-06-20 19:55:47 -04:00
David Wendt
6ce7ecee78
Implement `letterSpacing`.
2020-06-20 19:55:47 -04:00
David Wendt
171954d5e4
Add `edittext_leading` test.
...
This test constructs a handful of text fields and measures them. Each field has 0, 5, or 15px of `leading` applied to it's text format.
2020-06-20 19:55:47 -04:00
David Wendt
bbc73f1477
The `edittext_align` test now passes perfectly.
2020-06-20 19:55:46 -04:00
David Wendt
16da6d827c
Line-leading is always applied at least once, even if there are no line breaks in the text field.
2020-06-20 19:55:46 -04:00
David Wendt
410fb3ab86
Don't round each line's leading. Instead, round at the end of the operation.
...
This was verified by visual comparison with Flash Player; lines of text appear to be shifted by half-pixels, while the script output is always still rounded down.
2020-06-20 19:55:45 -04:00
David Wendt
2858c09b6e
Only apply leading adjustment on newlines.
...
This results in ALL height adjustments being off by 2px, regardless of leading or font size. Tantalizing!
2020-06-20 19:55:45 -04:00
David Wendt
2ab85c32e2
When wrapping text, measure the text including the trailing space (if present).
...
This matches Flash behavior, but breaks an existing test, which I've adjusted appropriately.
2020-06-20 19:55:44 -04:00
David Wendt
c67bf0b6b7
Add approximate test of text field metrics during alignment.
...
This is an approximate text with a 1-pixel tolerance because our height is currently off by one and I cannot explain why. Previous attempts to fix the bug have resulted in cascading errors that resulted in off-by-one errors in the opposite direction. This is still better than nothing and I need to check other tests in.
2020-06-20 19:55:44 -04:00
David Wendt
a1e52ab556
Add a test for formatting defaults on HTML text.
2020-06-20 19:55:44 -04:00
David Wendt
09c91d191a
Round-trip tab stops between `EditText` and AVM1
2020-06-20 19:55:43 -04:00
David Wendt
00217072e6
After the previous set of fixes our tests are now consistent with a layout engine that always rounds down to the nearest pixel and never up. Adjust code to match.
2020-06-20 19:55:43 -04:00
David Wendt
06c66533c7
Don't apply leading twice.
2020-06-20 19:55:42 -04:00
David Wendt
82c6269cf6
Ensure that presentational markup styles cascade from parent tag to child, and from the default format to the first tag.
2020-06-20 19:55:42 -04:00
David Wendt
88d07f5d17
We don't need to relayout when the new-text text format gets changed.
2020-06-20 19:55:42 -04:00
David Wendt
9981148482
Add a test for `BoxBounds.with_size`, since we're using it now
2020-06-20 19:55:41 -04:00
David Wendt
aae1f0ba7a
Skip fixups on empty lines.
2020-06-20 19:55:41 -04:00
David Wendt
bd40295076
Ensure that the font-provided leading is accounted for when moving the cursor for a newline.
2020-06-20 19:55:41 -04:00
David Wendt
0e0b2fb85d
All layout boxes on the line should have trailing whitespace trimmed off of their measurements.
...
Flash has a weird bug where it will NOT trim trailing spaces off of the metrics reported to users if the text is left-aligned. We replicate this here so that tests pass.
2020-06-20 19:55:40 -04:00
David Wendt
50a05df998
Generated lines should *always* include their end spaces, there should be no gaps.
2020-06-20 19:55:40 -04:00
David Wendt
ab2b9cc733
Change all of the `BoxBounds` in the layout machinery to not use `Default`.
...
The `Default` bounds are NOT safe to union against if they were uninitialized. Doing so will force any resulting layout box to enclose `(0,0)`, which can throw off certain layout calculations. Instead, we use `None` to signal an uninitialized box.
2020-06-20 19:55:40 -04:00
David Wendt
806a741bf4
EditText appears to have internal padding between it's borders equivalent to a CSS padding of `3px 4px 3px 0`.
...
Verified by experimentation with Flash Player, appears to be necessary for tests to pass.
2020-06-20 19:55:39 -04:00
David Wendt
96c43654d0
Retain the bounds returned when constructing layout boxes and use them as the `textWidth` and `textHeight` of a given text field.
2020-06-20 19:55:39 -04:00
David Wendt
318f09d241
Include the font-provided leading in the exterior bounds sent off for `autoSize` calculation.
2020-06-20 19:55:39 -04:00
David Wendt
06dc2f5fe0
Implement the `leading` attribute as defined by fonts.
...
`EditText` supports two different forms of leading:
1. Font-provided leading, specified relative to the EM square and scaled with font size
2. User-specificed leading, specified in pixels
Notably, the former appears to apply to the first line in the text and pushes it down. This showed up in the `edittext_font_size` test, and according to that test result the leading is rounded *up* to the nearest pixel, plus one.
That last bit seems possibly wrong and is subject to further change, but it matches the tests at multiple scales.
2020-06-20 19:55:29 -04:00
David Wendt
6e81f30a70
Round down to the nearest pixel when measuring text.
...
Certain text routines calculate text on the pixel grid, despite the fact that Flash ordinarily works in twips. There is probably a reason for this - my guess is to keep text wrapping stable across multiple pixel densities (e.g. low-res screens plus high-res print).
2020-06-20 19:53:42 -04:00
David Wendt
7a62a8e9ce
Programmatically created text fields get a biased depth.
2020-06-20 19:53:34 -04:00
David Wendt
75aaa49169
Y coordinates should always be adjusted by Y coordinates.
2020-06-20 19:48:14 -04:00
David Wendt
245cea784f
Running an `autoSize` on any text field should always synchronize the X coordinate between the bounding box and the base transform.
...
I don't know why, but this is necessary for the "NEW STUFF" box on homestarrunner.com's toons menu to position correctly. SOMEWHERE, we are performing some kind of operation that adjusts one of the two, but not the other, and I can't find out what.
2020-06-20 19:48:13 -04:00
David Wendt
5a2b74c5fc
Setting a new matrix should also transform the bounds as well.
2020-06-20 19:48:13 -04:00
David Wendt
e7e944ad76
Account for the width of glyphs when measuring text.
...
This fixes spaces at the start of text spans not being rendered, but also breaks center-align.
I also broke the font tests, so I had to rewrite them, which makes me question their value.
2020-06-20 19:48:13 -04:00
David Wendt
8a5a2bf7c7
When `Font.wrap_text` indicates that none of the line can fit, we should also refresh our width and offset and check if there's even more text to measure or not.
2020-06-20 19:48:12 -04:00
David Wendt
efc50da367
`Font.wrap_text` should return `0` if no part of the string can fit within the requested bounds.
2020-06-20 19:48:12 -04:00
David Wendt
38d679ef29
`wrap_line` should take spaces into account when sizing lines.
2020-06-20 19:48:12 -04:00
David Wendt
85a3a845d9
Dynamic `EditText` bounds should go from `x` to `x+width`, not `x` to `x+height` (etc)
2020-06-20 19:48:12 -04:00
David Wendt
bacbf06614
Setting the matrix of an `EditText` should scale it's bounds.
2020-06-20 19:48:12 -04:00
David Wendt
9564cbeda4
Use the new dynamic bounding box to calculate a width for word-wrapping, and update the new bounding box directly in autosize rather than hitting `DisplayObject` methods.
...
This also adjusts `DisplayObject` methods to use the bounds.
2020-06-20 19:48:11 -04:00
David Wendt
a0477e7525
Adjust the layout code to properly align content with right margins, trailing spaces on lines, and lines wider than the bounds.
...
Right margins: Simple enough, we just need to subtract the right margin from the bounds when we calculate our alignment adjustment.
Trailing spaces: This is very tricky as we effectively have to remeasure the last box in the line when fixing it up. This also means LayoutContext has to hold the text itself so we can remeasure again...
Lines wider than bounds: If word wrap is disabled it is possible for a line to exceed the bounds of the box. In this case it will be left-aligned. Effectively, the align adjustment is clamped to positive values and we do that here too.
2020-06-20 19:48:11 -04:00
David Wendt
4eb2113a77
Setting positions and widths on the `EditText` should adjust intrinsic bounds rather than stretching or transforming the field.
2020-06-20 19:48:11 -04:00
David Wendt
7cf2cce3ef
Add functions to set positions and widths on bounding boxes.
2020-06-20 19:48:10 -04:00
David Wendt
dc46885021
Implement `autoSize`.
...
This doesn't work right yet because the resulting width doesn't apply correctly to the field. This is because `EditText`'s `_width` and `_height` change it's intrinsic bounds rather than it's X and Y scale (like it would with a button or a movie clip).
2020-06-20 19:48:00 -04:00
dependabot-preview[bot]
6928e75cd6
build(deps): bump syn from 1.0.31 to 1.0.32
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.31 to 1.0.32.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.31...1.0.32 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-20 16:36:01 -07:00
David Wendt
18e93b3d11
Implement tests for `wrap_line`.
...
These tests depend on the particulars of our default device font, Noto Sans. If this test proves to be fragile we may need to create a testing font with a locked width and kerning table...
2020-06-20 19:26:47 -04:00
David Wendt
cb47e0bae8
`wrap_line` returns breakpoints relative to how we sliced the text, so we need to break things appropriately.
...
This prevents a bounds-check panic when we inevitably try to slice an array like `[300..2]` or something like that.
We also skip rendering the space that we're turning into a newline to avoid it popping up on the next line by accident.
2020-06-20 19:26:47 -04:00
David Wendt
ece879a15c
The align adjustment should be positive, not negative.
2020-06-20 19:26:47 -04:00
David Wendt
593f442372
Implement `leading` between lines
2020-06-20 19:26:47 -04:00
David Wendt
e83cebc4fb
Vertically align different-font-size boxes to the same bottom baseline.
2020-06-20 19:26:46 -04:00
David Wendt
b517019b57
Clean up how we calculate the width of the text field.
...
`max_length` isn't a geometrical width, despite the fact that the type system didn't prevent me from making erroneous conversions. It's actually just a text length limit, which we won't be dealing with for some time.
When first instantiated, we use the static bounds; however, further relayouts grab `local_bounds` and calculate a width from that. `EditText` works almost identically to any other display object, with the exception that device fonts do not render if the transform is not an axis-aligned bounding box (and it doesn't respect scale). We don't have to worry about that for now.
2020-06-20 19:26:46 -04:00
David Wendt
c7ac0e4bb1
Implement center and right alignment.
...
Justification will have to wait for another day.
2020-06-20 19:26:46 -04:00
David Wendt
562adcdc7e
Implement `leftMargin`, `rightMargin`, `indent` and `blockIndent`.
...
This is surprisingly difficult because of how Flash handles these properties: they are cached at the start of a new line (explicit or flown) and then used for all spans that intersect with that line. Ergo, `LayoutContext` needs to keep track of all the boxes we generate within the line and the span that ultimately is going to provide margins for it.
And yet, at the same time, we also have to precalculate the effects of these margins when flowing text so that we know how much space we have to play with. This needs to be calculated the same at the start of the line as it is at the end. This is why `LayoutContext` is a separate type: it handles all the state tracking and crap that has to be done when splitting text into spans, paragraphs, and lines all at the same time.
Fortunately, this design will make it easier to implement other features like text alignment where we couldn't even begin to calculate everything in one pass.
2020-06-20 19:26:46 -04:00
David Wendt
5fcaa52687
Restore newline functionality (mostly...)
2020-06-20 19:26:45 -04:00
David Wendt
9f60567f66
Remove library lookup as layout can do it itself
2020-06-20 19:26:45 -04:00
David Wendt
e3f59ac00f
Implement `color` on spans
2020-06-20 19:26:45 -04:00
David Wendt
9bcc7ef0cc
`setTextFormat` should trigger a relayout
2020-06-20 19:26:44 -04:00
David Wendt
b5de92edeb
Properly retrieve default font class
2020-06-20 19:26:44 -04:00
David Wendt
c4e5a9afc2
In the spirit of shared-nothing `post_instantiation` should duplicate any `LayoutBox`es it has, in case we mutate them later.
2020-06-20 19:26:44 -04:00
David Wendt
467fd9db80
Implement `TextField.length` in AVM1.
2020-06-20 19:26:44 -04:00
David Wendt
ef6ebe2b44
The default format of a text field should match it's SWF tag.
2020-06-20 19:26:43 -04:00
David Wendt
361ea1f774
Index fonts by font name, boldness, and italicization.
...
This involves a new struct called a `FontDescriptor` which is generated whenever a font is registered and used to index the font in the library. When a font is requested, it goes through the descriptor system to get found.
2020-06-20 19:26:43 -04:00
David Wendt
f234926e63
Default text formats are not replaced when movies call `setNewTextFormat`, they instead mix with the existing one.
...
"Mixing" is defined as `Option.or`ing all the properties in the new text format with the old one. Not specifying a text format in the new default will result in the field retaining it's old properties.
2020-06-20 19:26:43 -04:00
David Wendt
0aab45f389
Fix panic in `render_layout_box` caused by indexing an already-indexed slice.
2020-06-20 19:26:42 -04:00
David Wendt
3b80ff8d23
Clippy compliance
2020-06-20 19:26:42 -04:00
David Wendt
fde5e13358
Expose `replaceText` to AVM1 code.
2020-06-20 19:26:42 -04:00
David Wendt
a8a1b985a3
Expose `getTextFormat` and `setTextFormat` to AVM1.
2020-06-20 19:26:41 -04:00
David Wendt
74912525ed
Add ancestor iteration to XML nodes.
2020-06-20 19:26:41 -04:00
David Wendt
a2836a0b92
Tie `EditText` into the new layout system, which is currently unfinished.
...
This should *significantly* regress `EditText` layout.
2020-06-20 19:26:37 -04:00
David Wendt
8622cb97a9
Add a system of layout boxes to store text layout decisions made at update time.
2020-06-20 19:16:17 -04:00
David Wendt
4a2fac28d1
Add iterator for text spans
2020-06-20 19:16:17 -04:00
David Wendt
ec72ac518c
Allow HTML text nodes to populate text.
...
This will need to be updated to handle line breaks, spaces, and so on correctly - the way whitespace works in HTML differs from plain text.
2020-06-20 19:16:17 -04:00
David Wendt
816644c497
Add an internal implementation of `replaceText`.
2020-06-20 19:16:17 -04:00
David Wendt
a1f548f744
Add a routine to generate `TextFormat`s from presentational markup, and another lowering process which tracks the text formats generated by this process.
2020-06-20 19:16:16 -04:00
David Wendt
62a13cd7a6
Add the ability to `walk` through an XML tree.
...
This yields nodes as `Step`s. This allows keeping track of the structure of the tree as you walk through descendents, as each element will be yielded twice: both as a `Step::In` *and* as a `Step::Out`. Non-element nodes will be yielded once as a `Step::Around`.
I'm adding `walk` iteration specifically to avoid having to write certain methods recursively. Existing recursive callers of `children` should probably be updated to `walk` the tree and maintain a separate `Vec` stack.
2020-06-20 19:16:16 -04:00
David Wendt
4eca2d4bdd
Replace the existing default format on `EditText` with our brand-new `FormatSpans`.
...
This also includes code to automatically populate the default format with data from the SWF tag.
2020-06-20 19:16:16 -04:00
David Wendt
efdecdea64
Store the default text format, and use it when generating new spans during normalization.
...
I'm sure this will wind up having further uses eventually.
2020-06-20 19:16:15 -04:00
David Wendt
153571c0c4
Implement `FormatSpans::set_text_format`.
...
This also necessitated the addition of code to:
* Ensure span breaks exist at both sides of the text boundary, without creating degenerate (length-0) spans
* Consolidate spans with matching text formats
* Shorten or lengthen the total list of text spans to match the backing string
* Ensure at least one text span exists at all times
This still has some minor to-dos: for example, it relies on the default `TextSpan` formatting, which probably should be replaced with actually accepting or storing a default format to be used when constructing new text spans.
2020-06-20 19:16:15 -04:00
David Wendt
102c494de4
Add a type to hold text with some text spans, and some tests for that type.
2020-06-20 19:16:14 -04:00
David Wendt
1671fc6eba
Add an internal representation of text spans.
...
Despite having HTML and CSS rendering capabilities, the Flash text field actually does not use HTML as it's internal representation. Instead, the text-span format implied by `getTextFormat` and `setTextFormat` is used to drive layout. You can see this by watching what happens to `htmlText`, *especially* when you add and remove stylesheets.
The `LayoutBox` machinery will be adapted to consume text spans in a future commit. This would make the entire rendering pipeline: HTML/CSS -> Text Spans -> Layout Boxes -> Render commands.
2020-06-20 19:16:14 -04:00
David Wendt
850831181c
Add tests for all non-trivial methods of `Position`, `Size`, and `BoxBounds`.
2020-06-20 19:16:13 -04:00
David Wendt
ef035c5283
Add `Size.max`, conversions between `Position` and `Size`, `BoxBounds.extent`, and `BoxBounds.with_size`.
2020-06-20 19:16:13 -04:00
David Wendt
e7c34d9745
Switch `BoxBounds` from a position-and-size representation to an offset-and-extent representation.
...
This makes the implementation of rectangle union (`Add`/`AddAssign`) far easier as we just compute the min and max of the offset and extent coordinates. It also makes the conversion into and from `swf::Rectangle` easier as it's now effectively a generic version of that datatype.
On the other hand, `width`, `height`, and `size` now have to be calculated, and require `T` to be self-`Sub`. I'm not sure if this is that much of a problem or not.
2020-06-20 19:16:12 -04:00
David Wendt
0a1de3276f
Add extra types for indicating moving a position and resizing a box.
2020-06-20 19:16:12 -04:00
David Wendt
a4c8cd4711
Add a set of types for tracking CSS attributes, positions, sizes, and bounds on layout boxes.
2020-06-20 19:16:12 -04:00
David Wendt
4739e08c11
Add the ability to split lines from the middle of an already-existing flow operation
2020-06-20 19:16:12 -04:00
David Wendt
7e7ca88c3d
`post_instantiate` is morally equivalent to duplicating the display object it's called on, so we should also duplicate the XML document attached to it.
...
We don't have to do this for `object` because we don't actually construct the script object until instantiation time.
2020-06-20 19:16:11 -04:00
David Wendt
a3f4509d63
Store all text internally as an HTML tree, alongside the existing strings.
...
We're reusing the XML machinery to handle HTML - this is probably not 100% correct, but writing a new HTML parser to cover just `EditText` will be rather complicated.
2020-06-20 19:16:11 -04:00
David Wendt
cc854db9b3
Derive `Collect` on `EditTextData`.
2020-06-20 19:16:10 -04:00
David Wendt
ac9cd0cf87
Move `TextFormat` over to a new `html` module, which will hold all the stuff necessary for rendering HTML in an `EditText`.
...
`TextFormat` is owned data and should be collectable as static.
2020-06-20 19:16:10 -04:00
Nathan Adams
2e7ebbf258
avm1: Fatal errors will halt the AVM and prevent further execution
2020-06-20 15:02:00 -07:00
Nathan Adams
f5da954b32
avm1: Merge avm1::Error and avm1::ExecutionError for now. It's plausible that nested inside actions we can encounter an ExecutionError, so at that point it doesn't make sense to have a separation.
2020-06-20 15:02:00 -07:00
Nathan Adams
e2c607c70f
avm1: Avm1::retire_stack_frame can't error, so adjust its signature appropriately
2020-06-20 15:02:00 -07:00
Nathan Adams
a36e2105a3
avm1: Made avm1::Error an actual error type, and removed all calls that throw incorrect errors in avm1
2020-06-20 15:02:00 -07:00
Nathan Adams
ad07520af3
avm1: Add avm1::ExecutionError
2020-06-20 15:02:00 -07:00
Nathan Adams
adb8ffbf9c
core: Convert XML errors into an enum
2020-06-20 15:02:00 -07:00
Nathan Adams
59ccd75518
core: Rename loader::LoaderError to loader::Error
2020-06-20 15:02:00 -07:00
Nathan Adams
b6f012cf7f
core: Use thiserror to derive Loader errors
2020-06-20 15:02:00 -07:00
Nathan Adams
0f1eef9022
core: Introduce LoaderError to all Loader methods
2020-06-20 15:02:00 -07:00
Nathan Adams
c8f0753da4
core: Rename Value::as_number to Value::coerce_to_f64
2020-06-19 12:48:28 -07:00
Nathan Adams
67042b255c
core: Replace Value::as_* numeric methods in favour of coerce_to_* or manual matching
2020-06-19 12:48:28 -07:00
Nathan Adams
270f63b2f3
core: Made Object::to_string return a Cow<str>
2020-06-19 12:48:28 -07:00
Nathan Adams
f4b4d0ebb7
core: Replace Value::into_string in favour of coerce_to_string or manual matching
2020-06-19 12:48:28 -07:00
Nathan Adams
5662b2d4d9
core: Make Value::coerce_to_string return a Cow<str>`
2020-06-19 12:48:28 -07:00
Nathan Adams
9633dc71c3
core: Replace Value::as_string in favour of coerce_to_string or manual matching
2020-06-19 12:48:28 -07:00
Nathan Adams
e44568c31c
core: Remove Value::call_method, you must box the value first
2020-06-19 12:48:28 -07:00
Nathan Adams
5dd1a1e509
core: Remove Value::get, you must box the value first
2020-06-19 12:48:28 -07:00
Nathan Adams
fc18c2fce5
core: Rename Value::as_object to Value::coerce_to_object
2020-06-19 12:48:28 -07:00
Nathan Adams
b2b57c1540
core: Make Value::as_object always return a (possibly boxed) object
2020-06-19 12:48:28 -07:00
Nathan Adams
3695c3c9fa
tests: Add test for default names of display objects
2020-06-18 16:26:36 -07:00
Mike Welsh
62cfeb3754
core: Assign default name to unnamed clips ( fix #66 )
2020-06-18 16:26:36 -07:00
Nathan Adams
25ad2a428d
tests: Improve attach_movie test to prove when the first frame is executed
2020-06-17 14:16:38 -07:00
Mike Welsh
83feeefeeb
audio: Don't panic on unimplemented codecs
...
Remove `unimplemented` calls when encountring unsupported codecs
such as Nellymoser. Instead, return an Error that can be
gracefully handled.
2020-06-17 12:14:08 -07:00
Mike Welsh
1d7e6b7e8a
chore: Fix let-unit-value clippy lint
2020-06-17 11:25:06 -07:00
Mike Welsh
77cb186357
avm1: Constructors queue to run after a goto
...
If a class is registered to a clip that is placed on the timeline
during a goto, that constructor should run after the frame is
completely constructed. In order to tell whether to run the
constructor immediately, add a parameter to `post_instantiation`
to indicate if the clip is instantiated from the AVM or via a
standard timeline seek.
2020-06-16 14:53:44 -07:00
Mike Welsh
568d0513ed
tests: register_and_init_order tests for constructor after goto
2020-06-16 14:53:44 -07:00
Nathan Adams
5efab4c579
core: Implement RGB15 PNGs - fixes #724
2020-06-16 14:53:19 -07:00
dependabot-preview[bot]
fcea6012bb
build(deps): bump png from 0.16.4 to 0.16.5
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.4 to 0.16.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.16.4...v0.16.5 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-13 18:52:24 -07:00
Mike Welsh
5da9863402
tests: Add test for #710
2020-06-13 02:48:38 -07:00
Mike Welsh
35a4c05923
avm1: CallFunction can resolve variable paths
2020-06-13 02:48:38 -07:00
Mike Welsh
29dc88ec01
tests: Clip event test now tests for children unloading
...
The test now verifies that a child movie clip runs its `unload`
clip event if its parent is removed.
2020-06-11 23:39:16 -07:00
Mike Welsh
ce73b4eaa7
core: Recursively unload child display objects
...
Child movie clips should run their unload actions when the parent
is removed.
2020-06-11 23:39:16 -07:00
Mike Welsh
9b0881edb7
core: Set $version on root
...
_root has a $version property that should matches
`System.capabilites.version`. This allows Nanaca Crash to boot.
2020-06-11 10:03:29 -07:00
Mike Welsh
faa35a53e9
tests: Add test for getBounds with empty children
2020-06-10 17:17:08 -07:00
Mike Welsh
b5daf3d020
core: Fix BoundingBox::union for invalid bounds
2020-06-10 17:17:08 -07:00
dependabot-preview[bot]
f03e75951a
build(deps): bump syn from 1.0.30 to 1.0.31
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.30 to 1.0.31.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.30...1.0.31 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-09 22:14:57 -07:00
CUB3D
fa11ef1e81
core: Add remaining capabilities
2020-06-09 23:57:46 +01:00
CUB3D
dd5d2976ea
core: Add missing functions to System.security
2020-06-09 23:03:13 +01:00
CUB3D
07d4f3a8eb
core: Fix build
2020-06-09 22:41:11 +01:00
CUB3D
ad3bc612aa
chore: Fix clippy lints
2020-06-09 22:41:11 +01:00
CUB3D
4987cfdaac
core: Refactor enums, Add unknown windows os support and fix attributes
...
Now using Display to convert enums.
Also added support for a fallback "Windows" os for when the current version can't be detected
2020-06-09 22:41:11 +01:00
CUB3D
48bef91917
core: Remove clear_clipboard, format and fix tests
2020-06-09 22:41:11 +01:00
CUB3D
bc1055e381
core: Create system protos in globals.rs, fix version-dependant output
...
Make get_server_string output order match flash, also make language and manufacturer output respect emulated player version
2020-06-09 22:41:11 +01:00
CUB3D
de013426bc
core: Url encode serverString
2020-06-09 22:41:11 +01:00
CUB3D
887e09337f
core: Add dummy impl of System.security
2020-06-09 22:41:11 +01:00
CUB3D
fc8cd1139a
core: Add initial System.IME implementation
2020-06-09 22:41:11 +01:00
CUB3D
94a53f3506
core: Store System.capabilities in SystemProperties
2020-06-09 22:41:11 +01:00
CUB3D
af41ac5602
core: Add clipboard support to input backend
2020-06-09 22:41:11 +01:00
CUB3D
0f0f778830
core: Retain properties for System in the player
2020-06-09 22:41:11 +01:00
CUB3D
8471523e49
core: Add basic System.capabilities implementation
2020-06-09 22:41:11 +01:00
CUB3D
50abbe1887
core: Implement basic System global
2020-06-09 22:41:10 +01:00
Nathan Adams
58df56e4a4
core: Add `Value::get` shortcut that resolves Objects or returns Undefined
2020-06-08 15:12:05 -07:00
Nathan Adams
d0ad1b57fe
core: Replace `toString`/`valueOf` calls with `call_method`
2020-06-08 15:12:05 -07:00
Nathan Adams
c592b5fb2a
core: `Value::call_method` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
d39ffcfadc
core: `Value::call` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
fe55c5a264
core: `TObject::call_method` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
da3e2bb0a0
core: `TObject::call` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
26590d4c63
core: `TObject::get_local` no longer requires you to resolve after retrieving it
2020-06-08 15:12:05 -07:00
Nathan Adams
a121a3a4d0
core: `TObject::get` no longer requires you to resolve after retrieving it
2020-06-08 15:12:05 -07:00
dependabot-preview[bot]
36fb0cd43c
build(deps): bump quote from 1.0.6 to 1.0.7
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.6...1.0.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-07 17:17:32 -07:00
Mike Welsh
359df6860f
tests: Add String.charCodeAt tests
...
Tests the fix provided in #634 .
2020-06-04 16:02:55 -07:00
Nathan Adams
34cf21289b
avm1: Fixed some missing behaviours with flash.geom.Rectangle
2020-06-02 18:49:01 -07:00
Nathan Adams
f5765f2bac
avm1: Implement all of flash.geom.Rectangle + tests ( #305 )
2020-06-02 18:49:01 -07:00
Nathan Adams
226a97ef4b
core: Don't panic on `new DoesntExist()`
2020-06-02 18:49:01 -07:00
dependabot-preview[bot]
4b22fc723d
build(deps): bump indexmap from 1.3.2 to 1.4.0
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.3.2 to 1.4.0.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.3.2...1.4.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 13:42:08 -07:00
dependabot-preview[bot]
cf4df4058f
build(deps): bump png from 0.16.3 to 0.16.4
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.3 to 0.16.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/compare/v0.16.3...v0.16.4 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 12:23:21 -07:00
dependabot-preview[bot]
078c64c201
build(deps): bump syn from 1.0.28 to 1.0.30
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.28 to 1.0.30.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.28...1.0.30 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 12:19:30 -07:00
dependabot-preview[bot]
0e7b0f8467
build(deps): bump libflate from 1.0.0 to 1.0.1
...
Bumps [libflate](https://github.com/sile/libflate ) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/sile/libflate/releases )
- [Commits](https://github.com/sile/libflate/compare/1.0.0...1.0.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 11:24:15 -07:00
Nathan Adams
0d53f0a952
chore: Fix new clippy lint about short variable names - fixes #668
2020-06-01 10:31:46 -07:00
Mike Welsh
3a8c705e95
chore: Fix clippy lints
2020-05-30 03:47:12 -07:00
Nathan Adams
4c1ce6d765
core: Print swf version on startup, and warn when we run into avm2
2020-05-30 02:48:54 -07:00
dependabot-preview[bot]
c0593ce081
build(deps): bump syn from 1.0.27 to 1.0.28
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.27 to 1.0.28.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.27...1.0.28 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-29 09:49:49 -07:00
dependabot-preview[bot]
97f69e8ed2
build(deps): bump syn from 1.0.25 to 1.0.27
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.25 to 1.0.27.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.25...1.0.27 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-27 07:24:00 +00:00
Nathan Adams
ddf2aa3ec1
avm1: Implement all of flash.geom.Point ( #304 )
2020-05-27 00:23:45 -07:00
Nathan Adams
2e25fec099
tests: Add test coverage for flash.geom.Point
2020-05-27 00:23:45 -07:00
Nathan Adams
df6764a69c
chore: Add license metadata to all packages & crates
2020-05-27 00:11:02 -07:00
dependabot-preview[bot]
458ca2a478
build(deps): bump syn from 1.0.24 to 1.0.25
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.24 to 1.0.25.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.24...1.0.25 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 20:36:01 +00:00
CUB3D
590321133f
core: Fix incorrect String.charCodeAt bounds check ( close #633 )
2020-05-25 13:35:41 -07:00
dependabot-preview[bot]
4712446314
build(deps): bump syn from 1.0.23 to 1.0.24
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.23 to 1.0.24.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.23...1.0.24 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 01:42:44 +00:00
Mike Welsh
993421e732
core: Children run an initial frame when changing button states
...
There was a one-frame-off flicker when a button changed states.
Now children will tick a frame so that they are properly created
immediately when the parent button changes state.
2020-05-24 08:57:30 -07:00
Mike Welsh
932ad30570
core: Flatten ClipActions into a single event per action
...
Previously a MovieClip's clip action would have a set of events
that would trigger it. Now we flatten these out into a single
event per action, because this is by far the common case. If an
action does happen to have >1 event, it will be duplicated for each.
2020-05-24 08:57:30 -07:00
Mike Welsh
c427d55dbb
core: Clean up clip event handlers
...
Remove ButtonEvent and subsume it in ClipEvent. Player now tosses
ClipEvents down the display tree, cleaning up some of the event code.
2020-05-24 08:57:30 -07:00
Mike Welsh
6929cea996
core: Implement button event handlers for movie clips
2020-05-24 08:57:30 -07:00
Mike Welsh
09ca11f788
webgl: Implement linear RGB gradients
2020-05-22 11:03:16 -07:00
Mike Welsh
97db518fb1
core: First pass of drawing API (merge #611 )
2020-05-22 08:54:55 -07:00
Nathan Adams
3346accb9c
core: More accurate shape_bounds/edge_bounds in drawing api
2020-05-21 20:34:48 +02:00
Nathan Adams
62a1914c3e
core: BoundingBox::encompass should properly convert invalid BBs to valid BBs.
...
This means that encompassing 100,100 on an invalid BB should create a BB of 100,100-100,100, and not 0,0-100,100
2020-05-21 20:19:26 +02:00
Nathan Adams
279c07d9b8
core: Update drawings on render instead of on tick
2020-05-21 18:38:10 +02:00
Nathan Adams
55215273e8
core: Stretch edge & shape bounds separately and avoid a clone, in rendering api
2020-05-21 18:38:10 +02:00
Nathan Adams
04690581ba
core: Refactor common code in drawing api
2020-05-21 18:38:10 +02:00
Nathan Adams
1f8abc92fd
core: Keep track of cursor position in drawings
2020-05-21 18:38:10 +02:00
Nathan Adams
99574cfa72
core: Move drawing api out from `movie_clip` into `drawing`
2020-05-21 18:38:10 +02:00
Nathan Adams
4f69566f77
tests: Add test coverage for flash.geom.Matrix
2020-05-21 18:38:08 +02:00
dependabot-preview[bot]
898232394b
build(deps): bump syn from 1.0.22 to 1.0.23
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.22...1.0.23 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-21 03:49:03 +00:00
Nathan Adams
31b0a5ae76
avm1: Implement gradient matrix types
2020-05-20 14:54:41 +02:00
Nathan Adams
5098eb079d
avm1: Implement most of flash.geom.Matrix ( #303 )
2020-05-20 14:54:41 +02:00
Nathan Adams
14331da71b
avm1: Add flash.geom.Matrix and methods to convert between this and swf::Matrix
2020-05-20 14:54:41 +02:00
Nathan Adams
eda862c719
swf: Merged core::Matrix into swf::Matrix
2020-05-20 14:54:41 +02:00
Nathan Adams
61e464099c
core: Add initial drawing API to MovieClip
2020-05-20 14:54:40 +02:00
Nathan Adams
7ab6703fc9
render: Add RenderBackend::replace_shape method
2020-05-20 14:54:40 +02:00
Nathan Adams
4c80ae150c
core: Make DistilledShape use Boundingbox and not Rectangle
...
Rectangle more represents compressed swf data and isn't suited for performing operations, and the drawing api will be generating these dynamically
2020-05-20 14:54:33 +02:00
Nathan Adams
f7b5f14f65
core: Make RenderBack::register_bitmap* methods return a Result ( fixes #531 )
2020-05-19 07:12:36 -07:00
dependabot-preview[bot]
6134ae091f
build(deps): bump generational-arena from 0.2.7 to 0.2.8
...
Bumps [generational-arena](https://github.com/fitzgen/generational-arena ) from 0.2.7 to 0.2.8.
- [Release notes](https://github.com/fitzgen/generational-arena/releases )
- [Changelog](https://github.com/fitzgen/generational-arena/blob/master/CHANGELOG.md )
- [Commits](https://github.com/fitzgen/generational-arena/compare/0.2.7...0.2.8 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 23:54:45 -07:00
dependabot-preview[bot]
41a8b01fe7
build(deps): bump quote from 1.0.5 to 1.0.6
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.5...1.0.6 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 08:38:24 +00:00
dependabot-preview[bot]
3b163c2b6e
build(deps): bump syn from 1.0.21 to 1.0.22
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.21 to 1.0.22.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.21...1.0.22 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-16 09:46:08 +00:00
dependabot-preview[bot]
1f0e695465
build(deps): bump fnv from 1.0.6 to 1.0.7
...
Bumps [fnv](https://github.com/servo/rust-fnv ) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/servo/rust-fnv/releases )
- [Commits](https://github.com/servo/rust-fnv/compare/v1.0.6...v1.0.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-14 19:05:48 +00:00
dependabot-preview[bot]
1641d05d00
build(deps): bump syn from 1.0.20 to 1.0.21
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.20 to 1.0.21.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.20...1.0.21 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 17:18:29 +00:00
dependabot-preview[bot]
e22da9ac4c
build(deps): bump quote from 1.0.4 to 1.0.5
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.4...1.0.5 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 14:42:48 +00:00
Mike Welsh
031f5d6501
core: Avoid undefined behavior in f64_to_wrapping functions
2020-05-13 02:41:50 -07:00
Mike Welsh
b59140ee01
render: Add support for GIF decoding in DefineBitsJPEG tags
2020-05-13 00:15:09 -07:00
Mike Welsh
5d84d33710
render: Handle PNG data in DefineBitsJPEG tags ( fix #530 )
2020-05-13 00:15:09 -07:00
dependabot-preview[bot]
f68edb37b5
build(deps): bump syn from 1.0.19 to 1.0.20
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.19...1.0.20 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-12 00:10:19 -07:00
Nathan Adams
b82b869950
core: Don't panic when NullNavigatorBackend can't do futures
2020-05-11 01:09:07 -07:00
Nathan Adams
2343074c56
core: Make RenderBackend downcastable
2020-05-11 01:09:07 -07:00
Nathan Adams
edcd1e6d65
core: Add keyboard shortcut to dump every variable (ctrl+alt+V, same as Flash Player)
2020-05-10 23:39:54 -07:00
Nathan Adams
c787e28fcd
render: Introduce a DistilledShape and use that instead of swf::Shape for the rendering API
2020-05-10 22:03:56 -07:00
Nathan Adams
5767fb1772
swf: Added utility method for `Color::from_rgb(rgb, alpha)`
2020-05-10 22:03:56 -07:00
Nathan Adams
601715aa19
render: Merge begin_frame and clear as they're always called together
2020-05-10 22:03:56 -07:00
dependabot-preview[bot]
60ca1da468
build(deps): bump syn from 1.0.18 to 1.0.19
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.18...1.0.19 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 03:12:14 +00:00
Nathan Adams
054e6f1ac6
chore: Fix new rust check lint about std::mem::replace
2020-05-10 03:29:25 -07:00
Nathan Adams
bac99368be
chore: Fix new clippy lints about cloning
2020-05-10 03:29:25 -07:00
dependabot-preview[bot]
a81adfa336
build(deps): bump num_enum from 0.4.3 to 0.5.0
...
Bumps [num_enum](https://github.com/illicitonion/num_enum ) from 0.4.3 to 0.5.0.
- [Release notes](https://github.com/illicitonion/num_enum/releases )
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.3...0.5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-10 10:27:38 +00:00
dependabot-preview[bot]
08a786a213
build(deps): bump libflate from 0.1.27 to 1.0.0
...
Bumps [libflate](https://github.com/sile/libflate ) from 0.1.27 to 1.0.0.
- [Release notes](https://github.com/sile/libflate/releases )
- [Commits](https://github.com/sile/libflate/compare/0.1.27...1.0.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-05 08:12:26 +00:00
Nathan Adams
47a44a5fe8
desktop: Prime window with known width/height of the movie
2020-05-04 16:07:38 -07:00
Nathan Adams
51d9f3ef36
core: Change Player::new to take in a SwfMovie, not &[u8]
2020-05-04 16:07:38 -07:00
Nathan Adams
84f6b4d06e
core: Set init_object values after prototype but before constructor
2020-05-03 12:46:55 -07:00
Nathan Adams
96d1f8fd30
tests: Add test for order of init_object vs constructor when attaching movies
2020-05-03 12:46:55 -07:00
Nathan Adams
0152f384ea
core: Run any on(construct) events at the appropriate time
2020-05-03 12:46:55 -07:00
Nathan Adams
2b9219e8f9
tests: Add test for undocumented on(construct) property (note: this swf is hand-crafted)
2020-05-03 12:46:55 -07:00
Mike Welsh
f09bd8c079
core: Clean up tick/render loop
...
Don't call `render` from `Player::tick`; instead, require the
frontends to explicitly call `render` when they wish to redraw.
The frontend can query `Player::needs_render` to see if the stage
is dirty and needs a redraw. Update desktop and web to use this
new method.
This fits better with the newer winit event loop model, which
requires explicitly calling `request_redraw`, and should avoid
spurious renders.
2020-05-02 04:25:21 -07:00
Mike Welsh
6339c74d67
render: Add wgpu backend (merge #527 )
...
Adds a wgpu-rs render backend.
2020-05-02 03:42:05 -07:00
Nathan Adams
8384847084
avm1: Deleting on a non-object is a silent failure & warning, not a hard error
2020-04-30 14:18:54 -07:00
dependabot-preview[bot]
04660a9540
build(deps): bump quote from 1.0.3 to 1.0.4
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.3 to 1.0.4.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.3...1.0.4 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-30 21:18:17 +00:00
Nathan Adams
99d15aef0d
render: Cache color transforms in wgpu backend, don't re-upload unchanged values
2020-04-30 16:33:41 +02:00
dependabot-preview[bot]
014df249a8
build(deps): bump jpeg-decoder from 0.1.18 to 0.1.19
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.18 to 0.1.19.
- [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/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-28 04:54:23 +00:00
Mike Welsh
8aa12d181f
render: Remove RenderBackend::draw_pause_overlay
2020-04-27 04:45:53 -07:00
David Wendt
ed29b1c3bb
It turns out Macromedia just used an undocumented but user-modifiable property called `__constructor__` to store the constructor.
...
A previous version of this PR (whose history has been scrubbed, but go check 918d88abe68b7467a4194738b95e5bf3e9b5bb72 if you're curious) implemented a new `TObject` property which basically every line of code that dealt with object construction had to populate. It was terrible.
2020-04-25 14:37:24 -04:00
David Wendt
bb879870ec
Add test for the constructor property on v6 and v7 SWFs
2020-04-25 13:25:21 -04:00
Nathan Adams
b3322acc8c
tests: Copy as2_super_and_this test for manual prototype setting, used by mx (currently broken)
2020-04-25 13:25:20 -04:00
David Wendt
aaa6f481ac
Add a v6 version of the super-and-this test, which is exactly the same source compiled to SWF version 6.
2020-04-25 13:25:20 -04:00
David Wendt
17d96a0fa6
Constructing a new object sets `constructor` on that object for SWFv6 and lower.
2020-04-25 13:25:20 -04:00
David Wendt
b8fd1eac9c
Invoke virtual setters defined in the prototype chain.
...
This is accomplished via two new `TObject` methods: `has_own_virtual` and `call_setter`. If an object does not contain it's own version of a property, it will first crawl the prototype chain to see if there is an overwritable virtual. If so, it will invoke that prototype's setter.
A bit of borrow finangling was required to do this; `super` now no longer caches it's proto and constr values and instead dynamically constructs them. This also means it can't be downcasted to `Executable` anymore.
With this commit, virtual setters and super-setters now work correctly.
2020-04-25 13:25:19 -04:00
David Wendt
35197f889f
`Property.set` should return a `ReturnValue` as it can potentially execute AVM code
2020-04-25 13:25:19 -04:00
David Wendt
e76ba4de87
Method calls on `super` objects should substitute the child object instead of itself as `this`.
2020-04-25 13:25:19 -04:00
David Wendt
869cbd17da
Extend `as2_super_and_this` to cover accessing object properties in super-methods, super-getters, and super-setters.
2020-04-25 13:25:18 -04:00
David Wendt
9c5cd79e2c
Refactor how `SuperObject` works to use `base_proto` and avoid handing copies of itself as `this`.
...
This allows supercalled functions to properly read and mutate the object they were called on.
2020-04-25 13:25:18 -04:00
David Wendt
f3b3db51cb
Alter AVM1 to keep track of each function call's *base prototype*: the object from which a particular function was retrieved from.
...
A base prototype is only applicable in cases where a method is being called as a property on an object. Bare function calls, `apply`/`call` calls, and so on do not generate a base prototype.
We also add a convenience method, `call_method`, to all objects. This method automatically calculates the correct base prototype for a method call on an object, which is the only operation that should generate base prototypes.
2020-04-25 13:25:18 -04:00
David Wendt
15a19f4cf8
Add test from @Dinnerbone that checks to make sure super-called functions can still initialize the object they are a part of.
2020-04-25 13:25:17 -04:00
dependabot-preview[bot]
c5a8402eae
build(deps): bump syn from 1.0.17 to 1.0.18
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.17 to 1.0.18.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.17...1.0.18 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-25 10:19:18 +00:00
Mike Welsh
fd114959f9
core: Fix regressions from init order changes in #498
...
Revert to the old action queue method of popping off actions in a
loop, as new actions can be queued while iterating. Store proto
changes in a separate queue to maintain the high priority behavior.
2020-04-25 03:06:54 -07:00
Mike Welsh
bad34c4d8f
tests: Fix tests for regressions caused by #498
...
Changes to the action queue caused actions queued during other
actions to run too late. These regressions weren't caught by the
tests because many of the goto tests ran for more frames than was
necessary, allowing the late actions to still run.
2020-04-25 03:06:54 -07:00
Mike Welsh
c1dc69c6b7
chore: rustfmt
2020-04-24 22:16:16 -07:00
dependabot-preview[bot]
24a26541a3
build(deps): bump smallvec from 1.3.0 to 1.4.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.3.0...v1.4.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-24 12:20:39 +00:00
Nathan Adams
b43d0c2430
core: Pass SwfMovies along to empty movie clips
2020-04-21 05:49:25 -07:00
Nathan Adams
a673e7108d
tests: Add test for movieclip.createEmptyMovieClip().attachMovie()`
2020-04-21 05:49:25 -07:00
Nathan Adams
8b34fbdd81
chore: Removed debug code from a test
2020-04-21 05:48:17 -07:00
Nathan Adams
330e6b40f0
core: post_instantiation should happen after properties are set, but before first frame or actions
2020-04-17 23:48:58 -07:00
Nathan Adams
9318290336
core: Execute init actions immediately, do not queue them up
...
Clip initializers can and will influence how the next clips are loaded, and must execute before that
This fixes #418
2020-04-17 23:48:58 -07:00
Nathan Adams
fe6b79a9b7
chore: Make avm1 accessible to MovieClip::preload
2020-04-17 23:48:58 -07:00
Nathan Adams
46d31548b0
chore: Move MovieClipData::do_init_action to MovieClip::do_init_action
...
No functional changes, just replaces `self` with `self.0.read()` and removed `self_display_object` argument
2020-04-17 23:48:58 -07:00
Nathan Adams
c0d1dec7dd
chore: Move MovieClipData::preload to MovieClip::preload
...
No functional changes, just replaced `self` with `self.0.read/write`.
2020-04-17 23:48:58 -07:00
Nathan Adams
601fcbfebd
core: Queue up changes of movieclip prototypes, don't execute it immediately (but at a higher priority than normal actions)
2020-04-17 23:48:58 -07:00
Nathan Adams
6b48e77b61
avm1: Add TObject::set_proto
2020-04-17 23:48:58 -07:00
Nathan Adams
6316d7e0b3
tests: Add (currently failing) test for init order when combined with register_class
2020-04-17 23:48:58 -07:00
Nathan Adams
d0fd26a89c
avm1: Fix panic with [].unshift(x)
2020-04-17 21:17:13 -07:00
Nathan Adams
bf639e1802
avm1: Don't crash when enumerating non-objects, it's a silent fail
2020-04-15 05:26:09 -07:00
Mike Welsh
b7d464f367
chore: Bump enumset to 1.0.0
2020-04-13 04:14:29 -07:00
dependabot-preview[bot]
2146c42863
build(deps): bump smallvec from 1.2.0 to 1.3.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.2.0...v1.3.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-09 21:19:11 +00:00
Mike Welsh
47e936fcc2
tests: Add tests for Array.sort
2020-04-01 18:46:12 -07:00
Mike Welsh
bd0d2031bc
avm1: Implement Array.sort and constants
2020-04-01 18:46:12 -07:00
Mike Welsh
2bdbac9247
tests: Test that Color has no effect when target is undefined
2020-03-30 01:09:05 -07:00
Mike Welsh
e47c2aa356
avm1: Color object has no effect if target is undefined/empty
2020-03-30 01:01:37 -07:00
Mike Welsh
d5bd7c2dd8
avm1: Math.round rounds towards infinity
2020-03-29 18:44:28 -07:00
Mike Welsh
0c0d3dfd41
core: Add Navigator::time_since_launch to use for getTimer
...
Change `ActionGetTime` (`getTimer`) to use a new backend method.
This allows it to return updated times if it is called multiple
times in a single frame. This fixes hangs caused by games that use
busy-loop "frame limiter" code.
2020-03-28 22:28:07 -07:00
Mike Welsh
f7375c3700
avm1: Use `PropertyMap::get_index` for stage object properties
2020-03-28 16:22:02 -07:00
Mike Welsh
4ea609cca1
tests: Don't special case enumeration tests
2020-03-28 16:22:02 -07:00
Mike Welsh
8da9487c0a
avm1: Match Flash's property enumeration order ( fix #153 )
2020-03-28 16:22:02 -07:00
Mike Welsh
2cdf780e6f
avm1: Handle case sensitivity in DisplayObject children
...
Alter `get_child_by_name` and alter `get_level_by_path` to respect
case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh
81a0bb370b
tests: Add test for SWF<=6 case insensitivty
2020-03-28 16:22:02 -07:00
Mike Welsh
ea245895b0
avm1: Use PropertyMap for stage object magic properties
2020-03-28 16:22:02 -07:00
Mike Welsh
7d848f4f34
avm1: Add avm parameter to TObject methods
...
This is necessary to get the current SWF version for properly
handing case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh
1ef698f2ea
core: Add PropertyMap for handling AVM1 object properties
...
`PropertyMap` wraps over `IndexMap` to handle object properties in
AVM1. All insert/remove/get methods require and `swf_version`
parameter, and the `PropertyMap` will take care of handling case
senstivity and maintaing iteration order based on the SWF version.
2020-03-28 16:22:02 -07:00
Mike Welsh
d42a402522
avm1: Add display object methods to TextField
2020-03-26 14:19:18 -07:00
Mike Welsh
7865ec1021
avm1: Implement Button object
...
First implementation of Button object. Hook up to the button
display object and run onRelease etc. methods as appropriate.
Pull out common display object methods into globals::display_object.
2020-03-26 00:21:21 -07:00
Mike Welsh
4df1128c19
core: Implement Object.registerClass (merge #344 )
...
Implement Object.registerClass
2020-03-25 18:55:49 -07:00
dependabot-preview[bot]
ef5ee3a889
build(deps): bump syn from 1.0.16 to 1.0.17
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.16 to 1.0.17.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.16...1.0.17 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-21 01:37:48 +00:00
Mike Welsh
e9cb05aeb4
avm1: Correct order of modulo operands
...
Addresses part of #458 .
2020-03-20 16:00:28 -07:00
hthh
a16885d84b
avm1: Fix string-to-number octal and whitespace handling
...
This conversion allows negative octal values, but not negative
hex values, and ignores only leading ASCII whitespace. A test
for this behavior is included.
2020-03-20 04:27:41 -07:00
Nathan Adams
b4624fddce
avm1: GetVariable and SetVariable look through the scope chain. Fixes #414
...
GetVariable and SetVariable attempt to resolve paths on each scope
in the scope chain.
2020-03-19 19:58:16 -07:00
Mike Welsh
454cd29ed6
chore: EditText::font takes self by value
2020-03-17 19:42:57 -07:00
Mike Welsh
068f4c3bee
core: Edit text uses device fonts when outline flag isn't set
...
Specifically fall back to the device font when the UseOutlines
flag is not set in DefineEditText (SWF19 p.172). Fixes #451 .
Note that since we only use a single font for "device" rendering,
this may sometimes be a different font than is specified in the
Flash IDE.
2020-03-17 19:13:20 -07:00
dependabot-preview[bot]
da3398c832
build(deps): bump bitstream-io from 0.8.4 to 0.8.5
...
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io ) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/tuffy/bitstream-io/releases )
- [Commits](https://github.com/tuffy/bitstream-io/commits/v0.8.5 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:08:59 +00:00
dependabot-preview[bot]
2bfa2502a9
build(deps): bump num_enum from 0.4.2 to 0.4.3
...
Bumps [num_enum](https://github.com/illicitonion/num_enum ) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/illicitonion/num_enum/releases )
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.2...0.4.3 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:07:35 +00:00
Mike Welsh
c2ce9892b1
core: Clamp RGBA when un-multiplying alpha
...
Fixes some bad pixels sometimes appearing in decoded JPEGs (such
as in #437 and in Dad 'n' Me).
2020-03-16 16:11:59 -07:00
dependabot-preview[bot]
0f7f36681d
build(deps): bump quick-xml from 0.17.2 to 0.18.1
...
Bumps [quick-xml](https://github.com/tafia/quick-xml ) from 0.17.2 to 0.18.1.
- [Release notes](https://github.com/tafia/quick-xml/releases )
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md )
- [Commits](https://github.com/tafia/quick-xml/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 05:34:45 +00:00
Mike Welsh
24a557807d
chore: Fix more clippy lints
2020-03-12 21:40:48 -07:00
Mike Welsh
13b039fa34
chore: Fix clippy iter-nth-zero warnings
...
New lint added in latest clippy versions.
2020-03-12 21:16:30 -07:00
Mike Welsh
098bf33068
chore: Bump quote to 1.0.3
2020-03-08 18:58:39 -07:00
dependabot-preview[bot]
a0ee19fd37
build(deps): bump syn from 1.0.14 to 1.0.16
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.14 to 1.0.16.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.14...1.0.16 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 20:26:50 +00:00
dependabot-preview[bot]
ba185d3d43
build(deps): bump minimp3 from 0.3.3 to 0.3.5
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.3.3 to 0.3.5.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 19:07:25 +00:00
dependabot-preview[bot]
3f28554285
build(deps): bump enumset from 0.4.4 to 0.4.5
...
Bumps [enumset](https://github.com/Lymia/enumset ) from 0.4.4 to 0.4.5.
- [Release notes](https://github.com/Lymia/enumset/releases )
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md )
- [Commits](https://github.com/Lymia/enumset/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 18:14:25 +00:00
Nathan Adams
751b15beec
chore: Raise errors during Object.registerClass
2020-02-29 23:13:02 +01:00
Nathan Adams
7bed4d4940
chore: Document each trace in attach_movie avm1 tests
2020-02-29 23:05:17 +01:00
Nathan Adams
041bb6b44c
avm1: Implement `Object.registerClass`
2020-02-29 23:05:17 +01:00
Nathan Adams
d850443c84
avm1: Refactor to expose `avm, context` in `post_instantiate`
2020-02-29 23:05:15 +01:00
David Wendt
fdce33ff5e
Return an `Err` when decompression fails, rather than just logging it and returning an empty vec.
2020-02-26 18:18:24 -05:00
David Wendt
ded7737ac0
`SwfMovie::from_data` is falliable and we should not hide those errors behind panics.
2020-02-26 18:15:01 -05:00
David Wendt
0313225164
Don't allow movie loads to be removed from the load manager unless they have completed or errored.
2020-02-26 18:03:45 -05:00
David Wendt
a023e161fc
Don't panic if our target handle was removed from the load manager. Instead, return an `Err` so that it can be properly reported on the console without killing the player.
2020-02-26 17:38:31 -05:00
Mike Welsh
223edb9bc1
core: Matrix translation is in twips
2020-02-26 12:47:47 -08:00
Mike Welsh
c4c02260fb
core: Implement keyUp event
2020-02-26 03:48:07 -08:00
Mike Welsh
db9bd1616e
chore: Remove unused deref impl from AudioBackend
2020-02-26 02:00:28 -08:00
Mike Welsh
86ec2c6cb8
input: Add InputBackend::set_mouse_cursor. Change cursor on buttons
...
It doesn't feel like Flash without having the hand cursor display
when hovering over buttons. First pass at implementing this;
core communicates which mouse cursor to use via
`InputBackend::set_mouse_cursor`.
TODO: Hand cursor only displayed for Button display objects
currently. Movie clips should also display this when they are in
"button mode" (when a button mouse event is set on them in AVM1,
or `buttonMode` property in AVM2).
2020-02-25 02:50:26 -08:00
Mike Welsh
a917fa4028
tests: Add temporary test for MovieClip.getRect
...
This is just testing that it exists and returns the same values as
getBounds for shapes without strokes.
TODO: When it is properly implemented for strokes, add stroked
shapes to testing.
2020-02-24 14:12:48 -08:00
Mike Welsh
d8079ac04a
core: Stub out MovieClip.getRect
...
Just defer to getBounds for now. TODO: getRect should return bounds
ignoring strokes, so in reality it is <= getBounds.
2020-02-24 14:12:48 -08:00
Mike Welsh
993c05cf19
core: Calculate bounds for each morphshape frame
2020-02-24 14:12:48 -08:00
Mike Welsh
a5c08f2e59
avm1: Implement MovieClip.getBounds and clean up bounding box methods
...
Implements MovieClip.getBounds, and also reorganized the
DisplayObject AABB methods:
* `self_bounds` calculates the inherent untransfomed bounds of
the object without children. All `DisplayObject`s must implement
this method. For example, `Bitmap` returns the size of bitmap.
Composite objects like `MovieClip` return a null AABB because they
are made up of only children.
* `bounds` calculates the untransformed bounds including children.
* `local_bounds` calculates the bounds relative to the object's
parent.
* `world_bounds` calculates the bounds in global stage space.
* `bounds_with_transform` calculates a tight AABB for the object
with a given transform, and is used to implement the above.
2020-02-24 14:12:48 -08:00
Mike Welsh
73a9a0e771
tests: Add test for MovieClip.getBounds
2020-02-24 14:12:48 -08:00
Mike Welsh
8c486b7544
chore: Use free functions for movie_clip methods
...
Try to keep style more consistent by using functions for all MC
methods. Previous was a mix of closures and functions (we're still
a little bad with this elsewhere)
2020-02-24 11:17:40 -08:00
Mike Welsh
f163afc5b4
core: Use collect to copy level pointers
2020-02-24 02:28:27 -08:00
Mike Welsh
1b08fb538d
chore: Rename layer -> level
...
Unify mix of 'layer' and 'level' in the code, and it's probably
better to stick with Flash nomenclature.
2020-02-23 23:41:55 -08:00
David Wendt
05e5fbb69c
For some reason, this color transform code broke on the moviefetch branch
2020-02-22 00:02:52 -05:00
David Wendt
abc1d00276
Fix incorrect preload of `_root` in `DefineFunction2` function calls.
...
This is caused by the fact that `avm.root_object` references the *current* stack frame, not the one we are about to introduce. Ergo, we need to pull the base clip of the *new* stack frame and find it's root.
This particular behavior only crops up in situations where there can be multiple root objects, at least until we implement `_lockroot`.
2020-02-22 00:02:51 -05:00
David Wendt
766ded6dfd
When replacing a movie clip with another movie, don't wipe out the entire display object base as that disassociates us from our parent, siblings, and most importantly, *layer depth*.
2020-02-22 00:02:51 -05:00
David Wendt
e0b4a0f193
Top-level layers are referenced via their path (`_leveln`) rather than name - in fact, their name is always the empty string.
2020-02-22 00:02:51 -05:00
David Wendt
00f88f9e87
Use the depth to indicate which layer a particular root clip is, and then use that to calculate it's `_leveln` path.
2020-02-22 00:02:50 -05:00
David Wendt
8ef759d377
Top-level layers do not get an instance name of `_leveln`.
2020-02-22 00:02:50 -05:00
David Wendt
9adf0f43d7
Allow levels to be read as scope variables, and add a test for this.
2020-02-22 00:02:50 -05:00
David Wendt
5a7e530c91
Add a test for cross-movie `_root`.
...
This test does not pass yet. Other layers need to resolve as target paths in order for this to happen.
2020-02-22 00:02:48 -05:00
David Wendt
aa6aba13dd
Abolish `context.root` completely.
...
`_root` is calculated dynamically based on the clip the currently executing function was called in.
Other things that used `context.root` have been changed to either update all layers or just update layer 0, which is the former `context.root`.
2020-02-22 00:02:46 -05:00
David Wendt
33d26b9149
Shorten `Pin<Box<dyn Future<Output=Result<T,E>> + 'static>>` into `OwnedFuture<T,E>`.
...
This is technically stricter on `fetch` impls, but right now we can't support non-`'static` futures at all.
2020-02-22 00:02:45 -05:00
David Wendt
aab339880d
Implement `XML.load()`, with tests.
...
Interestingly enough, very little actually has to be done inside the async process for XML. The async process basically just fetches data and fires an event handler when it's done. Everything else is handled via a system builtin, `XML.onData`.
2020-02-22 00:02:45 -05:00
David Wendt
538a5f05e5
Add tests for various forms of `loadVariables`.
...
Surprisingly enough these tests passed without any changes, somehow.
2020-02-22 00:02:43 -05:00
David Wendt
c00ecccd1f
Basic, stub implementation of `MovieClipLoader.getProgress`, plus test.
...
This implementation just returns the size of the current loaded movie. The test is also deliberately written to be loose on timings so that it likely won't see a partially loaded movie. (I don't want it to be a test of load events, so I just wait a few frames, rather than the correct way of waiting for `onLoadComplete`.)
Until we support streaming file loads, we can't faithfully support these properties. Still, it's better to have them, just in case.
2020-02-22 00:02:42 -05:00
David Wendt
3f7e3a9ed8
Implement `MovieClipLoader.unloadClip`, with tests.
2020-02-22 00:02:41 -05:00
David Wendt
a132226da4
Run `onLoadInit` at the *end* of a frame, rather than before the movie clip's own actions.
...
This is technically better, but it may make more sense to trigger `ClipEvent::Load` at the start of the next frame instead. Furthermore, I don't know if other forms of load events should trigger on the next frame (or end of the current one) like this.
2020-02-22 00:02:39 -05:00
David Wendt
55734619f7
`GetUrl2` can accept a `DisplayObject` as target in `LoadTargetFlag` mode.
...
I have no idea what happens to non-MovieClip objects, or if I'm really supposed to `coerce_to_string` here.
2020-02-22 00:02:36 -05:00
David Wendt
d49c0e9bf7
Rewrite some of the unload and cliploader tests to be more generous with load timing.
...
Loads in Flash Player, like all web technologies, are asynchronous tasks of some kind (probably a separate thread). They appear to operate on some kind of a delay. If I `trace` each frame out, like in the previous version of `mcl_loadclip`, you get a series of events that look like this:
1. Parent frame 1
2. Parent frame 2
3. Event: onLoadStart
4. Event: onLoadProgress
5. Event: onLoadComplete
6. Parent frame 3
7. Event: onLoadInit
If I run that version of the test on Ruffle, everything happens after frame 1. This is an artifact of how we're testing asynchronous behavior in Ruffle. In order to guarantee test determinism, we have a dummy implementation of `fetch` that does a blocking load, and we poll all futures every frame of execution. This means that there is a very specific order of execution with these tests, which is good for testing, but probably isn't 100% accurate.
Flash Player appears to delay all loads by at least one frame, even loads that are coming from disk which should load immediately. I don't know if this is intentional or not, so I don't want to implement a load delay just for the sake of making tests pass. Ergo, I'm loosening the tests to just test the ability to load and unload movies, and fire events from a loader.
Specifically:
1. `mcl_loadclip` no longer traces out frames of the parent timeline
2. `unloadmovie` et. all use a target movie that doesn't fail the test until 10 frames have passed.
If someone can find a movie network that breaks with fast loading, then I'll consider implementing explicit frame delays for async tasks. Otherwise, this is how we're testing this.
2020-02-22 00:01:22 -05:00
David Wendt
8ece2d1b31
Add another ignored test, this time measuring the timing of load events broadcasted by `MovieClipLoader`. We're loading too early, which is why this is ignored.
2020-02-22 00:01:20 -05:00
David Wendt
b56c3b6aed
Fire events directly onto `broadcastMessage` instead of the individual event handlers on the `MovieClipLoader`, so that listeners run correctly.
...
Also, this fixes a double-borrow for `onClipInit`.
2020-02-22 00:01:19 -05:00
David Wendt
89e5dd97f3
Implement `MovieClipLoader.loadClip`
2020-02-22 00:01:19 -05:00
David Wendt
162b6b70f8
Allow unloading a movie by sending `None` to `replace_with_movie`.
...
This also adjusts `MovieClip.unloadMovie` to do just that, instead of removing the clip from the display list. We also have to unload clips when loading new movies into them, since `unloadMovie` desugars to loading `""` as the URL.
2020-02-22 00:01:19 -05:00
David Wendt
8ef4a94672
Add new tests for `unloadMovie`, `unloadMovieNum`, and `MovieClip.unloadMovie`.
...
They currently fail in Ruffle, so they're ignored.
2020-02-22 00:01:18 -05:00
David Wendt
cc5dff4254
Add a test for `MovieClip.loadMovie`.
2020-02-22 00:01:17 -05:00
David Wendt
82d305a0f5
Add test for `loadmovienum`
2020-02-22 00:01:16 -05:00
David Wendt
a9621da47d
Add tests for `loadMovie`.
...
This test also includes changes to the SWF testing environment to allow asynchronous movie loads to execute.
2020-02-22 00:01:15 -05:00
David Wendt
a8545ee277
Implement `onLoadInit` by pulling `LoadManager` into all clip load events.
2020-02-22 00:01:14 -05:00
David Wendt
7ff885a0de
Implement `MovieClipLoader` event broadcasts for `onLoadStart`, `onLoadProgress`, `onLoadComplete`, and `onLoadError`.
...
Note that we do not implement `onLoadInit` yet - this requires some ability to trigger an event when another movie clip loads.
2020-02-22 00:01:14 -05:00
David Wendt
db41bec91e
Implement `MovieClipLoader`'s `addListener`, `removeListener`, and `broadcastMessage` methods.
...
Interestingly, this constitutes an implementation of `AsBroadcaster`. It appears Macromedia decided to implement event handling on `MovieClipLoader` in a very similar fashion to `AsBroadcaster`, down to invoking `broadcastMessage` and searching a `_listeners` property for listeners.
2020-02-22 00:01:12 -05:00
David Wendt
b7d318a897
Implement `MovieClip.loadMovie`, `MovieClip.loadVariables`, and `MovieClip.unloadMovie`.
...
*De*implement the free function versions of the above, as well as their `Num` variants, since they don't actually exist as callables. Instead, the ActionScript compiler treats them as preprocessor functions that represent various forms of `ActionGetURL`/`ActionGetURL2`.
2020-02-21 23:59:13 -05:00
David Wendt
31b1364b82
Implement `unloadMovie` / `unloadMovieNum`
2020-02-21 23:58:00 -05:00
David Wendt
b2b2a165fc
Implement `loadVariables` and `loadVariablesNum`.
2020-02-21 23:58:00 -05:00
David Wendt
c7539872f7
Add the ability to POST data from `fetch`, and allow methods that read AVM locals into form data to `GET` or `POST` them.
2020-02-21 23:58:00 -05:00
David Wendt
3fe6884c90
Refactor layer resolution into a separate function.
...
This function is part of `Avm1`, rather than a hypothetical `LayerManager`, because we're going to need to eventually construct layers differently for AVM2.
2020-02-21 23:57:59 -05:00
David Wendt
ea28c2c4a2
Impl `loadMovie` / `loadMovieNum` (sans local variable support)
2020-02-21 23:57:59 -05:00
David Wendt
07637fe676
Replaced movies should start out playing. This fixes a regression from a previous rebase.
2020-02-21 23:57:58 -05:00
David Wendt
64b787b73f
Implement `Collect` for `Loader`. (How did this compile without that?)
2020-02-21 23:57:58 -05:00
David Wendt
d84e11ed40
Introduce a new top-level object, `LoadManager`, which is responsible for all asynchronous behavior in the program. Migrate the existing async impls to it.
2020-02-21 23:57:58 -05:00
David Wendt
2d7a4fef28
`Sound` methods that reference sounds by library export name should default to `_layer0`'s library if the `Sound` was created without a movie clip target.
2020-02-21 23:57:57 -05:00
David Wendt
6b78ec6e03
More thoroughly clean `MovieClip`s that have movies loaded into them. This does everything except wipe the object it's attached to - I need further testing to see how Flash handles that.
2020-02-21 23:57:57 -05:00
David Wendt
2a82d21966
Change the layer list from a static array to a `BTreeMap`.
...
Flash allows creating layers at any 31-bit height without issue, so this should support similar limitations.
2020-02-21 23:57:57 -05:00
David Wendt
f4e4171ebe
Make spawned futures falliable, and report those errors.
2020-02-21 23:57:56 -05:00
David Wendt
5ce499d11e
Add separate libraries for each loaded movie.
2020-02-21 23:57:56 -05:00
David Wendt
e0c0779bd0
Make sure to preload all loaded clips.
2020-02-21 23:57:55 -05:00
David Wendt
6da374c567
Implement loading movies into `_leveln` via `ActionGetUrl`
2020-02-21 23:57:55 -05:00
David Wendt
ed799fd2b9
Split the player up into nine layers, each of which is a separate root movie clip.
2020-02-21 23:57:55 -05:00
David Wendt
8c9d290db7
Implement the MovieClip loading portion of `ActionGetURL2`.
2020-02-21 23:57:54 -05:00
David Wendt
5ed5876e9a
Merge SWF data and version into a single structure. Refactor everything that interacts with it to use `SwfSlice`s.
2020-02-21 23:57:53 -05:00
David Wendt
250ec13c12
Implement LoadVariablesFlag.
...
This has some subtle problems: we cannot hold references to garbage-collected data in Futures, so we have to arrange for the AVM itself to forcibly root them for us. Then we get them back when our async code is ready to do something to the AVM.
2020-02-21 23:44:06 -05:00
David Wendt
55149b7b7e
Reference count the Player and provide a weak reference in UpdateContext.
...
This allows the formation of `'static` futures that can still interact with a player. Async code will need to upgrade the weak reference in order to be able to interact with the player.
2020-02-21 23:44:06 -05:00
David Wendt
491d94c947
Pinbox all Futures.
...
Due to some strangeness with the way Rust implemented unsafe-to-move behavior, boxed futures are implicitly `Unpin`. Which is useless to us.
The reason for this is a little counter-intuitive. Actually, the fact that Rust supports memory pinning at all is a little odd, because the core language explicitly requires all types be movable. To get around this, Pin requires that all !Unpin types be *born pinned*. This is because you can't re-pin an already unpinned value in memory.
Anyway, this necessitates this silly API change.
2020-02-21 23:44:05 -05:00
David Wendt
00d25a768c
Extremely basic impl of fetch/spawn methods for getting data off the web
2020-02-21 23:44:05 -05:00
David Wendt
2137b9f1fd
Migrate `set_frame_rate` into the core `AudioBackend` trait
2020-02-21 23:44:05 -05:00
David Wendt
c1cf73ccb3
Add a public method to trigger a player update.
...
User-defined player updates are treated the same as if a stage frame had been run: queued actions are executed and garbage is collected.
2020-02-21 23:44:04 -05:00
Mike Welsh
f80c188048
core: Stop stream sounds when a clip is removed
2020-02-21 19:24:45 -08:00
Mike Welsh
6b503ac053
avm1: Fix DefineFunction2 preload order when _parent is undefined
...
The order is misdocumented in SWF19 (and also miscompiled assuming
this incorrect order by the Flash IDE!).
`_global` gets preloaded before `_parent`.
2020-02-20 12:58:26 -08:00
Mike Welsh
dc1f99e2ba
tests: Add test for misdocumented DefineFunction2 register preload
2020-02-20 12:58:26 -08:00
Mike Welsh
10fb6c7c04
tests: Add define_function2_preload test
2020-02-19 23:22:33 -08:00
Mike Welsh
19d0bf64a9
avm1: Preload _parent directly from base clip
...
When `_parent` is preloaded in a `DefineFunction2` action,
we previously resolve it on the scope chain. This could cause
double borrow panics as the parent object could already be
borrowed, and also this matches the behavior of the official Flash
player.
Addresses #398 .
2020-02-19 23:22:33 -08:00
Mike Welsh
8d7e58011e
avm1: undefined coerces to "" in SWFv6 and below
...
Except in the AVM1 trace op, which will print out "undefined".
2020-02-19 10:47:43 -08:00
Mike Welsh
dfde98da7d
tests: Add tests for coercing undefined to string in SWF6
2020-02-19 10:47:43 -08:00
Mike Welsh
452ac84f0e
tests: Uncomment Number.POSITIVE_INFINITY/Number.NEGATIVE_INFINITY tests
2020-02-18 10:17:55 -08:00
Mike Welsh
c073afb077
avm1: Use proper value for Number.MIN_VALUE
...
This is the smallest positive number, not the most negative value.
This is actually the smallest positive subnormal f64, which Rust
does not provide a constant for. This is ~5e-324.
2020-02-18 10:17:55 -08:00
Mike Welsh
6bbe1dbab8
avm1: Match Flash when converting exotic numbers to string ( fix #361 )
...
Match Flash's more closely when converting number to string:
* NAN -> NaN
* inf -> Infinity
* -inf -> -Infinity
* Use exponential notation for very large/very small
This is a little bit of a cheat by using Rust's number-to-string
formatting for exponentials, and shoving a sign in front of the
exponent.
2020-02-18 10:17:55 -08:00
Mike Welsh
324dd1c5e4
tests: Add swf_tests_approx macro
...
Use this macro to test numeric calculations that might have some
variance using approx_eq.
2020-02-17 15:42:29 -08:00
Mike Welsh
b6249cdb73
tests: Add localToGlobal/globalToLocal test
2020-02-17 15:42:29 -08:00
Mike Welsh
2af21d87e0
avm1: Implement MovieClip.localToGlobal/globalToLocal
2020-02-17 15:42:29 -08:00
Mike Welsh
cd94486f7e
desktop: Fix stream audio from prematurely ending ( fix #222 )
2020-02-14 20:32:25 -08:00
Mike Welsh
7c406732c7
audio: Ensure stream sounds stop upon goto/loop ( fix #370 )
2020-02-14 20:32:25 -08:00
Mike Welsh
9ad069e11a
avm1: Improve display object property setters for weird values
...
Setting a property such as _x to undefined or null should have no
effect. This was working for v7+ SWFs because it would coerce to
NaN and we toss out NaNs. But on v6 and below, these coerce to 0
and would end up setting the property to 0.
Explicitly check for undefined/null and bail out. Fixes #380 .
Also adjust the _visible setter, since this actually coerces to a
number (because of its legacy from SWFv4). For example,
_visible = "" should have no effect.
2020-02-14 15:34:14 -08:00
Mike Welsh
3a1a73ae11
tests: Add more tests for display object properties
...
Add more _x = weirdo value tests, and copy the test into a v6 SWF.
(because undefined etc. can coerce to 0 instead of NaN in SWFv6).
2020-02-14 15:34:14 -08:00
Mike Welsh
7d14b98f3b
avm1: Ignore undefined values in Color.setTransform
...
If a property is not set on the object passed to Color.setTransform,
then that channel is left unmodified. This fixes invisible objects
in some games (fixes #369 , addresses #380 ).
Also improve handling of wrapping/invalid values to better match the
behavior in the Flash Player (some work pending on #193 ).
2020-02-13 18:06:27 -08:00
Mike Welsh
21f117e7bc
avm1: Add Value::coerce_to_i16
2020-02-13 18:06:27 -08:00
Mike Welsh
19df074a79
tests: Add more tests for AVM1 Color object
...
Include not defined values, wrapping values, invalid values.
2020-02-13 18:06:27 -08:00
David Wendt
18516c8eac
Pre-strip HTML from HTML tags, rather than skipping them.
2020-02-03 19:32:05 -05:00
David Wendt
7d225f8b55
Fix overflow when shifting `u8`s
2020-02-03 14:46:36 -05:00
David Wendt
3d6b00c1e4
Impl the remaining text layout properties
2020-02-03 14:46:36 -05:00
David Wendt
517e7ce9ff
Add word-wrap for `measure_text` and caching for word-wrap calculations
2020-02-03 14:46:36 -05:00
David Wendt
5e808c8cd6
Adjust the wordwrap machinery to work in break points (indicies where new lines start) so we can cache them later
2020-02-03 14:46:35 -05:00
David Wendt
fb8664c818
Implement wordWrap and multiline rendering, poorly
2020-02-03 14:46:35 -05:00
David Wendt
7df8eb7674
Impl `is_multiline`'s effect of respecting newlines
2020-02-03 14:46:35 -05:00
David Wendt
f95ec777de
Also impl storage of the `wordWrap` flag
2020-02-03 14:46:34 -05:00
David Wendt
819757e2b6
Fix text measurement now that the underlying SWF tags are correctly parsed as `Twips`.
...
Transform coordinates are always in twips, so we have to convert pixels to twips when evaluating the font, and then convert back when measuring.
2020-02-03 14:46:34 -05:00
David Wendt
63b7d172f4
`TextRecord.height` is also in `Twips`.
...
Notably, the `Text` rendering code does not appear to actually work in pixel scale.
2020-02-03 14:46:34 -05:00
David Wendt
fde7715fb8
`EditText.height` is in `Twips`
2020-02-03 14:46:33 -05:00
David Wendt
75022f36d2
Pull `TextFormat` into the `font` module.
...
Also, since there's a separate function for attaching virtual properties to an AVM1 `TextField` object, let's use that!
2020-02-03 14:46:33 -05:00
David Wendt
4b3660bf2c
Impl get/set for `is_multiline`.
2020-02-03 14:46:32 -05:00
David Wendt
c1ff1d94d5
Pull the `EditText.evaluateFont` method into `Font`.
...
`Text` itself doesn't use this method, but it probably could with some changes.
2020-02-03 14:46:32 -05:00
David Wendt
81b7958090
Impl `textWidth` / `textHeight`, although it currently only works well for single-line scenarios.
2020-02-03 14:46:32 -05:00
David Wendt
2181f0d0d0
Impl `getNewTextFormat`/`setNewTextFormat`.
...
These don't actually do anything yet, because we don't track text spans, nor do we actually use those text spans to alter rendering or text layout.
2020-02-03 14:46:30 -05:00
David Wendt
db56217f20
`TextFormat` does *not* coerce `undefined` or `null`; instead those both become `null`.
2020-02-03 14:46:30 -05:00
David Wendt
8449d964ef
Implement `TextFormat` as a property bag.
2020-02-03 14:46:29 -05:00
David Wendt
2b0600ab1a
Impl `createTextField`.
2020-02-03 14:46:29 -05:00
Mike Welsh
2ff76775e0
core: Empty movie clips can not be used as a mask
...
When a movie clip or button is used as a mask, the masking will be
disabled if that object has no children; the maskee will be
completely visible. An empty movie clip inside an empty movie clip
successfully masks.
An EditText can also not be used as a masker (although it can be
wrapped inside a movie clip, and then the text successfully masks).
Add a `TDisplayObject::allow_mask` trait method that will
return whether the object can be used as a mask.
This fixes characters not being visible in Dad 'n' Me.
2020-02-01 01:15:31 -08:00
Mike Welsh
2e304a81ef
core: Flag as transformed-by-script after swapDepths
2020-01-31 19:44:42 -08:00
Mike Welsh
a55a378a73
avm1: Improve comments in MovieClip depth methods
2020-01-31 19:44:42 -08:00
Mike Welsh
4d1f7c4d4a
tests: Add movieclip depth method tests
2020-01-31 19:44:42 -08:00
Mike Welsh
a4e175a790
avm1: Implement MovieClip.getNextHighestDepth
2020-01-31 19:44:42 -08:00
Mike Welsh
4d12cd1566
avm1: Implement MovieClip.getDepth
2020-01-31 19:44:42 -08:00
Mike Welsh
9e337ede34
avm1: Implement MovieClip.swapDepths
2020-01-31 19:44:42 -08:00
dependabot-preview[bot]
2f98fd1a0e
build(deps-dev): bump webpack-dev-server in /web/selfhosted
...
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server ) from 3.10.1 to 3.10.2.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases )
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md )
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v3.10.1...v3.10.2 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-31 19:44:42 -08:00
Mike Welsh
0d91fb423e
core: Goto only runs if frame is an integer
2020-01-30 15:17:01 -08:00
Mike Welsh
c079cb3bca
core: Don't run frame actions when seeking past end of timeline
...
If you goto past the final loaded frame of a timeline, for example,
with gotoAndStop(9999), this seeks to the final frame on the
timeline, but it doesn't run the actions on this frame.
MovieClip::goto_frame now will not run the final frame actions if
the target frame was not reached.
2020-01-30 15:17:01 -08:00
Mike Welsh
8aae07bbf3
core: Frame labels are case insensitive
2020-01-30 15:17:01 -08:00
Mike Welsh
a835573f3c
tests: Add test for global GotoFrame action
2020-01-30 15:17:01 -08:00
Mike Welsh
62467bb880
avm1: Handle invalid parameters in GotoFrame2
...
Use the same code path for the global GotoFrame2 action and
MovieClip.gotoAndX, which properly handles out-of-range and invalid
values like NaN.
Fixes Disorderly hanging on game start
(https://www.newgrounds.com/portal/view/121896 )
2020-01-30 15:17:01 -08:00
David Wendt
a57d0e12b3
Do not apply a color filter at all unless rendering a bitmap or gradient.
...
This significantly improves render times, as browsers appear to apply filters in the most general, inefficient way possible.
2020-01-29 14:19:18 -05:00
dependabot-preview[bot]
dc8858505d
build(deps): bump smallvec from 1.1.0 to 1.2.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.1.0...v1.2.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-29 18:42:28 +00:00
Mike Welsh
003cc414aa
core: Create clips in execution order during a goto
...
The list of goto commands is now a Vec that will already be in order
of creation. This ensures that subsequent ActionScript in these clips
runs in the correct order.
2020-01-28 04:15:08 -08:00
Mike Welsh
81a1c05682
tests: Add goto_execution_order2 regression test
...
Tests execution order of children added during a goto.
2020-01-28 04:15:08 -08:00
Mike Welsh
7532e89aff
avm1: Use `resolve_target_display_object` in `Color`
...
Fixes the boss damage blinking in Alien Hominid. Target was a path
string.
2020-01-27 23:35:41 -08:00
Mike Welsh
69f19f03c4
avm1: Output trace warning for invalid SetTarget ( fix #332 )
2020-01-27 23:35:41 -08:00
Mike Welsh
a0032b9aa1
avm1: Better handling of movie clip paths strings ( fix #317 )
...
Ops and functions that take a movie clip path in String form have
a very forgiving syntax. These include:
* `SetTarget`
* `CloneSprite`
* `RemoveSprite`
* `swapDepths`
This change adds `Avm1::resolve_target_display_object` to parse
these paths correctly, along with `target_paths` test to test a
wide variety of formats.
This also applies to `GetVariable`/`SetVariable`, which accept
target paths to variables and is used by some SWF4/5 content.
(fixes #324 , #337 ).
2020-01-27 23:35:41 -08:00
Mike Welsh
2751b89d4e
avm1: Root clip should not have a name
...
Previously we set the name of the root clip to `_level0`. Top-level
clips should actually have no name (`_root._name` returns `""`).
However, when constructing a dot path, `_level0` still gets inserted
by `DisplayObject::path` for the top-level, so that `trace(_root)`
still correctly prints `_level0`.
TODO: When `loadMovieNum` gets merged in, the proper level # needs
to be returned by `.DisplayObject::path`.
2020-01-27 23:35:41 -08:00
Mike Welsh
0446644742
tests: Add target_path test
2020-01-27 23:35:41 -08:00
David Wendt
db51ec9e3c
Implement a separate `Object` impl for functions that holds an `Executable`.
2020-01-27 21:57:32 -05:00
David Wendt
8eeb9a5c60
This technically isn't a test of `toString`, so remove stuff from the test that it relies upon.
2020-01-27 21:50:11 -05:00
David Wendt
d217f51c6c
Don't crash if `Function.prototype.call` is called without arguments.
2020-01-27 21:50:10 -05:00
David Wendt
0470b8d0a7
Add a test for `Function.call` and `Function.apply`
2020-01-27 21:50:10 -05:00
David Wendt
2c0d892154
Implement Function.call/apply
2020-01-27 21:50:09 -05:00
Mike Welsh
4b7bac706b
avm1: ActionNewMethod supports auto-boxing values
...
This allows `new ("FOO".bar)()`, although there is probably no
good reason to do this. :-)
2020-01-21 18:24:49 -08:00
Mike Welsh
70bec9437f
tests: Boolean() returns undefined
2020-01-21 18:24:49 -08:00
Mike Welsh
d9e7a6a960
avm1: Implement Boolean class
2020-01-21 18:24:49 -08:00
Mike Welsh
e71099edd5
tests: Add primitive_type_globals test
2020-01-21 18:24:49 -08:00
Mike Welsh
8263d13fd0
avm1: Implement Number class
2020-01-21 18:24:49 -08:00
Mike Welsh
b49357e46f
avm1: Boxing a value calls the object constructor
2020-01-21 18:24:49 -08:00
Mike Welsh
ccf62979a1
avm1: Implement String methods
2020-01-21 18:24:49 -08:00
Mike Welsh
5f12ce78b6
tests: Add string method tests
2020-01-21 18:24:49 -08:00
David Wendt
2f9d50cdb8
Very rudimentary/basic/not-good implementation of `String`, plus auto-boxing for primitive strings getting their methods taken.
2020-01-21 18:24:49 -08:00
David Wendt
4d1e49882b
Add another object class for boxed primitive values, because the language demands it.
2020-01-21 18:24:49 -08:00
Mike Welsh
13b4cd4c1b
avm1: Add Value::coerce_to_i32/u32/u16 methods
...
Add these methods that will explicilty coerce a value to an int,
following the wrapping behavior in the ECMAScript specs (ToInt32,
ToUInt32, ToUInt16).
This also fixed an off-by-one error for negative numbers in the
previous implementation.
These will call `valueOf` if necessary. AVM code that requires an
integer will probably use one of these (`coerce_to_i32` usually).
2020-01-20 13:28:27 -08:00
dependabot-preview[bot]
87e96212e4
build(deps): bump syn from 1.0.13 to 1.0.14
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.13 to 1.0.14.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.13...1.0.14 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-20 18:56:56 +00:00
Nathan Adams
4ad6ef8b83
core: Implemented Key.getCode()
2020-01-17 15:11:38 -08:00
Nathan Adams
adceceed5d
avm1: Removed redundant double registration of Key
2020-01-17 15:11:38 -08:00
Nathan Adams
cef7d3eba2
avm1: Implement Key constants
2020-01-17 15:11:38 -08:00
Mike Welsh
8cb4278903
tests: Use pretty_assertions for nice output on test fail
2020-01-17 13:54:39 -08:00
Mike Welsh
cf7a564f2c
core: Fix properties not resetting in goto when rewinding
...
Properties of a display object would not reset when rewinding if
it existed in both the initial and final frames of the goto.
This fixes the weapons toggles in UFA.
2020-01-16 09:58:33 -08:00
Mike Welsh
8448fc80ef
avm1: Don't panic when calling ActionRandom with <= 0
2020-01-14 00:05:13 -08:00
Mike Welsh
4eef8a1821
tests: Add test for ActionCall
2020-01-14 00:04:11 -08:00
Mike Welsh
2d3801dac8
avm1: Implement ActionCall opcode
2020-01-14 00:04:11 -08:00
Nathan Adams
fdf1d38d21
avm1: Implement remainder of Math
2020-01-13 15:57:56 -08:00
dependabot-preview[bot]
6c2f5143b3
build(deps): bump rand from 0.7.2 to 0.7.3
...
Bumps [rand](https://github.com/rust-random/rand ) from 0.7.2 to 0.7.3.
- [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/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-13 18:38:15 +00:00
Mike Welsh
001a931afe
avm1: Avm1::pop should always succeed
...
Don't return a Result from `pop`. Instead, emit a warning and
return Undefined if there is an underflow.
2020-01-07 15:59:14 -08:00
Mike Welsh
170813ffbf
audio: Assume little endian for PCM unknown endian sounds
2020-01-07 02:40:09 -08:00
Mike Welsh
a28e97d8c3
avm1: Don't push returns from non-function stack frames
2020-01-06 20:49:05 -08:00
Mike Welsh
7e05da6147
avm1: Fix issues with traversing the scope chain in SetVariable
...
When setting a variable in a function-local scope, if that variable
has not been defined in the function scope, it should be defined in
the executing movieclip's scope. Previously it would get defined
in the function's scope. Changed Scope::overwrite to Scope::set,
and modified the behavior to stop traversing and define the value
when it hits a movie clip Target scope.
Also, modified With scopes to properly add onto the end of the scope
chain.
2020-01-06 20:49:05 -08:00
Mike Welsh
a60fadf0bb
tests: Add test for correct scope in SetVariable
2020-01-06 20:49:05 -08:00
David Wendt
0d1d0e8de7
Don't bother preserving the `Cow`ness of unescaped strings when we're going to clone them anyway.
2020-01-05 00:31:45 -05:00
David Wendt
7957434036
This is a copy type, copy it
2020-01-05 00:24:31 -05:00
David Wendt
f8b5b8a032
Use `unwrap_or_default` where available
2020-01-05 00:22:36 -05:00
David Wendt
ef7c5d7eb9
Move XML properties to separate functions rather than closures
2020-01-05 00:17:57 -05:00
David Wendt
14dba0d100
Log errors encountered when removing the children of a node we plan to parse XML into.
...
Also, remove a handful of unnecessary `#[allow(unused_must_use)]` instances.
2020-01-05 00:04:45 -05:00
David Wendt
464563a703
Change the no-double-introduction warning into a proper `assert!`. Add doc warning about the panic.
2020-01-05 00:00:29 -05:00
David Wendt
750e6e4370
Replace bare number constants for XML errors with symbolic `const` values
2020-01-04 23:56:10 -05:00
David Wendt
fd541fabea
Implement `status`.
...
I'm not entirely sure how to test this one - the list of errors that Flash kicks out for XML and the list of errors that `quick_xml` kicks out don't line up at all; so I just ensured that any error is a negative number (currently the one for OOM errors) and stuck whatever errors *did* match up together.
Consequently I don't know entirely *how* to write tests for this.
2020-01-04 19:00:49 -05:00
David Wendt
fec95dd226
Add regression test for `idMap`.
2020-01-04 19:00:49 -05:00
David Wendt
f3226537bf
Implement `idMap`.
...
`idMap` is a strange property; it's only populated with nodes which had a given `id` *at the time of parsing*, and said nodes continue to be referenced even if the node is removed from the document. I have yet to find a way by which nodes can be deleted from `idMap`.
It also takes expandos, so this has to be a new retained object on the XML document. I originally considered not creating *another* `Object` impl and populating a regular `ScriptObject` with nodes, but that meant we couldn't lazy-instantiate their AVM1 side counterparts. Boo. :/
2020-01-04 19:00:48 -05:00
David Wendt
1722558d44
Add test for `XML.parseXML`
2020-01-04 19:00:47 -05:00
David Wendt
823e8602ff
Impl `XML.parseXML`
2020-01-04 19:00:46 -05:00
David Wendt
d00ef01965
Add a convenience method: `XMLNode.into_string`
2020-01-04 19:00:46 -05:00
David Wendt
b4b722e1d6
Add another test for AVM1 XML's failure to roundtrip unsupported node types (e.g. comments).
2020-01-04 19:00:45 -05:00
David Wendt
2c790f1d41
Filter non-AS2 compatible nodes from toString output, and add non-SWF tests for XML filtering.
2020-01-04 19:00:45 -05:00
David Wendt
ce1b958abb
Add some more tests for XML namespace URIs.
2020-01-04 19:00:45 -05:00
David Wendt
e2fa685d41
Fix tagname parsing.
...
There is a bug in `quick_xml` - or at least, I *think* it's a bug - where the `unescaped` method of `BytesStart` yields a bunch of attributes if you have slightly invalid crap in your tag like `xmlns:`. To work around it, I turned off unescaping; we're instead using `name` and ignoring unescaping. This will probably fail somewhere.
2020-01-04 19:00:44 -05:00
David Wendt
e1034fce31
clippy compliance
2020-01-04 19:00:44 -05:00
David Wendt
7ac3204759
format prev commit
2020-01-04 19:00:43 -05:00
David Wendt
d2aa3dd987
Add a test for `createElement` and `createTextNode`.
2020-01-04 19:00:43 -05:00
David Wendt
db38982ffb
For some reason, text nodes have an attributes object.
2020-01-04 19:00:42 -05:00
David Wendt
91155d6870
Text nodes have empty arrays for `childNodes` rather than being `undefined`.
2020-01-04 19:00:42 -05:00
David Wendt
d28094a019
Implement `createElement` and `createTextNode`.
2020-01-04 19:00:42 -05:00
David Wendt
97bcb6b2dc
Add an ignored test for `xmlDecl`.
...
Test is currently ignored because AS2 XML currently handles XML declarations in ways not compatible with our current parser. Investigating hacky ways around this.
2020-01-04 19:00:41 -05:00
David Wendt
c02da74afa
Expose the `<?xml ?>` declaration to ActionScript.
...
I can't write proper tests for this because our underlying XML parsing technology doesn't let us do what AS2 XML does: just copy the first xml tag out of the document and into a string. No, seriously, anything at the start of the parsed XML that starts with `<?xml` and ends with `?>` gets copied into Flash's moral equivalent of `xml::Document` as a string. We parse the whole thing, which is wrong, so we'll need to additionally retain the original xmldecl string in order to pass the test I wrote for this.
2020-01-04 19:00:41 -05:00
David Wendt
ce0546fc2c
Add test for `docTypeDecl`.
2020-01-04 19:00:40 -05:00
David Wendt
a7a349b02b
Expose `docTypeDecl` to ActionScript.
...
This also involves storing the `DocType` node on the document object and retrieving it later.
2020-01-04 19:00:40 -05:00
David Wendt
a80aab1b08
Document roots can store an attributes object, even though they don't have attributes
2020-01-04 19:00:40 -05:00
David Wendt
6a472d32bb
Filter incompatible nodes from the sibling and child lists.
2020-01-04 19:00:39 -05:00
David Wendt
fd14d0c9df
Doctype nodes should be represented as text nodes to ActionScript (if they somehow grab hold of them)
2020-01-04 19:00:38 -05:00
David Wendt
6b4bbee195
Create and store `DocType` nodes on the tree when we encounter a `<!DOCTYPE...>` tag.
2020-01-04 19:00:38 -05:00
David Wendt
aa749dc1b0
Store the XML document version, encoding, and standalone flags.
2020-01-04 19:00:38 -05:00
David Wendt
a869107480
The `DocumentRoot` node type should have it's own node type ID, and AS2 XML should filter it out. This also filters out comment nodes as text, which isn't technically wrong but we should do better
2020-01-04 19:00:37 -05:00
David Wendt
7965045d87
Add test for XMLNode.toString.
2020-01-04 19:00:37 -05:00
David Wendt
673f85f067
XMLNode type 1 is an element, not a text node.
2020-01-04 19:00:36 -05:00
David Wendt
88aa5f8004
Add extra whitespace to empty tags.
2020-01-04 19:00:36 -05:00
David Wendt
0c7a1fe667
Text and comment nodes are stored plain and must be escaped for XML
2020-01-04 19:00:36 -05:00
David Wendt
c7e1f34a5d
Print empty nodes as empty tags rather than start/end
2020-01-04 19:00:35 -05:00
David Wendt
c76e5ce447
appendChild also refuses to orphan nodes already part of another XML tree.
2020-01-04 19:00:35 -05:00