Commit Graph

4079 Commits

Author SHA1 Message Date
David Wendt c53130e940 avm2: Automatically select a given event's class based on it's data. 2022-01-22 19:58:32 -08:00
David Wendt ada093938e avm2: Expose `MouseEvent` as a system class. 2022-01-22 19:58:32 -08:00
David Wendt ac0f62d475 avm2: Implement `MouseEvent.stageX`/`stageY` 2022-01-22 19:58:32 -08:00
David Wendt 9ee263160a avm2: Implement `MouseEvent.relatedObject` 2022-01-22 19:58:32 -08:00
David Wendt 477b8fb87f avm2: Implement `MouseEvent.movementX`/`movementY` 2022-01-22 19:58:32 -08:00
David Wendt b612980ace avm2: Impl `MouseEvent.localX`/`localY` 2022-01-22 19:58:32 -08:00
David Wendt 948b591378 avm2: Stub `MouseEvent.isRelatedObjectInaccessible` 2022-01-22 19:58:32 -08:00
David Wendt a3c48c5e29 avm2: Implement `MouseEvent.delta` 2022-01-22 19:58:32 -08:00
David Wendt 22638f4aae avm2: Impl `MouseEvent.buttonDown` 2022-01-22 19:58:32 -08:00
David Wendt d790b138b0 avm2: Implement accessor methods for `altKey`, `commandKey`, `controlKey`/`ctrlKey`, and `shiftKey`. 2022-01-22 19:58:32 -08:00
David Wendt d9bbafb0bb avm2: Make `MouseEvent`'s constructor set event data based on it's parameters. 2022-01-22 19:58:32 -08:00
David Wendt 016cd6ccc0 avm2: Make event construction take an `EventData` parameter.
This also necessitated the introduction of a `FullScreenEvent` data type.
2022-01-22 19:58:32 -08:00
David Wendt 43161976c7 avm2: Add a new field to store mouse event data on dispatched events. 2022-01-22 19:58:32 -08:00
relrelb 164e1a38c0 core: Remove unnecessary parameter from `post_instantiation`
`display_object` was always equivalent to `self`, there's no need to
pass both.
2022-01-22 11:37:33 -08:00
Mike Welsh e11e1e870f avm1: Improve Object comparisons in SWFv5
SWFv5 always calls `Object.valueOf` at least once and sometimes
twice in the Equals2 op, even when comparing two Objects.

For example, `Object(1) == Object(1)` is true in SWFv5 but false
in SWFv6.
2022-01-21 16:40:19 -08:00
Mike Welsh bf599d9107 avm1: Clean up Value::abstract_eq
Consolidate several cases and fix some issues:
 * Object-to-primitive comparison always goes through `valueOf`.
 * `Object(undefined) == undefined` is true; this will coerce
   to a bare object with no `valueOf`, resulting in
   `undefined==undefined`.
 * `{valueOf:function() { return NaN; }} == NaN` is true.
2022-01-21 16:40:19 -08:00
Mike Welsh 4d8db1e64d avm1: Fix function closures inside `with`
When creating a scope for a closure, any `with` scopes were being
filtered out, but this was incorrect; `with` scopes are still on
the scope chain when the function is called.
2022-01-19 20:29:26 -08:00
relrelb 1de284dc5b html: Fix handling of end tag mismatch
Flash ignores mismatched end tags (i.e. end tags with a missing/different
corresponding start tag). `quick-xml` checks end tag mismatches by
default, but it cannot recover after encountering one.

Commit 7e20543578 already disabled
`quick-xml`'s check, but that caused mismatched `Event::End` to be
handled, which may empty `format_stack` and later panic on
`format_stack.last().unwrap()`.

Thus, check for mismatched end tags ourselves, in a similar manner
of `quick-xml`, but in a recoverable way.
2022-01-18 13:50:26 -08:00
David Wendt 57acf47a10 avm2: Allow access to stage properties without a valid root movie clip. 2022-01-18 11:06:23 -08:00
David Wendt df25d1ca8b avm2: Children of the root inherit their parent's `loaderInfo` 2022-01-18 11:06:23 -08:00
David Wendt f041cced72 avm2: The stage's loader info object allows access to `url`, `bytes`, and `parameters`. 2022-01-18 11:06:23 -08:00
Mike Welsh b181debff6 swf: Use bitflags for `avm1::GetUrl2` 2022-01-17 21:35:57 -08:00
Mike Welsh 4c3e14eae5 core: Clean up `DefineFunction` action
* Have `DefineFunction` and `DefineFunction2` go through the same
   code path by implementing `From<DefineFunction>` for
   `DefineFunction2`.
 * Change `register` to a `Option<NonZeroU8>` for size optimization.
 * Add `function::Param` to store param info instead of a tuple.
2022-01-17 21:35:57 -08:00
Mike Welsh c618a12d14 core: Remove _ pattern in `avm1::Activation::do_action`
The match is exhaustive, so replace `_` with `Action::Unknown`.
2022-01-17 21:35:57 -08:00
Mike Welsh 2b2346b65e swf: Add `avm1::Action::End`
Returning an `Action::End` instead of `None` when reading the end
of an action.
2022-01-17 21:35:57 -08:00
Mike Welsh 9141451ca1 swf: Use structs for avm1 `Action` variants
Use a struct for all variants of `avm1::Action`.
This makes the style more consistent instead of using a mix of
struct and tuple variants, and allows the data to be easily passed
around.
2022-01-17 21:35:57 -08:00
Adrian Wielgosik 5358940774 avm2: Support basic string.replace
Supports:
- string.replace(string, string)
- string.replace(regex, simple_string)

Does not support:
- string.replace(regex, string_with_replacement_codes)
- string.replace(any, function)
2022-01-17 20:10:20 -08:00
relrelb 3b25a3b901 avm1: Correct `MovieClipLoader.getProgress`
Handle strings, numbers and DisplayObject targets.
Return compressed length rather than uncompressed length.
2022-01-15 13:08:01 -08:00
relrelb eb23f19fad avm1: Correct `MovieClipLoader.unloadClip`
Handle strings, numbers and DisplayObject targets.
2022-01-15 13:08:01 -08:00
relrelb 0da8e504ab avm1: Correct `MovieClipLoader.loadClip`
Handle strings, numbers and DisplayObject targets (not just MovieClips).
To support non-MovieClip targets, turn `clip.as_movie_clip().unwrap()`
to `if let Some(mc) = clip.as_movie_clip()` in `Loader`.
2022-01-15 13:08:01 -08:00
relrelb e9607cfcbb chore: Appease clippy 2022-01-15 11:16:24 -08:00
relrelb 25722e7abe avm1: Fix `onLoadInit` event order
`onLoadInit` is queued after all `DoAction`s of the loaded clips.
That is, if clip1, clip2, clip3 are loaded in the same frame
(in this order), then actions will be executed as follows:

* `DoAction` of clip3
* `DoAction` of clip2
* `DoAction` of clip1
* `onLoadInit` of clip3
* `onLoadInit` of clip2
* `onLoadInit` of clip1

Previously, those were incorrectly executed as follows:

