Commit Graph

6221 Commits

Author SHA1 Message Date
sleepycatcoding 4671122dee avm2: Add a way to lookup E4XNode ancestors 2023-08-29 00:48:48 +02:00
renovate[bot] 4e75c3890a fix(deps): update rust dependencies 2023-08-28 07:39:35 +02:00
Aaron Hill 2f6f00179b avm2: Log an error when a symbol class lookup fails
This is almost guaranteed to cause problems, so it shouldn't
be a warning.
2023-08-27 21:15:34 -04:00
Aaron Hill 88acc96467 avm2: Fix XML/XMLDocument ignoreWhite handling for cdata
The ignoreWhite settings only affect text nodes, not cdata nodes.
Additionally, there should be no special case for empty text.
2023-08-27 20:28:20 -04:00
sleepycatcoding 33164d3f56 avm2: Preserve attribute flag when filling lazy multiname with QName
Fixes #12570
2023-08-27 19:40:00 -04:00
Aaron Hill 879dac347c avm2: Handle child being removing from `Loader`
`Loader` override `removeChild` and `removeChildAt` to try to prevent
user code from removing the loaded content child. However, this can be
bypassed by calling `otherContainer.addChild(loader.content)`, which
actually removes the child from the loader. Stealth Hunter 2 relies
on this behavior.

