Commit Graph

3092 Commits

Author SHA1 Message Date
relrelb 0fd1c05fd5 chore: Use into() in more places 2021-06-22 11:49:41 -07:00
relrelb 13977d9d22 avm1: Correct some Array set_length cases
Array builtins (pop, shift, unshift) doesn't update the length of
non-Array objects. However, push does update the length for all
objects.
2021-06-22 10:43:10 -07:00
relrelb c383b70336 avm1: Merge array_function with constructor 2021-06-22 10:43:10 -07:00
relrelb 7948d872dc avm1: Correct AsBroadcaster removeListener 2021-06-22 10:43:10 -07:00
relrelb 8742f288cb avm1: Correct AsBroadcaster addListener 2021-06-22 10:43:10 -07:00
relrelb b0b48b5b0c avm1: Cleanup ScriptObject constructors 2021-06-22 10:43:10 -07:00
relrelb ab5f5b4878 avm1: Use custom array index parsing method
Indices can be of arbitrary size (by overflowing around i32), but
Rust's `parse` is limited to the i32 range.
2021-06-22 10:43:10 -07:00
relrelb 95c30b85e1 avm1: Extract ArrayObject 2021-06-22 10:43:10 -07:00
Chris Midgley b7de03b5c8
avm1: implement hscroll and maxhscroll for TextField 2021-06-22 01:43:02 -07:00
EmperorBale 1ee61cca57
avm2: ByteArray updates 2021-06-22 01:26:27 -07:00
danharris-stu e010775099 core: Fix documentation spelling 2021-06-21 20:57:49 +03:00
dependabot[bot] a66dce3548 chore: Bump rand from 0.8.3 to 0.8.4
Bumps [rand](https://github.com/rust-random/rand) from 0.8.3 to 0.8.4.
- [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.3...0.8.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-20 03:10:42 -07:00
dependabot[bot] c22c18b809 chore: Bump bitstream-io from 1.0.0 to 1.1.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/tuffy/bitstream-io/releases)
- [Commits](https://github.com/tuffy/bitstream-io/commits)

---
updated-dependencies:
- dependency-name: bitstream-io
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-20 03:10:31 -07:00
Mike Welsh e886756aab avm1: Wire up _soundbuftime
Store the `_soundbuftime` property in the audio manager. This is
currently unused by Ruffle, but the value will now be stored.
2021-06-20 01:25:27 -07:00
Mike Welsh e3d0538999 core: Add AudioManager::stream_buffer_time 2021-06-20 01:25:27 -07:00
relrelb 6d1b6009e8 avm1: Use bitflags for ChannelOptions 2021-06-18 15:30:09 -07:00
Adrian Wielgosik 867b7ffcad
core: Preallocate bitmaps for remaining cases in decode_define_bits_lossless 2021-06-17 15:43:36 -07:00
Mike Welsh 09b86cda8b avm1: Implement ToggleHighQuality op
Wire up the op so that it affects the quality setting, although the
setting is still unused by Ruffle.

This op will remember whether the stage was in `High`/`Best` quality.
Split out the "bitmap downsampling" flag in `Stage` so that we can
persist this state.
2021-06-17 13:55:56 -07:00
Mike Welsh eb12a3af17 avm1: Wire up _highquality 2021-06-17 13:55:56 -07:00
Mike Welsh 9357fd7b4f avm2: Wire up Stage.quality 2021-06-17 13:55:56 -07:00
Mike Welsh 9370b84092 avm1: Wire up _quality 2021-06-17 13:55:56 -07:00
Mike Welsh ee8439e55c core: Add Stage::quality 2021-06-17 13:55:56 -07:00
Mike Welsh a1ceb07bec core: Fix PlaceObjectAction::Replace in gotos (fix #4545) 2021-06-16 20:57:43 -07:00
Mike Welsh 622f35eb71 core: Pump action queue after handling an event 2021-06-16 12:42:49 -07:00
Mike Welsh e2659e451c core: Fire button events after mouse move events 2021-06-16 12:42:49 -07:00
Mike Welsh 71024939e3 core: Remove self_node parameter from DisplayObject::mouse_pick 2021-06-16 12:42:49 -07:00
Mike Welsh 6894382e8e avm1: Implement _droptarget 2021-06-16 12:42:49 -07:00
Mike Welsh 495f8d90e6 avm1: Implement dragOver/dragOut button events 2021-06-16 12:42:49 -07:00
Mike Welsh 6de7ee1a8c core: Support drag events with magic button frame labels 2021-06-16 12:42:49 -07:00
Mike Welsh 90024a1266 core: Wire up dragOver/dragOut events for buttons 2021-06-16 12:42:49 -07:00
Mike Welsh b0143ff918 core: Add Player::mouse_pressed_object 2021-06-16 12:42:49 -07:00
Mike Welsh 2f25887080 avm1: SetTarget of a removed clip is invalid
A `SetTarget` call should ignore any clip that has been removed.
This can happen in cases such as `tellTarget("_root")` seeking
to a frame where the clip no longer exists.

Fixes this issue:
https://github.com/ruffle-rs/ruffle/pull/4452#issuecomment-860747028
2021-06-14 14:04:28 -07:00
Mike Welsh ed1bfd74fe core: keyPress events take precedence over text input 2021-06-14 14:04:28 -07:00
Mike Welsh 4687eb6d4e core: Ensure bitmaps run post_instantiate 2021-06-14 14:04:28 -07:00
Mike Welsh 1f96af6b64 core: Add Avm1::exec_list to manage global list of display objects 2021-06-14 14:04:28 -07:00
dependabot[bot] cf4a1136c5 chore: Bump env_logger from 0.8.3 to 0.8.4
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.3 to 0.8.4.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.3...v0.8.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 00:47:57 -07:00
dependabot[bot] 1b6b4964c9 chore: Bump syn from 1.0.72 to 1.0.73
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.72 to 1.0.73.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.72...1.0.73)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 00:47:40 -07:00
Mike Welsh 83f842faf9 avm1: Implement MovieClip.beginBitmapFill 2021-06-13 20:03:53 -07:00
Mike Welsh 554aa7fd63 core: Add backend::render::BitmapSource trait
This interface handles returning a bitmap given an ID and is used
by the render backend to get the bitmap used for a bitmap fill.
This will allow for bitmap fills in the drawing API, as these will
manage their own list of bitmaps.
This also  removes the MovieLibrary dependency from render backends
and will allow for better decoupling in the future.
2021-06-13 20:03:53 -07:00
Chris Midgley b6a2738dab core: support magic button labels for avm1 2021-06-13 10:46:24 -07:00
Adrian Wielgosik 7d1bd57066 avm1: Call ContextMenu.onSelect before preparing context menu items 2021-06-13 10:37:38 -07:00
relrelb 9c5b9b7072 avm1: Rewrite TObject array methods 2021-06-13 10:37:15 -07:00
Mike Welsh 3b215d6c76 core: Use swf::ClipEventFlag in stored clip event handlers
* Rename movie_clip::ClipAction to movie_clip::ClipEventHandler.
 * Store the swf::ClipEventFlag event flags that trigger the event
   directly in the event handler. Previously we split up any event
   that had multiple event flags into separate events. Now these
   can be kept as a single event.
 * Remove `MovieClip::has_button_event`, and instead store the
   union of all event flags in `MovieClip::clip_event_flags`. This
   will be useful for other cases in the future.
2021-06-11 12:54:53 -07:00
relrelb ede9650899 chore: Avoid unused_variables annotations
Instead prefix the unused variables with an underscore.
2021-06-11 16:16:53 +03:00
Mike Welsh 5462b8a522 core: Allow MorphShapes and Texts to be replaced via PlaceObject
PR #4540 allowed shapes to replace their inner art handles via
replace PlaceObject tags. This can also happen for morph shapes and
static texts.

Add MorphShape::replace_with and Text::repalce_with. This fixes the
incorrect art in main menu buttons of Super Mario 63.
2021-06-09 23:37:38 -07:00
Mike Welsh 4fc9225e8f avm2: Only construct Shapes once
Shape objects were mistakenly being reconstructed each frame in
`Graphic::construct_frame`.
2021-06-08 19:47:16 -07:00
Mike Welsh b1318ecb01 core: PlaceObjectAction::Replace swaps out graphic handles
A `PlaceObjectAction::Replace` signals that a shape should
be swapped with a different shape. Previously we instantiated a
completely new `Graphic`, but this is incorrect; instead the
underlying shape handle should be swapped out, but the outer object
remains. This is visible in AVM2 where you can access `Shape` as
a normal display object.
2021-06-08 19:47:16 -07:00
Mike Welsh 93e83d7ad5 avm1: DefineFunction should respect case sensitivity 2021-06-08 16:51:59 -07:00
Mike Welsh 21c351fe5b swf: Change Twips::zero fn to Twips::ZERO const 2021-06-08 14:57:15 -07:00
Mike Welsh d23ea90459 swf: Change Matrix to use Fixed16 for a, b, c, d
Matrices in an SWF file store their scale/skew components in
in 16.16 format (fbits).

Split `ruffle_core::Matrix` and `swf::Matrix`. `swf::Matrix` now
stores its data as `Fixed16` instead of immediately converting to
`f32`.
2021-06-08 14:57:15 -07:00
relrelb 39decde5bc avm1: Refactor ScriptObject::get_local 2021-06-08 10:48:50 -07:00
relrelb 1c0007f34f avm1: Make TObject::get_local return Option 2021-06-08 10:48:50 -07:00
relrelb 15fa92a9fb avm1: Add TObject::set_local 2021-06-08 10:48:50 -07:00
relrelb c9d015d7c5 avm1: Cleanup some TObject methods 2021-06-08 10:48:50 -07:00
dependabot[bot] 2f1dc0cbb1 chore: Bump approx from 0.4.0 to 0.5.0
Bumps [approx](https://github.com/brendanzab/approx) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/brendanzab/approx/releases)
- [Commits](https://github.com/brendanzab/approx/compare/v0.4.0...v0.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-07 11:30:59 -07:00
relrelb b8eae51888 swf: Move num_colors into BitmapFormat::ColorMap8 2021-06-07 11:29:28 -07:00
relrelb ef2e581f09 core: Use casting instead of ToPrimitive 2021-06-07 11:29:28 -07:00
relrelb aee37276ec core: Replace num_enum with num_derive 2021-06-05 10:19:31 -07:00
relrelb f82faf9603 chore: Appease clippy 2021-06-05 10:16:00 -07:00
Adam Gashlin ba83f17ef7 core: Set init_object after first run_frame (fix #2084, #3414) 2021-06-02 23:28:24 -07:00
dependabot[bot] 83243acc37 chore: Bump regress from 0.2.0 to 0.3.0
Bumps [regress](https://github.com/ridiculousfish/regress) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/ridiculousfish/regress/releases)
- [Commits](https://github.com/ridiculousfish/regress/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-31 10:06:11 -07:00
Mike Welsh f173b81e38 swf: Use bitflags for Function flags 2021-05-30 22:14:32 -07:00
Mike Welsh 2b98c878f0 swf: Use Fixed in more places 2021-05-30 21:24:03 -07:00
Adrian Wielgosik 34d54dbc05
avm1: Fix string methods handling of negative args (fix #4437)
* Improve string.substr handling of negative args
* Add tests for more substr() combinations
2021-05-30 12:04:17 -07:00
Mike Welsh 1304b2c55a avm2: Move Object properties to Object.prototype 2021-05-24 17:52:15 -07:00
Moulins af5694b642 [avm1] extend impl_custom_object! to reduce boilerplate
This add two knobs to the impl_custom_object! macro:
  - `set(...)`, for using a specific prototype in the `set`
method;
  - `bare_object(...)`, for objects that are convertible to a raw object
type.
2021-05-24 17:06:47 -07:00
Mike Welsh 3ddb97d2f6 core: Add SwfMovie::frame_rate and num_frames 2021-05-23 23:02:38 -07:00
Mike Welsh 172ad82aa5 core: Add SwfMovie::uncompressed_len 2021-05-23 23:02:38 -07:00
Mike Welsh 077c7f045e core: Add SwfMovie::stage_size
Change `SwfMovie::width` and `height` to return `Twips`.
2021-05-23 23:02:38 -07:00
Mike Welsh bec6eb9dd3 core: Use SwfMovie::avm_type instead of MovieLibrary::avm_type 2021-05-23 23:02:38 -07:00
Mike Welsh e1439f4105 swf: Add HeaderExt struct providing additional info
When reading an SWF, search for FileAttributes and
SetBackgroundColor and return this along with the header data
because it's useful (in particular, the AS3 flag).
2021-05-23 23:02:38 -07:00
Chris Midgley aa7dc50385
core: Handle visible flag from PlaceObject (fix #3403) 2021-05-23 11:48:12 -07:00
relrelb a6387c3c10 core: Fix build without serde feature
Previously `cargo build --no-default-features` failed because then
`serde` was not found.
Fix that by not implementing serde's traits in that case, similarly
to `config.rs`.
2021-05-22 22:50:20 -07:00
Mike Welsh 8960414436 swf: Use bitflags for FileAttributes 2021-05-22 15:53:02 -07:00
relrelb 3fbadbe26f avm1: Remove unnecessary gc_context parameters
`add_property_with_case`, `set_watcher` and `remove_watcher` already
take an `activation`, from which the `gc_context` can be retrieved.
2021-05-22 10:49:27 -07:00
Mike Welsh bb22a5aba2 avm1: Remove extraneous self parameters from MovieClip methods
Previously these were used because the methods were on `MovieClipData`
instead of `MovieClip`, but now they are no longer necessary.
2021-05-21 17:50:25 -07:00
relrelb 7717b97027 avm1: Remove unnecessary calls to create_bare_object
In favor of ScriptObject::object and ScriptObject::array, which
always succeed.
2021-05-21 16:13:25 -07:00
relrelb aeb8902f8c avm1: Remove unused TObject::as_string 2021-05-21 15:27:35 -07:00
Moulins 35b9fb7317 avm1: add property_decl::declare_properties! macro for defining built-ins
This allows for reduced boilerplate when defining native methods,
properties, and constants (but not values depending on other runtime
values, like built-ins objects and prototypes).

Also remove ScriptObject::force_set_function (replaced by DeclKind::Method)
2021-05-17 10:34:41 -07:00
dependabot[bot] 00194e351e chore: Bump serde from 1.0.125 to 1.0.126
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.125 to 1.0.126.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.125...v1.0.126)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 10:13:02 -07:00
Mike Welsh f478ee7b2f avm2: Properly implement Avm2Button::hit_test_shape and mouse_pick
The hit area is not a proper child of the Avm2Button, so manually
transform the test point into local space before passing it to the
hit area.
2021-05-16 17:53:07 -07:00
Mike Welsh dfc8c32937 core: Do not include stage transform in DisplayObject::local_to_global_matrix
TODO: Eventually we may want to include the stage transform here,
and the deeper ActionScript APIs transform it to remove the stage
scaling.
2021-05-16 17:53:07 -07:00
Mike Welsh 7784d8c099 avm2: Remove some AVM1 leftovers from Avm2Button 2021-05-16 17:53:07 -07:00
Mike Welsh 9b58dac841 avm2: Fix up DisplayObject root and stage properties
Move `MovieClip::is_swf` flag to `DisplayObject::is_root`, and use
this flag to handle the behavior of `DisplayObject.root` crawling
upwards until it hits a top-most loaded SWF/Bitmap.

Simplify `root` and `stage` so that they don't have to consider
buttons. Instead, do some trickery to ensure the button's states
see the proper values of `parent`, `root`, and `stage` during
construction.
2021-05-16 17:53:07 -07:00
Mike Welsh 2176e30e22 avm2: Use define_public_builtin_instance_properties for SimpleButton 2021-05-16 17:53:07 -07:00
David Wendt e555a6b488 avm2: Impl `SimpleButton.useHandCursor` 2021-05-16 17:53:07 -07:00
David Wendt 6f6e2c1b9f avm2: Impl `SimpleButton.enabled` 2021-05-16 17:53:07 -07:00
David Wendt 514c51510c avm2: Impl `SimpleButton.trackAsMenu` 2021-05-16 17:53:07 -07:00
David Wendt b383aec78d tests: Move the button tests into the new test directory. 2021-05-16 17:53:07 -07:00
David Wendt 71bb0c901a avm2: Impl the constructor parameters for `SimpleButton` 2021-05-16 17:53:07 -07:00
David Wendt a82e78b597 tests: Don't check the `exitFrame` or `frameConstructed` events in the nested test as it appears to fire the events redundantly 2021-05-16 17:53:07 -07:00
David Wendt cfd95e3b3b core: `root` and `stage` should yield `None` if an inactive state child of an `Avm2Button` is involved in the parent chain. 2021-05-16 17:53:07 -07:00
David Wendt 169a99397a core: `stage` also yields the current context's stage if there isn't one in the parent chain and we aren't in a button 2021-05-16 17:53:07 -07:00
David Wendt bfebc3c78f core: AVM2Button does not set the parent of the movie until after it's constructors have run 2021-05-16 17:53:07 -07:00
David Wendt 6a9249e52f core: Store the root of each loaded movie and use it as a last-ditch way to get the root 2021-05-16 17:53:07 -07:00
David Wendt 9ded256c23 core: Implement the AVM2 concept of `stage`. 2021-05-16 17:53:07 -07:00
David Wendt 39e9ef9dc5 core: Implement a separate `avm2_root` method that provides an AS3 notion of root 2021-05-16 17:53:07 -07:00
David Wendt e4a6a10038 tests: Add tests for what children see as their parent when constructed or shuffled between movie clips and buttons 2021-05-16 17:53:07 -07:00
David Wendt a9d7b30dc2 core: `Avm2Button` should unparent any added children 2021-05-16 17:53:07 -07:00
David Wendt 082ecb16cb core: `avm2_parent` always returns a container, or nothing. 2021-05-16 17:53:07 -07:00
David Wendt 157ced3dc3 core: Split the parent accessor further into `parent` and `avm1_parent`.
`parent` is now a bare accessor, `avm1_parent` returns what AVM1 thinks the parent should be, and `avm2_parent` returns what AVM2 thinks the parent should be.
2021-05-16 17:53:07 -07:00
David Wendt f90cfb3bd0 core: Ensure sprite children get linked up correctly 2021-05-16 17:53:07 -07:00
David Wendt 5274df11f7 core: `Shape` should always expose it's defining movie instead of punting to the parent clip 2021-05-16 17:53:07 -07:00
David Wendt 826b20e8e4 tests: Don't assert execution order of frame scripts within buttons 2021-05-16 17:53:07 -07:00
David Wendt ef4de4d0d7 core: Order of events for child `Avm2Button` states is hit-up-down-over.
Ok, it's not *actually* that - all our tests actually have different, conflicting information. As far as I can tell there doesn't seem to be a single set order for these; so I'm going to just pick one and then stop testing the order in which states run.
2021-05-16 17:53:07 -07:00
David Wendt c936ccd4b4 avm2: When constructing new `SimpleButton`s, make sure the display object sees it's AVM2 side, else we replace all it's contents with AVM1 objects somehow(?!) 2021-05-16 17:53:07 -07:00
David Wendt 208c191d88 core: `Avm2Button` always runs a frame on set children, even if it's not the current state 2021-05-16 17:53:07 -07:00
David Wendt bf1fb93b83 core: Allow linking `Avm2Button`'s object 2021-05-16 17:53:07 -07:00
David Wendt d7deaf5e00 tests: Add currently-failing tests for the `SimpleButton` constructor and order-of-events. 2021-05-16 17:53:07 -07:00
David Wendt 44e82ea480 core: `Avm2Button` fires off events in this order when you set one of it's children:
1. `added`/`addedToStage` on the new state
2. `removed` (presumably) on the old state
3. `frameConstructed` on the new state
4. Any frame scripts on the new state
5. `exitFrame` on the new state

This is a rough approximation; I have several tests that fail in weird and interesting ways. Also, this only happens if you set the *active* state; presumably these events are all fired when the state changes but I can't automate tests for that yet.
2021-05-16 17:53:07 -07:00
David Wendt 434563da2f avm2: `SimpleButton` should build a button when constructed 2021-05-16 17:53:07 -07:00
David Wendt 67c7f156ac avm2: `instanceof` accepts `null` and `undefined` 2021-05-16 17:53:07 -07:00
David Wendt 7f294f5209 avm2: Constructor-based symbol instantiation should also post-instantiate before constructing a frame 2021-05-16 17:53:07 -07:00
David Wendt ea80d999da tests: Add an almost-passing test for buttons with multiple levels of children 2021-05-16 17:53:07 -07:00
David Wendt 07513da3ba core: State-constructed sprites in `Avm2Button` should be post-instantiated after everything else so they get their instance numbers later 2021-05-16 17:53:07 -07:00
David Wendt bba2ecae8e core: `Shape` gets an instance number 2021-05-16 17:53:07 -07:00
David Wendt 3707ef7fec tests: Add a test for child events using the same timeline structure as the structure test. 2021-05-16 17:53:07 -07:00
David Wendt 11d7fe5107 core: Correct the order of events that are fired when an `Avm2Button` is instantiated on the timeline. 2021-05-16 17:53:07 -07:00
David Wendt 6a70c1b3e0 tests: Extend the simplebutton structure test to include frame 2 2021-05-16 17:53:07 -07:00
David Wendt a013a7dfdf core: Initial construction should also prevent normal frame execution first frame 2021-05-16 17:53:07 -07:00
David Wendt 9f5a7f5065 core: AVM2 `Button`s run their children one frame at construction time 2021-05-16 17:53:07 -07:00
David Wendt bfef7f9969 core: `Avm2Button` should always construct a sprite for each state, even if it's not used. 2021-05-16 17:53:07 -07:00
David Wendt afefdb892f tests: Add a test for timeline-constructed AS3 `SimpleButton` contents 2021-05-16 17:53:07 -07:00
David Wendt 821ed25374 avm2: `Avm2Button` should construct it's children 2021-05-16 17:53:07 -07:00
David Wendt 71b87f8935 avm2: Also impl `construct_frame` and `run_frame_scripts` for `Avm2Button` 2021-05-16 17:53:07 -07:00
David Wendt 4869ec650e core: `Avm2Button` should construct a sprite whenever there's anything other than one child 2021-05-16 17:53:07 -07:00
David Wendt c317d77916 core: `Avm2Button` shouldn't try to construct a Sprite using it's prototype 2021-05-16 17:53:07 -07:00
David Wendt 10bed4fe30 core: `set_avm2_constructor` works on constructors, not prototypes 2021-05-16 17:53:07 -07:00
David Wendt d049ba8c0f core: Child instantiation should print the error message it got when it fails 2021-05-16 17:53:07 -07:00
David Wendt 25473ac1dc core: Allow AVM2 movies to define `Avm2Button` characters in their libraries 2021-05-16 17:53:07 -07:00
David Wendt cb44554135 avm2: Add setters and getters for the four states of `SimpleButton` 2021-05-16 17:53:07 -07:00
David Wendt 494083673c core: Add AVM2 version of Button 2021-05-16 17:53:07 -07:00
David Wendt 22eac776be avm2: Stub `flash.display.SimpleButton` 2021-05-16 17:53:07 -07:00
David Wendt cffa739a54 avm2: Store the sprite proto 2021-05-16 17:53:07 -07:00
David Wendt c0296d9963 core: Rename `Button` to `Avm1Button` 2021-05-16 17:53:07 -07:00
Reiner Gerecke efdb9c153d core: Fix endless loop when layouting text
If a textfield has word wrapping enabled, is very small in size and
tries to layout a single character onto it, the layout code can run into
an endless loop where it's creating new lines and trying to fit the text
again.

If text doesn't fit at the start of a line, it won't fit on the next
either, so abort and display the whole text span on the line. Text will
be cut-off.

This can be reproduced with a AS2 file like this:

    class Test {
      static var app : Test;

      function Test() {
        _root.createTextField("tf",0,0,0,6,20);
        _root.tf.text = "0";
        _root.tf.wordWrap = true;
      }

      static function main(mc) {
        app = new Test();
      }
    }

Build it with `mtasc -main -header 100💯30 test.as -swf test.swf`
2021-05-15 18:56:51 -07:00
Mike Welsh 69a0700ca1 core: Remove collect::CollectWrapper
No longer necessary, it is possible to mark individual fields
as `#[collect(require_static)]`.
2021-05-13 23:24:10 -07:00
Mike Welsh b882284fc9 core: Use bitflags for HitTestOptions 2021-05-12 23:02:06 -07:00
relrelb 85b234003f avm1: Handle undefined/empty method name in NewMethod
Seems like it behaves similarly to CallMethod with an undefined/empty
method name.
2021-05-12 20:47:06 -07:00
relrelb 2589ecdde0 avm1: Correct ImplementsOp 2021-05-12 20:47:06 -07:00
relrelb 3bf3f1015d avm1: Return undefined on invalid count in InitArray and InitObject
Both InitArray and InitObject should bail-out without popping anything
off the stack when the elements/properties count is negative or greater
than or equals 2147483648.
2021-05-12 20:47:06 -07:00
relrelb 72531eddff avm1: Cleanup CallMethod 2021-05-12 20:47:06 -07:00
relrelb 2e0bc78cd6 avm1: Fix variadic arguments
Previously, if the arguments count was greater than the actual
stack size, then a stack underflow occurred which resulted in a
sequence of undefined values. That didn't match Flash's behavior.

Also, this prevents potential huge allocations that hang Ruffle.

In addition, num_args seems like it should use coerce_to_u32
(wraps at 4294967297). This also means that -1 ends up acting like
u32::MAX and would pop all values off of the stack.
2021-05-12 20:47:06 -07:00
dependabot[bot] 62301dea54 chore: Bump syn from 1.0.71 to 1.0.72
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.71 to 1.0.72.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.71...1.0.72)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-10 09:40:26 -07:00
Mike Welsh 6051ee4cb1 core: Disallow .. in shared object paths (fix #3961)
Toss out any shared objects that contain ".." in the name
to avoid accessing files outside of the Ruffle data directory.

The DiskStorageBackend also will fail any requests with a ".."
component as an extra precaution.

Fixes #3961.
2021-05-09 23:20:32 -07:00
CUB3D 61298b2be3 avm1: Add parsing of legacy json SharedObjects for backwards compatability 2021-05-09 23:20:32 -07:00
CUB3D f4a9446829 avm1: Fix tests for SharedObject 2021-05-09 23:20:32 -07:00
CUB3D c398aded68 chore: Remove debug printing 2021-05-09 23:20:32 -07:00
CUB3D cd1cde1708 avm1: Implement de/serialization of shared objects into Flash Player Lso format 2021-05-09 23:20:32 -07:00
relrelb 6b6b335440 avm1: Use bitflags for Array.sort flags 2021-05-08 01:37:05 -07:00
Mike Welsh ba7fd1b2b9 chore: Appease clippy, bump url
Bump url and avoid `Url::into_string` deprecation warnings.
Fix `single_char_pattern` clippy lints.
2021-05-07 20:51:26 -07:00
relrelb b2bc24919a avm1: Replace `current_swf_version` with `swf_version`
They happen to be identical, and `swf_version` is more idomatic.
2021-05-07 13:26:20 -07:00
Mike Welsh ef617eebad avm1: Use `set_html_text` when initializing textfield from a variable binding
If a textfield was created with a variable binding, and the variable
already existed, the initial text of the textfield is set to the
variable value. However, this was not obeying the HTML setting of
the text field, so HTML tags were mistakenly shown in some content.

Fixes #3522.
2021-05-06 16:58:33 -07:00
Adrian Wielgosik 5319a5bb81 Remove lifetime from constants 2021-05-06 10:54:33 -07:00
Adrian Wielgosik faa0e50e89 avm2: Unify NativeMethod and GenericNativeMethod 2021-05-06 10:54:33 -07:00
Adrian Wielgosik 46ddb9be82 avm2: Generate class traits from const arrays 2021-05-06 10:54:33 -07:00
Adrian Wielgosik 8312243f42 avm2: Don't repeatedly call class.write(mc) 2021-05-06 10:54:33 -07:00
Mike Welsh b82391726f avm1: MovieClip.getBytesLoaded/Total should return the clip's length
MovieClip.getBytesLoaded and getBytesTotal return the size of that
specific clip, even if it's not a loaded SWF.  The previous logic
only returned the size of the parent SWF.

If the clip is an SWF, the uncompressed size of the SWF is returned.
Otherwise, the length of the tag list inside the clip's DefineSprite
tag is returned.
2021-05-04 16:36:56 -07:00
Aaron Hill 08d0829177 Move all SWF tests out of `core` to new `tests` package
This allows `regressions_tests.rs` to depend on other crates in the
workspace, such as `render`, without introducing a cyclic dependency.

Split out from #4054
2021-05-04 11:47:59 -07:00
Mike Welsh f9769451d6 avm1: Handle CDATA sections in XML 2021-05-03 16:23:04 -07:00
Moulins 78627acc92 chore: Move core::property_map to core::avm1::property_map 2021-05-03 13:47:14 -07:00
Moulins 272841729e core: Replace SwfMovie's PropertyMap by a list of key-value pairs
PropertyMap is an AVM1-only concept, and shouldn't be used on cross-VM
types.
2021-05-03 13:47:14 -07:00
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