Commit Graph

5751 Commits

Author SHA1 Message Date
Aaron Hill 0d5ead4c02 core: Ignore newer PlaceObject tag in same frame with duplicate depth
If we have two PlaceObject tags in the same frame with the same depth,
only the first one actually places an object. The second one is ignored
(Flash Player logs a warning).
2023-06-06 14:50:07 -05:00
Aaron Hill d037038170 avm2: Make `caller_domain` an `Option`, and call `expect` when actually needed
There are only a few places where we actually need to use the
`caller_domain`, so we don't actually need it available for most native
method calls. This means that `Activation::from_nothing` can be used
in the vast majority of cases without causing a panic later on.
2023-06-06 21:05:19 +02:00
Nathan Adams 10134467c9 avm2: Don't error on removeChildren() for empty containers - fixes #11382 2023-06-05 18:30:08 -05:00
renovate[bot] f1fe998869 chore(deps): lock file maintenance rust dependencies 2023-06-04 22:53:18 -05:00
relrelb 9c8e212641 avm1: Migrate `GradientBevelFilter` to `NativeObject` 2023-06-03 21:33:12 +03:00
Nathan Adams 136417c58c core: Make debug windows scrollable 2023-06-03 09:11:06 +02:00
Nathan Adams 85f6fd3889 core: Add movie clip info to debug menu 2023-06-03 09:11:06 +02:00
Nathan Adams a26a64d88f core: Format Rectangle to 2 decimal places 2023-06-03 09:11:06 +02:00
Nathan Adams c9d0a08863 core: Move debug children list's button into header 2023-06-03 09:11:06 +02:00
Nathan Adams 9f384df27b core: Don't have dynamic_root in UpdateContext unless egui feature is enabled 2023-06-03 09:11:06 +02:00
Nathan Adams a641c564de core: Show debug rect on hovering stuff 2023-06-03 09:11:06 +02:00
Nathan Adams 16ce9aa437 core: Add debug rects to debugger 2023-06-03 09:11:06 +02:00
Nathan Adams a6b8883acd core: Add mask/masker/clip info to debug UI 2023-06-03 09:11:06 +02:00
Nathan Adams 59eceb8b7a core: Add AVM1 path to debug UI 2023-06-03 09:11:06 +02:00
Nathan Adams 77bd1cd1c8 core: Add depth and color transform to debug ui 2023-06-03 09:11:06 +02:00
Nathan Adams e12e2a2e54 core: Initial Debug UI 2023-06-03 09:11:06 +02:00
Nathan Adams eb70a4f361 core: Update gc_arena to 63dab12871321e0e5ada10ff1f1de8f4cf1764f9 2023-06-03 09:11:06 +02:00
Aaron Hill 2cd518013c
wgpu: Don't skip alpha/erase blend modes for BitmapData.draw (#11323)
We can skip these when we're drawing to a fresh buffer, but not when we're blending over an existing BitmapData texture.
2023-06-02 21:16:05 +00:00
relrelb e5da68c1df avm1: Migrate `ConvolutionFilter` to `NativeObject` 2023-06-02 23:39:02 +03:00
Aaron Hill 21429cc205 avm2: Add PixelBender bytecode parsing to ShaderData
We now parse PixelBender bytecode, and populate the parameters
from the bytecode on `ShaderData`. This is enough to progress
Steamlands, which needs to access dynamically set properties
on `ShaderData`

Bytecode execution is not implemented yet.
2023-06-02 15:23:32 -05:00
Aaron Hill 999e2f5b71 wgpu: Implement Context3D.setScissorRectangle 2023-06-02 14:56:14 -05:00
relrelb abb0e33431 chore: Use Rust's `OnceCell`/`OnceLock`
They were stabilized in Rust 1.70.0, which was released yesterday.
This removes the `once_cell` dependency.
2023-06-02 22:21:38 +03:00
Lord-McSweeney 5fdbfe2fd4 avm2: Partial implementation of Loader.unload 2023-05-31 21:03:18 -05:00
Aaron Hill 8b257ef6da avm2: Always run `construct_frame` in `initialize_for_allocator`
When we create a DisplayObject from ActionScript, we should always
run `construct_frame` on it, regardless of what frame phase we
are currently in.

