Commit Graph

3733 Commits

Author SHA1 Message Date
relrelb ad2b8ea007 avm1: Merge `XmlDocument` into `XmlObject`
As `XmlDocument` and `XmlObject` had 1-to-1 relation, and `XmlDocument`
is already tightly coupled with AVM1, there's no good reason for them
being separate objects.

This brings us one step closer towards an XML implementation hosted
completely in AVM1.

A future PR will merge `XmlNode` into `XmlNodeObject` in a similar
manner.
2022-02-11 19:08:02 +02:00
relrelb aee98d81c8 avm1: Fix nightly build error 2022-02-11 18:45:32 +02:00
relrelb 360ad90a85 avm1: Call sort function with a primitive `this`
This is now possible thanks to #6108.
2022-02-11 18:45:32 +02:00
Toad06 b15806d9c2 avm1: Remove `random` from globals 2022-02-11 00:55:13 +02:00
relrelb 44fd13c654 avm1: Fix builtins' attributes
Fixes #5827.
2022-02-10 19:42:05 +02:00
relrelb b6c7cc1ca3 core: Cleanup `Avm1ConstructorRegistry`
Instead of storing shared pointers to `Avm1ConstructorRegistry` in
`MovieLibrary`, access the `PropertyMap` directly, without an extra
abstraction.

