Commit Graph

3827 Commits

Author SHA1 Message Date
Mike Welsh 659db7facc avm1: Add2 calls valueOf for objects 2022-03-31 16:57:07 -07:00
Adrian Wielgosik a929a4becd avm2: Do not borrow Object's lock just to get the bound method 2022-03-31 16:56:55 -07:00
Adrian Wielgosik 7e8738d82e avm2: Add ContextMenuEvent stub 2022-03-30 21:42:48 +02:00
Adrian Wielgosik ef64413b8c avm2: Support ContextMenuItem fields 2022-03-30 21:42:48 +02:00
Adrian Wielgosik ea56902d80 chore: cargo fmt 2022-03-30 21:42:48 +02:00
Adrian Wielgosik 90b1d4722c avm2: Add ContextMenuItem stub 2022-03-30 21:42:48 +02:00
Adrian Wielgosik 2389422c99 avm2: Add ioErrorEvent stub 2022-03-30 21:42:48 +02:00
Adrian Wielgosik 388dc6fe31 avm2: Add customItems to ContextMenu stub 2022-03-30 21:42:48 +02:00
Mike Welsh d920dfa9b0 core: Add padding on autosized TextFields 2022-03-29 22:22:32 -07:00
Mike Welsh a671d2977b core: Pre-multiply alpha when loading PNG/GIF data (fix #6559)
When decoding PNG/GIF data, convert the image to premultiplied
alpha so that it plays nicely with the renderer.

This applies to both dynamically loaded images and to PNG/GIF data
embedded inside a DefineBitsJPEG tag. This is in contrast to
DefineBitsLossless and DefineBitsJPEG tags w/ alpha, which are
already premultiplied in the SWF.

Also remove unnecessary clamps now that Rust defines casts as
saturating.

Fixes #6559.
2022-03-29 13:41:04 -07:00
Mike Welsh 9c50770c1c avm1: Return Value from `abstract_lt`
All callers converted the result to `Value` anyway.
2022-03-28 19:07:12 -07:00
Mike Welsh 98ea2f81b6 avm1: {} < {} returns false
The Less2 op returns false if the `valueOf` of either parameter
results in an object. The exception is display objects:
`mc < mc` returns undefined.
2022-03-28 19:07:12 -07:00
dependabot[bot] fcb5eaec0e build(deps): bump syn from 1.0.89 to 1.0.90
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.89 to 1.0.90.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.89...1.0.90)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 00:09:22 +03:00
dependabot[bot] bf57d2c15a build(deps): bump jpeg-decoder from 0.2.2 to 0.2.3
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) from 0.2.2 to 0.2.3.
- [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.2...v0.2.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-29 00:09:01 +03:00
David Wendt b9da107339 core: Refactor `MovieClipLoader` broadcast messages into separate `Loader` associated functions.
These are *not* methods, because we cannot borrow both the update context and the loader at the same time. At least not without making loaders free-standing objects (`GcCell`s), which I don't want to do yet.
2022-03-27 18:55:38 -07:00
David Wendt ac7bb84e08 core: Report unexpected content type errors better. 2022-03-27 18:55:38 -07:00
David Wendt 27697c6611 chore: No, loading an image does not replace the clip with a bitmap. 2022-03-27 18:55:38 -07:00
David Wendt e1d18be7fa core: First pass at image loading through `loadMovie` et all 2022-03-27 18:55:38 -07:00
Toad06 4ad0253076 avm1: `String(function)` returns `[type Function]` 2022-03-27 11:39:44 -07:00
Mike Welsh ac765bd187 chore: Update copyright
I (Michael R. Welsh) assign to Ruffle LLC all rights, title, and
interest to copyrights of my personal contributions to Ruffle,
effective March 26, 2022.
2022-03-26 18:13:14 -07:00
relrelb 1c576816b6 core: Refactor `LoadManager::load_form_into_load_vars`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
relrelb f3c22d930b core: Refactor `LoadManager::load_form_into_object`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
relrelb 83353e17c5 core: Refactor `LoadManager::load_movie_into_clip`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
relrelb 7e4b3c1003 core: Refactor `LoadManager::load_root_movie`
Make it call `navigator.fetch()` directly rather than receiving an
existing `Future`.
2022-03-26 15:56:06 -07:00
Moulins 1bff5c517a Move back AvmString into ruffle_core::string
This allows removing the gc_arena dependency in ruffle_wstr
2022-03-26 13:42:57 -07:00
Moulins 1911aa9a6b Move core::string into separate ruffle_wstr crate. 2022-03-26 13:42:57 -07:00
relrelb 1230b5e713 swf: Use bitflags for `FontFlag` 2022-03-26 11:33:26 -07:00
relrelb 71a1757d29 swf: Make `Glyph::advance` non-`Option`
Simply use `0` instead of `None`.
2022-03-26 11:33:26 -07:00
relrelb 984342abf3 swf: Avoid some `Vec::resize` usages
Use the `vec![]` macro instead.
2022-03-26 11:33:26 -07:00
dependabot[bot] f9e361ddae build(deps): bump bitstream-io from 1.2.0 to 1.3.0
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io) from 1.2.0 to 1.3.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>
2022-03-26 10:52:26 -07:00
dependabot[bot] 0c4806854c build(deps): bump quote from 1.0.16 to 1.0.17
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.16 to 1.0.17.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.16...1.0.17)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 10:30:46 -07:00
relrelb 8f7b8c4b76 xml: Make `XmlNodeData` a struct
The difference between element nodes and text nodes is very minor.
So instead of representing them by two distinct enum members, make
`XmlNodeData` a single unified struct that can represent both. A new
`node_type` field is introduced, in order to still distinguish
between element and text nodes. Also, Ruffle made some incorrect
assumptions, which are now corrected, including:

