David Wendt
153ab675e9
When aligning a line, actually consider all the boxes within the line.
2020-06-20 19:55:49 -04:00
David Wendt
3d094ed689
Add margins test.
...
This test is also approx'd to 1px due to the same issue where heights are off by one.
2020-06-20 19:55:48 -04:00
David Wendt
db0398d2ee
Left and right margins and indents should not be included in `textWidth`.
2020-06-20 19:55:48 -04:00
David Wendt
74d4c25133
Add a test for letter spacing.
...
This test is approximate because the 0.5px test is off by 1px in terms of height.
2020-06-20 19:55:47 -04:00
David Wendt
6ce7ecee78
Implement `letterSpacing`.
2020-06-20 19:55:47 -04:00
David Wendt
171954d5e4
Add `edittext_leading` test.
...
This test constructs a handful of text fields and measures them. Each field has 0, 5, or 15px of `leading` applied to it's text format.
2020-06-20 19:55:47 -04:00
David Wendt
bbc73f1477
The `edittext_align` test now passes perfectly.
2020-06-20 19:55:46 -04:00
David Wendt
16da6d827c
Line-leading is always applied at least once, even if there are no line breaks in the text field.
2020-06-20 19:55:46 -04:00
David Wendt
410fb3ab86
Don't round each line's leading. Instead, round at the end of the operation.
...
This was verified by visual comparison with Flash Player; lines of text appear to be shifted by half-pixels, while the script output is always still rounded down.
2020-06-20 19:55:45 -04:00
David Wendt
2858c09b6e
Only apply leading adjustment on newlines.
...
This results in ALL height adjustments being off by 2px, regardless of leading or font size. Tantalizing!
2020-06-20 19:55:45 -04:00
David Wendt
2ab85c32e2
When wrapping text, measure the text including the trailing space (if present).
...
This matches Flash behavior, but breaks an existing test, which I've adjusted appropriately.
2020-06-20 19:55:44 -04:00
David Wendt
c67bf0b6b7
Add approximate test of text field metrics during alignment.
...
This is an approximate text with a 1-pixel tolerance because our height is currently off by one and I cannot explain why. Previous attempts to fix the bug have resulted in cascading errors that resulted in off-by-one errors in the opposite direction. This is still better than nothing and I need to check other tests in.
2020-06-20 19:55:44 -04:00
David Wendt
a1e52ab556
Add a test for formatting defaults on HTML text.
2020-06-20 19:55:44 -04:00
David Wendt
09c91d191a
Round-trip tab stops between `EditText` and AVM1
2020-06-20 19:55:43 -04:00
David Wendt
00217072e6
After the previous set of fixes our tests are now consistent with a layout engine that always rounds down to the nearest pixel and never up. Adjust code to match.
2020-06-20 19:55:43 -04:00
David Wendt
06c66533c7
Don't apply leading twice.
2020-06-20 19:55:42 -04:00
David Wendt
82c6269cf6
Ensure that presentational markup styles cascade from parent tag to child, and from the default format to the first tag.
2020-06-20 19:55:42 -04:00
David Wendt
88d07f5d17
We don't need to relayout when the new-text text format gets changed.
2020-06-20 19:55:42 -04:00
David Wendt
9981148482
Add a test for `BoxBounds.with_size`, since we're using it now
2020-06-20 19:55:41 -04:00
David Wendt
aae1f0ba7a
Skip fixups on empty lines.
2020-06-20 19:55:41 -04:00
David Wendt
bd40295076
Ensure that the font-provided leading is accounted for when moving the cursor for a newline.
2020-06-20 19:55:41 -04:00
David Wendt
0e0b2fb85d
All layout boxes on the line should have trailing whitespace trimmed off of their measurements.
...
Flash has a weird bug where it will NOT trim trailing spaces off of the metrics reported to users if the text is left-aligned. We replicate this here so that tests pass.
2020-06-20 19:55:40 -04:00
David Wendt
50a05df998
Generated lines should *always* include their end spaces, there should be no gaps.
2020-06-20 19:55:40 -04:00
David Wendt
ab2b9cc733
Change all of the `BoxBounds` in the layout machinery to not use `Default`.
...
The `Default` bounds are NOT safe to union against if they were uninitialized. Doing so will force any resulting layout box to enclose `(0,0)`, which can throw off certain layout calculations. Instead, we use `None` to signal an uninitialized box.
2020-06-20 19:55:40 -04:00
David Wendt
806a741bf4
EditText appears to have internal padding between it's borders equivalent to a CSS padding of `3px 4px 3px 0`.
...
Verified by experimentation with Flash Player, appears to be necessary for tests to pass.
2020-06-20 19:55:39 -04:00
David Wendt
96c43654d0
Retain the bounds returned when constructing layout boxes and use them as the `textWidth` and `textHeight` of a given text field.
2020-06-20 19:55:39 -04:00
David Wendt
318f09d241
Include the font-provided leading in the exterior bounds sent off for `autoSize` calculation.
2020-06-20 19:55:39 -04:00
David Wendt
06dc2f5fe0
Implement the `leading` attribute as defined by fonts.
...
`EditText` supports two different forms of leading:
1. Font-provided leading, specified relative to the EM square and scaled with font size
2. User-specificed leading, specified in pixels
Notably, the former appears to apply to the first line in the text and pushes it down. This showed up in the `edittext_font_size` test, and according to that test result the leading is rounded *up* to the nearest pixel, plus one.
That last bit seems possibly wrong and is subject to further change, but it matches the tests at multiple scales.
2020-06-20 19:55:29 -04:00
David Wendt
6e81f30a70
Round down to the nearest pixel when measuring text.
...
Certain text routines calculate text on the pixel grid, despite the fact that Flash ordinarily works in twips. There is probably a reason for this - my guess is to keep text wrapping stable across multiple pixel densities (e.g. low-res screens plus high-res print).
2020-06-20 19:53:42 -04:00
David Wendt
7a62a8e9ce
Programmatically created text fields get a biased depth.
2020-06-20 19:53:34 -04:00
David Wendt
75aaa49169
Y coordinates should always be adjusted by Y coordinates.
2020-06-20 19:48:14 -04:00
David Wendt
245cea784f
Running an `autoSize` on any text field should always synchronize the X coordinate between the bounding box and the base transform.
...
I don't know why, but this is necessary for the "NEW STUFF" box on homestarrunner.com's toons menu to position correctly. SOMEWHERE, we are performing some kind of operation that adjusts one of the two, but not the other, and I can't find out what.
2020-06-20 19:48:13 -04:00
David Wendt
5a2b74c5fc
Setting a new matrix should also transform the bounds as well.
2020-06-20 19:48:13 -04:00
David Wendt
e7e944ad76
Account for the width of glyphs when measuring text.
...
This fixes spaces at the start of text spans not being rendered, but also breaks center-align.
I also broke the font tests, so I had to rewrite them, which makes me question their value.
2020-06-20 19:48:13 -04:00
David Wendt
8a5a2bf7c7
When `Font.wrap_text` indicates that none of the line can fit, we should also refresh our width and offset and check if there's even more text to measure or not.
2020-06-20 19:48:12 -04:00
David Wendt
efc50da367
`Font.wrap_text` should return `0` if no part of the string can fit within the requested bounds.
2020-06-20 19:48:12 -04:00
David Wendt
38d679ef29
`wrap_line` should take spaces into account when sizing lines.
2020-06-20 19:48:12 -04:00
David Wendt
85a3a845d9
Dynamic `EditText` bounds should go from `x` to `x+width`, not `x` to `x+height` (etc)
2020-06-20 19:48:12 -04:00
David Wendt
bacbf06614
Setting the matrix of an `EditText` should scale it's bounds.
2020-06-20 19:48:12 -04:00
David Wendt
9564cbeda4
Use the new dynamic bounding box to calculate a width for word-wrapping, and update the new bounding box directly in autosize rather than hitting `DisplayObject` methods.
...
This also adjusts `DisplayObject` methods to use the bounds.
2020-06-20 19:48:11 -04:00
David Wendt
a0477e7525
Adjust the layout code to properly align content with right margins, trailing spaces on lines, and lines wider than the bounds.
...
Right margins: Simple enough, we just need to subtract the right margin from the bounds when we calculate our alignment adjustment.
Trailing spaces: This is very tricky as we effectively have to remeasure the last box in the line when fixing it up. This also means LayoutContext has to hold the text itself so we can remeasure again...
Lines wider than bounds: If word wrap is disabled it is possible for a line to exceed the bounds of the box. In this case it will be left-aligned. Effectively, the align adjustment is clamped to positive values and we do that here too.
2020-06-20 19:48:11 -04:00
David Wendt
4eb2113a77
Setting positions and widths on the `EditText` should adjust intrinsic bounds rather than stretching or transforming the field.
2020-06-20 19:48:11 -04:00
David Wendt
7cf2cce3ef
Add functions to set positions and widths on bounding boxes.
2020-06-20 19:48:10 -04:00
David Wendt
dc46885021
Implement `autoSize`.
...
This doesn't work right yet because the resulting width doesn't apply correctly to the field. This is because `EditText`'s `_width` and `_height` change it's intrinsic bounds rather than it's X and Y scale (like it would with a button or a movie clip).
2020-06-20 19:48:00 -04:00
dependabot-preview[bot]
6928e75cd6
build(deps): bump syn from 1.0.31 to 1.0.32
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.31 to 1.0.32.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.31...1.0.32 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-20 16:36:01 -07:00
David Wendt
18e93b3d11
Implement tests for `wrap_line`.
...
These tests depend on the particulars of our default device font, Noto Sans. If this test proves to be fragile we may need to create a testing font with a locked width and kerning table...
2020-06-20 19:26:47 -04:00
David Wendt
cb47e0bae8
`wrap_line` returns breakpoints relative to how we sliced the text, so we need to break things appropriately.
...
This prevents a bounds-check panic when we inevitably try to slice an array like `[300..2]` or something like that.
We also skip rendering the space that we're turning into a newline to avoid it popping up on the next line by accident.
2020-06-20 19:26:47 -04:00
David Wendt
ece879a15c
The align adjustment should be positive, not negative.
2020-06-20 19:26:47 -04:00
David Wendt
593f442372
Implement `leading` between lines
2020-06-20 19:26:47 -04:00
David Wendt
e83cebc4fb
Vertically align different-font-size boxes to the same bottom baseline.
2020-06-20 19:26:46 -04:00
David Wendt
b517019b57
Clean up how we calculate the width of the text field.
...
`max_length` isn't a geometrical width, despite the fact that the type system didn't prevent me from making erroneous conversions. It's actually just a text length limit, which we won't be dealing with for some time.
When first instantiated, we use the static bounds; however, further relayouts grab `local_bounds` and calculate a width from that. `EditText` works almost identically to any other display object, with the exception that device fonts do not render if the transform is not an axis-aligned bounding box (and it doesn't respect scale). We don't have to worry about that for now.
2020-06-20 19:26:46 -04:00
David Wendt
c7ac0e4bb1
Implement center and right alignment.
...
Justification will have to wait for another day.
2020-06-20 19:26:46 -04:00
David Wendt
562adcdc7e
Implement `leftMargin`, `rightMargin`, `indent` and `blockIndent`.
...
This is surprisingly difficult because of how Flash handles these properties: they are cached at the start of a new line (explicit or flown) and then used for all spans that intersect with that line. Ergo, `LayoutContext` needs to keep track of all the boxes we generate within the line and the span that ultimately is going to provide margins for it.
And yet, at the same time, we also have to precalculate the effects of these margins when flowing text so that we know how much space we have to play with. This needs to be calculated the same at the start of the line as it is at the end. This is why `LayoutContext` is a separate type: it handles all the state tracking and crap that has to be done when splitting text into spans, paragraphs, and lines all at the same time.
Fortunately, this design will make it easier to implement other features like text alignment where we couldn't even begin to calculate everything in one pass.
2020-06-20 19:26:46 -04:00
David Wendt
5fcaa52687
Restore newline functionality (mostly...)
2020-06-20 19:26:45 -04:00
David Wendt
9f60567f66
Remove library lookup as layout can do it itself
2020-06-20 19:26:45 -04:00
David Wendt
e3f59ac00f
Implement `color` on spans
2020-06-20 19:26:45 -04:00
David Wendt
9bcc7ef0cc
`setTextFormat` should trigger a relayout
2020-06-20 19:26:44 -04:00
David Wendt
b5de92edeb
Properly retrieve default font class
2020-06-20 19:26:44 -04:00
David Wendt
c4e5a9afc2
In the spirit of shared-nothing `post_instantiation` should duplicate any `LayoutBox`es it has, in case we mutate them later.
2020-06-20 19:26:44 -04:00
David Wendt
467fd9db80
Implement `TextField.length` in AVM1.
2020-06-20 19:26:44 -04:00
David Wendt
ef6ebe2b44
The default format of a text field should match it's SWF tag.
2020-06-20 19:26:43 -04:00
David Wendt
361ea1f774
Index fonts by font name, boldness, and italicization.
...
This involves a new struct called a `FontDescriptor` which is generated whenever a font is registered and used to index the font in the library. When a font is requested, it goes through the descriptor system to get found.
2020-06-20 19:26:43 -04:00
David Wendt
f234926e63
Default text formats are not replaced when movies call `setNewTextFormat`, they instead mix with the existing one.
...
"Mixing" is defined as `Option.or`ing all the properties in the new text format with the old one. Not specifying a text format in the new default will result in the field retaining it's old properties.
2020-06-20 19:26:43 -04:00
David Wendt
0aab45f389
Fix panic in `render_layout_box` caused by indexing an already-indexed slice.
2020-06-20 19:26:42 -04:00
David Wendt
3b80ff8d23
Clippy compliance
2020-06-20 19:26:42 -04:00
David Wendt
fde5e13358
Expose `replaceText` to AVM1 code.
2020-06-20 19:26:42 -04:00
David Wendt
a8a1b985a3
Expose `getTextFormat` and `setTextFormat` to AVM1.
2020-06-20 19:26:41 -04:00
David Wendt
74912525ed
Add ancestor iteration to XML nodes.
2020-06-20 19:26:41 -04:00
David Wendt
a2836a0b92
Tie `EditText` into the new layout system, which is currently unfinished.
...
This should *significantly* regress `EditText` layout.
2020-06-20 19:26:37 -04:00
David Wendt
8622cb97a9
Add a system of layout boxes to store text layout decisions made at update time.
2020-06-20 19:16:17 -04:00
David Wendt
4a2fac28d1
Add iterator for text spans
2020-06-20 19:16:17 -04:00
David Wendt
ec72ac518c
Allow HTML text nodes to populate text.
...
This will need to be updated to handle line breaks, spaces, and so on correctly - the way whitespace works in HTML differs from plain text.
2020-06-20 19:16:17 -04:00
David Wendt
816644c497
Add an internal implementation of `replaceText`.
2020-06-20 19:16:17 -04:00
David Wendt
a1f548f744
Add a routine to generate `TextFormat`s from presentational markup, and another lowering process which tracks the text formats generated by this process.
2020-06-20 19:16:16 -04:00
David Wendt
62a13cd7a6
Add the ability to `walk` through an XML tree.
...
This yields nodes as `Step`s. This allows keeping track of the structure of the tree as you walk through descendents, as each element will be yielded twice: both as a `Step::In` *and* as a `Step::Out`. Non-element nodes will be yielded once as a `Step::Around`.
I'm adding `walk` iteration specifically to avoid having to write certain methods recursively. Existing recursive callers of `children` should probably be updated to `walk` the tree and maintain a separate `Vec` stack.
2020-06-20 19:16:16 -04:00
David Wendt
4eca2d4bdd
Replace the existing default format on `EditText` with our brand-new `FormatSpans`.
...
This also includes code to automatically populate the default format with data from the SWF tag.
2020-06-20 19:16:16 -04:00
David Wendt
efdecdea64
Store the default text format, and use it when generating new spans during normalization.
...
I'm sure this will wind up having further uses eventually.
2020-06-20 19:16:15 -04:00
David Wendt
153571c0c4
Implement `FormatSpans::set_text_format`.
...
This also necessitated the addition of code to:
* Ensure span breaks exist at both sides of the text boundary, without creating degenerate (length-0) spans
* Consolidate spans with matching text formats
* Shorten or lengthen the total list of text spans to match the backing string
* Ensure at least one text span exists at all times
This still has some minor to-dos: for example, it relies on the default `TextSpan` formatting, which probably should be replaced with actually accepting or storing a default format to be used when constructing new text spans.
2020-06-20 19:16:15 -04:00
David Wendt
102c494de4
Add a type to hold text with some text spans, and some tests for that type.
2020-06-20 19:16:14 -04:00
David Wendt
1671fc6eba
Add an internal representation of text spans.
...
Despite having HTML and CSS rendering capabilities, the Flash text field actually does not use HTML as it's internal representation. Instead, the text-span format implied by `getTextFormat` and `setTextFormat` is used to drive layout. You can see this by watching what happens to `htmlText`, *especially* when you add and remove stylesheets.
The `LayoutBox` machinery will be adapted to consume text spans in a future commit. This would make the entire rendering pipeline: HTML/CSS -> Text Spans -> Layout Boxes -> Render commands.
2020-06-20 19:16:14 -04:00
David Wendt
850831181c
Add tests for all non-trivial methods of `Position`, `Size`, and `BoxBounds`.
2020-06-20 19:16:13 -04:00
David Wendt
ef035c5283
Add `Size.max`, conversions between `Position` and `Size`, `BoxBounds.extent`, and `BoxBounds.with_size`.
2020-06-20 19:16:13 -04:00
David Wendt
e7c34d9745
Switch `BoxBounds` from a position-and-size representation to an offset-and-extent representation.
...
This makes the implementation of rectangle union (`Add`/`AddAssign`) far easier as we just compute the min and max of the offset and extent coordinates. It also makes the conversion into and from `swf::Rectangle` easier as it's now effectively a generic version of that datatype.
On the other hand, `width`, `height`, and `size` now have to be calculated, and require `T` to be self-`Sub`. I'm not sure if this is that much of a problem or not.
2020-06-20 19:16:12 -04:00
David Wendt
0a1de3276f
Add extra types for indicating moving a position and resizing a box.
2020-06-20 19:16:12 -04:00
David Wendt
a4c8cd4711
Add a set of types for tracking CSS attributes, positions, sizes, and bounds on layout boxes.
2020-06-20 19:16:12 -04:00
David Wendt
4739e08c11
Add the ability to split lines from the middle of an already-existing flow operation
2020-06-20 19:16:12 -04:00
David Wendt
7e7ca88c3d
`post_instantiate` is morally equivalent to duplicating the display object it's called on, so we should also duplicate the XML document attached to it.
...
We don't have to do this for `object` because we don't actually construct the script object until instantiation time.
2020-06-20 19:16:11 -04:00
David Wendt
a3f4509d63
Store all text internally as an HTML tree, alongside the existing strings.
...
We're reusing the XML machinery to handle HTML - this is probably not 100% correct, but writing a new HTML parser to cover just `EditText` will be rather complicated.
2020-06-20 19:16:11 -04:00
David Wendt
cc854db9b3
Derive `Collect` on `EditTextData`.
2020-06-20 19:16:10 -04:00
David Wendt
ac9cd0cf87
Move `TextFormat` over to a new `html` module, which will hold all the stuff necessary for rendering HTML in an `EditText`.
...
`TextFormat` is owned data and should be collectable as static.
2020-06-20 19:16:10 -04:00
Nathan Adams
2e7ebbf258
avm1: Fatal errors will halt the AVM and prevent further execution
2020-06-20 15:02:00 -07:00
Nathan Adams
f5da954b32
avm1: Merge avm1::Error and avm1::ExecutionError for now. It's plausible that nested inside actions we can encounter an ExecutionError, so at that point it doesn't make sense to have a separation.
2020-06-20 15:02:00 -07:00
Nathan Adams
e2c607c70f
avm1: Avm1::retire_stack_frame can't error, so adjust its signature appropriately
2020-06-20 15:02:00 -07:00
Nathan Adams
a36e2105a3
avm1: Made avm1::Error an actual error type, and removed all calls that throw incorrect errors in avm1
2020-06-20 15:02:00 -07:00
Nathan Adams
ad07520af3
avm1: Add avm1::ExecutionError
2020-06-20 15:02:00 -07:00
Nathan Adams
adb8ffbf9c
core: Convert XML errors into an enum
2020-06-20 15:02:00 -07:00
Nathan Adams
59ccd75518
core: Rename loader::LoaderError to loader::Error
2020-06-20 15:02:00 -07:00
Nathan Adams
b6f012cf7f
core: Use thiserror to derive Loader errors
2020-06-20 15:02:00 -07:00
Nathan Adams
0f1eef9022
core: Introduce LoaderError to all Loader methods
2020-06-20 15:02:00 -07:00
Nathan Adams
c8f0753da4
core: Rename Value::as_number to Value::coerce_to_f64
2020-06-19 12:48:28 -07:00
Nathan Adams
67042b255c
core: Replace Value::as_* numeric methods in favour of coerce_to_* or manual matching
2020-06-19 12:48:28 -07:00
Nathan Adams
270f63b2f3
core: Made Object::to_string return a Cow<str>
2020-06-19 12:48:28 -07:00
Nathan Adams
f4b4d0ebb7
core: Replace Value::into_string in favour of coerce_to_string or manual matching
2020-06-19 12:48:28 -07:00
Nathan Adams
5662b2d4d9
core: Make Value::coerce_to_string return a Cow<str>`
2020-06-19 12:48:28 -07:00
Nathan Adams
9633dc71c3
core: Replace Value::as_string in favour of coerce_to_string or manual matching
2020-06-19 12:48:28 -07:00
Nathan Adams
e44568c31c
core: Remove Value::call_method, you must box the value first
2020-06-19 12:48:28 -07:00
Nathan Adams
5dd1a1e509
core: Remove Value::get, you must box the value first
2020-06-19 12:48:28 -07:00
Nathan Adams
fc18c2fce5
core: Rename Value::as_object to Value::coerce_to_object
2020-06-19 12:48:28 -07:00
Nathan Adams
b2b57c1540
core: Make Value::as_object always return a (possibly boxed) object
2020-06-19 12:48:28 -07:00
Nathan Adams
3695c3c9fa
tests: Add test for default names of display objects
2020-06-18 16:26:36 -07:00
Mike Welsh
62cfeb3754
core: Assign default name to unnamed clips ( fix #66 )
2020-06-18 16:26:36 -07:00
Nathan Adams
25ad2a428d
tests: Improve attach_movie test to prove when the first frame is executed
2020-06-17 14:16:38 -07:00
Mike Welsh
83feeefeeb
audio: Don't panic on unimplemented codecs
...
Remove `unimplemented` calls when encountring unsupported codecs
such as Nellymoser. Instead, return an Error that can be
gracefully handled.
2020-06-17 12:14:08 -07:00
Mike Welsh
1d7e6b7e8a
chore: Fix let-unit-value clippy lint
2020-06-17 11:25:06 -07:00
Mike Welsh
77cb186357
avm1: Constructors queue to run after a goto
...
If a class is registered to a clip that is placed on the timeline
during a goto, that constructor should run after the frame is
completely constructed. In order to tell whether to run the
constructor immediately, add a parameter to `post_instantiation`
to indicate if the clip is instantiated from the AVM or via a
standard timeline seek.
2020-06-16 14:53:44 -07:00
Mike Welsh
568d0513ed
tests: register_and_init_order tests for constructor after goto
2020-06-16 14:53:44 -07:00
Nathan Adams
5efab4c579
core: Implement RGB15 PNGs - fixes #724
2020-06-16 14:53:19 -07:00
dependabot-preview[bot]
fcea6012bb
build(deps): bump png from 0.16.4 to 0.16.5
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.4 to 0.16.5.
- [Release notes](https://github.com/image-rs/image-png/releases )
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md )
- [Commits](https://github.com/image-rs/image-png/compare/v0.16.4...v0.16.5 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-13 18:52:24 -07:00
Mike Welsh
5da9863402
tests: Add test for #710
2020-06-13 02:48:38 -07:00
Mike Welsh
35a4c05923
avm1: CallFunction can resolve variable paths
2020-06-13 02:48:38 -07:00
Mike Welsh
29dc88ec01
tests: Clip event test now tests for children unloading
...
The test now verifies that a child movie clip runs its `unload`
clip event if its parent is removed.
2020-06-11 23:39:16 -07:00
Mike Welsh
ce73b4eaa7
core: Recursively unload child display objects
...
Child movie clips should run their unload actions when the parent
is removed.
2020-06-11 23:39:16 -07:00
Mike Welsh
9b0881edb7
core: Set $version on root
...
_root has a $version property that should matches
`System.capabilites.version`. This allows Nanaca Crash to boot.
2020-06-11 10:03:29 -07:00
Mike Welsh
faa35a53e9
tests: Add test for getBounds with empty children
2020-06-10 17:17:08 -07:00
Mike Welsh
b5daf3d020
core: Fix BoundingBox::union for invalid bounds
2020-06-10 17:17:08 -07:00
dependabot-preview[bot]
f03e75951a
build(deps): bump syn from 1.0.30 to 1.0.31
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.30 to 1.0.31.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.30...1.0.31 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-09 22:14:57 -07:00
CUB3D
fa11ef1e81
core: Add remaining capabilities
2020-06-09 23:57:46 +01:00
CUB3D
dd5d2976ea
core: Add missing functions to System.security
2020-06-09 23:03:13 +01:00
CUB3D
07d4f3a8eb
core: Fix build
2020-06-09 22:41:11 +01:00
CUB3D
ad3bc612aa
chore: Fix clippy lints
2020-06-09 22:41:11 +01:00
CUB3D
4987cfdaac
core: Refactor enums, Add unknown windows os support and fix attributes
...
Now using Display to convert enums.
Also added support for a fallback "Windows" os for when the current version can't be detected
2020-06-09 22:41:11 +01:00
CUB3D
48bef91917
core: Remove clear_clipboard, format and fix tests
2020-06-09 22:41:11 +01:00
CUB3D
bc1055e381
core: Create system protos in globals.rs, fix version-dependant output
...
Make get_server_string output order match flash, also make language and manufacturer output respect emulated player version
2020-06-09 22:41:11 +01:00
CUB3D
de013426bc
core: Url encode serverString
2020-06-09 22:41:11 +01:00
CUB3D
887e09337f
core: Add dummy impl of System.security
2020-06-09 22:41:11 +01:00
CUB3D
fc8cd1139a
core: Add initial System.IME implementation
2020-06-09 22:41:11 +01:00
CUB3D
94a53f3506
core: Store System.capabilities in SystemProperties
2020-06-09 22:41:11 +01:00
CUB3D
af41ac5602
core: Add clipboard support to input backend
2020-06-09 22:41:11 +01:00
CUB3D
0f0f778830
core: Retain properties for System in the player
2020-06-09 22:41:11 +01:00
CUB3D
8471523e49
core: Add basic System.capabilities implementation
2020-06-09 22:41:11 +01:00
CUB3D
50abbe1887
core: Implement basic System global
2020-06-09 22:41:10 +01:00
Nathan Adams
58df56e4a4
core: Add `Value::get` shortcut that resolves Objects or returns Undefined
2020-06-08 15:12:05 -07:00
Nathan Adams
d0ad1b57fe
core: Replace `toString`/`valueOf` calls with `call_method`
2020-06-08 15:12:05 -07:00
Nathan Adams
c592b5fb2a
core: `Value::call_method` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
d39ffcfadc
core: `Value::call` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
fe55c5a264
core: `TObject::call_method` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
da3e2bb0a0
core: `TObject::call` no longer requires you to resolve after calling it
2020-06-08 15:12:05 -07:00
Nathan Adams
26590d4c63
core: `TObject::get_local` no longer requires you to resolve after retrieving it
2020-06-08 15:12:05 -07:00
Nathan Adams
a121a3a4d0
core: `TObject::get` no longer requires you to resolve after retrieving it
2020-06-08 15:12:05 -07:00
dependabot-preview[bot]
36fb0cd43c
build(deps): bump quote from 1.0.6 to 1.0.7
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.6...1.0.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-07 17:17:32 -07:00
Mike Welsh
359df6860f
tests: Add String.charCodeAt tests
...
Tests the fix provided in #634 .
2020-06-04 16:02:55 -07:00
Nathan Adams
34cf21289b
avm1: Fixed some missing behaviours with flash.geom.Rectangle
2020-06-02 18:49:01 -07:00
Nathan Adams
f5765f2bac
avm1: Implement all of flash.geom.Rectangle + tests ( #305 )
2020-06-02 18:49:01 -07:00
Nathan Adams
226a97ef4b
core: Don't panic on `new DoesntExist()`
2020-06-02 18:49:01 -07:00
dependabot-preview[bot]
4b22fc723d
build(deps): bump indexmap from 1.3.2 to 1.4.0
...
Bumps [indexmap](https://github.com/bluss/indexmap ) from 1.3.2 to 1.4.0.
- [Release notes](https://github.com/bluss/indexmap/releases )
- [Commits](https://github.com/bluss/indexmap/compare/1.3.2...1.4.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 13:42:08 -07:00
dependabot-preview[bot]
cf4df4058f
build(deps): bump png from 0.16.3 to 0.16.4
...
Bumps [png](https://github.com/image-rs/image-png ) from 0.16.3 to 0.16.4.
- [Release notes](https://github.com/image-rs/image-png/releases )
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md )
- [Commits](https://github.com/image-rs/image-png/compare/v0.16.3...v0.16.4 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 12:23:21 -07:00
dependabot-preview[bot]
078c64c201
build(deps): bump syn from 1.0.28 to 1.0.30
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.28 to 1.0.30.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.28...1.0.30 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 12:19:30 -07:00
dependabot-preview[bot]
0e7b0f8467
build(deps): bump libflate from 1.0.0 to 1.0.1
...
Bumps [libflate](https://github.com/sile/libflate ) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/sile/libflate/releases )
- [Commits](https://github.com/sile/libflate/compare/1.0.0...1.0.1 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-01 11:24:15 -07:00
Nathan Adams
0d53f0a952
chore: Fix new clippy lint about short variable names - fixes #668
2020-06-01 10:31:46 -07:00
Mike Welsh
3a8c705e95
chore: Fix clippy lints
2020-05-30 03:47:12 -07:00
Nathan Adams
4c1ce6d765
core: Print swf version on startup, and warn when we run into avm2
2020-05-30 02:48:54 -07:00
dependabot-preview[bot]
c0593ce081
build(deps): bump syn from 1.0.27 to 1.0.28
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.27 to 1.0.28.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.27...1.0.28 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-29 09:49:49 -07:00
dependabot-preview[bot]
97f69e8ed2
build(deps): bump syn from 1.0.25 to 1.0.27
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.25 to 1.0.27.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.25...1.0.27 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-27 07:24:00 +00:00
Nathan Adams
ddf2aa3ec1
avm1: Implement all of flash.geom.Point ( #304 )
2020-05-27 00:23:45 -07:00
Nathan Adams
2e25fec099
tests: Add test coverage for flash.geom.Point
2020-05-27 00:23:45 -07:00
Nathan Adams
df6764a69c
chore: Add license metadata to all packages & crates
2020-05-27 00:11:02 -07:00
dependabot-preview[bot]
458ca2a478
build(deps): bump syn from 1.0.24 to 1.0.25
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.24 to 1.0.25.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.24...1.0.25 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 20:36:01 +00:00
CUB3D
590321133f
core: Fix incorrect String.charCodeAt bounds check ( close #633 )
2020-05-25 13:35:41 -07:00
dependabot-preview[bot]
4712446314
build(deps): bump syn from 1.0.23 to 1.0.24
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.23 to 1.0.24.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.23...1.0.24 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 01:42:44 +00:00
Mike Welsh
993421e732
core: Children run an initial frame when changing button states
...
There was a one-frame-off flicker when a button changed states.
Now children will tick a frame so that they are properly created
immediately when the parent button changes state.
2020-05-24 08:57:30 -07:00
Mike Welsh
932ad30570
core: Flatten ClipActions into a single event per action
...
Previously a MovieClip's clip action would have a set of events
that would trigger it. Now we flatten these out into a single
event per action, because this is by far the common case. If an
action does happen to have >1 event, it will be duplicated for each.
2020-05-24 08:57:30 -07:00
Mike Welsh
c427d55dbb
core: Clean up clip event handlers
...
Remove ButtonEvent and subsume it in ClipEvent. Player now tosses
ClipEvents down the display tree, cleaning up some of the event code.
2020-05-24 08:57:30 -07:00
Mike Welsh
6929cea996
core: Implement button event handlers for movie clips
2020-05-24 08:57:30 -07:00
Mike Welsh
09ca11f788
webgl: Implement linear RGB gradients
2020-05-22 11:03:16 -07:00
Mike Welsh
97db518fb1
core: First pass of drawing API (merge #611 )
2020-05-22 08:54:55 -07:00
Nathan Adams
3346accb9c
core: More accurate shape_bounds/edge_bounds in drawing api
2020-05-21 20:34:48 +02:00
Nathan Adams
62a1914c3e
core: BoundingBox::encompass should properly convert invalid BBs to valid BBs.
...
This means that encompassing 100,100 on an invalid BB should create a BB of 100,100-100,100, and not 0,0-100,100
2020-05-21 20:19:26 +02:00
Nathan Adams
279c07d9b8
core: Update drawings on render instead of on tick
2020-05-21 18:38:10 +02:00
Nathan Adams
55215273e8
core: Stretch edge & shape bounds separately and avoid a clone, in rendering api
2020-05-21 18:38:10 +02:00
Nathan Adams
04690581ba
core: Refactor common code in drawing api
2020-05-21 18:38:10 +02:00
Nathan Adams
1f8abc92fd
core: Keep track of cursor position in drawings
2020-05-21 18:38:10 +02:00
Nathan Adams
99574cfa72
core: Move drawing api out from `movie_clip` into `drawing`
2020-05-21 18:38:10 +02:00
Nathan Adams
4f69566f77
tests: Add test coverage for flash.geom.Matrix
2020-05-21 18:38:08 +02:00
dependabot-preview[bot]
898232394b
build(deps): bump syn from 1.0.22 to 1.0.23
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.22 to 1.0.23.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.22...1.0.23 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-21 03:49:03 +00:00
Nathan Adams
31b0a5ae76
avm1: Implement gradient matrix types
2020-05-20 14:54:41 +02:00
Nathan Adams
5098eb079d
avm1: Implement most of flash.geom.Matrix ( #303 )
2020-05-20 14:54:41 +02:00
Nathan Adams
14331da71b
avm1: Add flash.geom.Matrix and methods to convert between this and swf::Matrix
2020-05-20 14:54:41 +02:00
Nathan Adams
eda862c719
swf: Merged core::Matrix into swf::Matrix
2020-05-20 14:54:41 +02:00
Nathan Adams
61e464099c
core: Add initial drawing API to MovieClip
2020-05-20 14:54:40 +02:00
Nathan Adams
7ab6703fc9
render: Add RenderBackend::replace_shape method
2020-05-20 14:54:40 +02:00
Nathan Adams
4c80ae150c
core: Make DistilledShape use Boundingbox and not Rectangle
...
Rectangle more represents compressed swf data and isn't suited for performing operations, and the drawing api will be generating these dynamically
2020-05-20 14:54:33 +02:00
Nathan Adams
f7b5f14f65
core: Make RenderBack::register_bitmap* methods return a Result ( fixes #531 )
2020-05-19 07:12:36 -07:00
dependabot-preview[bot]
6134ae091f
build(deps): bump generational-arena from 0.2.7 to 0.2.8
...
Bumps [generational-arena](https://github.com/fitzgen/generational-arena ) from 0.2.7 to 0.2.8.
- [Release notes](https://github.com/fitzgen/generational-arena/releases )
- [Changelog](https://github.com/fitzgen/generational-arena/blob/master/CHANGELOG.md )
- [Commits](https://github.com/fitzgen/generational-arena/compare/0.2.7...0.2.8 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 23:54:45 -07:00
dependabot-preview[bot]
41a8b01fe7
build(deps): bump quote from 1.0.5 to 1.0.6
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.5...1.0.6 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-18 08:38:24 +00:00
dependabot-preview[bot]
3b163c2b6e
build(deps): bump syn from 1.0.21 to 1.0.22
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.21 to 1.0.22.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.21...1.0.22 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-16 09:46:08 +00:00
dependabot-preview[bot]
1f0e695465
build(deps): bump fnv from 1.0.6 to 1.0.7
...
Bumps [fnv](https://github.com/servo/rust-fnv ) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/servo/rust-fnv/releases )
- [Commits](https://github.com/servo/rust-fnv/compare/v1.0.6...v1.0.7 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-14 19:05:48 +00:00
dependabot-preview[bot]
1641d05d00
build(deps): bump syn from 1.0.20 to 1.0.21
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.20 to 1.0.21.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.20...1.0.21 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 17:18:29 +00:00
dependabot-preview[bot]
e22da9ac4c
build(deps): bump quote from 1.0.4 to 1.0.5
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.4...1.0.5 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-13 14:42:48 +00:00
Mike Welsh
031f5d6501
core: Avoid undefined behavior in f64_to_wrapping functions
2020-05-13 02:41:50 -07:00
Mike Welsh
b59140ee01
render: Add support for GIF decoding in DefineBitsJPEG tags
2020-05-13 00:15:09 -07:00
Mike Welsh
5d84d33710
render: Handle PNG data in DefineBitsJPEG tags ( fix #530 )
2020-05-13 00:15:09 -07:00
dependabot-preview[bot]
f68edb37b5
build(deps): bump syn from 1.0.19 to 1.0.20
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.19 to 1.0.20.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.19...1.0.20 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-12 00:10:19 -07:00
Nathan Adams
b82b869950
core: Don't panic when NullNavigatorBackend can't do futures
2020-05-11 01:09:07 -07:00
Nathan Adams
2343074c56
core: Make RenderBackend downcastable
2020-05-11 01:09:07 -07:00
Nathan Adams
edcd1e6d65
core: Add keyboard shortcut to dump every variable (ctrl+alt+V, same as Flash Player)
2020-05-10 23:39:54 -07:00
Nathan Adams
c787e28fcd
render: Introduce a DistilledShape and use that instead of swf::Shape for the rendering API
2020-05-10 22:03:56 -07:00
Nathan Adams
5767fb1772
swf: Added utility method for `Color::from_rgb(rgb, alpha)`
2020-05-10 22:03:56 -07:00
Nathan Adams
601715aa19
render: Merge begin_frame and clear as they're always called together
2020-05-10 22:03:56 -07:00
dependabot-preview[bot]
60ca1da468
build(deps): bump syn from 1.0.18 to 1.0.19
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.18 to 1.0.19.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.18...1.0.19 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 03:12:14 +00:00
Nathan Adams
054e6f1ac6
chore: Fix new rust check lint about std::mem::replace
2020-05-10 03:29:25 -07:00
Nathan Adams
bac99368be
chore: Fix new clippy lints about cloning
2020-05-10 03:29:25 -07:00
dependabot-preview[bot]
a81adfa336
build(deps): bump num_enum from 0.4.3 to 0.5.0
...
Bumps [num_enum](https://github.com/illicitonion/num_enum ) from 0.4.3 to 0.5.0.
- [Release notes](https://github.com/illicitonion/num_enum/releases )
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.3...0.5.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-10 10:27:38 +00:00
dependabot-preview[bot]
08a786a213
build(deps): bump libflate from 0.1.27 to 1.0.0
...
Bumps [libflate](https://github.com/sile/libflate ) from 0.1.27 to 1.0.0.
- [Release notes](https://github.com/sile/libflate/releases )
- [Commits](https://github.com/sile/libflate/compare/0.1.27...1.0.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-05 08:12:26 +00:00
Nathan Adams
47a44a5fe8
desktop: Prime window with known width/height of the movie
2020-05-04 16:07:38 -07:00
Nathan Adams
51d9f3ef36
core: Change Player::new to take in a SwfMovie, not &[u8]
2020-05-04 16:07:38 -07:00
Nathan Adams
84f6b4d06e
core: Set init_object values after prototype but before constructor
2020-05-03 12:46:55 -07:00
Nathan Adams
96d1f8fd30
tests: Add test for order of init_object vs constructor when attaching movies
2020-05-03 12:46:55 -07:00
Nathan Adams
0152f384ea
core: Run any on(construct) events at the appropriate time
2020-05-03 12:46:55 -07:00
Nathan Adams
2b9219e8f9
tests: Add test for undocumented on(construct) property (note: this swf is hand-crafted)
2020-05-03 12:46:55 -07:00
Mike Welsh
f09bd8c079
core: Clean up tick/render loop
...
Don't call `render` from `Player::tick`; instead, require the
frontends to explicitly call `render` when they wish to redraw.
The frontend can query `Player::needs_render` to see if the stage
is dirty and needs a redraw. Update desktop and web to use this
new method.
This fits better with the newer winit event loop model, which
requires explicitly calling `request_redraw`, and should avoid
spurious renders.
2020-05-02 04:25:21 -07:00
Mike Welsh
6339c74d67
render: Add wgpu backend (merge #527 )
...
Adds a wgpu-rs render backend.
2020-05-02 03:42:05 -07:00
Nathan Adams
8384847084
avm1: Deleting on a non-object is a silent failure & warning, not a hard error
2020-04-30 14:18:54 -07:00
dependabot-preview[bot]
04660a9540
build(deps): bump quote from 1.0.3 to 1.0.4
...
Bumps [quote](https://github.com/dtolnay/quote ) from 1.0.3 to 1.0.4.
- [Release notes](https://github.com/dtolnay/quote/releases )
- [Commits](https://github.com/dtolnay/quote/compare/1.0.3...1.0.4 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-30 21:18:17 +00:00
Nathan Adams
99d15aef0d
render: Cache color transforms in wgpu backend, don't re-upload unchanged values
2020-04-30 16:33:41 +02:00
dependabot-preview[bot]
014df249a8
build(deps): bump jpeg-decoder from 0.1.18 to 0.1.19
...
Bumps [jpeg-decoder](https://github.com/image-rs/jpeg-decoder ) from 0.1.18 to 0.1.19.
- [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/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-28 04:54:23 +00:00
Mike Welsh
8aa12d181f
render: Remove RenderBackend::draw_pause_overlay
2020-04-27 04:45:53 -07:00
David Wendt
ed29b1c3bb
It turns out Macromedia just used an undocumented but user-modifiable property called `__constructor__` to store the constructor.
...
A previous version of this PR (whose history has been scrubbed, but go check 918d88abe68b7467a4194738b95e5bf3e9b5bb72 if you're curious) implemented a new `TObject` property which basically every line of code that dealt with object construction had to populate. It was terrible.
2020-04-25 14:37:24 -04:00
David Wendt
bb879870ec
Add test for the constructor property on v6 and v7 SWFs
2020-04-25 13:25:21 -04:00
Nathan Adams
b3322acc8c
tests: Copy as2_super_and_this test for manual prototype setting, used by mx (currently broken)
2020-04-25 13:25:20 -04:00
David Wendt
aaa6f481ac
Add a v6 version of the super-and-this test, which is exactly the same source compiled to SWF version 6.
2020-04-25 13:25:20 -04:00
David Wendt
17d96a0fa6
Constructing a new object sets `constructor` on that object for SWFv6 and lower.
2020-04-25 13:25:20 -04:00
David Wendt
b8fd1eac9c
Invoke virtual setters defined in the prototype chain.
...
This is accomplished via two new `TObject` methods: `has_own_virtual` and `call_setter`. If an object does not contain it's own version of a property, it will first crawl the prototype chain to see if there is an overwritable virtual. If so, it will invoke that prototype's setter.
A bit of borrow finangling was required to do this; `super` now no longer caches it's proto and constr values and instead dynamically constructs them. This also means it can't be downcasted to `Executable` anymore.
With this commit, virtual setters and super-setters now work correctly.
2020-04-25 13:25:19 -04:00
David Wendt
35197f889f
`Property.set` should return a `ReturnValue` as it can potentially execute AVM code
2020-04-25 13:25:19 -04:00
David Wendt
e76ba4de87
Method calls on `super` objects should substitute the child object instead of itself as `this`.
2020-04-25 13:25:19 -04:00
David Wendt
869cbd17da
Extend `as2_super_and_this` to cover accessing object properties in super-methods, super-getters, and super-setters.
2020-04-25 13:25:18 -04:00
David Wendt
9c5cd79e2c
Refactor how `SuperObject` works to use `base_proto` and avoid handing copies of itself as `this`.
...
This allows supercalled functions to properly read and mutate the object they were called on.
2020-04-25 13:25:18 -04:00
David Wendt
f3b3db51cb
Alter AVM1 to keep track of each function call's *base prototype*: the object from which a particular function was retrieved from.
...
A base prototype is only applicable in cases where a method is being called as a property on an object. Bare function calls, `apply`/`call` calls, and so on do not generate a base prototype.
We also add a convenience method, `call_method`, to all objects. This method automatically calculates the correct base prototype for a method call on an object, which is the only operation that should generate base prototypes.
2020-04-25 13:25:18 -04:00
David Wendt
15a19f4cf8
Add test from @Dinnerbone that checks to make sure super-called functions can still initialize the object they are a part of.
2020-04-25 13:25:17 -04:00
dependabot-preview[bot]
c5a8402eae
build(deps): bump syn from 1.0.17 to 1.0.18
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.17 to 1.0.18.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.17...1.0.18 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-25 10:19:18 +00:00
Mike Welsh
fd114959f9
core: Fix regressions from init order changes in #498
...
Revert to the old action queue method of popping off actions in a
loop, as new actions can be queued while iterating. Store proto
changes in a separate queue to maintain the high priority behavior.
2020-04-25 03:06:54 -07:00
Mike Welsh
bad34c4d8f
tests: Fix tests for regressions caused by #498
...
Changes to the action queue caused actions queued during other
actions to run too late. These regressions weren't caught by the
tests because many of the goto tests ran for more frames than was
necessary, allowing the late actions to still run.
2020-04-25 03:06:54 -07:00
Mike Welsh
c1dc69c6b7
chore: rustfmt
2020-04-24 22:16:16 -07:00
dependabot-preview[bot]
24a26541a3
build(deps): bump smallvec from 1.3.0 to 1.4.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.3.0...v1.4.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-24 12:20:39 +00:00
Nathan Adams
b43d0c2430
core: Pass SwfMovies along to empty movie clips
2020-04-21 05:49:25 -07:00
Nathan Adams
a673e7108d
tests: Add test for movieclip.createEmptyMovieClip().attachMovie()`
2020-04-21 05:49:25 -07:00
Nathan Adams
8b34fbdd81
chore: Removed debug code from a test
2020-04-21 05:48:17 -07:00
Nathan Adams
330e6b40f0
core: post_instantiation should happen after properties are set, but before first frame or actions
2020-04-17 23:48:58 -07:00
Nathan Adams
9318290336
core: Execute init actions immediately, do not queue them up
...
Clip initializers can and will influence how the next clips are loaded, and must execute before that
This fixes #418
2020-04-17 23:48:58 -07:00
Nathan Adams
fe6b79a9b7
chore: Make avm1 accessible to MovieClip::preload
2020-04-17 23:48:58 -07:00
Nathan Adams
46d31548b0
chore: Move MovieClipData::do_init_action to MovieClip::do_init_action
...
No functional changes, just replaces `self` with `self.0.read()` and removed `self_display_object` argument
2020-04-17 23:48:58 -07:00
Nathan Adams
c0d1dec7dd
chore: Move MovieClipData::preload to MovieClip::preload
...
No functional changes, just replaced `self` with `self.0.read/write`.
2020-04-17 23:48:58 -07:00
Nathan Adams
601fcbfebd
core: Queue up changes of movieclip prototypes, don't execute it immediately (but at a higher priority than normal actions)
2020-04-17 23:48:58 -07:00
Nathan Adams
6b48e77b61
avm1: Add TObject::set_proto
2020-04-17 23:48:58 -07:00
Nathan Adams
6316d7e0b3
tests: Add (currently failing) test for init order when combined with register_class
2020-04-17 23:48:58 -07:00
Nathan Adams
d0fd26a89c
avm1: Fix panic with [].unshift(x)
2020-04-17 21:17:13 -07:00
Nathan Adams
bf639e1802
avm1: Don't crash when enumerating non-objects, it's a silent fail
2020-04-15 05:26:09 -07:00
Mike Welsh
b7d464f367
chore: Bump enumset to 1.0.0
2020-04-13 04:14:29 -07:00
dependabot-preview[bot]
2146c42863
build(deps): bump smallvec from 1.2.0 to 1.3.0
...
Bumps [smallvec](https://github.com/servo/rust-smallvec ) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/servo/rust-smallvec/releases )
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.2.0...v1.3.0 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-09 21:19:11 +00:00
Mike Welsh
47e936fcc2
tests: Add tests for Array.sort
2020-04-01 18:46:12 -07:00
Mike Welsh
bd0d2031bc
avm1: Implement Array.sort and constants
2020-04-01 18:46:12 -07:00
Mike Welsh
2bdbac9247
tests: Test that Color has no effect when target is undefined
2020-03-30 01:09:05 -07:00
Mike Welsh
e47c2aa356
avm1: Color object has no effect if target is undefined/empty
2020-03-30 01:01:37 -07:00
Mike Welsh
d5bd7c2dd8
avm1: Math.round rounds towards infinity
2020-03-29 18:44:28 -07:00
Mike Welsh
0c0d3dfd41
core: Add Navigator::time_since_launch to use for getTimer
...
Change `ActionGetTime` (`getTimer`) to use a new backend method.
This allows it to return updated times if it is called multiple
times in a single frame. This fixes hangs caused by games that use
busy-loop "frame limiter" code.
2020-03-28 22:28:07 -07:00
Mike Welsh
f7375c3700
avm1: Use `PropertyMap::get_index` for stage object properties
2020-03-28 16:22:02 -07:00
Mike Welsh
4ea609cca1
tests: Don't special case enumeration tests
2020-03-28 16:22:02 -07:00
Mike Welsh
8da9487c0a
avm1: Match Flash's property enumeration order ( fix #153 )
2020-03-28 16:22:02 -07:00
Mike Welsh
2cdf780e6f
avm1: Handle case sensitivity in DisplayObject children
...
Alter `get_child_by_name` and alter `get_level_by_path` to respect
case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh
81a0bb370b
tests: Add test for SWF<=6 case insensitivty
2020-03-28 16:22:02 -07:00
Mike Welsh
ea245895b0
avm1: Use PropertyMap for stage object magic properties
2020-03-28 16:22:02 -07:00
Mike Welsh
7d848f4f34
avm1: Add avm parameter to TObject methods
...
This is necessary to get the current SWF version for properly
handing case sensitivity.
2020-03-28 16:22:02 -07:00
Mike Welsh
1ef698f2ea
core: Add PropertyMap for handling AVM1 object properties
...
`PropertyMap` wraps over `IndexMap` to handle object properties in
AVM1. All insert/remove/get methods require and `swf_version`
parameter, and the `PropertyMap` will take care of handling case
senstivity and maintaing iteration order based on the SWF version.
2020-03-28 16:22:02 -07:00
Mike Welsh
d42a402522
avm1: Add display object methods to TextField
2020-03-26 14:19:18 -07:00
Mike Welsh
7865ec1021
avm1: Implement Button object
...
First implementation of Button object. Hook up to the button
display object and run onRelease etc. methods as appropriate.
Pull out common display object methods into globals::display_object.
2020-03-26 00:21:21 -07:00
Mike Welsh
4df1128c19
core: Implement Object.registerClass (merge #344 )
...
Implement Object.registerClass
2020-03-25 18:55:49 -07:00
dependabot-preview[bot]
ef5ee3a889
build(deps): bump syn from 1.0.16 to 1.0.17
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.16 to 1.0.17.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.16...1.0.17 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-21 01:37:48 +00:00
Mike Welsh
e9cb05aeb4
avm1: Correct order of modulo operands
...
Addresses part of #458 .
2020-03-20 16:00:28 -07:00
hthh
a16885d84b
avm1: Fix string-to-number octal and whitespace handling
...
This conversion allows negative octal values, but not negative
hex values, and ignores only leading ASCII whitespace. A test
for this behavior is included.
2020-03-20 04:27:41 -07:00
Nathan Adams
b4624fddce
avm1: GetVariable and SetVariable look through the scope chain. Fixes #414
...
GetVariable and SetVariable attempt to resolve paths on each scope
in the scope chain.
2020-03-19 19:58:16 -07:00
Mike Welsh
454cd29ed6
chore: EditText::font takes self by value
2020-03-17 19:42:57 -07:00
Mike Welsh
068f4c3bee
core: Edit text uses device fonts when outline flag isn't set
...
Specifically fall back to the device font when the UseOutlines
flag is not set in DefineEditText (SWF19 p.172). Fixes #451 .
Note that since we only use a single font for "device" rendering,
this may sometimes be a different font than is specified in the
Flash IDE.
2020-03-17 19:13:20 -07:00
dependabot-preview[bot]
da3398c832
build(deps): bump bitstream-io from 0.8.4 to 0.8.5
...
Bumps [bitstream-io](https://github.com/tuffy/bitstream-io ) from 0.8.4 to 0.8.5.
- [Release notes](https://github.com/tuffy/bitstream-io/releases )
- [Commits](https://github.com/tuffy/bitstream-io/commits/v0.8.5 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:08:59 +00:00
dependabot-preview[bot]
2bfa2502a9
build(deps): bump num_enum from 0.4.2 to 0.4.3
...
Bumps [num_enum](https://github.com/illicitonion/num_enum ) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/illicitonion/num_enum/releases )
- [Commits](https://github.com/illicitonion/num_enum/compare/0.4.2...0.4.3 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-17 17:07:35 +00:00
Mike Welsh
c2ce9892b1
core: Clamp RGBA when un-multiplying alpha
...
Fixes some bad pixels sometimes appearing in decoded JPEGs (such
as in #437 and in Dad 'n' Me).
2020-03-16 16:11:59 -07:00
dependabot-preview[bot]
0f7f36681d
build(deps): bump quick-xml from 0.17.2 to 0.18.1
...
Bumps [quick-xml](https://github.com/tafia/quick-xml ) from 0.17.2 to 0.18.1.
- [Release notes](https://github.com/tafia/quick-xml/releases )
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md )
- [Commits](https://github.com/tafia/quick-xml/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-16 05:34:45 +00:00
Mike Welsh
24a557807d
chore: Fix more clippy lints
2020-03-12 21:40:48 -07:00
Mike Welsh
13b039fa34
chore: Fix clippy iter-nth-zero warnings
...
New lint added in latest clippy versions.
2020-03-12 21:16:30 -07:00
Mike Welsh
098bf33068
chore: Bump quote to 1.0.3
2020-03-08 18:58:39 -07:00
dependabot-preview[bot]
a0ee19fd37
build(deps): bump syn from 1.0.14 to 1.0.16
...
Bumps [syn](https://github.com/dtolnay/syn ) from 1.0.14 to 1.0.16.
- [Release notes](https://github.com/dtolnay/syn/releases )
- [Commits](https://github.com/dtolnay/syn/compare/1.0.14...1.0.16 )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 20:26:50 +00:00
dependabot-preview[bot]
ba185d3d43
build(deps): bump minimp3 from 0.3.3 to 0.3.5
...
Bumps [minimp3](https://github.com/germangb/minimp3-rs ) from 0.3.3 to 0.3.5.
- [Release notes](https://github.com/germangb/minimp3-rs/releases )
- [Commits](https://github.com/germangb/minimp3-rs/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 19:07:25 +00:00
dependabot-preview[bot]
3f28554285
build(deps): bump enumset from 0.4.4 to 0.4.5
...
Bumps [enumset](https://github.com/Lymia/enumset ) from 0.4.4 to 0.4.5.
- [Release notes](https://github.com/Lymia/enumset/releases )
- [Changelog](https://github.com/Lymia/enumset/blob/master/RELEASES.md )
- [Commits](https://github.com/Lymia/enumset/commits )
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 18:14:25 +00:00
Nathan Adams
751b15beec
chore: Raise errors during Object.registerClass
2020-02-29 23:13:02 +01:00
Nathan Adams
7bed4d4940
chore: Document each trace in attach_movie avm1 tests
2020-02-29 23:05:17 +01:00
Nathan Adams
041bb6b44c
avm1: Implement `Object.registerClass`
2020-02-29 23:05:17 +01:00
Nathan Adams
d850443c84
avm1: Refactor to expose `avm, context` in `post_instantiate`
2020-02-29 23:05:15 +01:00
David Wendt
fdce33ff5e
Return an `Err` when decompression fails, rather than just logging it and returning an empty vec.
2020-02-26 18:18:24 -05:00
David Wendt
ded7737ac0
`SwfMovie::from_data` is falliable and we should not hide those errors behind panics.
2020-02-26 18:15:01 -05:00
David Wendt
0313225164
Don't allow movie loads to be removed from the load manager unless they have completed or errored.
2020-02-26 18:03:45 -05:00
David Wendt
a023e161fc
Don't panic if our target handle was removed from the load manager. Instead, return an `Err` so that it can be properly reported on the console without killing the player.
2020-02-26 17:38:31 -05:00
Mike Welsh
223edb9bc1
core: Matrix translation is in twips
2020-02-26 12:47:47 -08:00