Commit Graph

1135 Commits

Author SHA1 Message Date
Mike Welsh ab63f221ed web: Bump to wasm-bindgen 0.2.57 2020-01-06 13:01:39 -08:00
Mike Welsh f576a39760 web: Fix must_use warning on AudioContext::decode_audio_data
web-sys 0.3.34 added `must_use` to `Promise`. Add `let _ =` to
squlech this warning.
2020-01-06 13:01:39 -08:00
dependabot-preview[bot] 5c4a180913 build(deps): bump web-sys from 0.3.33 to 0.3.34
Bumps [web-sys](https://github.com/rustwasm/wasm-bindgen) from 0.3.33 to 0.3.34.
- [Release notes](https://github.com/rustwasm/wasm-bindgen/releases)
- [Changelog](https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rustwasm/wasm-bindgen/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-06 13:01:39 -08:00
Mike Welsh bcc51f2dd8
avm1: Merge #205, XML support
Support for AVM1 XML and XMLNode objects.
2020-01-05 12:57:38 -08:00
David Wendt 0d1d0e8de7 Don't bother preserving the `Cow`ness of unescaped strings when we're going to clone them anyway. 2020-01-05 00:31:45 -05:00
David Wendt 7957434036 This is a copy type, copy it 2020-01-05 00:24:31 -05:00
David Wendt f8b5b8a032 Use `unwrap_or_default` where available 2020-01-05 00:22:36 -05:00
David Wendt ef7c5d7eb9 Move XML properties to separate functions rather than closures 2020-01-05 00:17:57 -05:00
David Wendt 14dba0d100 Log errors encountered when removing the children of a node we plan to parse XML into.
Also, remove a handful of unnecessary `#[allow(unused_must_use)]` instances.
2020-01-05 00:04:45 -05:00
David Wendt 464563a703 Change the no-double-introduction warning into a proper `assert!`. Add doc warning about the panic. 2020-01-05 00:00:29 -05:00
David Wendt 750e6e4370 Replace bare number constants for XML errors with symbolic `const` values 2020-01-04 23:56:10 -05:00
David Wendt fd541fabea Implement `status`.
I'm not entirely sure how to test this one - the list of errors that Flash kicks out for XML and the list of errors that `quick_xml` kicks out don't line up at all; so I just ensured that any error is a negative number (currently the one for OOM errors) and stuck whatever errors *did* match up together.

Consequently I don't know entirely *how* to write tests for this.
2020-01-04 19:00:49 -05:00
David Wendt fec95dd226 Add regression test for `idMap`. 2020-01-04 19:00:49 -05:00
David Wendt f3226537bf Implement `idMap`.
`idMap` is a strange property; it's only populated with nodes which had a given `id` *at the time of parsing*, and said nodes continue to be referenced even if the node is removed from the document. I have yet to find a way by which nodes can be deleted from `idMap`.

It also takes expandos, so this has to be a new retained object on the XML document. I originally considered not creating *another* `Object` impl and populating a regular `ScriptObject` with nodes, but that meant we couldn't lazy-instantiate their AVM1 side counterparts. Boo. :/
2020-01-04 19:00:48 -05:00
David Wendt 1722558d44 Add test for `XML.parseXML` 2020-01-04 19:00:47 -05:00
David Wendt 823e8602ff Impl `XML.parseXML` 2020-01-04 19:00:46 -05:00
David Wendt d00ef01965 Add a convenience method: `XMLNode.into_string` 2020-01-04 19:00:46 -05:00
David Wendt b4b722e1d6 Add another test for AVM1 XML's failure to roundtrip unsupported node types (e.g. comments). 2020-01-04 19:00:45 -05:00
David Wendt 2c790f1d41 Filter non-AS2 compatible nodes from toString output, and add non-SWF tests for XML filtering. 2020-01-04 19:00:45 -05:00
David Wendt ce1b958abb Add some more tests for XML namespace URIs. 2020-01-04 19:00:45 -05:00
David Wendt e2fa685d41 Fix tagname parsing.
There is a bug in `quick_xml` - or at least, I *think* it's a bug - where the `unescaped` method of `BytesStart` yields a bunch of attributes if you have slightly invalid crap in your tag like `xmlns:`. To work around it, I turned off unescaping; we're instead using `name` and ignoring unescaping. This will probably fail somewhere.
2020-01-04 19:00:44 -05:00
David Wendt e1034fce31 clippy compliance 2020-01-04 19:00:44 -05:00
David Wendt 7ac3204759 format prev commit 2020-01-04 19:00:43 -05:00
David Wendt d2aa3dd987 Add a test for `createElement` and `createTextNode`. 2020-01-04 19:00:43 -05:00
David Wendt db38982ffb For some reason, text nodes have an attributes object. 2020-01-04 19:00:42 -05:00
David Wendt 91155d6870 Text nodes have empty arrays for `childNodes` rather than being `undefined`. 2020-01-04 19:00:42 -05:00
David Wendt d28094a019 Implement `createElement` and `createTextNode`. 2020-01-04 19:00:42 -05:00
David Wendt 97bcb6b2dc Add an ignored test for `xmlDecl`.
Test is currently ignored because AS2 XML currently handles XML declarations in ways not compatible with our current parser. Investigating hacky ways around this.
2020-01-04 19:00:41 -05:00
David Wendt c02da74afa Expose the `<?xml ?>` declaration to ActionScript.
I can't write proper tests for this because our underlying XML parsing technology doesn't let us do what AS2 XML does: just copy the first xml tag out of the document and into a string. No, seriously, anything at the start of the parsed XML that starts with `<?xml` and ends with `?>` gets copied into Flash's moral equivalent of `xml::Document` as a string. We parse the whole thing, which is wrong, so we'll need to additionally retain the original xmldecl string in order to pass the test I wrote for this.
2020-01-04 19:00:41 -05:00
David Wendt ce0546fc2c Add test for `docTypeDecl`. 2020-01-04 19:00:40 -05:00
David Wendt a7a349b02b Expose `docTypeDecl` to ActionScript.
This also involves storing the `DocType` node on the document object and retrieving it later.
2020-01-04 19:00:40 -05:00
David Wendt a80aab1b08 Document roots can store an attributes object, even though they don't have attributes 2020-01-04 19:00:40 -05:00
David Wendt 6a472d32bb Filter incompatible nodes from the sibling and child lists. 2020-01-04 19:00:39 -05:00
David Wendt fd14d0c9df Doctype nodes should be represented as text nodes to ActionScript (if they somehow grab hold of them) 2020-01-04 19:00:38 -05:00
David Wendt 6b4bbee195 Create and store `DocType` nodes on the tree when we encounter a `<!DOCTYPE...>` tag. 2020-01-04 19:00:38 -05:00
David Wendt aa749dc1b0 Store the XML document version, encoding, and standalone flags. 2020-01-04 19:00:38 -05:00
David Wendt a869107480 The `DocumentRoot` node type should have it's own node type ID, and AS2 XML should filter it out. This also filters out comment nodes as text, which isn't technically wrong but we should do better 2020-01-04 19:00:37 -05:00
David Wendt 7965045d87 Add test for XMLNode.toString. 2020-01-04 19:00:37 -05:00
David Wendt 673f85f067 XMLNode type 1 is an element, not a text node. 2020-01-04 19:00:36 -05:00
David Wendt 88aa5f8004 Add extra whitespace to empty tags. 2020-01-04 19:00:36 -05:00
David Wendt 0c7a1fe667 Text and comment nodes are stored plain and must be escaped for XML 2020-01-04 19:00:36 -05:00
David Wendt c7e1f34a5d Print empty nodes as empty tags rather than start/end 2020-01-04 19:00:35 -05:00
David Wendt c76e5ce447 appendChild also refuses to orphan nodes already part of another XML tree. 2020-01-04 19:00:35 -05:00
David Wendt bff851e6a4 Add test for insertBefore 2020-01-04 19:00:34 -05:00
David Wendt 34cbe2e04b insertNode rejects child nodes that already have a parent 2020-01-04 19:00:34 -05:00
David Wendt 7b4a509ebc Avoid double-borrows when moving a child within it's parent 2020-01-04 19:00:33 -05:00
David Wendt 7753e20fe3 Add a test for XML.removeNode(). 2020-01-04 19:00:33 -05:00
David Wendt 30266b2ce7 remove_child should also ensure the child disowns the parent. 2020-01-04 19:00:33 -05:00
David Wendt 8c5dcfe662 Swap in newly constructed nodes *before* filling them with content.
Fixes a bug where new XML("<node />").childNode[0].parentNode did NOT refer to the overall document object, but to a phantom text node.

This is because the swap operation used to construct an XMLObject's node in-place was happening AFTER parsing, which means that referents already existed to the temporary XMLNode created by XMLObject::new. swap is not to be called after tree structure has been created; it does not update referents to the swapped nodes.

In the future I should examine the implications of explicitly reconstructing already existing nodes, e.g. through XML.apply(some_xml). Right now, the existing node will be swapped with a new one, and two nodes will exist pointing to the same script object, which is a huge problem with our overall design. We should, at the very least, disassociate swapped nodes from their script object, just in case they still have referents.

Ideally, we wouldn't have to swap nodes, but to avoid a swap, I'd have to instead have a second layer of indirection just to hold a rewritable pointer that every XMLObject points to. This isn't really worth it unless I HAVE to do it, so I'm not going to do it.
2020-01-04 19:00:32 -05:00
David Wendt 568d90f4dc Warn if XML.removeNode fails for whatever reason 2020-01-04 19:00:32 -05:00