Commit Graph

9409 Commits

Author SHA1 Message Date
iwannabethedev 307f364d6f
web: Log used renderer
Log which renderer-backend was actually used in the
browser console.
2023-05-02 23:59:57 +03:00
relrelb 182ae6c9a9 swf: Introduce `ShapeRecordFlag`
No functionality change.
2023-05-02 20:24:38 +03:00
Kornelius Rohrschneider fe56f8d212 core: Implement suggested changes in PR to documentation & code
- Documentation has been added, improved and clarified.
- The code of a string concatenation has been improved.
2023-05-02 17:13:42 +02:00
Kornelius Rohrschneider 27738a492e web: Implement suggested changes in PR to navigate_to_url handling
The suggested changes to the navigate_to_url handling in the feedback to
the pull request have been implemented.
Therefore, this commit consists of multiple smaller changes:

1. The allow_javascript_calls variable has been removed (as a CLI
argument and in the navigator). Javascript calls are now always denied
on desktop. This is because setting the argument was useless; no
javascript was executed in any case, at most, just a browser tab opened.
Therefore, it makes no sense to include this option.
2. The NavigateWebsiteHandlingMode default value has been provisionally
changed from Confirm to Allow. In the future (after a GUI toolkit has
been added), the default confirmation windows should include a "Save
this preference" checkbox.
3. The NetworkingRestrictionMode enum has been renamed to
NetworkingAccessMode since the previous naming was counter-intuitive.
4. The NavigateWebsiteHandlingMode enum (and variables related to it)
have been renamed to OpenURLMode to simplify the name.
5. The documentation has been improved.
2023-05-02 17:13:42 +02:00
Kornelius Rohrschneider 809a9f6907 web: Add and partially implement networking API restrictions
The networking API restrictions imposed by the allowNetworking parameter
& attribute have been added and partially implemented.

A new NetworkingRestrictionMode enum has been added to Ruffle (in Rust
and Typescript). It contains the values "All", "Internal" and "None" and
models the possible values of the allowNetworking parameter / attribute.
All means that all networking APIs are permitted in the SWF file,
Internal means that the SWF file may not call browser navigation or
browser interaction APIs and None means the same and that the SWF file
cannot use any SWF-to-SWF communication APIs either.
A respective allowNetworking variable has been added to the JS config.
Its default value is All.
Ruffle now recognises the allowNetworking parameter and attribute in the
SWF HTML object and parses it and sets the config variable
correspondingly if it's recognised.
Only if the variable is set to All, the external interface (responsible
for javascript calls in AS3) is created. Additionally, the variable is
given to the WebNavigatorBackend and saved in it. The navigator denies
all navigate_to_url calls if the variable hasn't been set to All.
Therefore, the API restrictions imposed by setting allowNetworking to
internal or none have been partially implemented.

Formatting has been improved.
2023-05-02 17:13:42 +02:00
Kornelius Rohrschneider 44ef22f646 core: Add navigate_to_url call configuration options
New configuration options (changing the navigate_to_url call handling)
have been added. The default behaviour has been changed as well.

A NavigateWebsiteHandlingMode enum has been added to Ruffle (in Rust and
Typescript). It contains the values "Allow", "Confirm" and "Deny" and
describes how navigate_to_url website calls should be handled. Allow
means that all website calls are allowed, Confirm means that a
confirmation window opens with each website call and Deny means that all
website calls are denied.
A respective navigate_website_handling_mode variable has been added to
the desktop CLI and to the JS config. The default value is "Confirm" in
each. The variable is given to the navigator (ExternalNavigatorBackend
or WebNavigatorBackend, depending on the platform) and is saved in it.
On each navigate_to_url website call, the respective navigator is now
checking navigate_website_handling_mode and acts correspondingly (allows
it, opens a confirmation window or denies it).
This changes the default behaviour of Ruffle from allowing all website
calls to opening a confirmation window with each website call.
On Safari, the confirm window can cause the background music to stop,
but this seems to be an issue with Safari.
Closes #838.