This fixes a regression in Fancy Pants World 4 Part 1, where entering
the first door produced an error.
2023-05-31 17:33:25 -05:00
Crowdin Bot 6dc3743f4b chore: Update translations from Crowdin 2023-05-30 23:21:28 +02:00
relrelb c952106ee3 avm1: Correct `ActionCloneSprite` and `duplicateMovieClip()`
* `ActionCloneSprite` coerces `depth` before `target`.
* `duplicateMovieClip()` coerces `name` before `depth`.
* `duplicateMovieClip()` returns `undefined` on SWF<6.
2023-05-30 23:10:36 +03:00
Nathan Adams 0c10e2a7b7 desktop: Add advanced open dialog 2023-05-29 22:12:56 +02:00
TÖRÖK Attila b8fc64df6f core/avm1: Accept Value as smaller than 16 bytes on 32 bit platforms. 2023-05-29 07:58:53 -05:00
renovate[bot] 847dece735 chore(deps): lock file maintenance rust dependencies 2023-05-28 23:54:33 -05:00
Aaron Hill 0955ab40e6 avm2: Fix rounding behavior in BitmapData rectangle operations
Flash Player performs `x + width` and `y + height` as floating
point operations before `round_to_even`. This affects the extent
covered by a `Rectangle` in various BitmapData methods, as the sum
of two values might be large enough to be rounded up to a larger
value (when rounding `x` and `width` individually would have
produced a smaller overall extent).
2023-05-28 18:46:55 -05:00
Aaron Hill 2ae15b05e8 core: Store Color as an u32 instead of a i32
This is a packed ARGB value, so it doesn't make sense for it to be
signed.
2023-05-28 16:52:09 -05:00
Aaron Hill 3f93abffd5 avm2: Allow replacing and deleting XML attributes 2023-05-28 15:52:57 -05:00
Aaron Hill 14c6d1d959 avm2: Implement URLRequest.requestHeaders
These are directly set on the underlying navigator's HTTP
request type, and get printed out in our test navigator backend.