To make this work, `Loader.content` needs to go through
`contentLoaderInfo`, instead of relying on a child being present.
2023-08-27 19:13:45 -04:00
Nathan Adams 19ad492eaa avm2: Implement Graphics.cubicCurveTo and CUBIC_CURVE_TO 2023-08-27 20:17:43 +02:00
Nathan Adams eb2afb19c4 render: Add DrawCommand::CubicCurveTo 2023-08-27 20:17:43 +02:00
Nathan Adams 076977cc75 render: Rename DrawCommand::CurveTo to DrawCommand::QuadraticCurveTo 2023-08-27 20:17:43 +02:00
Lord-McSweeney 04f93737c4 avm2: Make instance initialization functions variadic for int and uint 2023-08-26 13:38:33 +02:00
Lord-McSweeney 32599945bb avm2: uint/int toPrecision/toFixed/toExponential should call Number's toPrecision/toFixed/toExponential methods. This deduplicates the methods across int and uint. 2023-08-26 13:38:33 +02:00
Lord-McSweeney 72c659fd0e avm2: Add some static properties to Number 2023-08-26 13:38:33 +02:00
Lord-McSweeney d366d19de6 avm2: Various (u)int/Number correctness fixes 2023-08-26 13:38:33 +02:00
SuchAFuriousDeath 40daa56f0b
avm2: partially implement Graphics.drawTriangles and drawGraphicsData (#12559) 2023-08-26 10:57:07 +00:00
nosamu d25fda7cc8 avm2: Throw TypeError for null argument in TextField string property setters 2023-08-26 12:35:01 +02:00
Moulins 87437c1d6b avm2: use `RefLock` instead of `GcCell` in avm2's scope chain
Also bumps gc-arena to be able to use `Write<Option<_>>::as_write`
2023-08-26 11:00:40 +02:00
Moulins ecb5036d9e avm1/2 use plain `RefCell` for `TextFormat` objects
`TextFormat` only contains static data and doesn't need write barriers
2023-08-26 11:00:40 +02:00
Moulins c27728b7b2 avm1/2: use plain `Cell` in `Date` object
`Date` only contains static data, so write barrier management is
unnecessary.
2023-08-26 11:00:40 +02:00
Moulins e2b73e80a5 avm2: use Lock instead of GcCell in BytecodeMethod 2023-08-26 11:00:40 +02:00
Moulins 9b915b7e4e core: use GcLock instead of GcCell in FocusTracker
Slightly reorganizes `FocusTracker::set` to only trigger a write barrier
if the focus changed.
2023-08-26 11:00:40 +02:00
Moulins 88c7f69c57 avm1: use Lock instead of GcCell in MovieClipReference 2023-08-26 11:00:40 +02:00
sleepycatcoding 75566b92e0 avm2: XML/XMLList is converted to a string when set as attribute value 2023-08-25 11:20:51 +02:00
David Wendt 52d940b8de core: Rename `init_buffer` to `reset_buffer` 2023-08-23 15:36:20 -06:00
David Wendt 51c8799b32 core: Rename `collect_sound_stream` to `cleanup_sound_stream` 2023-08-23 15:36:20 -06:00
David Wendt 6e3c468592 core: When reading part of a `Substream` slice for the tag reader, don't throw out the rest of it 2023-08-23 15:36:20 -06:00
David Wendt 046a1f0efc core: When loading new data into a `NetStream` you must always clear the existing data out first.
`init_buffer` will remove all existing buffer state and prepare the `NetStream` to accept a new/different video.
2023-08-23 15:36:20 -06:00
David Wendt 3b90e75b17 core: AVM1 streams do not need to be attached to a movie clip in order to play audio 2023-08-23 15:36:20 -06:00
David Wendt 3fd31f1739 core: Fix #12502.
This would ordinarily be a separate branch but the fix deadlocks without the new buffer type.
2023-08-23 15:36:20 -06:00
David Wendt 2d0815c013 tests: Add test cases for `SliceCursor` 2023-08-23 15:36:20 -06:00
David Wendt 4ee721e5c2 chore: Fix various cargo errors 2023-08-23 15:36:20 -06:00
David Wendt 304f04952d core: `get_sound_duration` does not accept `SoundInstanceHandles` and I don't know why the compiler didn't flag this 2023-08-23 15:36:20 -06:00
David Wendt a55ba16c29 core: When playing audio, queue all the tags first and then start the sound.
This prevents the sound from finishing before we can add a second slice to it.
2023-08-23 15:36:20 -06:00
David Wendt 8113b3a5f8 core: Allow the MP3 decoder to look ahead by up to 5 tags in the FLV to try and get rid of audio stuttering
Spolier alert: this doesn't work, I'm just committing this for archival purposes.
2023-08-23 15:36:20 -06:00
David Wendt 1b7eb646b6 core: Split all FLV audio, video, and script tag processing into separate functions. 2023-08-23 15:36:20 -06:00
David Wendt 257aabe4c0 core: `SubstreamChunksIter` must always advance on `next`! 2023-08-23 15:36:20 -06:00
David Wendt 782181557b core: Fix `SubstreamTagReader`'s chunk resizing 2023-08-23 15:36:20 -06:00
David Wendt cfe8b3c464 core: Add `LowerHex` and `UpperHex` representations of `Slice` and `SliceRef` for debugging. 2023-08-23 15:36:20 -06:00
David Wendt 7158039135 audio: Audio streamed from FLVs do not have the SWF MP3 header 2023-08-23 15:36:20 -06:00
David Wendt dde4579a9e core: `Substream` sounds must be started with at least one data block in them 2023-08-23 15:36:20 -06:00
David Wendt 438f53a936 core: Explicitly report a `TooManySounds` error instead of coercing all failure modes into returning `None` in `AudioManager` 2023-08-23 15:36:20 -06:00
David Wendt be3787a489 core: Fix `SubstreamCursor` not accounting for consumed bytes properly 2023-08-23 15:36:20 -06:00
David Wendt 9b29791eeb avm1: Implement `MovieClip.attachAudio`.
`NetStream`s in AVM1 do not play audio unless attached to a `MovieClip`. As far as I can tell there doesn't seem to be any equivalent API in AVM2.
2023-08-23 15:36:20 -06:00
David Wendt dbee260d79 core: Stream audio data from FLVs into the audio backend 2023-08-23 15:36:20 -06:00
David Wendt f5d6bf9fb9 audio: Add support for playing substream sounds through the audio manager 2023-08-23 15:36:20 -06:00
David Wendt 4b5398e122 audio: Implement `start_substream`.
This also removes `append_substream` since `Substream` now handles that internally.

This requires duplicating a huge chunk of the decoder code to work with `Buffer` types instead of `SwfMovie` types. Eventually we'll want to wipe out all the SWF-specific stuff and use `Buffer` exclusively.
2023-08-23 15:36:20 -06:00
David Wendt 21cedcee2e core: `Substream` now holds a shared chunk list 2023-08-23 15:36:20 -06:00
David Wendt e411dbeee5 core: Add a `Cursor` equivalent for `Slice`s 2023-08-23 15:36:20 -06:00
David Wendt b46ef355fd core: Add two new methods for managing streaming audio:
* `start_substream` plays audio data from a `Substream`, giving back a `SoundInstanceHandle` that can be manipulated the same way as the one from `start_stream`

 * `append_substream` adds more data to an already playing `Substream` backed `SoundInstance`. In the event that a sound has finished playing, `append_substream` will fail, and you have to start a new sound stream.

This is ultimately intended to replace the current streaming audio setup, which is SWF-specific and has a number of unused parameters. It is also designed to support progressive download in the future.

We also include stub impls for `NullAudioBackend`.
2023-08-23 15:36:20 -06:00
David Wendt c03aa31b21 core: Add a `Substream` type for referencing multiple slices of a `Buffer`.
A `Substream` can be read in one of two ways:

 * Converting it to an iterator that yields individual chunks of the substream in `Slice` form.
 * Converting it to a `SubstreamCursor`, which implements `Read` for bytewise read access.

Chunk-based reading is intended for code that needs to know about chunk boundaries. Self-terminating chunk formats should be read with the cursor type.
2023-08-23 15:36:20 -06:00
David Wendt 6f646f618b core: Add a new `Buffer` type for shared ownership of data.
This is ultimately intended to replace `Vec<u8>` in both `SwfMovie` and `NetStream`, but for the time being we only apply this to streams. SWF-related types are deeply embedded elsewhere and the changes to slice dereferencing will be quite invasive.

We also remove some unnecessary reader drops in `NetStream.tick` at the same time.
2023-08-23 15:36:20 -06:00
nosamu 89d94ae098 avm2: getStackTrace() returns null when the stack trace is unavailable
Fixes #12572
2023-08-22 20:57:10 +02:00
nosamu 20b07ff147 avm1: Fix XML=>String coercion mangling non-ascii chars
Fixes #12859
2023-08-22 17:23:56 +02:00
nosamu 2f40f0093a avm1: Unescape + to space 2023-08-22 16:38:24 +02:00
sleepycatcoding 991976e437 avm2: Implement XML pretty printing 2023-08-22 09:57:59 -04:00
sleepycatcoding 34295f25ff chore: Appease beta Clippy 2023-08-22 15:29:01 +02:00
renovate[bot] 2f4c7d2fe3 fix(deps): update rust dependencies 2023-08-21 08:59:07 +02:00
Nathan Adams 89cc0eb31d core: EditText::is_link_at doesn't need to evaluate fonts 2023-08-20 22:31:27 +02:00
Nathan Adams 385c2d7cb0 core: Fix links in TextEdits when scrolled down 2023-08-20 22:31:27 +02:00
Nathan Adams f0d356589a core: Implement avm2 event: links in texts 2023-08-20 22:31:27 +02:00
Nathan Adams 814a900b03 avm1: asfunction goes by the parent, not root 2023-08-20 22:31:27 +02:00
Nathan Adams b8cda975f3 core: Allow clicking EditTexts if we're clicking links 2023-08-20 22:31:27 +02:00
Nathan Adams 658ac2dd9f core: Implement url handling (+asfunction) in textedits 2023-08-20 22:31:27 +02:00
Nathan Adams d32867d992 core: Fix getting correct text position by coordinates, in multiline text 2023-08-20 22:31:27 +02:00
Nathan Adams 506d1918dd core: Add span list to debug window of EditTexts 2023-08-20 22:31:27 +02:00
Kornelius Rohrschneider a50f5cd072 avm1: Remove delay to enter the unloaded state for non-root MovieClips
avm1_unload_movie has been adapted to only enter the unloaded state with
one frame delay if the MovieClip is a root MovieClip. The unloaded state
is now immediately entered for non-root MovieClips.
This fixes the regressions #12254 and #12265 which got introduced
because of this delay.

However, in Flash Player, even non-root MovieClips enter the unloaded
state one frame after the unloadMovie command has been read. Ruffle is
probably replacing a MovieClip differently to Flash, therefore
introducing these regressions when trying to emulate that delay.
Documentation explaining this all has been added to avm1_unload_movie.

Therefore, the test movieclip_library_state_values has been added. It
tests the default state and the unloaded state of a (non-root) child
MovieClip that's loaded from the library. It is marked as known_failure
because Ruffle currently doesn't implement the delay before entering the
unloaded state for non-root MovieClips.
2023-08-19 17:29:00 +02:00
Kornelius Rohrschneider f582ea572c core: Add is_root parameter to MovieClip::replace_with_movie
The method MovieClip::replace_with_movie accepts an
Option<Arc<SwfMovie>>. If no movie is given, an empty stub movie is
generated and used.
Previously, the IS_ROOT flag has been set for the new replaced SwfMovie,
depending on whether a movie was given to the method or not.
However, there are cases where an explicitely given movie should not be
set as a root movie (e.g. if a specific empty stub movie is given to the
method). Conversely, there are also cases where no movie is given, but
the stub movie should still be set as a root movie (e.g. in specific
MovieClip states).
Therefore, an is_root parameter has been added to the method. This
explicit parameter is now used to set the flag for the new replaced
SwfMovie.

All calls of replace_with_movie have been adapted to use the new
parameter correctly.
2023-08-19 17:29:00 +02:00
Kornelius Rohrschneider 0abe0b9386 avm1: Remove completed MovieUnloaders
Previously, a MovieUnloader has been kept in the LoadManager, even after
the movie has been unloaded.
This has been fixed. A remove_loader method has been added to the
LoadManager. It is now called in the avm1_unload_movie method; every
MovieUnloader will be removed after the unloaded state has been entered.

The documentation about loaders has been improved and fixed in multiple
places, clarifying how loaders are removed.
2023-08-19 17:29:00 +02:00
nosamu 050da0740a avm1: Pass flashvars in loadMovie and MovieClipLoader
Fixes #11497
2023-08-19 16:45:01 +02:00
nosamu bd82563bb6 avm2: More lenient SWF version check for invalid frame label behavior
Fixes #11987
2023-08-19 16:10:40 +02:00
Lord-McSweeney 89b9bc3827 core/avm2: Support accessing applicationDomain on a LoaderInfo before load starts/finishes; also improve Loader.unload stub. 2023-08-19 00:24:03 +02:00
renovate[bot] 1f4bfcf10d fix(deps): update rust dependencies 2023-08-18 23:32:15 +02:00
Nathan Adams a6aa72351f avm2: Add a Function() call handler 2023-08-18 22:13:46 +02:00
Nathan Adams 7df861f212 avm2: Disallow 'new Function(args)' 2023-08-18 22:13:46 +02:00
Nathan Adams f2233855c7 avm2: Throw proper error on 'x is SomethingThatIsntAClass' 2023-08-18 22:13:46 +02:00
Nathan Adams 46381d181a avm2: Use correct error when trying to construct something invalid 2023-08-18 22:13:46 +02:00
Nathan Adams 8bbf8f4ea1 avm2: Use correct error in toString with invalid radix 2023-08-18 22:13:46 +02:00
Nathan Adams c9c2e213bb avm2: Use correct error in toPrecision 2023-08-18 22:13:46 +02:00
sleepycatcoding 2f98da44fb avm2: String.indexOf returns -1 when passed in undefined 2023-08-18 20:41:41 +02:00
sleepycatcoding cde49de1fb avm2: Remove undefined specific behavior in String.split 2023-08-18 20:41:41 +02:00
sleepycatcoding a44546ab1c avm2: Do not ignore nulls in String.fromCharCode 2023-08-18 20:41:41 +02:00
sleepycatcoding 7316f51cb1 avm2: String.toString defaults to "" 2023-08-18 20:41:41 +02:00
sleepycatcoding b835cc8091 avm2: Boolean.valueOf and Boolean.toString default to false
Makes tests `e15_6_3_1`, `e15_6_3_1_3`, `e15_6_4`, `e15_6_4__1` and `ecall_1` pass.
2023-08-18 16:07:15 +02:00
nosamu f3feabb59a avm2: nextScene() and prevScene() should fall back to current scene
Fixes #12797
2023-08-18 00:33:32 +02:00
Nathan Adams f00671e9cc core: Fix rendering masks + scrollRects when cacheAsBitmap 2023-08-16 16:34:24 +02:00
sleepycatcoding f4d42ac75a chore: fmt 2023-08-16 16:11:57 +02:00
sleepycatcoding e1bc8ed269 core: Replace usages of MutationContext with Mutation 2023-08-16 16:11:57 +02:00
renovate[bot] 93f08d7738 chore(deps): lock file maintenance rust dependencies 2023-08-14 23:58:45 +02:00
Tom Schuster d93c449199 avm2: Throw TypeError on unbound namespace prefix 2023-08-14 19:58:21 +02:00
Tom Schuster 7639d045ad avm2: Limited XML namespace support 2023-08-14 19:58:21 +02:00
Nathan Adams b274d53c6e avm1: Hook up TextField.filters 2023-08-13 14:40:03 +02:00
Nathan Adams b2c334b815 avm1: Hook up Button.cacheAsBitmap 2023-08-13 14:40:03 +02:00
Nathan Adams 5e1a30cf4a core: Fix avm2 button bounding box when using scroll rects 2023-08-13 14:14:34 +02:00
Nathan Adams 3117469e20 core: simple_content_to_string and xml_to_string are now infallible 2023-08-12 20:15:21 +02:00
Nathan Adams db7c6dec00 core: Implement XML.toString for comments and processing instructions 2023-08-12 20:15:21 +02:00
Nathan Adams af1cb4ebd9 core: xml_to_xml_string is now infallible 2023-08-12 20:15:21 +02:00
Nathan Adams 5d9c73cbb1 core: to_xml_string is now infallible 2023-08-12 20:15:21 +02:00
Nathan Adams 135d8c08bf avm2: to_xml_string_inner no longer needs to return a Result<(), Error> 2023-08-12 20:15:21 +02:00
Nathan Adams bf7c17737b avm2: Trim the start of processing instruction values 2023-08-12 20:15:21 +02:00
Nathan Adams 90b3fa4c63 avm2: Implement to_xml_string_inner for procesing instructions 2023-08-12 20:15:21 +02:00
Nathan Adams 247d61675c avm2: Parse name and value out of XML Processing Instructions 2023-08-12 20:15:21 +02:00
Nathan Adams 8e23c7807e avm2: Implement XMLList.processingInstructions() 2023-08-12 20:15:21 +02:00
Nathan Adams 80981e80e6 avm2: Implement XML.processingInstructions() 2023-08-12 20:15:21 +02:00
Nathan Adams f4216aefc1 avm2: Implement XMLList.comments() 2023-08-12 20:15:21 +02:00
Nathan Adams d4b4554553 avm2: Implement XML.comments() 2023-08-12 20:15:21 +02:00
Nathan Adams 2330a45348 avm2: Implement XMLList.toJSON() 2023-08-12 20:15:21 +02:00
Nathan Adams c199316ad3 avm2: Implement XML.toJSON() 2023-08-12 20:15:21 +02:00
Nathan Adams 1f21f120d6 avm2: Implement XMLList.valueOf() 2023-08-12 20:15:21 +02:00
Nathan Adams c133e50469 avm2: Implement XML.valueOf() 2023-08-12 20:15:21 +02:00
Nathan Adams adda66723e core: Use filters to calculate render sizes of objects 2023-08-12 13:00:27 +02:00
Nathan Adams 1a4a808c23 render: Make Filter::calculate_dest_rect work in Twips 2023-08-12 13:00:27 +02:00
Nathan Adams da090f0bd7 render: Move filter size calculation from wgpu to render/swf 2023-08-12 13:00:27 +02:00
Nathan Adams d35b2b8b84 core: Inform Bitmaps to invalidate, if their backing BitmapDatas change 2023-08-12 11:56:18 +02:00
Nathan Adams f55147d7c3 core: Override render_bounds_with_transform in Avm2Button 2023-08-11 11:23:03 +02:00
Nathan Adams f7bc92366b core: Don't invalidate self when mask changes 2023-08-11 11:23:03 +02:00
Nathan Adams a9c5bdfbab core: Better handle scroll_rect and/or masks with cacheAsBitmap 2023-08-11 11:23:03 +02:00
nosamu 0b368f1223 core: Use root movie URL as base for relative NetStream URLs 2023-08-11 09:58:37 +02:00
Crowdin Bot 205ef09cc6 chore: Update translations from Crowdin 2023-08-08 23:49:31 +02:00
renovate[bot] a4b179e1e0 chore(deps): lock file maintenance rust dependencies 2023-08-08 23:19:16 +02:00
MrCheeze 68f8cd6149 avm2: Remove focus from an EditText when it unloads (close #12092) 2023-08-07 23:16:06 +02:00
Daniel Jacobs bb1f405a19 core: Reset preload_offset when loading new netstream 2023-08-07 14:31:33 -06:00
Daniel Jacobs dbb5e381f2 core/desktop/web: Play unsupported videos with browser 2023-08-07 14:31:33 -06:00
SuchAFuriousDeath 37085767f6
avm2: implement BitmapData.merge (#12593) 2023-08-06 22:14:10 +00:00
Nathan Adams 0381116934 avm2: Don't make the descendants op call a function to get descendants, just get it directly 2023-08-06 10:51:25 +02:00
Nathan Adams 42b4812601 avm2: Throw error when using descendants op (..) on anything that isn't XML, even if it has descendants property 2023-08-06 10:51:25 +02:00
michiel2005 690ce110d8
avm1: reference displayObjects parents if parent is a button (#12541) 2023-08-05 20:32:03 +00:00
Lord-McSweeney 2c90b1631b avm2: Implement context menu events 2023-08-05 22:06:10 +02:00
sleepycatcoding b98b0e88aa chore: fmt 2023-08-05 14:42:09 +02:00
sleepycatcoding f6da7258c5 avm1,avm2: Rename some functions to make them consistent between Sockets 2023-08-05 14:42:09 +02:00
sleepycatcoding 2468c71d02 core: Implement suggestion from review 2023-08-05 14:42:09 +02:00
sleepycatcoding aac1931569 avm1: Prevent panic when close is called in event handler
Also adds a test case for this.
2023-08-05 14:42:09 +02:00
sleepycatcoding 82c57a0d97 avm2: Clear tempBuf when closing connection 2023-08-05 14:42:09 +02:00
sleepycatcoding d8ae2ce6b9 avm1: Fix only one message arriving when multiple are sent in the same packet
Test case has been improved to cover this.
2023-08-05 14:42:09 +02:00
sleepycatcoding cec74242cf core: Socket subsystem fixes
Clears the read and write buffer of Socket before returning to ActionScript, this could potentially be problematic
when a SWF reuses the same Socket to connect.

Also remove the handle from Arena when server closes the connection, this fixes
connected still returning true after server disconnection.
2023-08-05 14:42:09 +02:00
sleepycatcoding d3e627fb5f core: Clear the read buffer when the connection is closed 2023-08-05 14:42:09 +02:00
sleepycatcoding 358d3e8ede chore: fmt 2023-08-05 14:42:09 +02:00
sleepycatcoding 8293a2db75 avm1: Write null byte when sending out a message 2023-08-05 14:42:09 +02:00
sleepycatcoding e4b7cc2afd avm1: Replace avm_warn! with tracing::warn! 2023-08-05 14:42:09 +02:00
sleepycatcoding 01801980f4 core: Rename some imports to make code more readable 2023-08-05 14:42:09 +02:00
sleepycatcoding 783527fbad chore: Fix clippy warning 2023-08-05 14:42:09 +02:00
sleepycatcoding 87b7af4370 avm1: Use movie domain when null is passed as host 2023-08-05 14:42:09 +02:00
sleepycatcoding 25b1ed7e9c avm1: Implement onData() 2023-08-05 14:42:09 +02:00
sleepycatcoding 2b18a5999b chore: fmt 2023-08-05 14:42:09 +02:00
sleepycatcoding 705042c1ee chore: Fix a warning 2023-08-05 14:42:09 +02:00
sleepycatcoding dccf254281 avm1: Implement some event handlers 2023-08-05 14:42:09 +02:00
sleepycatcoding 78a68f95ea avm1: Implement send() 2023-08-05 14:42:09 +02:00
sleepycatcoding b64c45f797 avm1: Implement connect() 2023-08-05 14:42:09 +02:00
sleepycatcoding 931c355779 avm1: Use Gc instead of GcCell 2023-08-05 14:42:09 +02:00
sleepycatcoding 7237295364 chore: fmt 2023-08-05 14:42:09 +02:00
sleepycatcoding cd92677b2a core: Add SocketKind and use it to separate XMLSocket and Socket 2023-08-05 14:42:09 +02:00
sleepycatcoding 662c7f986d avm1: Implement onData 2023-08-05 14:42:09 +02:00