Additionally, an allow_javascript_calls variable (which defaults to
false) has been added to the desktop CLI. The variable is given to the
desktop navigator and is saved in it.
If a navigate_to_url javascript call is executed on desktop, the
navigator is now checking allow_javascript_calls and acts
correspondingly (allows it or denies it).
This changes the default behaviour of Ruffle on desktop to not allowing
javascript calls.
Closes #9316.
2023-05-02 17:13:42 +02:00
divinity76 7bc51ae2cb
web: Make panicText readonly
it's not supposed to be editable. ref https://github.com/ruffle-rs/ruffle/pull/10819#issuecomment-1529977894
2023-05-02 06:53:44 +00:00
Adrian Wielgosik e1d47e3527 web: Avoid array.at() for browser compatibility 2023-05-02 01:00:20 +02:00
nosamu 91bc57c67f web: Fix panic error details display
Fix regression caused by #10819
2023-05-01 08:52:46 +03:00
Toad06 ee7403952a avm1: Allow `button.enabled` to hold any value 2023-04-30 21:08:27 +03:00
Toad06 86c27078d3 avm1: `button.enabled = undefined` doesn't disable the button 2023-04-30 21:08:27 +03:00
Lord-McSweeney 822c845d83 avm2: Stub Socket.connected 2023-04-30 20:16:24 +03:00
iwannabethedev 7b10052c26 extension: Add UI presentation for playerVersion default value. 2023-04-30 07:45:19 +03:00
Tom Schuster 69134d7d8d tests: Test XML.hasOwnProperty 2023-04-29 16:34:10 -05:00
Tom Schuster 791081051f avm2: Alternative implementation of XML hasOwnProperty @attribute 2023-04-29 16:34:10 -05:00
relrelb 24079518d9 tests: Expand `Matrix` unit tests to cover `PointDelta`s 2023-04-29 22:29:37 +03:00
relrelb ef79d556b4 tests: Allow trailing commas in `Matrix` unit tests 2023-04-29 22:29:37 +03:00
relrelb 3046d68da1 swf: Introduce `PointDelta`
Generally, when transforming a difference between two points, `p1`
and `p2`, with a matrix `m`, we would like the following property
to hold:

```
m * (p1 - p2) == m * p1 - m * p2
```

Unfortunately, it wasn't like this before, because matrices have a
translation component, which is non-linear. In `m * p1 - m * p2`,
the translations of `m * p1` and `m * p2` are the same and therefore
cancel out each other. However, in `m * (p1 - p2)` the translation
stays.

In order to preserve this property, introduce a new `PointDelta`
type which is not subject to translation when transformed by a matrix.

For now, the following operations are supported:

* `Point - Point -> PointDelta`
* `Point + PointDelta -> Point`
* `Point += PointDelta`
* `Point - PointDelta -> Point`
* `Point -= PointDelta`

As a consequence, the expression `position + global_to_local_matrix * mouse_delta`
in `update_drag()` now ignores translation, which fixes #817.
2023-04-29 22:29:37 +03:00
Lord-McSweeney d1e4cccabb avm2: Stub flash.net.Socket 2023-04-29 22:18:06 +03:00
iwannabethedev 1f956ffe55 web: Add extension option for setting 'playerVersion'.
Basic input validation UI and logic is also added and improved.
2023-04-29 01:09:09 +03:00
relrelb 5eb14572ac core: Fix moving objects while being dragged
`startDrag()` used to capture the offset between the mouse cursor
and dragged object. This is buggy when the dragged object position
is changed *while* being dragged, as the original offset no longer
holds.

Change the dragging mechanism to be based purely on mouse deltas,
eliminating said offset completely.

