Commit Graph

1144 Commits

Author SHA1 Message Date
David Wendt 4f5ac09b73 Expose XML document constructor, including text parsing ability 2020-01-04 19:00:09 -05:00
David Wendt 554f0dc1e5 Add XMLNode class and constructor impl 2020-01-04 19:00:07 -05:00
David Wendt 6a65e984ae Add a new `XMLObject` variant to the AVM1 object ecosystem.
This particular variant is actually a two-in-one deal: `XMLObject`s may either refer to a document or a node.
2020-01-04 18:58:42 -05:00
David Wendt 89c9753520 Add rudimentary custom DOM impl on top of `quick_xml`.
`quick_xml` was chosen due to it's high performance and support for zero-copy use cases. However, we are not using `minidom`, which is the already-extant DOM impl that uses `quick_xml` as it's parsing provider. This is because `minidom` nodes are not amenable to garbage collection.

Specifically: we want to be able to construct a new `Object` variant that holds part of an XML node. However, `minidom::Element` directly owns it's children, meaning that we can't hold references to it from within `Object` while also keeping those objects to the `'gc` lifetime. Hence, we provide a GC-exclusive DOM implementation.

I ruled out solutions such as holding an entire XML tree in an `Rc` and having AVM objects that shadow them. This works for `SwfSlice` because indexing an array is cheap; but traversing a tree can get very expensive. XML is used in many places in Flash Player, so it's important that we treat it like a first-class citizen.
2020-01-04 18:48:17 -05:00
Mike Welsh 4ce67535b0 tests: Add test for Color 2020-01-03 20:31:32 -08:00
Mike Welsh 36b3e5b34f avm1: Implement Color class 2020-01-03 20:31:32 -08:00
Mike Welsh 4bf29f677f avm1: Implement Sound.duration
Add AudioBackend::get_sound_duration.
2020-01-03 17:11:00 -08:00
Mike Welsh b9d24d9a49 avm1: First pass at implementing Sound.stop 2020-01-03 17:11:00 -08:00
Mike Welsh d0142f1d67 audio: Add AudioBackend::stop_sound 2020-01-03 17:11:00 -08:00
Mike Welsh 63dd92259b avm1: First pass of Sound object 2020-01-03 17:11:00 -08:00
dependabot-preview[bot] c966f9bf59 build(deps): bump winit from 0.20.0-alpha5 to 0.20.0-alpha6
Bumps [winit](https://github.com/rust-windowing/winit) from 0.20.0-alpha5 to 0.20.0-alpha6.
- [Release notes](https://github.com/rust-windowing/winit/releases)
- [Changelog](https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-windowing/winit/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-04 00:02:22 +00:00
dependabot-preview[bot] a01e5b7854 build(deps): bump syn from 1.0.12 to 1.0.13
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.12 to 1.0.13.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.12...1.0.13)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 19:15:37 +00:00
dependabot-preview[bot] b4a47e17da build(deps): bump generational-arena from 0.2.6 to 0.2.7
Bumps [generational-arena](https://github.com/fitzgen/generational-arena) from 0.2.6 to 0.2.7.
- [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.6...0.2.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 19:14:43 +00:00
dependabot-preview[bot] 353dc5c229 build(deps-dev): bump webpack from 4.41.4 to 4.41.5 in /web/selfhosted
Bumps [webpack](https://github.com/webpack/webpack) from 4.41.4 to 4.41.5.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v4.41.4...v4.41.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 08:25:48 +00:00
dependabot-preview[bot] 1048170235 build(deps): bump syn from 1.0.11 to 1.0.12
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.11 to 1.0.12.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.11...1.0.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-03 08:24:29 +00:00
dependabot-preview[bot] 861a4484a5 build(deps): bump structopt from 0.3.6 to 0.3.7
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.6 to 0.3.7.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.6...v0.3.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-29 23:10:17 +00:00
dependabot-preview[bot] 71ba4cb86e build(deps): bump lyon from 0.15.1 to 0.15.3
Bumps [lyon](https://github.com/nical/lyon) from 0.15.1 to 0.15.3.
- [Release notes](https://github.com/nical/lyon/releases)
- [Changelog](https://github.com/nical/lyon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nical/lyon/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-29 22:56:08 +00:00
Mike Welsh 7feddfcb03 desktop: Bump to lyon 0.15.2 (fix #196)
The new tessellator in lyon seems to fix many of the cases where
art would not tessellate correctly.
2019-12-27 17:21:48 -08:00
Mike Welsh 87158647d1 core: Implement keyPress button events 2019-12-24 03:06:03 -08:00
Mike Welsh 30983c5bab web: Use pointer events on web 2019-12-23 13:16:58 -08:00
dependabot-preview[bot] db8e0bd997 build(deps): bump wasm-bindgen-test from 0.3.5 to 0.3.6
Bumps [wasm-bindgen-test](https://github.com/rustwasm/wasm-bindgen) from 0.3.5 to 0.3.6.
- [Release notes](https://github.com/rustwasm/wasm-bindgen/releases)
- [Changelog](https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rustwasm/wasm-bindgen/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-23 19:39:55 +00:00
Mike Welsh 2f0963fa6c core: Fix button action with multiple conditions not firing (fix #195)
If a button event had both a keyPress condition and another
condition:

on(release, keyPress "A") { }

these actions would not fire on click, because it would still
check if the key was down (which doesn't apply to clicks!)

Fixes #195.
2019-12-22 15:55:03 -08:00
dependabot-preview[bot] 9211c7ac05 build(deps): bump structopt from 0.3.5 to 0.3.6
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.5 to 0.3.6.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.5...v0.3.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-22 22:54:14 +00:00
Nathan Adams 9000451d58 core: Implemented Mouse.show() & Mouse.hide() 2019-12-22 14:33:46 -08:00
Mike Welsh 4cdeec5b64 avm1: Fix number coercion in arithmetic ops
A lot of the arithmetic ops were still using SWFv4 style coercion
(`Value::into_number_v1`) even though they use full ECMA-262
coercion in SWF5+. This would cause `undefined` to turn into 0
isntead of NaN, for example.

Fixes disappearing player in Achievement Unlocked
(https://www.newgrounds.com/portal/view/474371)

It's possible even the older ops such as ActionAdd should do this,
too. Handcrafted bytecode will need to be used to test as you
cannot export these ops in newer SWF versions from the Flash IDE.
2019-12-22 03:01:58 -08:00
Mike Welsh c9e0bdeaf5 core: GC trace Button::object 2019-12-21 23:54:50 -08:00
Mike Welsh 1d8ae9154b tests: Add tests for AVM1 logical ops 2019-12-21 23:01:10 -08:00
Mike Welsh a4a307cf9a avm1: Use proper bool conversions for logical ops
ActionAnd, ActionOr, and ActionNot were incorrectly comparing
to 0. This only works for SWF<4. Now they all go through the
Value::as_bool method to handle version specific behavior.

Value::from_bool_v1 was also renamed to Value::from_bool.
2019-12-21 23:01:10 -08:00
Mike Welsh 00fdc74f1f tests: Add test for property updating in fast-forward gotos 2019-12-21 21:16:27 -08:00
Mike Welsh fd92bd5f78 core: Fix PlaceObject modifications in fast-forward gotos
When fast-forwarding with a goto, modifications were not taking
effect to objects that exist both in the starting and the final
frame.
2019-12-21 21:16:27 -08:00
Mike Welsh c05b03dd06 web: Handle keydown/keyup and preventDefault if Ruffle has focus 2019-12-21 19:08:06 -08:00
David Wendt 69094b56b5 Add input support to the web backend. 2019-12-21 19:08:06 -08:00
Nathan Adams 3fd79a6982 chore: Rename GliumInputBackend -> WinitInputBackend 2019-12-21 19:08:06 -08:00
Nathan Adams 856a2f2910 desktop: Implemented glium based input handler for Key.isDown 2019-12-21 19:08:06 -08:00
Nathan Adams eedc4bbe24 core: Added Input backend, currently unimplemented, for polling user input 2019-12-21 19:08:06 -08:00
Nathan Adams 6c484fe29d core: Changed KeyCode into an enum that maps out every Flash key code 2019-12-21 19:08:06 -08:00
Mike Welsh d7df15989f core: Clear drag if object is removed while dragging 2019-12-21 16:28:41 -08:00
Mike Welsh 531e4d640d avm1: Implement StartDrag/EndDrag 2019-12-21 16:28:41 -08:00
Mike Welsh 713e959ce4 core: Implement DisplayObject::object for Button 2019-12-21 16:28:41 -08:00
Mike Welsh 4bd54cc2ea core: Fix DisplayObject::global_to_local and local_to_global 2019-12-21 16:28:41 -08:00
Mike Welsh f2d31b222b core: Implement DefineButtonCxform SWF tag
(Although nothing uses this... it was only used in SWF version 2
and below!)
2019-12-20 19:20:25 -08:00
Mike Welsh bc872cbf9c swf: Clean up DefineButtonCxform tag 2019-12-20 19:20:25 -08:00
dependabot-preview[bot] e8e0b83d23 build(deps): bump smallvec from 1.0.0 to 1.1.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.0.0...v1.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-20 22:36:07 +00:00
dependabot-preview[bot] 4aebeab577 build(deps): bump web-sys from 0.3.32 to 0.3.33
Bumps [web-sys](https://github.com/rustwasm/wasm-bindgen) from 0.3.32 to 0.3.33.
- [Release notes](https://github.com/rustwasm/wasm-bindgen/releases)
- [Changelog](https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rustwasm/wasm-bindgen/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-20 18:36:15 +00:00
Mike Welsh 4821966898 ci: Bump to Rust 1.40 2019-12-20 01:09:23 -08:00
Mike Welsh 4026e22bbf core: Handle DefineButtonSound SWF tag
This plays sounds whenever a button is hovered/clicked. Fixes
gun sounds in Pico's School.
2019-12-20 01:08:28 -08:00
Mike Welsh cadf14f077 chore: Add .swd files to .gitignore (SWF debug symbols) 2019-12-19 17:33:27 -08:00
Mike Welsh d459bbe010 avm1: Functions store their base clip
Functions now store their base clip (the code that contains the
executing bytecode). This is because `GotoFrame` and other actions
will execute on the clip the bytecode exists on, not on `this`.

(Note that `this.gotoAndStop` uses `GetMember` actions, which
worked correctly).

`Activation` now stores `target_clip`, and `Avm1::target_clip` and
`target_clip_or_root` grab this from the current stack frame.

Renamed `start_clip` to `base_clip` to match Flash conventions.
Removed `active_clip` as this was superfluous. Now you can use
`Avm1::target_clip_or_root`.

`UpdateContext` no longer contains `target_clip` etc.
2019-12-19 17:30:50 -08:00
Mike Welsh c4b446ff78 tests: Add test for functions closing over base clip 2019-12-19 17:30:50 -08:00
Mike Welsh 13c43ed171 tests: Update movieclip_hittest to verify points are in root coordinates 2019-12-19 12:35:56 -08:00