Commit Graph

57 Commits

Author SHA1 Message Date
Mike Welsh c1abbdacdd chore: Fix naming convention 2020-03-26 02:55:25 -07:00
Mike Welsh e237536293 web: Blacklist "Adobe Flash Player" title attribute (fix #468)
The "Click to activate Flash" box from Chrome stomps on the title
attribute of a Flash embed when you mouse over it. This causes
an annoying "Adobe Flash Player" tooltip to appear even after
Ruffle replaces the embeds.

Now we check for this specific title and remove it.
2020-03-26 02:37:25 -07:00
Mike Welsh c2e9d5d757 web: Install plugin spoof immediately on script load
Scripts like SWFObject check for the Flash plugin immediately when
they load, so we can't defer installing the spoof. Fixes #448.
2020-03-25 20:14:31 -07:00
Mike Welsh 353eeec6c3 web: Return matching Flash Player version for MIME type description
The plugin detection spoofer would add " "Shockwave Flash 32.0 r0
(compatible; Ruffle 0.1)" to the Flash MIME type description in
the plugins array. However, this breaks SWFObject's version
detection, which does a simple String split.

Now we return the same value as the official player:
"Shockwave Flash 32.0 r0"
2020-03-25 20:14:31 -07:00
Mike Welsh 774aa59210 web: Default public_path to currentScript URL
Also automatically add trailing slash on public_path if necessary.
2020-03-25 00:54:21 -07:00
Mike Welsh fa063a6f53 web: Enable dynamic-content polyfill by default
Co-authored-by: Justin-CB <55590227+Justin-CB@users.noreply.github.com>
2020-03-24 22:13:10 -07:00
Mike Welsh e332e5c24c web: Simplify polyfill code
Addresses #464. Use `document.getElementsByTagName` to find all
object and embed tags in the document. For dynamic content,
we keep these live collections around, and re-check them whenever
a MutationObserver fires.

Co-authored-by: Justin-CB <55590227+Justin-CB@users.noreply.github.com>
2020-03-24 22:13:10 -07:00
Mike Welsh 4561b591bf web: Handle percentage dimensions in polyfill (fix #433)
When Ruffle replaces a Flash embed, the width/height of the embed
are copied over to CSS of the Ruffle element. "px" was being
appended even if the dimensions were a % value, which CSS rejected.

Try to be a little smarter about parsing out the HTML dimension
attributes (HTML is more lenient). Append "px" only if the value
isn't a percentage.

Fixes #433.
2020-03-21 01:23:23 -07:00
Mike Welsh 9e6fe41a91 web: Ignore errors on `Element.setAttribute` in polyfill
Ruffle would not polyfill a Flash embed if it had bogus attributes
in the embed tag. Now these errors are silently ignored.

Fixes the other part of #457.
2020-03-20 20:47:58 -07:00
Mike Welsh 099c497a91 web: Activate polyfill if embed src ends in .swf
Fixes part of #457. Even if the MIME type/class IDs are missing
on the embed/object tags, browsers will still attempt to play
the file as Flash if it ends in a .swf extension.
2020-03-20 20:47:58 -07:00
Mike Welsh 0e228441e1 web: Add missing returns to RufflePlayer.local/local_compatible 2020-01-13 12:28:30 -08:00
David Wendt 51023145c8 Build the extension using webpack, the same as the local version. 2020-01-10 22:10:43 -05:00
Mike Welsh 29754eace8 web: Avoid `copyToChannel` on Safari
`AudioBuffer.copyToChannel` does not work on Safari, so switch to
using `getChannelData` to fill the audio buffers.

Limitations in wasm-bindgen prevent us from actually modifying the
data returned by `getChannelData` on the Rust side, so import a JS
function to fill the audio buffer (js-src/ruffle-imports.js).
2019-12-03 23:05:42 -08:00
Mike Welsh 9f85686666 web: Add missing return to VersionRange.from_requirement_string 2019-11-17 17:43:19 -05:00
Mike Welsh f41708a584 web: Add missing return to Ruffle.newest() 2019-11-17 17:43:19 -05:00
David Wendt 5d8d02a5a2 Add `local` and `local_compatible` methods to the Public API. 2019-11-17 17:43:19 -05:00
David Wendt ab9af6958e Enforce the opt-out entirely within trusted extension space, so that we don't load any untrusted world code at all in that case. 2019-11-17 17:43:19 -05:00
David Wendt 5aab97053b Don't depend on the legacy elements polyfill anymore, as that no longer exists, and we define all elements on demand. 2019-11-17 17:43:19 -05:00
David Wendt d964afe72e Expose the `RufflePlayer` element directly. 2019-11-17 17:43:19 -05:00
David Wendt 75e00aff7b Allow looking up sources directly by version. 2019-11-17 17:43:19 -05:00
David Wendt 99714d445c Expand version handling to support ranges and requirements. 2019-11-17 17:43:19 -05:00
David Wendt 3b1ab0e987 Fix the fallback object detection. 2019-11-17 17:43:19 -05:00
David Wendt 5b5aaecb83 Interdictions are now called polyfills 2019-11-17 17:43:19 -05:00
David Wendt 2fa42e3b31 Allow fault tolerance for naming conflicts with Ruffle elements 2019-11-17 17:43:19 -05:00
David Wendt d53f9c8f47 Allow configuring the Webpack path 2019-11-17 17:43:19 -05:00
David Wendt fbca5a0a6f Fix broken interdictions 2019-11-17 17:43:19 -05:00
David Wendt ccd763b696 Tolerate Ruffle loading after the page loads 2019-11-17 17:43:19 -05:00
David Wendt 6d34997975 Fix some bugs in the Public API 2019-11-17 17:43:19 -05:00
David Wendt 4163ea7975 Add the ability to upgrade the Public API itself.
This isn't intended to be used right away.
2019-11-17 17:43:19 -05:00
David Wendt 6b0881e3f2 Add proper version negotiation 2019-11-17 17:43:19 -05:00
David Wendt db01ee8984 Add class to parse version strings 2019-11-17 17:43:19 -05:00
David Wendt bb184469d8 Actually install new sources 2019-11-17 17:43:19 -05:00
David Wendt f957ec4744 Create a standard list of interdictions rather than checking for specific strings. 2019-11-17 17:43:19 -05:00
David Wendt d1aa71e488 Add explicit classes for the Ruffle Public API. 2019-11-17 17:43:19 -05:00
David Wendt 5dcbe43fe1 Consolidate public API into a shared module 2019-11-17 17:43:19 -05:00
David Wendt 4742baf40d Make interdictions configured via a window object call 2019-11-17 17:43:18 -05:00
David Wendt 48fd6cc7a7 Fix declarative configuration reader 2019-11-17 17:43:18 -05:00
David Wendt 485f166df3 Add data attributes to declaratively control Ruffle. 2019-11-17 17:43:18 -05:00
David Wendt fe782e5db3 Create a third web target: "selfhosted".
Currently, selfhosted just omits some of the crazier interdictions.
2019-11-17 17:43:18 -05:00
David Wendt 4502ad54c2 Allow dynamic interdiction to apply to object/embed tags directly 2019-09-14 15:15:26 -05:00
David Wendt a942eb3ab2 Support data parameter for SWF url. 2019-09-14 15:15:26 -05:00
David Wendt 84759f8cea Fix our previous changes to the Ruffle core loader so that both the extension and demo work 2019-09-11 20:28:58 -04:00
David Wendt f59d62516e Fix demo site regressions. 2019-09-03 18:38:05 -04:00
David Wendt 406cc746ce The MimeType for `application/x-shockwave-flash` should list it's extension as `swf`, not `spl`. 2019-08-31 18:57:26 -04:00
David Wendt fc67f0872f Don't break Ruffle if we encounter an embed or object without a size. 2019-08-30 22:27:51 -04:00
David Wendt b4b38057e4 Add checks for the Ruffle element being connected.
When a Ruffle player element is disconnected, attempts to play SWF files
fail semi-silently.

We also check for nested objects, since only the top should be
successful in loading.
2019-08-30 22:27:50 -04:00
David Wendt f01f479f54 Don't forget random bits of object tag contents! 2019-08-30 22:27:50 -04:00
David Wendt 2b2f27afad Falsify a better-sounding version of Flash.
This is at least the version Chrome claims to have.
2019-08-30 22:27:50 -04:00
David Wendt 0d8b72acce Don't try to wrap text nodes, it won't end well. 2019-08-30 22:27:50 -04:00
David Wendt 190666fe91 Interdict Flash tags that use ActiveX. 2019-08-30 22:27:50 -04:00