* Nodes can have any arbitrary `u8` type. This is resolved by the
introduction of the `node_type` field which is a `u8`.
* Text nodes can have children. This is resolved by simply not checking
for text nodes in `append_child` etc.
2022-03-26 10:12:47 -07:00
relrelb 161071e8c4 core: Re-implement `NullExecutor`
Make it a thin abstraction layer over either the `futures` or `wasm-bindgen-futures`
crates, as already done in `render/wgpu/src/uniform_buffer.rs`,
instead of a hand-made single-thread executor.

Ideally this would also be usable on desktop, but I didn't manage to
get `LocalPool` working with `winit` (it needs to post a task to the
`EventLoopProxy` as a wake procedure).
2022-03-26 10:03:42 -07:00
Moulins bb63ac2de7 wstr: fix memory leak
WString's Drop impl didn't actually drop anything
2022-03-25 18:36:00 -07:00
Toad06 c1119fdc0b avm1: Apply autosize to a new `EditText` from an SWF `DefineEditText` tag 2022-03-21 20:00:06 -07:00
Aaron Hill a281db3af6 Add `define_indirect_properties` helper macro for property/slot pairs
In both `FrameLabel` and `Scene`, we define multiple
'public property / private slot' pairs.
The public property has a getter which delegates to the private
property. There is no setter for the property, ensuring that
the private slot can only be modified from within Ruffle itself.

This PR adds a macro `define_indirect_properties` to abstract over
this pattern. Currently, it only supports the read-only property
pattern - however, it could be extended in the future to generate
a setter that invokes a caller-provided callback function.

This needs to be a macro (rather than a method) so that we can
generate a function with the property name hard-coded into it.
Using a closure that references an upvar will not work, since
`Method::from_builtin` requires a function pointer.
2022-03-21 19:00:25 -07:00
relrelb b7a60384cf xml: Inline `update_id_map`
Move its logic to `from_start_event`, where `XmlNode`s are created.
2022-03-20 11:04:48 +02:00
relrelb 724f4165d6 avm1: Implement `nodeName` and `nodeValue` setters
These are actually handled by the same function.
2022-03-19 16:31:24 -07:00
relrelb f9dff4191b xml: Remove `XmlNodeData::DocumentRoot`
Document roots (a.k.a. `XML` objects) are very similar to regular
element nodes (a.k.a. `XMLNode` objects). The primary difference is
that `XML` objects return `null` for their `nodeName`. But this can
be changed too; Setting `xml.nodeName = "someName"` will make `XML`
objects behave much like `XMLNode`. Moreover, many checks in Ruffle
that refuse to operate on document roots were wrong, and actually
these should be accepted as normal element nodes.
Besides the functional corrections, this also simplifies the code.
2022-03-19 16:31:24 -07:00
relrelb fa70cc07ab xml: Inline `text_from_text_event` and `is_whitespace_text` 2022-03-19 15:08:16 -07:00
relrelb b31e826ee6 core: Simplify `SwfMovie` parsing in `Loader`
This also slightly changes behavior: Previously `SwfMovie::from_data`
errors were propagated as `FetchError` and `display_root_movie_download_failed_message`
was called, offering the user to sidestep CORS by opening the SWF
in a new tab. But that wouldn't help, obviously, because no network
error is involved. Now, these errors are propagated as `InvalidSwf`,
and `display_root_movie_download_failed_message` is not called.
2022-03-17 20:31:59 -07:00
relrelb ad944800be core: Perfer `Loader`'s `FetchError`
`NetworkError` and `NetworkUnavailable` were rarely used, and they
were very similar to `FetchError`.
2022-03-17 20:31:59 -07:00
relrelb bf32fc8576 core: Remove unused `Loader` types 2022-03-17 20:31:59 -07:00
dependabot[bot] d56377b166 build(deps): bump quote from 1.0.15 to 1.0.16
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.15 to 1.0.16.
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.15...1.0.16)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-17 20:29:26 -07:00
dependabot[bot] 50bdb40914 build(deps): bump syn from 1.0.87 to 1.0.88
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.87...1.0.88)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-17 01:00:16 +02:00
dependabot[bot] 7fc6a7c000 build(deps): bump syn from 1.0.87 to 1.0.88
Bumps [syn](https://github.com/dtolnay/syn) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/1.0.87...1.0.88)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-17 00:21:26 +02:00
relrelb 8a17d88c77 core: Remove `NavigatorBackend::time_since_launch`
`core` already depends on the `instant` crate which abstracts
`std::instant::Instant` and polyfills it on Web. Use it to replace
`NavigatorBackend::time_since_launch` in order to make `NavigatorBackend`
a little smaller and more simple.
2022-03-17 00:08:44 +02:00
relrelb 031126a1b8 core: Remove `LocaleBackend`
Previously there were 3 implementations of `LocaleBackend`:
`DesktopLocaleBackend`, `WebLocaleBackend` and `NullLocaleBackend`.

While `DesktopLocaleBackend`, `WebLocaleBackend` were identical,
`NullLocaleBackend` always returned a fixed date/time for tests
determinism.

Unify them in a single file, and use `cfg!(test)` and a new dedicated
`deterministic` feature to decide whether to mock date/time or not.
This should not cause any behavioral changes.
2022-03-16 19:57:53 +02:00
relrelb 1db29217eb chore: Appease clippy 2022-03-16 18:51:39 +02:00
Aaron Hill e87ad52deb avm2: Add initial implementation of `Matrix`
This implements the `a, b, c, d, tx, ty` properties,
as well as the constructor, `identity`, and `scale` methods.
2022-03-16 13:52:58 +02:00