* `DoAction` of clip3
* `onLoadInit` of clip3
* `DoAction` of clip2
* `onLoadInit` of clip2
* `DoAction` of clip1
* `onLoadInit` of clip1
2022-01-14 17:27:14 -08:00
TÖRÖK Attila 12f9bec194 chore: Bump h263-rs git reference
To make use of https://github.com/ruffle-rs/h263-rs/pull/17
2022-01-14 17:09:39 -08:00
Mike Welsh 232f1dd120 chore: Appease clippy 2022-01-10 23:37:11 -08:00
dependabot[bot] 8f53449762 build(deps): bump indexmap from 1.7.0 to 1.8.0
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.rst)
- [Commits](https://github.com/bluss/indexmap/compare/1.7.0...1.8.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-10 22:08:19 -08:00
dependabot[bot] 491cc05a79 build(deps): bump syn from 1.0.84 to 1.0.85
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.84 to 1.0.85.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.84...1.0.85)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-10 22:07:29 -08:00
relrelb b39ab9034c core: Remove `Player::is_mouse_down`
Now that `InputManager` tracks the mouse button, it can be used
instead.
2022-01-10 01:18:49 -08:00
relrelb 573aa89c9a core: Handle mouse events in `InputManager::handle_event` 2022-01-10 01:18:49 -08:00
relrelb 82b4c6ef27 core: Support mouse buttons in `KeyCode`
Add `MouseLeft`, `MouseRight` and `MouseMiddle` to `KeyCode` for
AVM1's `Key.isDown()` function.
2022-01-10 01:18:49 -08:00
relrelb 6396c21bc0 core: Rename `PlayerEvent::MouseLeft` to `MouseLeave`
So it's not consfusing with `KeyCode::MouseLeft`.
2022-01-10 01:18:49 -08:00
relrelb c00532aed2 core: Cleanup mouse update logic
Move code that is exclusive to mouse events from
`Player::update_mouse_state` to `Player::handle_event`.
2022-01-10 01:18:49 -08:00
Adrian Wielgosik 86210363f0 avm2: Remove Object::derive() machinery for AS3 prototypes 2022-01-09 18:23:10 -08:00
relrelb b79144c122 avm1: Remove `TextFormatObject::set_text_format`
Use `text_format_mut` instead.
2022-01-10 00:26:33 +02:00
Mike Welsh 2653c5f5c3 audio: Handle gaps in MP3 SoundStreamBlock tags (fix #3817)
An MP3 "stream" sound can sometimes have frames without a
SoundStreamBlock tag, despite the SWF spec saying there should
at least be a tag with 0 samples on each frame. Ruffle would
stop the sound in this case, but the Flash Player may or may not
stop thje sound in the audio depending on the number of "empty"
frames. This could cause the audio to stutter as it continuously
stopped and restarted.

Handle this by keeping track of how many samples we've encountered
in MP3 blocks, and deducting the amount of samples consumed by each
timeline frame. Stop the sound if we run out of samples, as opposed
to when we hit a frame without a SoundStreamBlock.

Fixes #3817.
2022-01-07 13:23:53 -08:00
Mike Welsh b2f7c98f88 audio: Sync animation with embedded audio streams
This is a first pass at syncing animation and audio playback when
and embedded audio stream is playing.

Fixes #3020, #3663, #3958.
2022-01-07 13:23:53 -08:00
relrelb 8c736b9756 avm1: Fix `MovieClipLoader` event arguments
The first argument of all events is the target MovieClip. It was
incorrect.

Also, `onLoadComplete` accepts an additional `httpStatus` argument.
Stub it to 0.
2022-01-07 10:39:16 -08:00
relrelb e045a9502b core: Small cleanup in `Loader`
Remove unnecessary calls to `introduce_loader_handle`, which are
dominated by `add_loader` that already calls it. As a result, `add_loader`
remained the only function to call `introduce_loader_handle`, so inline
it there.
2022-01-07 10:39:16 -08:00
relrelb c05ff4cbc8 core: Unify `Loader::Xml` into `Loader::LoadVars`
Since they are identical (they both load the URL as a string, then
fire the `onHTTPStatus` and `onData` events). In fact, AVM1's
`XML.prototype.load` and `LoadVars.prototype.load` functions are
both defined as `ASnative(301, 0)`, so they invoke the same native
code under the hood.
2022-01-07 09:51:27 -08:00
dependabot[bot] a9e86a73cf build(deps): bump serde from 1.0.132 to 1.0.133
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.132 to 1.0.133.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.132...v1.0.133)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-03 23:28:57 +02:00
dependabot[bot] 6533511994 build(deps): bump quote from 1.0.10 to 1.0.14
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.10 to 1.0.14.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.10...1.0.14)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-03 22:50:58 +02:00
Mike Welsh 34ed9cbbaa core: Fix incorrect closing of paths in drawing API (fix #5598)
The path starting position was not being set correctly after a
moveTo command, which could cause stray strokes to appear in the
drawing.

Fixes #5598, #5768, #5957.
2022-01-01 22:24:08 -08:00
relrelb 655adedc1c xml: Remove `XmlNode::is_as2_compatible`
Now all `XmlNodeData` types are AS2-compatible, so `is_as2_compatible`
always returns `true`.
2022-01-02 07:36:49 +02:00
relrelb 30cd2aa4f1 xml: Remove `XmlNodeData::DocType`
`XmlNode::is_as2_compatible` returns `false` for `XmlNodeData::DocType`
nodes, which means they are not included in string representations of
XML documents, and they cannot be traversed using the DOM methods.

So don't create those when parsing an XML from string, but still
store the `DOCTYPE` declaration string on the `XmlDocument`, which
is accissible through the `.docTypeDecl` property.
2022-01-02 07:36:49 +02:00
relrelb 827bb6e48e xml: Remove `XmlNodeData::Comment`
`XmlNode::is_as2_compatible` returns `false` for `XmlNodeData::Comment`
nodes, which means they are not included in string representations of
XML documents, and they cannot be traversed using the DOM methods.

So simply don't create those when parsing an XML from string.
2022-01-02 07:36:49 +02:00
relrelb e477fca9e4 xml: Use OR patterns
This results in a slightly shorter code, and avoids some duplication.
2021-12-31 19:00:12 +02:00
relrelb 8bd144ec88 xml: Make `XmlDocumentData::root` non-`Option`
Since `XmlNode::document` doesn't exist anymore, so as the circular-
reference between `XmlDocument` and `XmlNode`.
2021-12-31 19:00:12 +02:00
relrelb 3676db47a3 xml: Remove unused `XmlNode::document` 2021-12-31 19:00:12 +02:00
relrelb f7e80e3fb9 xml: Inline `XmlDocument::add_child_to_tree`
Include the XML root node itself as part of the stack, so appending
children to it is no longer considered a special case.
2021-12-31 09:35:09 +02:00
relrelb e1198bd30c xml: Inline `XmlDocument::process_event`
Now that `replace_with_str` is defined in `XmlDocument`, there is
no need anymore for a separate function that handles nodes which have
document-wide implications.
2021-12-31 09:35:09 +02:00
relrelb 7d148fb61d xml: Move `XmlNode::replace_with_str` to `XmlDocument`
It only makes sense to call this method on document roots.
2021-12-31 09:35:09 +02:00
Adrian Wielgosik fcab60de7e core: register non-ascii fonts lazily 2021-12-31 01:10:48 +01:00
relrelb 0bab5f6d91 avm1: Use `XmlObject`
Previously Ruffle's AVM1 runtime incorrectly permitted calling `XML`
functions on `XMLNode` objects. For example:

```as
var xml = new XML("<a><b></b></a>");
trace(XML.prototype.createElement.call(xml.firstChild, "aaa")); // traces "undefined" in Flash, but "<aaa />" in Ruffle before this commit.
```

Disallow this by using the newly-reintroduced `XmlObject` for `XML` objects
(rather than `XmlNodeObject` that represents also `XMLNode` object), and check
for it in all `XML` builtins.
2021-12-30 22:13:14 +02:00
relrelb b501b4697a avm1: Re-introduce `XmlObject`
The newly-reintroduced `XmlObject` will represent `XML` document objects.
Currently it's unused, but the following commit will make use of it.
2021-12-30 22:13:14 +02:00
TÖRÖK Attila 09ca48e389 chore: Bump h263-rs git reference 2021-12-30 16:22:27 +01:00
TÖRÖK Attila 6f68938591 video/vp6: Fix keyframe detection on Vp6WithAlpha videos 2021-12-29 11:28:05 +01:00
dependabot[bot] 56b340ebf5 build(deps): bump syn from 1.0.82 to 1.0.84
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.82 to 1.0.84.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.82...1.0.84)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-27 22:32:21 +02:00
relrelb e547fd710d xml: Remove `XmlName`
Instead use a much simpler approach using `XmlNode::local_name` and
`XmlNode::prefix`.
2021-12-27 20:53:34 +02:00
relrelb 6ca1ac05da avm1: Rename `XmlObject` to `XmlNodeObject`
The name `XmlObject` will be re-used in a future PR for `XML`
document objects.
2021-12-27 20:53:34 +02:00
Moulins 74ab24c0c3 core: fix wide string handling in html::text_format
Closes #5839
2021-12-21 22:19:13 +02:00
Adrian Wielgosik 4230d1f19f avm2: Add Mouse.hide(), Mouse.show() 2021-12-21 17:32:57 +01:00
dependabot[bot] fd816f3a0a build(deps): bump serde from 1.0.131 to 1.0.132
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.131 to 1.0.132.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.131...v1.0.132)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-21 08:35:54 +02:00
relrelb b1151b2ab2 html: Rewrite `FormatSpans::to_html`
The new implementation doesn't use the `xml` crate, nor `quick-xml`,
but rather just iterates the `TextSpan`s and builds the formatted HTML
string.
2021-12-20 08:31:59 +02:00
relrelb 2ad5c644b0 avm1: Make `ArrayObject` proto non-`Option`
It was always passed as `Some`, so there's no reason for allowing
`None`.
2021-12-18 13:39:22 +02:00
relrelb 9d87a34f25 html: Ignore tag errors
Flash stops parsing the XML in such cases, but still returns the
partially-processed text.
2021-12-18 11:34:31 +02:00
relrelb c1404f6a3e html: Expand empty elements
`quick-xml` has a feature to split empty elements into an `Open` and
a `Close` event. Use it to avoid duplicated code.
2021-12-18 11:34:31 +02:00
relrelb 7e20543578 html: Don't check end names
Flash permits mismatched closing tags (e.g. `<mytag></different_tag>`),
so turn-off this check.
2021-12-18 11:34:31 +02:00
Adrian Wielgosik 5d81a0ce64 avm2: Remove .clone() calls now that Index is Copy 2021-12-17 21:09:40 -07:00
Adrian Wielgosik a8fb1c2b16 avm2: pass Multiname to resolve_type() by reference 2021-12-17 21:09:40 -07:00
Adrian Wielgosik 22a0711d85 avm2: Use TU's method cache for callstatic, newfunction opcodes 2021-12-17 21:09:40 -07:00
Adrian Wielgosik 4b23f4dfb7 avm2: Set correct value type in op_convert_u/i 2021-12-17 21:06:33 -07:00
TÖRÖK Attila 0a2767fcb4 video: Wire up DefineVideoStream smoothing flag to the renderer
With all the weird logic for when it actually takes effect
2021-12-17 21:03:57 -07:00
David Wendt 2aee3555ab chore: Fix all new clippy lints added in latest Rust nightly 2021-12-17 20:53:26 -07:00
relrelb 07c5330456 core: Introduce `InputManager`
`InputManager` encapsulates the common logic that previously the
`UiBackend`s used to implement.
2021-12-15 14:20:30 -08:00
Adrian Wielgosik 726ec47f19 avm2: Support inheritance of protected traits 2021-12-15 22:26:41 +01:00
Adrian Wielgosik 11534a4b34 avm2: Implement parseInt, parseFloat 2021-12-15 22:16:49 +01:00
Adrian Wielgosik 49feb23649 avm2: Move toplevel functions to separate file 2021-12-15 22:16:49 +01:00
TÖRÖK Attila 95665bdc47 video: Extract software decoders (or glue) into their own modules, add screenvideo feature 2021-12-14 19:41:17 -07:00
TÖRÖK Attila fdc448533d video: Add Flash Screen Video (V1 only) decoder
Thanks a lot for the code and the help, Kostya!
2021-12-14 19:41:17 -07:00
Toad06 db98f0b42f avm1: Use inner SWFs version number 2021-12-14 19:39:30 -07:00
dependabot[bot] c6dfcb4e37 build(deps): bump serde from 1.0.130 to 1.0.131
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.130 to 1.0.131.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.130...v1.0.131)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-13 23:23:13 +02:00
dependabot[bot] b8ff8bb185 build(deps): bump jpeg-decoder from 0.2.0 to 0.2.1
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.0 to 0.2.1.
- [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.2.0...v0.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-13 23:23:01 +02:00
dependabot[bot] ef679d25c7 build(deps): bump encoding_rs from 0.8.29 to 0.8.30
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.29 to 0.8.30.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.29...v0.8.30)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-13 23:22:28 +02:00
EmperorBale 30f2e0f8b1
avm2: Implement JSON (#5172)
* avm2: Implement JSON.parse

* avm2: Add AvmSerializer for serializing AVM values to JSON

* avm2: Add support for replacer objects

* avm2: use *const ObjectPtr for object stack

* avm2: Add support for space parameter is JSON.stringify

* avm2: Refactor AvmSerializer design

* avm2: Restrict spaces to a maximum of 10

* avm2: Refactor map_value

* tests: Add JSON.parse test

* chore: Appease clippy

* avm2: Check if value is undefined before inserting

* tests: Add test for JSON.stringify

* tests: Improve JSON.stringify test

* chore: Replace map_or with explicit match statements

* chore: Use QName::dynamic_name

* avm2: Use Object<'gc> instead of ObjectPtr

* chore: Use explicit match in deserialize_value

* Rebase fixes

Co-authored-by: Adrian Wielgosik <adrian.wielgosik@gmail.com>
2021-12-13 18:32:04 +01:00
Adrian Wielgosik ad1442dbaa avm2: Add a basic ContextMenu stub 2021-12-13 18:31:03 +01:00
Adrian Wielgosik 1f5979f168 chore: clippy 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 1311b0a3d0 avm2: refactor Domain::get_defining_script 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 0fb075a309 chore: cargo fmt 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 3d8f611651 avm2: Update comments. 2021-12-11 20:48:09 +01:00
Adrian Wielgosik b747541709 avm2: Panic upon encountering CallMethod opcode 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 1d8c556944 avm2: Handle TODOs, throw errors where applicable 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 24247dff0b avm2: install_const_late always appends slots 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 4bd12ae4b3 avm2: Get prototypes from classes without get_property() 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 49d16dea8b avm2: Rip out `receiver` from get/set/call_property 2021-12-11 20:48:09 +01:00
Adrian Wielgosik ee0798b258 avm2: Cleanup slots/global initialization some more 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 21865edf9b avm2: Support const slots, fill some TODOs 2021-12-11 20:48:09 +01:00
Adrian Wielgosik b272d8722e avm2: Reword slot/disp_id assignment, remove Slot. 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 4d8999c012 avm2: Make all prototypes ScriptObjects; also cleanup vector enumeration, Proxy 2021-12-11 20:48:09 +01:00
Adrian Wielgosik 3706db86d2 avm2: move properties from instances to vtable 2021-12-11 20:48:09 +01:00
relrelb d3fe4ea59a avm1: Split `XML` and `XMLNode` definitions
This reduces the file size of the previous `xml.rs` file, and makes
the code a bit more organized.
2021-12-11 20:28:37 +02:00
Adrian Wielgosik 6594d4159d avm2: Use Vec instead of HashMap for loaded constants 2021-12-11 10:03:29 +01:00
relrelb ca3b215561 chore: Appease clippy 2021-12-10 21:06:38 +02:00
relrelb 7966d850dd core: Normalize `\r` to `\n` in `avm_trace`
Fixes #3120.
2021-12-10 19:54:35 +02:00
relrelb eacf34d80a avm1: Remove `Function.prototype.toString`
`Function.prototype` doesn't have its own `toString` method, but
rather inherts it from `Object.prototype`. So remove `Function.prototype.toString`
and move its logic to `Object.prototype.toString`.
2021-12-10 11:36:39 +02:00
relrelb ce2eff8b25 render: Stub L16 JPEG pixel format
16-bit luminance (grayscale) images are very rare, so it's hard to
tell what the expected behavior should be.
2021-12-10 00:28:45 +02:00
dependabot[bot] 8007f21ffe build(deps): bump jpeg-decoder from 0.1.22 to 0.2.0
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.1.22 to 0.2.0.
- [Release notes](https://github.com/image-rs/jpeg-decoder/releases)
- [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/image-rs/jpeg-decoder/compare/v0.1.22...v0.2.0)

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

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

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

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

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

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

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

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

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

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

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

* Run 'cargo format --all'

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

To limit the impact on performance, the regex, the string we're
currently matching on, and the last known (utf8, utf16) positions
are cached, avoiding extra utf8 conversions in common use cases
where a single string is repeatedly searched with increasing
`lastIndex`.
2021-11-27 11:20:47 -07:00
Moulins 23cbe4c2fd core: Add `string::Pattern` trait, based on `std::str::Pattern`
This allows `Str::{find, rfind, split}` to accept multiple types
2021-11-27 11:20:47 -07:00
Moulins 110f568aa4 core: Remove some useless utf8<->utf16 conv. in {avm1,avm2}/activation.rs 2021-11-27 11:20:47 -07:00
Moulins 8885175550 core: Replace string::utils *_ignore_case functions by methods on WStr 2021-11-27 11:20:47 -07:00
Moulins 79d47a9863 avm1: Requires a WStr<'_> to access PropertyMap 2021-11-27 11:20:47 -07:00
Moulins 7f4af210b8 core: Reimplement AVM string methods using our UCS2 API
This generally means that methods are more efficient, as we
don't need to encode to UTF16 on-the-fly to have correct indices.

This also fix some bugs:
 - charCode now properly handle surrogate pairs
 - calling lastIndexOf with the empty pattern and an OoB index now
properly returns the string length

Still missing is AVM2's String.match
2021-11-27 11:20:47 -07:00
Moulins 32fa20b857 core: Make AvmString "two-headed" by storing a UTF8 and an UCS2 string
This is only temporary; once all code paths use the ruffle `WString` API
instead of dereferencing to a string, the UTF8 `String` will be removed.
2021-11-27 11:20:47 -07:00
Moulins 3d20c4acc7 core: Add owned string::WString type 2021-11-27 11:20:47 -07:00
Moulins c1ccd3a3ac core: Introduce `WStr` and `WStrMut` types, for representing Flash strings
These types represent an UCS2 string (UTF-16 with unpaired surrogates).

The string is stored either as a sequence of u8s (Bytes) or u16s (Wide);
the type of string is tracked by setting the high bit of the length of
its fat pointer.
2021-11-27 11:20:47 -07:00
relrelb b32ec3cf6c audio: Calculate sound transform values using 30-bit integers
The fix in #5218 wasn't sufficient; 30-bit arithmetic should be used
along all the way when calculating an effective sound transform.

For example, a sound transform composited by volumes `-0x80000000` and
`25` should end up as effectively 0, whereas previously it would have
been calculated as `-0x80000000 * 25 / 100 = -0x20000000`, which is a
30-bit integer that hasn't been truncated.

Fixes #5655.
2021-11-27 12:09:33 +02:00
relrelb e2b821e92f chore: Replace `min` + `max` with `clamp`
`clamp` is a bit more efficient, in both runtime and size terms.
2021-11-26 20:54:48 +02:00
relrelb 41eb215b02 chore: Avoid using `std::char`
Use the `char` primitive type instead.
2021-11-26 10:45:30 +02:00
relrelb dc6d4804ff core: Avoid odd import 2021-11-26 10:45:30 +02:00
relrelb 0a3ede31dc core: Remove unused `Downcast` 2021-11-26 10:45:30 +02:00
relrelb 79a0ba31ae avm1: Use `.unwrap_or(&Value::Undefined)` in more places 2021-11-26 10:45:30 +02:00
Adrian Wielgosik f35b2666a3 build: Use the 'union' SmallVec feature for minor memory savings 2021-11-26 00:45:09 +01:00
relrelb 79deba87f3 avm1: Small cleanup in `start_drag` 2021-11-25 07:35:33 +02:00
relrelb a2aeadf9e1 core: Small cleanups in `Player::handle_event`
* Use `match` for AVM debug key combos.
* Remove redundant `if let Some(button_event)` inside an `if button_event.is_some()`.
2021-11-25 07:35:33 +02:00
relrelb cbce91365c desktop: Track `keys_down` by `KeyCode`
This makes `DesktopUiBackend::is_key_down` a simple one-line check.
Also unify the handling code of `ElementState::Pressed` and `ElementState::Released`,
which had a lot of common code.
2021-11-25 07:35:33 +02:00
Adrian Wielgosik da4ed75bc8 avm2: Compare QNames by local name first 2021-11-22 17:59:00 -07:00
Adrian Wielgosik c2d521df41 avm2: refactor: Merge has-setter-and-no-getter into one lookup 2021-11-22 17:59:00 -07:00
Adrian Wielgosik 370186dc3c avm2: refactor: Make trait lookups return a single item 2021-11-22 17:59:00 -07:00
TÖRÖK Attila 0e4d2d48f5 video/vp6: Don't throw an error on skip frames, reuse the last frame instead 2021-11-22 17:08:31 +01:00
relrelb 56b5183262 avm1: Refactor and fix `BitmapData::compare` 2021-11-20 14:11:14 +02:00
bbb651 687069ba7d avm1: Added BitmapData::compare 2021-11-20 14:11:14 +02:00
relrelb 3760e0e275 core: De-duplicate `round_to_even` function
Put a single implementation in `ecma_conversions.rs`.
Need to consider what to do with the similar implementation in `matrix.rs`.
2021-11-20 13:36:06 +02:00
relrelb 7c6d006862 avm2: Correct `TextFormat` properties coercion 2021-11-20 13:36:06 +02:00
relrelb 10b7c69719 avm1: Correct `TextFormat` properties coercion 2021-11-20 13:36:06 +02:00
David Wendt 068e7acc6f avm2: Remove the need for `lazy_static` 2021-11-19 20:43:53 -07:00
David Wendt dda8a73899 avm2: Refactor so we don't need to rebox and unbox the numbers into values.
Also, use an actual constant table for the ellipsises.
2021-11-19 20:43:53 -07:00
David Wendt 4665a6c210 avm2: None of `Graphics`' methods need to be `pub`. 2021-11-19 20:43:53 -07:00
David Wendt c719e69693 avm2: Also implement `drawEllipse` using `drawRoundRect`. 2021-11-19 20:43:53 -07:00
David Wendt ef46d780ba avm2: Implement `Graphics.drawCircle` using `drawRoundRect` 2021-11-19 20:43:53 -07:00
David Wendt b318eb9969 avm2: Implement `Graphics.drawRoundRect` 2021-11-19 20:43:53 -07:00
relrelb 24db13ae1e html: Handle self-closing tags
"br" and "sbr" tags can appear in a self-closing form (i.e. `<br />`).
Commit 3cab464026 forgot to handle this.
2021-11-15 23:28:51 +02:00
relrelb 855bc721a8 html: Restore handling of "br" tags
This fully reverts commit 2119ce9.
Seems like Flash does handle "br" tags, but ignores them under some
unknown circumstances (e.g. setting `htmlText` in AVM1).
For now handle "br" tags unconditionally.
2021-11-15 23:28:51 +02:00
relrelb 73f5982cad avm1: Fix `Sound.setVolume()` and `Sound.setPan()` with no arguments
Instead of coercing `undefined` into `f64` (which results `NaN` in SWF7+),
treat the missing value argument as `0`.
2021-11-14 20:25:45 +02:00
relrelb df514f319a html: Restore handling of "sbr" tags
This partially reverts commit 2119ce9821,
only restoring "sbr" tags handling because Flash seems to ignore only
"br" tags.
2021-11-13 12:11:48 +02:00
relrelb 2119ce9821 html: Remove handling of "br" and "sbr" tags
Seems like Flash just ignores them.
2021-11-13 10:21:41 +02:00
relrelb 12e8d3a82f html: Fix typo 2021-11-13 10:21:41 +02:00
David Wendt c0874f445d avm2: Functions are functions. 2021-11-11 17:12:49 -07:00
David Wendt 7dd9776d40 avm2: Implement `uint`, `Number`, and `Boolean`'s constructors, too. 2021-11-11 16:34:11 -07:00
David Wendt 7cc7f0fe7f avm2: Impl `int`'s instance initializer. 2021-11-11 16:34:11 -07:00
David Wendt be3e126ebb avm2: Stub the `Sprite` constructor as just creating a `MovieClip`. 2021-11-11 16:33:33 -07:00
Tal Hayon 7ed38850fd core: implement displayState for Stage in avm1/2 2021-11-11 16:20:05 -07:00
relrelb 7b95441874 core: Re-use `EditText::html_text` in `EditText::propagate_text_binding` 2021-11-11 08:05:33 +02:00
relrelb cf05137c1f core: `EditText::html_text` cannot fail 2021-11-11 08:05:33 +02:00
relrelb 848b721165 xml: Remove `XmlNode::walk` 2021-11-11 08:05:33 +02:00
relrelb c4729d733c core: Avoid one usage of `FormatSpans::replace_text`
Use `FormatSpans::from_text` instead.
2021-11-11 08:05:33 +02:00
relrelb 3cab464026 core: Use `quick-xml` directly when creating `FormatSpans` 2021-11-11 08:05:33 +02:00
relrelb 8c64951b15 core: Remove unused `EditText::document` 2021-11-11 08:05:33 +02:00
relrelb a900aae63e core: Make `EditText::set_html_text` accept a `&str` 2021-11-11 08:05:33 +02:00
relrelb 0787662079 core: Make `EditText::set_text` accept a `&str` 2021-11-11 08:05:33 +02:00
David Wendt 67e7526517 avm2: `EventDispatcher` contains an undocumented `toString` method. 2021-11-10 18:16:26 -07:00
David Wendt 360ae1f044 avm2: Private classes in different scripts are allowed to share the same name without conflicting. 2021-11-10 17:43:02 -07:00
David Wendt 60eb88b326 avm2: Note currently incorrect behavior intended to be fixed in a future PR. 2021-11-09 17:28:33 -07:00
David Wendt 4cfa3253d5 avm2: Impl `Proxy`'s enumeration-related methods. 2021-11-09 17:28:33 -07:00
David Wendt 4289f89350 avm2: Split out enumerant values into a separate method as well. 2021-11-09 17:28:33 -07:00
David Wendt 297526269c avm2: Allow objects to assign arbitrary enumerant indexes, by having objects drive the enumeration process rather than just counting from one 2021-11-09 17:28:33 -07:00
David Wendt 1170385c3b avm2: Implement `Proxy.hasproperty` 2021-11-09 17:28:33 -07:00
David Wendt 427b2bf17a avm2: Implement `Proxy.deleteproperty` 2021-11-09 17:28:33 -07:00
David Wendt 503dc08594 avm2: Refactor `Object.delete_property` to work similar to get/set 2021-11-09 17:28:33 -07:00
David Wendt e67ca1afe0 avm2: Implement `Proxy.callproperty` 2021-11-09 17:28:33 -07:00
David Wendt 301fd1020f avm2: Implement `Proxy.setproperty` 2021-11-09 17:28:33 -07:00
David Wendt 8f47f494e7 avm2: Implement `Proxy`'s `getproperty` behavior. 2021-11-09 17:28:33 -07:00
David Wendt f05e92c974 avm2: Fix `RTQNameL`'s parameters being popped backwards 2021-11-09 17:28:33 -07:00
David Wendt d225d03043 avm2: Implement `flash.utils.Proxy` 2021-11-09 17:28:33 -07:00
David Wendt 51af0f708f core: Remove commented-out helper methods. 2021-11-09 16:48:29 -07:00
David Wendt c78e5e31fd core: Store `DisplayObjectBase` in `InteractiveObjectBase`.
This also necessitated removing the `impl_display_object` family of macros, as you cannot name a field of a field in a macro expression. I tried. So instead I've reverted to standard default method inheritance, in the same way we did with AVM2 objects.
2021-11-09 16:48:29 -07:00
David Wendt 2ea35dcbb1 avm2: Enforce the `mouseEnabled` flag. 2021-11-09 16:48:29 -07:00
David Wendt b2e0586252 docs: Document the current event-handling flow in `Player`. 2021-11-09 16:48:29 -07:00
David Wendt bb8ca8f136 core: Move `handle_clip_event` to `TInteractiveObject`, and split it into three pieces.
`handle_clip_event` is now a default trait method that calls three methods in order:

 * `filter_clip_event`, to determine which events that either this object or it's children may handle
 * `propagate_to_children`, to check if any children of this object want to handle an event. (This also includes AVM2 button states, which are not technically "children" in the usual sense...)
 * `event_dispatch`, which does the actual "object reacts to an event" bit if no child handles the object.

These roughly correspond to phases of existing event-handling objects pre-`InteractiveObject`.
2021-11-09 16:48:29 -07:00
David Wendt 95f105aadd core: `Stage`, `EditText`, and `Avm2Button` should also be interactive objects. 2021-11-09 16:48:29 -07:00
David Wendt e71c749db5 avm2: Implement accessors for new `InteractiveObject` flags. 2021-11-09 16:48:29 -07:00
David Wendt 618c32f859 core: Add `InteractiveObject` trait for objects that can receive input events 2021-11-09 16:48:29 -07:00
relrelb 89718475df avm2: Introduce `TextFormatObject` 2021-11-09 16:21:35 -07:00
relrelb 9308513ae8 chore: Appease clippy 2021-11-06 10:44:01 +02:00
David Wendt 6c7d10e4d4 avm2: Requests for instance traits instead resolve to an associated public-namespace method 2021-11-02 16:54:38 -06:00
dependabot[bot] 0ef702d415 build(deps): bump syn from 1.0.80 to 1.0.81
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.80 to 1.0.81.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.80...1.0.81)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-02 07:02:06 +02:00
Mike Welsh c6e6de4a47 core: Unclosed fills in Drawing API should auto-close 2021-10-31 19:01:55 -07:00
Mike Welsh 8cf0f9b7b1 avm1: duplicateMovieClip copies drawings (fix #5487)
duplicateMovieClip also clones the drawing API state of the clip,
including in-progress drawing and style info.

Fixes #5487.
2021-10-31 19:01:55 -07:00
Mike Welsh 0e4b0f7c62 avm1: Allow duplicateMovieClip on dynamically created clips
Previously duplicating a clip created with `createEmptyMovieClip`
would fail.
2021-10-31 19:01:55 -07:00
David Wendt b0b1c79143 avm2: Split the `slot_id` and `disp_id` accessors. 2021-10-31 00:52:58 -07:00
David Wendt 0cc55df5ca avm2: Remove `FINAL` flag and associated machinery as we now validate traits at class construction time. 2021-10-31 00:52:58 -07:00
David Wendt a1be42abfb avm2: Exempt system classes from class validation. 2021-10-31 00:52:58 -07:00
David Wendt dd4717e08e avm2: Move `final`/`override` check enforcement to class construction time.
This is an O(n^2) algorithm, which sucks, but at least it only runs once per class rather than per *object allocation*.
2021-10-31 00:52:58 -07:00
David Wendt 8d40e41ee1 avm2: Make `Executable` zero-alloc 2021-10-31 00:52:58 -07:00
David Wendt cea3997396 avm2: Remove `superclass_object` and related parameters from `TObject.call` and other downstream functions.
Turns out there's a *lot* of downstream functions.
2021-10-31 00:52:58 -07:00
David Wendt 272b1784b8 avm2: Don't skip method binding in `callproperty` if the method requires `arguments`, as it may access `callee`. 2021-10-31 00:52:58 -07:00
David Wendt 1b5869e15a avm2: Preserve ability to `callmethod` on slot IDs that have not yet been bound, by binding them at that time. 2021-10-31 00:52:58 -07:00
David Wendt d0d19bcf38 avm2: Stop instantiating methods at object construction time. 2021-10-31 00:52:58 -07:00
David Wendt bfbd2271b0 avm2: Allow uninstantiated methods to be created on-the-fly. 2021-10-31 00:52:58 -07:00
David Wendt 3562c50dee avm2: `call_property` on classes should also call unbound methods 2021-10-31 00:52:58 -07:00
David Wendt 477add3dd0 avm2: Add `ClassObject` methods for pulling unbound methods or bound method objects from the class or instance. 2021-10-31 00:52:58 -07:00
David Wendt 9c031070b3 avm2: `ClassObject` should include class traits in `TObject` methods that reference the current object's traits. 2021-10-31 00:52:58 -07:00
David Wendt 74fb965301 avm2: Call methods directly if we can find a class with an instance trait matching it's name. 2021-10-31 00:52:58 -07:00
David Wendt 039777c41e avm2: `Object.hasOwnProperty`, `propertyIsEnumerable`, and `setPropertyIsEnumerable` only work with public-NS properties. 2021-10-30 11:44:29 -06:00
relrelb 9aed0e7db4 core: Reset `TextFormat.color` alpha
Since `TextFormat.color` should preserve the alpha value, and the AVM1
getter/setter no longer reset it, we need to reset it in other places:

* `TextField.textColor` setter.
* `EditText` SWF tag handling.
* HTML parsing.

And to set it explicitly to 255 in `LayoutBox::as_renderable_text`.
2021-10-30 10:03:36 -07:00
relrelb 34d1fa5226 avm1: Introduce `TextFormatObject`
`TextFormat` objects differ from regular objects in that
`TextField.setTextFormat` and `TextField.setNewTextFormat` accept
only the former, and ignore the latter.

Also, `TextFormat.prototype` has native accessors that coerce the
values on get/set.
2021-10-30 10:03:36 -07:00
Mike Welsh bc801b2b32 avm1: GotoFrame2 after bogus SetTarget affects _root
For example, `tellTarget("bogus!!!") { var n = 2; gotoAndPlay(n); }`
should cause the _root clip to go to frame 2.

Fixes the character freezing in Steppenwolf 3-1 mentioned in #4585.
2021-10-28 10:18:18 -07:00
Mike Welsh 2e3154baa0 avm1: tellTarget should fail if base clip is removed
`tellTarget` to other clips should fail if the current base clip
has been removed. All properties of the clip return `undefined`
at this point, so traversing the target path should fail.

Fixes soft-lock in Steppenwolf 2-1 as mentioned in #4452.
2021-10-28 10:18:18 -07:00
EmperorBale 5ac8e75239 avm2: Make ObjectEncoding C-like 2021-10-25 16:32:55 -07:00
EmperorBale bab74f83fc avm2: Remove all unsafe from bytearray 2021-10-25 16:32:55 -07:00
EmperorBale 9126c9297c avm2: Derive PartialEq and Eq for enums 2021-10-25 16:32:55 -07:00
EmperorBale 69f2002d2a avm2: Add todo comment 2021-10-25 16:32:55 -07:00
EmperorBale da601a4984 chore: Improve safety comments 2021-10-25 16:32:55 -07:00
EmperorBale 3b2a84ef9b chore: Small cleanups 2021-10-25 16:32:55 -07:00
EmperorBale b257e5537c chore: Appease clippy 2021-10-25 16:32:55 -07:00
EmperorBale 42fe351c0d avm2: Optimize readBytes & writeBytes by implementing write_at_within 2021-10-25 16:32:55 -07:00
EmperorBale e86bdfdc3e avm2: Remove unneeded condition 2021-10-25 16:32:55 -07:00
EmperorBale 3f3e600820 chore: Appease clippy 2021-10-25 16:32:55 -07:00
EmperorBale 83005a7ce5 avm2: Update flash-lso version 2021-10-25 16:32:55 -07:00
EmperorBale efb3062d98 avm2: Add flash.net.ObjectEncoding 2021-10-25 16:32:55 -07:00
EmperorBale e5fc2c8e66 avm1: Update SharedObject 2021-10-25 16:32:55 -07:00
EmperorBale e2c2ac8961 avm2: Implement ByteArray.readObject + flash.net.ObjectEncoding 2021-10-25 16:32:55 -07:00
EmperorBale c191340972 avm2: Refactor readBytes & writeBytes 2021-10-25 16:32:55 -07:00
EmperorBale 67ffc7bcc8 avm2: Forward get_enumerant_name and property_is_enumerable to base when not found 2021-10-25 13:45:29 -07:00
Mike Welsh 25c56b7000 chore: Appease clippy 2021-10-24 15:59:59 -07:00
Mike Welsh 8ae8de4d51 chore: Appease clippy
Squelch some false positives from `question_mark` and
`match_str_case_mismatch` lints.
2021-10-24 15:33:09 -07:00
relrelb 1fec012053 avm1: Inline `Value::call`
It was used only in `CallableValue`, and is not very useful by itself,
as it's a tiny wrapper around `TObject::call`.
2021-10-23 10:51:21 -07:00
relrelb e6181dfcce Revert "avm1: Don't warn in case a method doesn't exist"
This reverts commit 54d417c539,
because it no longer necessary as the warning was removed in the
previous commit.
2021-10-23 10:51:21 -07:00
relrelb 982a83ce24 avm1: Remove `base_proto` parameter of `TObject::call`
Use prototype depths instead. Most calls passed `base_proto = None`,
which is equivalent to `depth = 0`, and is now the default.
The few other cases were adapted to use `Executable::exec` directly,
where `depth` can be specified manually.
2021-10-23 10:51:21 -07:00
relrelb 09f72b880d avm1: Avoid unnecessary calls to `search_prototype`
The signature of `search_prototype` is going to change in a following
commit.
Use `TObject::call_method` instead.
2021-10-23 10:51:21 -07:00
relrelb d0763607e2 avm1: Remove `base_proto` parameter of `TObject::set_local`
The only usage of it was `ScriptObject::set_local`, where it can
be computed locally.
2021-10-23 10:51:21 -07:00
relrelb 0a66dac280 avm1: Remove `set` specialization from `impl_custom_object!`
`base_proto` is going to be eliminated in a following commit, so
there will no longer be a difference between the two `set_local`
variants.
2021-10-23 10:51:21 -07:00
Mike Welsh 3fc0209e03 chore: Appease clippy 2021-10-22 22:48:26 -07:00
David Wendt 5abb11482e avm2: Make builtin class prototypes also instances of `Object`, with the sole exception of `Function`, whose prototype is an instance of it's class. 2021-10-22 20:12:48 -07:00
David Wendt 469f8cb9db avm2: All prototypes are instances of `Object`, not their own class. 2021-10-22 20:12:48 -07:00
Adrian Wielgosik c1850d0d54 avm2: Stub flash.net.SharedObject
Just enough for the following to not crash:

```
var so = SharedObject.getLocal("name");
so.data.stuff = "xyz";
so.flush();
trace(so.data.stuff);
```
2021-10-22 10:02:35 -07:00
Mike Welsh 11ae981890 audio: Fix skipping initial frame of MP3 audio
The changes in #5498 caused the samples from the initial MP3 frame
to be skipped. This was noticable in:
https://www.newgrounds.com/portal/view/1

This change properly removes the redundant `num_samples` variable
and considers the samples from the initial MP3 frame.
2021-10-21 10:25:47 -07:00
Adrian Wielgosik 969fab7619 refactor: Stop manually borrowing fields in mutate_with_update_context 2021-10-21 10:24:05 -07:00
Adrian Wielgosik 8cc00f32bb chore: Stop using traits available in prelude 2021-10-21 10:24:05 -07:00
Adrian Wielgosik bc82a4f705 build: Bump Rust edition to 2021 2021-10-21 10:24:05 -07:00
EmperorBale 70cbd13201 avm2: Global scope should be null instead of undefined by default 2021-10-19 18:39:41 -06:00
EmperorBale 903246d5af chore: Appease clippy 2021-10-19 18:39:41 -06:00
EmperorBale ab3ff34944 avm2: Derive Collect for NativeExecutable 2021-10-19 18:39:41 -06:00
EmperorBale 2a84b0cbbb avm2: Instance traits and class traits should use seperate scopechains 2021-10-19 18:39:41 -06:00
EmperorBale 77bf5973a7 chore: Appease clippy 2021-10-19 18:39:41 -06:00
EmperorBale 1dd899a76f avm2: Allow small mutations to ScopeChain 2021-10-19 18:39:41 -06:00
EmperorBale 9de7d7ba7a chore: Add todo comment for callstatic 2021-10-19 18:39:41 -06:00
EmperorBale a19488c048 chore: Cleanup comments 2021-10-19 18:39:41 -06:00
EmperorBale d71188e80c avm2: Change code_context to caller_domain 2021-10-19 18:39:41 -06:00
EmperorBale 4667921259 avm2: Push global scope when property is not found 2021-10-19 18:39:41 -06:00
EmperorBale 7e251cfe05 avm2: Add support for pushwith 2021-10-19 18:39:41 -06:00
EmperorBale 388fdbd513 avm2: Scope redesign
avm2: Update scopechain design
2021-10-19 18:39:41 -06:00
dependabot[bot] 5cab790bd7 build(deps): bump encoding_rs from 0.8.28 to 0.8.29
Bumps [encoding_rs](https://github.com/hsivonen/encoding_rs) from 0.8.28 to 0.8.29.
- [Release notes](https://github.com/hsivonen/encoding_rs/releases)
- [Commits](https://github.com/hsivonen/encoding_rs/compare/v0.8.28...v0.8.29)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 14:01:23 -07:00
dependabot[bot] ca32fe9b90 build(deps): bump gif from 0.11.2 to 0.11.3
Bumps [gif](https://github.com/image-rs/image-gif) from 0.11.2 to 0.11.3.
- [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.2...v0.11.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 13:43:37 -07:00
Mike Welsh 7745c9137f audio: Grab MP3 sample rate directly from MP3 data
MP3 data in an SWF can be of a different sample rate than
indicated in the SWF tag, so grab the sample rate from the MP3
decoder instead of passing it in from the SWF tag.

Also, a general clean up of the MP3 decoders.

Fixes #335.
2021-10-17 20:34:15 -07:00
Mike Welsh 3dfa5ade18 audio: Ask decoder for sound sample rate
Don't rely on the sample rate in the SWF tags, as this could differ
from the actual sample rate of the audio (see #335).
2021-10-17 20:34:15 -07:00
Mike Welsh 60f5dc2477 avm2: Implement SoundChannel.position
Fix various issues with `SoundChannel`:
 * Change `avm2::Object::as_sound_instance` to `as_sound_channel`.
 * Cache sound position in `SoundChannelObject`.
 * `SoundInfo::in_sample` is in units of 44100Hz.
 * Clamp `num_loops` to 1.
2021-10-16 22:53:25 -07:00
Mike Welsh 6034b4a3af avm1: Sound.position and duration are not version-gated
Even though they were added in SWFv6, they will be available when
playing a v5 SWF in Flash Player 6 and higher.

See #340 for an example in the wild.
2021-10-16 22:53:25 -07:00
Mike Welsh 105c889f5f desktop: Implement AudioBackend::get_sound_position 2021-10-16 22:53:25 -07:00
Mike Welsh bca31b2c51 audio: Grab Sound.position from audio backend
* Change `AudioBackend::get_sound_position` to return `f64` to
   match `AudioBackend::get_sound_duration`.
 * Wire up `AudioBackend::get_sound_position` to `Sound.position`.
 * Remove unimplmeneted warning from `Sound.position`.
2021-10-16 22:53:25 -07:00
relrelb e9efc2841b avm1: Store depth in `SuperObject`
This is a temporary hack to calculate depth from `base_proto` and
`this`, so that changing `this.__proto__` will affect `super`.

In the future, `depth` should be passed instead of `base_proto`.
2021-10-16 11:14:38 -07:00
relrelb 299b7a778c avm1: Correct `base_proto` for method calls
In case the method is found directly on `this` (normally it shouldn't
because it's usually defined on `this.__proto__`), it seems like the
`super` object behaves identically as-if the method was found on
the object's prototype.
2021-10-16 11:14:38 -07:00
relrelb 7008f9bacc avm1: Correct `base_proto` for constructions
Previously constructions had `base_proto` set to the newly-created
object (`this`). However this doesn't match the `base_proto` of method
calls, which is `this.__proto__` (or more precisely where the function
is found on the prototype chain). This caused wrong behavior when using
the `super` object from within constructors.

Change `base_proto` in that case to be `this.__proto__`, which aligns
with method calls.
In order to keep things working, `SuperObject::call` needs to look-up
one level less than before.

An alternative can be changing `base_proto` for method calls instead,
but that seems to be harder because this would require `search_prototype`
to return the before-last visited object in the prototype chain.
2021-10-16 11:14:38 -07:00
relrelb 1772def6e6 avm1: Fix `SuperObject::get_local_stored`
It should return `None` in order to continue further walking on the
prototype chain.
2021-10-16 11:14:38 -07:00
Chris Midgley c5ad8e76ee
audio: Fail to create invalid ADPCM decoder 2021-10-13 23:12:32 -07:00
Mike Welsh 219d3af284 avm1: Function base clip defaults to `this` if clip no longer exists
When a function is defined, the base clip is stored in the function
object, and used when the function is called in SWFv6+. This
affects the target clip for GotoFrame and other actions.

However, if that base clip no longer exists when the function is
called, the base clip should default to the `this` display object.
Previously Ruffle would still use the previously unloaded base clip.
2021-10-12 17:23:01 -07:00
relrelb c0021204c6 Revert "core: Fix clip depth handling in `MovieClip::mouse_pick`"
This reverts commit 37e3f0903e.
2021-10-12 22:42:11 +03:00
dependabot[bot] 72e50bd3c6 build(deps): bump quote from 1.0.9 to 1.0.10
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.9 to 1.0.10.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.9...1.0.10)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 17:14:42 -07:00
dependabot[bot] ce70dbb52e build(deps): bump png from 0.17.1 to 0.17.2
Bumps [png](https://github.com/image-rs/image-png) from 0.17.1 to 0.17.2.
- [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)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 15:30:20 -07:00
dependabot[bot] fd64530288 build(deps): bump syn from 1.0.78 to 1.0.80
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.78 to 1.0.80.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.78...1.0.80)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-11 15:29:29 -07:00
relrelb 37e3f0903e core: Fix clip depth handling in `MovieClip::mouse_pick` 2021-10-10 18:51:59 -07:00
Mike Welsh 0786350a6f avm2: Defer self-gotos to end of frame script execution
If a movieclip calls a seek operation like `gotoAndStop` on
itself while executing a frame script, this goto is not executed
until the frame script has completed. In contrast, calling a goto
on other clips will execute the goto immediately.
2021-10-10 18:27:30 -07:00
Mike Welsh 57be2397ef avm2: Initialize slots to appropriate values when no default given
Slots and const traits should initialize to an appropriate value
for their type if no default is specified. Remove the `Option`
from `default_value`, and always set it to an appropriate null-ish
value (`0` for ints, `NaN` for `Number`, `null` for objects, etc.)
2021-10-10 14:01:36 -07:00
EmperorBale 34ecb32b85 avm2: Add custom implementations for get_enumerant_name and property_is_enumerable for VectorObject 2021-10-10 11:02:42 -07:00
EmperorBale 6eea0f2067 avm2: Add custom get_enumerant_name & property_is_enumerable implementations for ArrayObject 2021-10-10 11:02:42 -07:00
Chris Midgley 2dfaa33282 chore: fmt 2021-10-09 10:10:03 -07:00
Chris Midgley c9e67d31dc core: move avm_type from display object to update context 2021-10-09 10:10:03 -07:00
relrelb 54df49f96e core: Random SWF-related cleanups 2021-10-08 13:22:45 -07:00
relrelb 4fcf0907ac core: Remove `SwfSlice` usage from `MovieClip::new` 2021-10-08 13:22:45 -07:00
relrelb b8152f431e core: Use `SwfSlice::read_from` 2021-10-08 13:22:45 -07:00
Moulins 4ad6e1e698 avm1: Propagate AvmString<'gc>s to all methods on Object
Some frequently-used Object methods have an Into<impl AvmString<'gc>>
parameter to reduce the size of the changes.
2021-10-06 19:47:35 -06:00
Moulins 9aa601d43b core: Store AvmString<'gc>s in avm1::PropertyMap 2021-10-06 19:47:35 -06:00
TÖRÖK Attila 525dfcba05 chore: Bump h263-rs and h263-rs-yuv git refs 2021-10-05 10:58:46 -07:00
TÖRÖK Attila 3869950578 video/vp6: Add VP6[A] video decoding support
Gated behind the "vp6" feature, enabled by default.
Utilizing a heavily stripped-down version of the NihAV project,
retaining only the VP6 decoder, relicensed under MIT.
Including VP6WithAlpha decoding, proper FrameDependency reporting,
and cropping the unwanted encoded pixels on the right/bottom manually.
2021-10-04 22:33:06 -07:00
dependabot[bot] 006275632c build(deps): bump syn from 1.0.77 to 1.0.78
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.77 to 1.0.78.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.77...1.0.78)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 15:01:47 -07:00
dependabot[bot] 3d754a5d7d build(deps): bump smallvec from 1.6.1 to 1.7.0
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.6.1 to 1.7.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.6.1...v1.7.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 15:01:36 -07:00
David Wendt ee9341cb1c avm2: Remove `is_boxed_primitive`, as we are no longer accepting boxed primitives on the stack. 2021-10-03 15:57:43 -07:00
David Wendt 71c953b6ac avm2: Automatically unbox any boxed primitives that happen to make their way onto the stack.
This particular occurance is unlikely in practice, but could become far more common as more primitive constructors are implemented.
2021-10-03 15:57:43 -07:00
relrelb d49ea10267 swf: Rename `TryBlock` fields
* `try_actions` -> `try_body`
* `catch` -> `catch_body`
* `finally` -> `finally_body`

This aligns with the names used in SWF19, and is more consistent.
2021-10-02 23:01:32 +03:00
relrelb 81c864c6c8 avm1: Propagate exceptions in `Key.isDown`
Also change `coerce_to_f64` to `coerce_to_i32`.
2021-10-02 23:01:32 +03:00
relrelb 0a30057a63 avm1: Use enum constants instead of hard-coded numbers 2021-10-02 23:01:32 +03:00
TÖRÖK Attila a1ee508ff8
chore: Fix nightly clippy lint: clippy::if_then_panic (#5400)
* chore: Fix nightly clippy lint: clippy::if_then_panic

* chore: Fix nightly clippy lint: clippy::if_then_panic in swf tests too

* Address review notes
2021-10-02 16:14:53 +03:00
David Wendt f2e7457bc0 avm2: Move `QNameObject` specific methods behind an `as_qname_object` downcast. 2021-10-01 16:30:58 -06:00
David Wendt aaca3460d4 avm2: `QName` overrides `toString` and `valueOf` in both namespaces 2021-10-01 16:30:58 -06:00
David Wendt 513965b624 avm2: `Function.call` and `Function.apply` need to be accessible in the public namespace.
We should be able to move the AS3 versions to traits, but that breaks two other tests.
2021-10-01 16:30:58 -06:00
David Wendt 273872e2ab avm2: `Any` namespaces are represented as `*` in `QName`'s string form 2021-10-01 16:30:58 -06:00
David Wendt 294b0fc53e avm2: Impl `QName`'s constructor and properties 2021-10-01 16:30:58 -06:00
David Wendt 5387b1a4e0 avm2: Add stub boxed `QName` object type and class 2021-10-01 16:30:58 -06:00
relrelb 05d8f13b26 audio: ADPCM small cleanup 2021-09-30 20:16:04 +03:00
relrelb b9307af78f audio: Move ADPCM's tables out of `AdpcmDecoder` 2021-09-30 20:16:04 +03:00
relrelb 50ec497c60 audio: Introduce `AdpcmDecoder::channels`
This reduces duplicated code.
2021-09-30 20:16:04 +03:00
relrelb 4deaaed75c audio: Inline `AdpcmDecoder::next_sample` 2021-09-30 20:16:04 +03:00
relrelb 99827caf2b audio: Localize `AdpcmDecoder::{left,right}_step`
Since they were used only in a single scope.
2021-09-30 20:16:04 +03:00
dependabot[bot] 8c123c10af build(deps): bump syn from 1.0.76 to 1.0.77
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.76 to 1.0.77.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.76...1.0.77)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 01:27:10 +03:00
dependabot[bot] 5fe0994a3a build(deps): bump symphonia from 0.3.0 to 0.4.0
Bumps [symphonia](https://github.com/pdeljanov/Symphonia) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/pdeljanov/Symphonia/releases)
- [Commits](https://github.com/pdeljanov/Symphonia/compare/v0.3.0...v0.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 01:26:57 +03:00
Adrian Wielgosik 5ce2266be7 chore: clippy 2021-09-27 11:03:48 +02:00
Adrian Wielgosik 87625fa302 avm2: Change core types from Object to ClassObject where possible 2021-09-27 11:03:48 +02:00
Adrian Wielgosik 83b7420a3f avm2: Remove unneeded indirection from ClassObject methods 2021-09-27 11:03:48 +02:00
David Wendt 6753608e78 chore: Fix incorrect doccomment 2021-09-25 16:54:36 -06:00
David Wendt c299f63784 avm2: Implement object space enumeration.
This required making enumerants into `Value`s, rather than `QName`s.
2021-09-25 16:54:36 -06:00
David Wendt dbe9dffe0e avm2: Implement object-space overrides for `getproperty`, `setproperty`, `deleteproperty`, and `in`. 2021-09-25 16:54:36 -06:00
David Wendt 925604f730 avm2: Implement `DictionaryObject` and `Dictionary` 2021-09-25 16:54:36 -06:00
EmperorBale 28b34cbe25 chore: Typo 2021-09-23 23:14:30 -06:00
EmperorBale 3f81910bb6 avm2: Remove custom_object macros 2021-09-23 23:14:30 -06:00
relrelb 54d417c539 avm1: Don't warn in case a method doesn't exist 2021-09-23 18:55:49 -06:00
David Wendt f298a23ec8 avm2: Ensure all bare function calls pull an appropriate `superclass_object` 2021-09-23 15:59:06 -06:00
David Wendt 7ef7b80395 avm2: Prototypes are not instances of their class 2021-09-23 15:59:06 -06:00
David Wendt b8c086eb7a avm2: Calls to object properties should use the new `call_property` method 2021-09-23 15:59:06 -06:00
David Wendt 7cefeb2b2a avm2: Add a `constructprop` method for objects, too. 2021-09-23 15:59:06 -06:00
David Wendt b07ad8070c avm2: Make `get_property`, `set_property`, `init_property`, and various other derivative methods take a `Multiname` and run the search inside `Object`.
This also introduces a `call_property` method.
2021-09-23 15:59:06 -06:00
David Wendt 945cb2c4bf avm2: Global class inheritance issues should report which class cannot be found 2021-09-23 15:59:06 -06:00
David Wendt 8f8134e4f4 avm2: Add private instance slots for `FrameLabel`'s properties 2021-09-23 15:59:06 -06:00
David Wendt 5ba2421225 avm2: Add private instance slots for `Scene`'s properties 2021-09-23 15:59:06 -06:00
David Wendt 97924d20ad avm2: Add private instance slots for `Point`'s properties 2021-09-23 15:59:06 -06:00
David Wendt dfc90984dc avm2: Add private instance slots for `Rectangle`'s properties 2021-09-23 15:59:06 -06:00
David Wendt 81da1aad4b avm2: `Video` is not a subclass of `flash.media.DisplayObject` (which doesn't exist) 2021-09-23 15:59:06 -06:00
EmperorBale 1874223224 avm2: Remove ignore_next 2021-09-23 00:01:50 +02:00
EmperorBale 31abe5d9d7 avm2: Specify that date should coerce to string by default 2021-09-23 00:01:50 +02:00
EmperorBale 64eb47a65c avm2: Remove YearType 2021-09-23 00:01:50 +02:00
EmperorBale bd6ca72510 avm2: Implement Date.parse 2021-09-23 00:01:50 +02:00
EmperorBale 10be7ef3bf avm2: Implement toUTCString 2021-09-23 00:01:50 +02:00
EmperorBale 292a9bda4b avm2: Implement toLocaleString, toLocaleTimeString, toDateString, toLocaleDateString 2021-09-23 00:01:50 +02:00
EmperorBale b9fd7f5977 avm2: Implement toString, toTimeString 2021-09-23 00:01:50 +02:00
EmperorBale 931080cd49 avm2: Implement valueOf 2021-09-23 00:01:50 +02:00
EmperorBale aca23b744e chore: Appease clippy 2021-09-23 00:01:50 +02:00
EmperorBale 7f8e01b426 avm2: Implement UTC 2021-09-23 00:01:50 +02:00
EmperorBale 453486265f avm2: Implement timezoneOffset 2021-09-23 00:01:50 +02:00
EmperorBale 0732efc9d9 avm2: Impement day, dayUTC 2021-09-23 00:01:50 +02:00
EmperorBale fe584f7508 chore: Fix typos 2021-09-23 00:01:50 +02:00
EmperorBale 97da4d1b7b avm2: Implement UTC variants 2021-09-23 00:01:50 +02:00
EmperorBale 0dc0bc9694 avm2: Implement month, fullYear 2021-09-23 00:01:50 +02:00
EmperorBale 273ae48654 avm2: Refactor date implementation 2021-09-23 00:01:50 +02:00
EmperorBale 6ab0d89040 avm2: Implement minutes, hours, date 2021-09-23 00:01:50 +02:00
EmperorBale d5621c1ce7 avm2: Implement time, seconds, milliseconds 2021-09-23 00:01:50 +02:00
EmperorBale 32eb9d1579 avm2: Implement Dates instance initializer 2021-09-23 00:01:50 +02:00
EmperorBale db550b035c avm2: Add Date stub 2021-09-23 00:01:50 +02:00
relrelb 3463e50a72 avm1: Avoid `impl Into<Value<'gc>>` parameter in `Avm1::push`
This might create templatized functions leading to unnecessary code bloat.

So instead use just `Value<'gc>` parameters and add `.into()` in callers
where needed.
2021-09-22 23:13:13 +02:00
kmeisthax 42275f43f3 avm2: Properly make all classes an instance of `Class`. (#57)
* avm2: Properly make all classes an instance of `Class`.

Also, does this technically mean that `Class` is a metaclass?

* avm2: Remove `Function::from_method_and_proto` as it will no longer be needed

* avm2: Ensure builtin classes are also instances of `Class`.

This requires tying a veritable gordian knot of classes; everything needs to be allocated up-front, linked together, and then properly initialized later on. This necessitated splitting the whole class construction process up into three steps:

1. Allocation via `from_class_partial`, which does everything that can be done without any other classes
2. Weaving via `link_prototype` and `link_type`, which links all of the allocated parts together correctly. This also includes initializing `SystemClasses` and `SystemPrototypes`.
3. Initialization via `into_finished_class`, which must be done *after* the weave has finished.

Once complete you have core classes that are all instances of `Class`, along with prototypes that have their usual legacy quirks.

Note that this does *not* make prototypes instances of their class. We do need to do that, but doing so breaks ES3 legacy support. This is because we currently only work with bound methods, but need to be able to call unbound methods in `callproperty`.

* tests: Add a test for all core classes' instance-of relationships
2021-09-22 00:29:37 +02:00
Adrian Wielgosik f8c32d3a68 avm2: Fix get_own_class_definition users to use either instance_of or as_. 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 71e41e2c92 chore: cargo fmt 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 22482ed080 avm2: Remove unwrap in get_own_class_definition 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 7736818069 avm2: Rename as_class -> get_own_class_definition 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 26e60fa8ea avm2: Rename as_class_object_really -> as_class_object 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 008162c514 avm2: Replace all uses of as_class_object by instance_of 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 4b7f8b3dbd avm2: inner_class_definition is not an Option 2021-09-22 00:29:37 +02:00
Adrian Wielgosik 3e1764aa1e avm2: Reimplement as_class_object() in terms of other methods 2021-09-22 00:29:37 +02:00
Adrian Wielgosik e02feb919a avm2: Reimplement as_class() in terms of other methods 2021-09-22 00:29:37 +02:00