Also, move the constructor registries to `Avm1`, for better
encapsulation.
2022-02-10 07:58:30 +02:00
Toad06 fff9cd1d63 avm1: Change cursor to arrow when the `enabled` property is set to false 2022-02-09 16:26:50 -08:00
TÖRÖK Attila ed0aa3758c core: Extend the embedded fake device font with more characters
By also embedding the "Basic Latin", "Latin I", and "Latin Extended A" sections.
2022-02-09 20:09:52 +01:00
relrelb 6c4a10792d avm1: Remove `XmlIdMapObject`
Use a bare `ScriptObject` instead.
2022-02-07 22:24:42 +02:00
relrelb e50aea864b xml: Simplify `XmlNodeObject::from_xml_node`
Since it's always called with the same prototype (`XMLNode.prototype`),
this can be pulled into the function itself, greatly simplifying it.
2022-02-07 22:24:42 +02:00
relrelb 79d5a0e326 avm1: Avoid some calls to `XmlNode::introduce_script_object`
Instead call `XmlNode::script_object`, which internally calls
`XmlNode::introduce_script_object`. This is a preparation for changing
the signature of `XmlNodeObject::from_xml_node`.
2022-02-07 22:24:42 +02:00
relrelb 7e32f7b85d xml: Remove `tests.rs`
These are already covered by the SWF tests.
2022-02-07 22:24:42 +02:00
Adrian Wielgosik 562a205f3d chore: clippy 2022-02-07 00:49:00 +01:00
Adrian Wielgosik 2c4b260a8c chore: cargo fmt 2022-02-07 00:49:00 +01:00
Adrian Wielgosik c67579e236 avm2: Implement Object() 2022-02-07 00:49:00 +01:00
Adrian Wielgosik 0004b9e58e avm2: Implement RegExp() 2022-02-07 00:49:00 +01:00
Adrian Wielgosik c8fe2fcfb2 avm2: Implement Namespace() stub 2022-02-07 00:49:00 +01:00
Adrian Wielgosik 8402f6637b avm2: Implement Vector.<T>(array_like) 2022-02-07 00:49:00 +01:00
Adrian Wielgosik db8aa42db9 avm2: Support custom Class() implementations 2022-02-07 00:49:00 +01:00
Fernando Karchiloff 0c853082dd core: Fix bullet append with box_count check 2022-02-06 20:52:04 +02:00
Fernando Karchiloff b7273e038c core: fix bullet append from html 2022-02-06 20:52:04 +02:00
relrelb 48c43b731e avm1: Remove unused `is_defined` 2022-02-05 13:43:19 +02:00
Toad06 83cc9dc308 avm1: Fire `onReleaseOutside` event even when the button is invisible 2022-01-30 14:08:47 -08:00
Mike Welsh 601918a998 core: Fix drawing API stroke rendering order (fix #3186) 2022-01-29 20:05:04 -08:00
Mike Welsh 705588a2ec core: Fix incorrect fill and stroke rendering order (fix #6129) 2022-01-29 20:05:04 -08:00
Mike Welsh 55da3cd7d0 chore: Add .cargo/config.toml for workspace-level lint config
Currently it is not directly possible to configure lints for the
entire workspace via TOML, which forced us to repeat `#![allow]`
blocks in each crate.

embark pointed out this workaround to configure lints at the
workspace level via RUSTFLAGS:

https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395

Remove the common `#![allow]` blocks and switch to this method for
global lint config.

Temporarily allow `needless_borrow` lint, buggy pending this fix:
https://github.com/rust-lang/rust-clippy/pull/8355
2022-01-29 14:22:44 -08:00
relrelb 99b22b24dd avm1: Remove unused `FunctionObjectData::primitive` 2022-01-29 12:12:39 -08:00
Daniel Jacobs 1e5956c02a core: Fix get_text_format bullet return value 2022-01-27 22:35:18 -08:00
TÖRÖK Attila 43b21e5d4d chore: Bump approx to 0.5.1, remove clippy lint suppressions 2022-01-25 18:34:35 -08:00
Toad06 da50d44460 core: Fix detection of button events 2022-01-24 11:48:37 -08:00
Mike Welsh 354d7f0ce6 avm1: Remove unused `this` from `Scope::resolve` and `set` 2022-01-24 02:04:57 -08:00
Mike Welsh c35edaae82 avm1: Allow `this` to be `undefined`
Change `Activation::this` to be `Value` instead of `Object`.
2022-01-24 02:04:57 -08:00
Mike Welsh 9ccb3ac3e7 avm1: Fix coercion in string-object concatenation
Previously we called `toString` when concatenating a string to an
Object. However, Flash actually has more complex behavior, usually
calling both `valueOf` and `toString`. This is loosely based on
ToPrimitive/DefaultValue with no type hint in the ECMAScript spec.

 * Call `valueOf`.
  * If the result isn't a primitive, call `toString`.
  * If the result still isn't primitive, return `"[type Object]"`.
 * For Date objects in SWFv6 and higher, call `toString`.
  * If the result isn't a primitive, call `toString` (AVM1 bug?)
  * If it still isn't primitive, return `"[type Object]"`.
2022-01-23 17:19:09 -08:00
David Wendt 48f8515c03 core: `mouseEnabled` controls whether or not display objects are mouse-pickable 2022-01-22 19:58:32 -08:00
David Wendt 35cbed01fa docs: Better document the `ClipEvent` dispatch patterns. 2022-01-22 19:58:32 -08:00
David Wendt e5d9379740 core: Implement `mouseMove` event 2022-01-22 19:58:32 -08:00
David Wendt 6271d069d7 core: `Stage` should not include it's own transform in it's local/global matrix. 2022-01-22 19:58:32 -08:00
David Wendt c42984a990 avm2: Implement `MouseEvent.toString`.
This also rearranges some things about how we construct events, because `MouseEvent` has different defaults from `Event`. When we finally support parameter metadata on methods we should remove that code.

We also remove the `value_of` code on `EventObject` as that was a mistake. Events don't do anything special in there and I misinterpreted the test results the first time around.
2022-01-22 19:58:32 -08:00
David Wendt 880211c238 core: Implement the `doubleClick` event on objects that request it. 2022-01-22 19:58:32 -08:00
David Wendt eeea5ffea6 core: Issue `MouseWheel` events for AVM2. 2022-01-22 19:58:32 -08:00
David Wendt 87a9a543ba chore: Fix clippy lint on nightly 2022-01-22 19:58:32 -08:00
David Wendt 84d1d5aa76 core: Issue `mouseOver`, `mouseOut`, etc when dragging. 2022-01-22 19:58:32 -08:00
David Wendt 42b606d058 core: Issue `rollOver`, `rollOut`, `mouseOut`, and `mouseOver` events to AVM2. 2022-01-22 19:58:32 -08:00
David Wendt 353a5a78d6 core: Move `mouse_pick` and `mouse_cursor` to `InteractiveObject` as no non-interactive object implements them.
This also cascades into other places, ultimately resulting in more things being marked as `InteractiveObject`.
2022-01-22 19:58:32 -08:00
David Wendt d0ef15503c avm2: Store the last-hovered or currently-hovered object on the event that notifies the clip that the hover state has changed. 2022-01-22 19:58:32 -08:00
David Wendt f69206aaa2 core: Fire AVM2's `mouseUp` event on the correct object.
This requires adding another notion of mouse-release events to `ClipEvent`. We now have four:

 * `MouseUp` - the mouse was released, any object on the render list can handle this event ("anycast" event)
 * `MouseUpInside` - the mouse was released inside this display object, only the mouse-picked target of the event can handle it
 * `Release` - the mouse was released inside the last clicked display object
 * `ReleaseOutside` - the mouse was released outside the last clicked display object

For those keeping score at home, in AVM2, the valid progression of events is either...

 * On the same object, `mouseDown`, `mouseUp`, and `click`
 * On one object, `mouseDown`, then some mouse movement that takes the cursor out of the first object, then on another object `mouseUp`, and then finally the first object gets `releaseOutside`.
2022-01-22 19:58:32 -08:00
David Wendt 35f020f482 avm2: Allow `Stage` to receive button presses 2022-01-22 19:58:32 -08:00
David Wendt 9d4b222b29 core: AVM2 wants the same semantics as `Press`/`Release`, not `MouseDown`/`MouseUp`.
`MouseDown`/`MouseUp` are effectively broadcasts; they hit every movie clip that can accept them until one of them has a handler for it. AVM2 instead wants events that only apply to specific mouse-picked display objects, which means we need to use the Player-tracked events `Press`, `Release`, and `ReleaseOutside`. The only problem is that we also need to emit a `mouseUp` event on both `Release` and `ReleaseOutside`.
2022-01-22 19:58:32 -08:00
David Wendt f0ab17c979 core: AVM2 `MovieClip`s can accept mouse events without being in button mode.
This technically changes the meaning of `require_button_mode` slightly to something more like "accepts input".
2022-01-22 19:58:32 -08:00
David Wendt f56782c5c7 core: Movie clips do not have a hand cursor unless they are also in button mode. 2022-01-22 19:58:32 -08:00