No validation of the header names is performed - on web, this will be
enforced by the browser.
2023-05-28 12:07:37 -05:00
relrelb ee30646745 avm1: Migrate `DisplacementMapFilter` to `NativeObject` 2023-05-27 23:08:42 +03:00
Lord-McSweeney 420643b045 avm2: Stub Worker 2023-05-27 00:58:34 -05:00
Nathan Adams aeb089ac0f avm2: Move DisplayObject assignment into an initializer 2023-05-26 22:06:20 -05:00
Aaron Hill cf4ca543bd core: Use clone-on-write behavior for render list iteration
When we iterate over a render list (in order to call
`enter_frame`, `construct_frame, etc.) we need to be sure
that we iterate over all of the original `DisplayObjects`
in the list, even if the list is modified during iteration
(e.g. some ActionScript code calls `parent.addChildAt`).

Previously, `RenderIter` would repeatedly call `child_by_index`
on the original `DisplayObjectContainer`, up to the original
child count. If new DisplayObjects were inserted into the list
during iteration, we could miss some of the original DisplayObjects
in the list (as they are now at a greater position in the list).

To solve this, we now store the render list as an `Rc<Vec>`,
and use `Rc::make_mut` to modify it. See the comments
for more details.
2023-05-26 21:42:06 -05:00
Crowdin Bot e98230c988 chore: Update translations from Crowdin 2023-05-27 00:34:44 +02:00
Aaron Hill 9fad8ddd9d core: Fix nightly clippy lints 2023-05-26 17:06:28 -05:00
Aaron Hill e98ff6a6d7 avm2: Add legacy handling for configureBackBuffer with SWF version < 30
With SWF version < 30, Context3D.configureBackBuffer throws
an error with a less informative message when the width/height
are out of range. Additionally, it seems to special case
the case width=0, height=0, antiAlias=0. enableDepthAndStencil=false,
and does *not* throw an error. This is relied on by Sniper Team.
2023-05-24 18:15:30 -05:00
Adrian Wielgosik a1797a351d avm2: Avoid a function call on every push() 2023-05-24 23:33:09 +02:00
Aaron Hill 9a1a21ef3a avm2: Implement Stage3D.visible 2023-05-24 14:20:40 -05:00
MartySVK 3be933d7c2
avm2: Stub ContextMenu.builtInItems setter (#11187) 2023-05-24 01:50:03 +00:00
iwannabethedev 1e0714aaa1 core: Fix serialization of arrays with dynamic properties. 2023-05-23 19:46:24 -05:00
iwannabethedev 83520d0daf avm2: Minor refactoring of duplicated code. 2023-05-24 02:30:52 +02:00
Aaron Hill 358beabf5a avm2: Add Matrix3D.[recompose,decompose,copyColumnTo,invert,determinant]
The Flash Player 'Matrix3D.recompose' method throws exceptions under
certain circumstances with the "quaternion" orientation style.
I haven't yet figured this out yet, so I've marked that case as a stub.

All of the implementations are based on the OpenFL code, with some
tweaks to match Flash Player's behavior.
2023-05-23 18:51:46 -05:00
Aaron Hill c53a903d35 avm2: Suppress events for selectable was_static TextFields
TextFields have a very unusual behavior - if they are selectable
and have `was_static`, they *block* the dispatch of mouse events when
they're targeted (not even the Stage will receive the event).
This only occurs when the TextField is actually targeted
(which requires mouseEnabled=true). With mouseEnabled=false,
the event will be dispatched with an ancestor as the target,
following the usual logic.

Also, TextFields now properly propagate mouse picks to
their parent if mouseEnabled=false. Previously, setting
mouseEnabled=false for a TextField made all mouse picks
cause a miss on it. This was the cause of the Turbo Kids
regression.

Fixes #10245
2023-05-23 17:57:06 -05:00
Nathan Adams afa78ebdfe avm1: Correctly send onUnload events for movies unloaded with GetURL2 - fixes #2422 2023-05-22 23:41:41 +02:00
Aaron Hill ace87861ce avm2: Make ByteArray.readMultiByte cut string off at null byte
We already had this behavior in `readUTF` and `readUTFBytes`,
but we need it in `readMultiByte` as well.
2023-05-22 16:01:50 -05:00
Aaron Hill b94f9f3043 avm2: Coerce function return value to declared return type
This can actually affect runtime behavior - if the return type is
declared as 'int', then an instance of a custom class will get
coerced to 0 when returned by the function.
'Plants vs Zombies Demo' relies on this - it has a function which
incorrectly returns an object instead of an array index, but the
value gets silently coerced to 0 under Flash Player.
2023-05-22 13:47:32 -05:00
renovate[bot] 5d2477fe98 chore(deps): lock file maintenance rust dependencies 2023-05-22 19:12:08 +03:00
nosamu bb15c90d82 avm2: Implement XML.hasSimpleContent and hasComplexContent 2023-05-22 06:17:37 -05:00
Aaron Hill 6ac4e5256d avm2: Check parent domain in export_class
The `export_class` function mirrors `export_definition`, and needs
to avoid exporting something already defined in a parent domain.
2023-05-21 17:37:54 -05:00
relrelb c230dcf0f8 avm1: Migrate `BitmapData` to `NativeObject` 2023-05-21 21:02:14 +03:00
nosamu 7dfc36c6fc web: Support pasting from clipboard 2023-05-21 15:26:42 +02:00
nosamu ee956927b7 core: Fix TextField.maxChars handling and address other reviews 2023-05-21 15:26:42 +02:00
nosamu 4e579b7e68 core: Move left/right arrow handling to `text_control_input` 2023-05-21 15:26:42 +02:00
nosamu 0dbb4c46e4 core: Move `Delete` and `Backspace` handling to `text_control_input()`
Co-authored-by: jmckiern <jmckiern@tcd.ie>
2023-05-21 15:26:42 +02:00
nosamu fab72ac01c core: Implement handling of text control input
Co-authored-by: jmckiern <jmckiern@tcd.ie>
2023-05-21 15:26:42 +02:00
jmckiern 67d74047a9 core: Add clipboard_content getter 2023-05-21 15:26:42 +02:00
Aaron Hill 95b0b29310 avm2: Initial implementation of URLStream
This is based on URLLoader, and doesn't actualy 'stream' data -
it all becomes available once the request finishes. However, this
is good enough to get Sniper Team working.
2023-05-21 15:00:08 +02:00
TÖRÖK Attila 65117499fd chore: Bump regress and toml dependencies 2023-05-21 14:42:01 +02:00
Aaron Hill 54cf9065fb core: Don't create a fake root clip when instantiating Stage
AVM2 can handle a missing root movie, and AVM1 doesn't seem
to rely on having a root movie during Stage initialization.
2023-05-21 08:11:11 +03:00
Lord-McSweeney 7c9b0378f6 nit: avm2: Fix stub message in Socket 2023-05-21 07:31:50 +03:00
iwannabethedev 7b12cb882f core: Fix error message in 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev 0f30b378b0 core: Re-arrange internal implementation of 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev deae231176 core: Clean up TODOs in 'pixelDissolve()'. 2023-05-21 01:47:06 +02:00
iwannabethedev 6f98d39c25 core: Implement 'pixelDissolve()' for AVM1. 2023-05-21 01:47:06 +02:00
iwannabethedev 40c40f278c core: 'pixelDissolve()' bug fix and clean-up. 2023-05-21 01:47:06 +02:00
iwannabethedev 1bd9f82496 core: Implements `BitmapData.pixelDissolve()` for AVM2.
The changes have automated tests for them.

The implementation has not been implemented or tested for AVM1 yet.
2023-05-21 01:47:06 +02:00
Aaron Hill ad77cb0209 core: Refactor Loader to properly load images
We now run all of the completion logic (including adding
the new DisplayObject as a child) in `Loader::movie_loader_complete`.
Previously, some of this logic was run from `Loader::preload_tick`,
which meant that loaded images did not have the logic run.

Also, `BitmapData` and `Bitmap` instances (with corresponding AVM2
objects) are now properly constructed for loaded images.
2023-05-20 18:35:10 -05:00
Toad06 b88e19ef6c avm1: Filter buttons that use a `keyPress` event 2023-05-21 01:13:26 +02:00
Aaron Hill 5d62ef90f2 wgpu: Use intermediate buffer for Context3DCommand::CopyBitmapToTexture
In a previous PR, I introduced an optimization that used
`copy_texture_to_texture` to copy directly from a BitmapData GPU
texture to a Stage3D GPU texture.

Unfortunately, this optimization is incorrect. A BitmapData GPU
texture can be modified at any time by normal AVM2 code - in
particular, in might be modified before we submit the encoded
`copy_texture_to_texture` command. This shows up in Sniper Team,
which re-uses BitmapData objects for multiple distinct textures.
The previous 'optimization' resulted in the wrong BitmapData contents
getting uploaded to a texture (since it was changed before the copy
command was submitted).
2023-05-20 17:38:26 -05:00
Aaron Hill 0864853d44 avm2: Allow passing `null` to `Context3D.setProgram`
This clears the vertex and fragment shader programs
(bringing the Context3D back to its initial state).
2023-05-20 16:23:03 -05:00
EmperorBale 53acdee979 avm2: Remove NOPMD comments 2023-05-20 13:59:12 -07:00
EmperorBale 78c8aa2a0d core: Remove linter code 2023-05-20 13:59:12 -07:00
Tom Schuster 2af58dc832 avm2: Support set on XMLList with a single child
XMLList with a single child should behave like an XML object.
2023-05-19 20:10:47 -05:00
Lord-McSweeney 0948bf7bbd avm2: Implement Capabilities.playerType and Capabilities.version (and mark the other Capabilities getters as stubs) 2023-05-19 16:54:46 -05:00
Aaron Hill 6025878aab avm2: Respect SKIP_INVISIBLE for DisplayObject
Previously, we allowed mouse picks of certain invisible
DisplayObjects, even when HitTestOptions::SKIP_INVISIBLE
was set.
2023-05-19 08:12:00 -05:00
Aaron Hill 5c68bceb7b avm2: Set 'bubbles' to 'false' for rollOut and rollOver events
This matches the Flash Player documentation. Since we were
manually traversing the displayobject hierarching when firing
the event, we ended up firing duplicate events to parents
because bubbling was enabled.
2023-05-18 19:01:55 -05:00
Aaron Hill 7004e98b23 avm2: Don't validate Context3DVertexBufferFormat when buffer is null
This matches Flash Player's behavior - some SWFS try to pass in 'null'
for both the buffer and format.
2023-05-18 15:14:29 -05:00
renovate[bot] f969bdce71 fix(deps): update wasm-bindgen 2023-05-17 06:44:50 +03:00
Aaron Hill 75569e1311 avm2: Throw error for invalid Stage3D back buffer size 2023-05-16 17:36:22 -05:00
Aaron Hill 12e815d383 core: Take 'self' instead of '&mut self' in `replace_with_movie` 2023-05-15 20:01:02 +03:00
renovate[bot] 5b26d1b2ee fix(deps): update wasm-bindgen 2023-05-15 10:00:49 +03:00
Lord-McSweeney b24fc7c07f avm2: Improve Shader stub 2023-05-15 09:40:43 +03:00
iwannabethedev d0f8061c85 core: documentation changes. 2023-05-15 00:51:54 +02:00
iwannabethedev 8c92cecb60 core: Add documentation to Color. 2023-05-15 00:51:54 +02:00
iwannabethedev 9de2abe8b8 core: Fix wrong color form used. 2023-05-15 00:51:54 +02:00
relrelb 4a26ceb14b render: Use `swf::Point<Twips>` in more places 2023-05-14 22:48:41 +03:00
relrelb 220f8cd1cf render: Use `swf::Point<Twips>` in `shape_hit_test()` 2023-05-14 22:48:41 +03:00
relrelb 598c8cde0e render: Use `swf::Point<Twips>` in `DrawCommand::CurveTo` 2023-05-14 22:48:41 +03:00
relrelb 544e445d2f render: Use `swf::Point<Twips>` in `DrawCommand::LineTo` 2023-05-14 22:48:41 +03:00
relrelb e5c7d70f3f render: Use `swf::Point<Twips>` in `DrawCommand::MoveTo` 2023-05-14 22:48:41 +03:00
Lord-McSweeney 3079ae30a5 avm2: Stub SharedObject.setProperty 2023-05-14 19:01:24 +03:00
Nathan Adams a9ba46594f chore: Updated translations from Crowdin 2023-05-14 13:31:32 +02:00
Lord-McSweeney 017a44084f avm2: nit: Provide error number (2025) in error message for validate_remove_operation 2023-05-13 21:30:47 +03:00
Aaron Hill 729d5a2c65 avm2: Don't overwrite existing entry in `export_class`
This makes the behavior consistent with `export_definition`
2023-05-13 11:15:54 +03:00
Aaron Hill 3c6820c6e1 avm2: Check length and copy vector in Matrix3D constructor 2023-05-13 11:00:31 +03:00
iwannabethedev 476ff4aeef core: Fix drawing on cpu with color transform.
Taken directly from this commit, credits to Dinnerbone:
9b76090e1f
2023-05-12 22:42:44 +02:00
Toad06 2e972b8f32 avm1: `button.useHandCursor` can hold any value 2023-05-12 01:13:28 +03:00
iwannabethedev 93450b28b0 avm2: Add 'static length' for most types. 2023-05-11 22:16:55 +02:00
relrelb 660acac427 swf: Use `PointDelta<Twips>` in `ShapeRecord` 2023-05-11 08:55:44 +03:00
relrelb b93a32af0f swf: Use `Point<Twips>` in `StyleChangeData::move_to`
No functionality change.
2023-05-11 08:55:44 +03:00
Aaron Hill e488cc9f7a wgpu: Allow unaligned writes to IndexBuffer3D
wgpu requires buffer copy sizes and offsets to be 4-byte aligned.
Unfortunately, ActionScript can perform 2-byte aligned uploads
into an IndexBuffer3D.

To support this, we now keep a copy of the IndexBuffer3D on the CPU.
When performing an upload to the buffer, we round the offset down
and the size up to the nearest 4-byte aligned value. The cpu buffer
is used to fill out the write with existing data, so that we don't
corrupt the contents of the GPU buffer.

To avoid introducing a new RefCell, I've changed IndexBuffer3D
to use a `Box` instead of an `Rc` to store the trait object.
This allows us to pass a mutable reference down to the backend.
2023-05-10 18:20:29 -05:00
Huw Pritchard b79b192a58 avm2: Implement PrintJobOptions 2023-05-09 20:51:44 -05:00
Nathan Adams fc96fdf1cc chore: Update translations from Crowdin 2023-05-10 00:29:13 +02:00
Nathan Adams fd5a7cdbc2 core: Rename text to core_text just to avoid confusion if used from another crate with its own text methods 2023-05-09 00:06:49 +02:00
Nathan Adams e6ea074a3f core: Made context menu items translatable 2023-05-09 00:06:49 +02:00
Nathan Adams 229c301e18 core: Add i18n module using Fluent 2023-05-09 00:06:49 +02:00
Aaron Hill 1908d85f65 avm2: Initialize `Object` instance vtable before other classes
Early class construction is tricky - `Object` defines properties
that need to get copied into subclass instance vtables, but `Class`
defines `prototype`, which needs to be copied into the *class* vtable
of `Object`.

To accomplish this, I've split out instance vtable initialization
into a separate `init_instance_vtable`. We call
`object_class.init_instance_vtable` before
`class_class.init_instance_vtable`, but do things in the opposite
order for `into_finished_class` (`class_class.into_finished_class` is
called before `object_class.into_finished_class`)
2023-05-07 07:46:30 -05:00
iwannabethedev 724df48186 avm2: Add AS 'length()' to XML. 2023-05-06 12:02:06 -05:00
Lord-McSweeney 4b9430c2cb avm2: Stub flash.system.fscommand 2023-05-06 09:52:30 +03:00
Toad06 8377fe0233 web: Support copying to clipboard 2023-05-05 21:58:41 +02:00
nosamu 0633b4cdfe core: Improve compatibility rule for Kongregate 2023-05-05 10:44:57 +03:00
friedkeenan bfe84c3685 Rename 'name_array' to 'name_vector'.
The '_array' suffix was from a previous iteration as I tried to figure out how to return a vector.
2023-05-04 19:51:04 -05:00
friedkeenan 24e0e0102c avm2: Implement ApplicationDomain::getQualifiedDefinitionNames 2023-05-04 19:51:04 -05:00
Tom Schuster f6c0685992 avm2: Allow setting XML methods as properties 2023-05-04 19:34:14 -05:00
Lord-McSweeney f78ce82f90
avm2: Socket should implement IDataOutput and IDataInput 2023-05-05 00:13:45 +03:00
friedkeenan c484d44226
avm2: Stub rest of Socket's methods 2023-05-04 17:03:52 +00:00
relrelb 891d1dce7e core: Don't duplicate `ButtonAction`s
Previously, a separate `ButtonAction` was stored for each
`ButtonActionCondition`. However, this can be eliminated using
`bitflags`.
2023-05-03 23:12:20 +03:00
Nathan Adams dc44c1c797 core: Use MutationContext instead of UpdateContext for copy_on_cpu 2023-05-03 21:15:48 +02:00
Nathan Adams 243d82770d core: Use copy_from_slice for whole-BMD-replacement 2023-05-03 21:15:48 +02:00
Nathan Adams 53c6927b6f core: Clarify comment when we can skip alpha premultiplication 2023-05-03 21:15:48 +02:00
Nathan Adams c5293bd981 core: Don't actually apply a filter if it's unsupported, just copy 2023-05-03 21:15:48 +02:00
Nathan Adams 5ff804f5c2 core: Add a method for BitmapData.draw() with color transform on cpu 2023-05-03 21:15:48 +02:00
Nathan Adams 7b20003c6a core: Treat copy_pixels_with_alpha_source as copy_pixels if alpha source is same as source 2023-05-03 21:15:48 +02:00
Nathan Adams fe3d8c10b1 core: Added an efficient copy method that does cpu or gpu copy depending on what's best situationally 2023-05-03 21:15:48 +02:00
Nathan Adams adabb81804 core: Introduce PixelRegion::clamp_with_intersection and made most operations with two overlapping regions use it 2023-05-03 21:15:48 +02:00
Lord-McSweeney d66d216917 avm2: Date related fixes
1. Date should have a call handler.
2. Date should have a static length property.
2023-05-03 20:04:59 +02:00
Aaron Kaluszka 472fe7068f avm2: Implement BitmapData.compare 2023-05-03 11:32:20 +02: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
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
Tom Schuster 791081051f avm2: Alternative implementation of XML hasOwnProperty @attribute 2023-04-29 16:34:10 -05:00
Lord-McSweeney d1e4cccabb avm2: Stub flash.net.Socket 2023-04-29 22:18:06 +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
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
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 cfde53cde2 core: replace `string::decode_swf_str` by a `SwfStrExt` extention trait 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
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 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
Nathan Adams cc731a78ee avm2: Respect data, method and contentType in Loader.load() 2023-04-26 12:46:23 +02:00
Lord-McSweeney f412f62127 avm2/tests: use try_get_object in JSON/Add test for undefined receiver 2023-04-26 00:17:44 +02:00
Lord-McSweeney 319886587d avm2: Use ParametersExt in JSON 2023-04-26 00:17:44 +02:00
Lord-McSweeney 58212ec280 avm2: Throw AVM errors for JSON operations (and add tests) 2023-04-26 00:17:44 +02:00
Aaron Hill 6eba8d07ee avm2: Implement MorphShape class and use it for MorphShape displayobject 2023-04-25 18:43:43 +02:00
Toad06 45795c9d24 desktop/web: Add a mouse enter event 2023-04-25 18:01:49 +02:00
Toad06 1ca1435dc7 core: Detect when the mouse moves out of the stage 2023-04-25 18:01:49 +02:00
Toad06 ad4dc943fa avm1: Fix some issues with buttons 2023-04-25 17:50:25 +02:00
Aaron Hill 4432c45eb3 avm2: Mark 'callee' property as non-enumerable on 'arguments' array
Some SWFs iterate over the 'arguments' array, and the 'callee' property
should not get enumerated.
2023-04-25 17:29:20 +02:00
relrelb ff7c458739 core: Accept borrowed strings in `NavigatorBackend::navigate_to_url`
This avoids some unnecessary clones.
2023-04-24 22:06:47 +03:00
nosamu 3cde3482f4 core: Add frame rate config option 2023-04-24 14:01:37 +02:00
relrelb 808a0fd26e core: Clamp various `BitmapData` thresholds to `u8` 2023-04-24 08:35:59 +03:00
Tom Schuster 886244478e avm2: Complete the implementation of XML abstract equality 2023-04-23 22:07:54 -05:00
renovate[bot] 3b3c08a354 chore(deps): lock file maintenance rust dependencies 2023-04-24 01:22:07 +02:00
Aaron Hill 15af946cf1 avm2: Stop after first frame when movieclip doesn't extend MovieClip
It's possible to have a DefineSprite tag with multiple frames,
but with a corresponding SymbolClass that directly extends
`Sprite` (and therefore does *not* extend `MovieClip`). When this
happens, Flash Player stops after the first frame.
2023-04-23 16:48:38 -05:00
Aaron Hill 33e9713279 avm2: Fix get_super and set_super with normal methods
Doing `super.someNonGetter` gives you back a function object.
We were previously attempting to call normal methods as though
they were getters. Additionally, we were failing to properly
get the property from the superclass vtable.
2023-04-23 16:28:59 -05:00
Lord-McSweeney 292e068e48 avm2: Take a MutationContext instead of an...
...Activation in ClassObject.install_class_vtable_and_slots
2023-04-22 20:21:16 +03:00
Lord-McSweeney 3c2ce683fb avm2: Take a MutationContext instead of an Activation in PropertyClass::name 2023-04-22 17:38:19 +02:00
relrelb 1e2139a3e4 core: Use `BitFlags::iter`
Instead of manually shifting bits.
2023-04-22 12:42:51 +02:00
Lord-McSweeney 8fd6224d90 avm2: Add flash.display.GraphicsShaderFill class 2023-04-22 08:16:08 +02:00
Lord-McSweeney 932aa8cd90 avm2: Make TObject.install_instance_slots take a MutationContext instead of an Activation 2023-04-22 08:04:52 +02:00
Lord-McSweeney 34156cc6d1
avm2: Throw AVM error for invalid frame labels 2023-04-22 08:52:19 +03:00
Lord-McSweeney bc0bbeca92 avm2: Throw AVM error for validate_remove_operation...
...in DisplayObjectContainer.
2023-04-21 17:15:43 +02:00
Moulins 60f34f8056 avm1: put an assert to ensure that `avm::Value`'s size doesn't grow again 2023-04-21 16:59:55 +02:00
Moulins bb08d356b1 avm1: shrink `Value` by boxing `MovieClipReference`s
This doesn't actually cost an extra allocation as we can replace an inner
`Gc<Vec<_>>` by a `Box<[_]>` directly.
2023-04-21 16:59:55 +02:00
Aaron Hill 22040552b8 avm2: Take UpdateContext instead of Activation in Object::is_of_type 2023-04-21 16:41:06 +02:00
Toad06 36e71882e7 core: Fix avm2 code interfering with avm1 2023-04-21 15:38:21 +02:00
Lord-McSweeney 5702b272db avm2: Add flash.text.engine stubs 2023-04-21 15:16:02 +02:00
Moulins be67761a22 chore: appease (beta) clippy 2023-04-21 14:44:15 +02:00
Adrian Wielgosik 4e9cdc338f avm2: Support `newcatch` with finally-scopes 2023-04-18 22:15:57 +02:00
Lord-McSweeney 2bab9022b4 avm2: Show detailed error message...
...while loading ABC files.
2023-04-18 21:28:38 +02:00
Aaron Hill 78b386d775 avm2: Stub URLLoader.close 2023-04-17 15:58:46 -07:00
Lord-McSweeney f25398898a
avm2: stageWidth/Height should be of int type (#10712) 2023-04-16 21:58:32 +02:00
AllinolCP d367f38eb4
avm2: stub xml.normalize() (#10709)
* avm2: stub xml.normalize()
2023-04-16 12:41:52 -04:00
Lord-McSweeney fef7eeed90 avm2: Stub TextField.useRichTextClipboard 2023-04-13 22:09:11 +02:00
nosamu a6c659945e core: Allow focusing selectable EditText fields 2023-04-13 21:48:40 +02:00
Tom Schuster aca4329dbf avm2: Implement XMLList.child 2023-04-11 14:49:32 -04:00
Nathan Adams 35f3a21110 core: Fix bitmapdata.floodFill() replacing X with X + test. Fixes #10642 2023-04-11 10:40:57 -04:00
Mike Welsh 7cfd4470b1 avm2: Use proper scale for `Graphics.beginBitmapFill` (fix #10628) 2023-04-11 11:36:49 +02:00
Toad06 aef3ed2fcb avm1: Correct `MovieClip.focusEnabled` 2023-04-09 14:11:24 -07:00
Tom Schuster baf9bda9e9 avm2: Partially implement XML/XMLList abstract equality 2023-04-09 12:02:20 -07:00
AllinolCP 0643426b84 avm2: stub URLRequest.requestHeaders 2023-04-08 18:31:02 -07:00
Mike Welsh 7d7fe1bfdd core: Implement `Display` for `NavigationMethod` 2023-04-08 13:37:25 -07:00
Mike Welsh 711a012fea avm1: Exclude shape children from `StageObject::get_keys`
Non-interactive children such as shapes are not returned when
iterating over the keys of a stage object in AVM1.
2023-04-08 13:37:25 -07:00
Mike Welsh 3716422b37 avm1: Grab correct variables for `MovieClip.loadVariables` and `loadMovie`
The request was being populated with parameters from the local
function scope, not the movieclip that is doing the loading.
2023-04-08 13:37:25 -07:00
relrelb 93a0fd43d6 avm1: Migrate `ColorMatrixFilter` to `NativeObject` 2023-04-08 13:40:32 +03:00
relrelb 3dcf246870 avm1: Migrate `DropShadowFilter` to `NativeObject` 2023-04-08 13:40:32 +03:00
relrelb 814cb00821 avm1: Migrate `GlowFilter` to `NativeObject` 2023-04-08 13:40:32 +03:00
relrelb b74f515c34 avm1: Refactor `BevelFilter` 2023-04-08 13:40:32 +03:00
relrelb cdffc00e94 avm1: Refactor `BlurFilter` 2023-04-08 13:40:32 +03:00
Tom Schuster d9e69563d3 avm2: Implement XMLList.copy 2023-04-07 12:29:49 -05:00
Udeshya 54a8672390
avm2: Trim xml text nodes when being parsed (#10341) 2023-04-06 22:41:46 -05:00
Lord-McSweeney 60ae2edf92 avm2: Use AVM error for invalid bitmapdata error 2023-04-06 11:53:56 -05:00
Aaron Hill 6844d1bf19 avm2: Call 'AS3::concat' in ColorMatrixFilter
This ensures that we call the normal Array concat method
(or a method that overrides it). Some SWFs may define a *public*
concat method in an Array subclass, with a different signature.

Fixes #10552
2023-04-05 22:48:12 -07:00
Aaron Hill 962cf92223 avm2: Implement Context3D.setSamplerStateAt
This fixes pixelated backgrounds in Fancy Pants World 4 Part 3
2023-04-05 16:44:07 -07:00
Toad06 5e165a0682 avm1: Fix some issues with `Selection.getFocus()` and `setFocus()` 2023-04-05 15:53:18 -07:00
Mike Welsh 792cfd82c7 avm2: Implement `Context3D.setColorMask` 2023-04-05 12:22:13 -07:00
Toad06 76b9ed80ba core: Support `maxlength` attribute in EditText 2023-04-05 11:59:17 -07:00
onkrot 19284cb1be avm2: Add more flash.accessibility members 2023-04-05 11:10:46 -07:00
Mike Welsh 37bf6b39e6 core: Remove `RenderContext::allow_mask`
This is now handled by `CommandList::maskers_in_progress`, so core
code does not have to worry about whether or not it can draw a
mask.
2023-04-04 13:10:45 -07:00
Lord-McSweeney 8d527ceed2 avm2: Array-related fixes
1. toString and toLocaleString should only be defined on the prototype.
2. concat should only be defined as an as3 and proto property, not as an instace property.
3. Array doesn't have a valueOf defined directly on it.
2023-04-04 00:43:46 -07:00
TÖRÖK Attila 493971ab8a render: Make RenderBackend::update_texture() take a Bitmap (like register_bitmap()) 2023-04-04 00:15:07 -07:00
TÖRÖK Attila 5f94476b2a render: Add BitmapFormat::Yuv420p and BitmapFormat::Yuva420p 2023-04-04 00:15:07 -07:00
nosamu 315a7c87e5 core: Focus EditText fields only if editable 2023-04-03 23:27:18 -07:00
Mike Welsh bde9765864 avm2: Implement `Matrix3D.transformVector` and `deltaTransformVector` 2023-04-03 17:09:16 -07:00
Nathan Adams 3a297f8adc core: Iterate y then x in bitmapdata operations 2023-04-03 18:25:20 +02:00
Nathan Adams 2a9288870a core: Made operations take in MutationContext instead of &mut UpdateContext where possible 2023-04-03 18:25:20 +02:00
Nathan Adams 4477d65331 core: Made overwrite_cpu_pixels_from_gpu take in MutationContext instead of &mut UpdateContext 2023-04-03 18:25:20 +02:00
Nathan Adams e62e2a94e8 core: Move dummy() from BitmapData to BitmapDataWrapper 2023-04-03 18:25:20 +02:00
Nathan Adams f9a9c05863 avm2: Made fill_bitmap_data_from_symbol return a BitmapDataWrapper, instead of taking in a BitmapData 2023-04-03 18:25:20 +02:00
Nathan Adams ab534bab87 core: Rename BitmapData (of the stage variety) to BitmapGraphicData to separate it from BitmapData of the editable data variety 2023-04-03 18:25:20 +02:00
Nathan Adams e1e4a01f13 avm2: Make BitmapDataObject::from_bitmap_data take BitmapDataWrapper 2023-04-03 18:25:20 +02:00
Nathan Adams 103158101a avm2: Make Object::init_bitmap_data take in BitmapDataWrapper 2023-04-03 18:25:20 +02:00
Nathan Adams a80a1422b0 avm2: Renamed bitmap_data_wrapper into bitmap_data 2023-04-03 18:25:20 +02:00
Nathan Adams 0f81d60db2 avm1: Removed BitmapDataObject::bitmap_data() as it's no longer used (or recommended to use) 2023-04-03 18:25:20 +02:00
Nathan Adams 7ffdcccf8a avm1: Don't sync in BitmapData.loadBitmap() 2023-04-03 18:25:20 +02:00
Nathan Adams f8ef01d2ef avm1: Don't sync a bitmapdata to read its width or height 2023-04-03 18:25:20 +02:00
Nathan Adams c037e014c2 avm1: Don't sync in new Bitmap(x) 2023-04-03 18:25:20 +02:00
Nathan Adams e593541309 avm1: Don't sync bitmapdata when disposing it 2023-04-03 18:25:20 +02:00
Nathan Adams f7da335083 avm2: Renamed as_bitmap_data_wrapper into as_bitmap_data 2023-04-03 18:25:20 +02:00
Nathan Adams 1521c7b6ee avm2: Removed Object::as_bitmap_data() as it's no longer used (or recommended to use) 2023-04-03 18:25:20 +02:00
Nathan Adams b1f7fecacb avm2: Don't sync in new Bitmap(x) 2023-04-03 18:25:20 +02:00
Nathan Adams 444e256708 avm2: Made Bitmap.bitmapData not recreate a new BitmapDataWrapper every time its called 2023-04-03 18:25:20 +02:00
Tom Schuster b0576c2155 avm2: Improve the Sound::extract stub 2023-04-03 00:22:23 -07:00
onkrot d047ecb130 avm2: Add X509 certificate classes 2023-04-02 23:59:37 -07:00
renovate[bot] cd3ad90d61 chore(deps): lock file maintenance rust dependencies 2023-04-02 22:00:49 -07:00
Lord-McSweeney d1b8ec7a7e avm2: Stub Shader 2023-04-02 19:56:14 -07:00
Lord-McSweeney c19031a6fc avm2: Stub ShaderData 2023-04-02 19:56:14 -07:00
Aaron Hill a2fa362091 wgpu: Implement double buffering for Context3D
This matches the Context3D docs. Calling 'present' swaps
the buffers.

I wasn't certain if we actually need a double-buffered depth
texture, but I included one just to be safe.
2023-04-02 19:24:23 -07:00
Aaron Hill 671ebdfa8f wgpu: Execute Context3D commands immediately
Now that most of the complicated Context3D methods have been
implemented, we can simplify the overall design. Instead of queueing
up commands and having `present` execute them in a loop, we
can execute each command immediately. The key insight is that
a `RenderPass` is only needed for `DrawTriangles`, so we don't
have to store it in `Context3D` and deal with complicated lifetime
issues.

The old behavior gave us implicit double-buffering behavior,
since nothing would get rendered until a 'present' call.
Now that a 'drawTriangles' call will immediately submit
a draw command, we need to implement actual double buffering.
This is done in the next commit.
2023-04-02 19:24:23 -07:00
Moulins 9441182b7d avm2: move event dispatch error handling in a single place
The `Avm2::{dispatch, broadcast}_event` methods now log and swallow any
AVM2 error occuring during the dispatch, instead of repeating the
handling code for each caller.

This also introduces some behavioral changes:
- Errors messages are more consistent;
- For consistency with `broadcast_event`, `dispatch_event` panics if
  given a non-event object to dispatch.
2023-04-02 16:52:42 -07:00
Udeshya 34775965ea
avm2: Implement `Transform.pixelBounds` 2023-04-02 23:25:10 +00:00
AllinolCP f0a8e50be1 avm2: implement decodeURI 2023-04-02 14:49:07 -07:00