Fixes #10775.
2023-04-28 11:55:33 +03:00
relrelb e5808b14a8 core: Use `Twips` in `DisplayObject::{,set_}{x,y}`
Instead of `f64`.
2023-04-28 11:55:33 +03:00
iwannabethedev e211f57f81 extension: Fix popup setting changed reload detection.
The problem seems to have been the inclusion of setting values
that the previous equality function did not handle correctly.
This function broadens the kinds of setting values that can
be handled correctly.
2023-04-28 11:06:52 +03:00
relrelb 60ffe07ae7 chore: Use `swf::Point` in many places
Convert nearly all instances of `(Twips, Twips)` (maybe besides in
`shape_utils.rs`) to `swf::Point<Twips>`.
2023-04-27 22:14:03 +03:00
Lord-McSweeney ba5a456d11 avm2: Implement XMLDocument.createElement 2023-04-27 13:16:00 -05:00
iwannabethedev b01e797e99
extension: Add option for setting max. exec. time
Add an option to the 'options' menu for the extension
for setting the maximum execution time for Actionscript
code.
2023-04-27 09:47:56 +00:00
Moulins e5caf0fda8 core: use unified repr for non-static `AvmString`s, interned and not
This shrinks the size of `AvmString` back from 3 to 2 usizes.
2023-04-27 00:17:31 +02:00
Moulins 2868333c05 avm2: require AvmAtom in Namespaces 2023-04-27 00:17:31 +02:00
Moulins 68fc567f7f core: add `AvmAtom` to represent interned strings
Makes `AvmString`s grow from 2 to 3 usizes, but this
will be reverted later.
2023-04-27 00:17:31 +02:00
Moulins 011cdd96ba core: don't keep strong references to interned strings in the interner.
This is done by implementing a simple WeakSet which clears its stale
entries during tracing.
2023-04-27 00:17:31 +02:00
Moulins 889a9bd009 avm2: Intern strings in constant pools
Strings belonging to multinames are interned too, but
the multinames themselves aren't.
2023-04-27 00:17:31 +02:00
Moulins 09c729074c avm1: Intern strings in constant pools 2023-04-27 00:17:31 +02:00
Moulins 27521e145c avm1: Thread GcContext through all globals initialization 2023-04-27 00:17:31 +02:00
Moulins c40fd2b17a core: Add (very) simple AvmString interner
Pass it to AVM1/2 initilization functions *via* the new `GcContext` type.
2023-04-27 00:17:31 +02:00
Moulins 90d5515d47 wstr: fix `wstr_impl_traits` macro not working without `use ruffle_wstr::*` 2023-04-26 23:49:18 +02:00
Moulins cfde53cde2 core: replace `string::decode_swf_str` by a `SwfStrExt` extention trait 2023-04-26 23:49:18 +02:00
Moulins e9a16ff5fe wstr: cleanup and expose the `ptr` module
- move `WStr` declaration to `common`;
- move `MAX_STRING_LEN` to the `WStr` type;
- split `ptr` methods into `*const` and  `*mut` variants;
- add safe methods `WStrMetadata::new32/len32`;
- add `WString::{from, into}_raw_parts`.
2023-04-26 23:49:18 +02:00
Moulins 34f2c45441 core: add `string::decode_swf_str` for SwfStr -> WString conversions 2023-04-26 23:49:18 +02:00
Moulins 604a15f957 wstr: add `WStr::make_ascii_lowercase` 2023-04-26 23:49:18 +02:00
Moulins 83f7bfc0c2 wstr: improve `Cow<WStr>` support
This adds missing `From` implementations, and utf8 conversion methods
returning `Cow<WStr>`.
2023-04-26 23:49:18 +02:00
Moulins ab0f9b9fc2 wstr: Inline more `WString` methods 2023-04-26 23:49:18 +02:00
iwannabethedev eaee14c7de web: Use default configuration in extension. 2023-04-26 23:24:53 +02:00
Toad06 f3a0652aea extension: Close `popup.html` when opening/reloading a window 2023-04-26 22:08:12 +03:00
Nathan Adams b12db0ac3a avm2: Support data, method and content-type in URLLoader by reusing code from Loader 2023-04-26 13:44:46 -05:00
relrelb 81dcc66c01 tests: Expand `as_broadcaster`
Verify that `AsBroadcaster` is actually a usable constructor.
2023-04-26 21:21:57 +03:00
relrelb 1c0c25b521 avm1: Make `AsBroadcaster` a function
Previously, `AsBroadcaster` was defined as a plain object. However,
it seems like in Flash it is defined as an empty function instead.
This means expressions like `new AsBroadcaster()` should return a
newly-created object. This is in opposition to the documentation
that says there is no constructor function for the `AsBroadcaster`
class.

Fixes #10673.
2023-04-26 21:21:57 +03:00
Lord-McSweeney 4a50f9f31e avm2: Add make_error_2008() function and use it 2023-04-26 18:49:35 +03:00
Daniel Jacobs 24dfb82d12 web: Address save manager styling review comments 2023-04-26 14:36:49 +02:00
Daniel Jacobs 902911745b web: Use different heights for save manager 2023-04-26 14:36:49 +02:00
Daniel Jacobs 5e31ce992e web: Fix save manager styling 2023-04-26 14:36:49 +02:00