Open mykmelez opened 8 years ago
I'm working on this over in https://github.com/mykmelez/positron/tree/webview-element.
I landed a partial implementation of <webview> in https://github.com/mozilla/positron/pull/60. Unsure if it's worth keeping this issue open for the rest of the implementation. It'd probably make more sense to track individual bits of that implementation in separate issues.
The <webview> element in Electron provides an unprivileged frame for loading untrusted web content along with an API for interacting with it, similar to <iframe mozbrowser> in Gecko.
It's implemented in Electron by web-view.js, which calls the native API WebFrame::RegisterEmbedderCustomElement to register the <webview> and <browserplugin> custom elements (as subclasses of HTMLObjectElement) and then exports a WebView() constructor.
The WebView() constructor then creates a <webview> instance, creates a <browserplugin> instance, creates a shadow root on the <webview>, and appends the <browserplugin> to the shadow root.
For Positron, we should be able to enable Web Components, use the standard
document.registerElement
to register a custom <webview> element whose shadow root contains an <iframe mozbrowser>, and then translate <webview> APIs to <iframe mozbrowser> APIs.We'll probably have to modify web-view.js in this case (although I've been avoiding modifications to the Electron scripts in positron/electron/lib/ generally, since it'll be easier to track upstream changes the less we modify that code).
Also note https://github.com/browserhtml/browserhtml/issues/639, which is about designing a <webview> implementation for Servo/browser.html. Of note, that issue references this comparison by Kan-Ru of <webview> and <iframe mozbrowser>.