Implement initial, experimental BrowserView API
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Tue, 11 Apr 2017 17:47:30 +0000 (20:47 +0300)
committerBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 12 Apr 2017 22:27:27 +0000 (01:27 +0300)
commit8b9f7e5b00187a1fc608c883fdfdbae9727f1729
tree5504fe1b724d1064408df69b08127c065f98517c
parent779e4e58893cd5eebfb4126a491392d4c6c90d58
Implement initial, experimental BrowserView API

Right now, `<webview>` is the only way to embed additional content in a
`BrowserWindow`. Unfortunately `<webview>` suffers from a [number of
problems](https://github.com/electron/electron/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20label%3Awebview%20).
To make matters worse, many of these are upstream Chromium bugs instead
of Electron-specific bugs.

For us at [Figma](https://www.figma.com), the main issue is very slow
performance.

Despite the upstream improvements to `<webview>` through the OOPIF work, it is
probable that there will continue to be `<webview>`-specific bugs in the
future.

Therefore, this introduces a `<webview>` alternative to called `BrowserView`,
which...

- is a thin wrapper around `api::WebContents` (so bugs in `BrowserView` will
  likely also be bugs in `BrowserWindow` web contents)

- is instantiated in the main process like `BrowserWindow` (and unlike
  `<webview>`, which lives in the DOM of a `BrowserWindow` web contents)

- needs to be added to a `BrowserWindow` to display something on the screen

This implements the most basic API. The API is expected to evolve and change in
the near future and has consequently been marked as experimental. Please do not
use this API in production unless you are prepared to deal with breaking
changes.

In the future, we will want to change the API to support multiple
`BrowserView`s per window. We will also want to consider z-ordering
auto-resizing, and possibly even nested views.
25 files changed:
atom/browser/api/atom_api_browser_view.cc [new file with mode: 0644]
atom/browser/api/atom_api_browser_view.h [new file with mode: 0644]
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/common_web_contents_delegate.cc
atom/browser/native_browser_view.cc [new file with mode: 0644]
atom/browser/native_browser_view.h [new file with mode: 0644]
atom/browser/native_browser_view_mac.h [new file with mode: 0644]
atom/browser/native_browser_view_mac.mm [new file with mode: 0644]
atom/browser/native_browser_view_views.cc [new file with mode: 0644]
atom/browser/native_browser_view_views.h [new file with mode: 0644]
atom/browser/native_window.h
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm
atom/browser/native_window_views.cc
atom/browser/native_window_views.h
atom/common/node_bindings.cc
docs/api/browser-view.md [new file with mode: 0644]
docs/api/browser-window.md
filenames.gypi
lib/browser/api/browser-view.js [new file with mode: 0644]
lib/browser/api/module-list.js
spec/api-browser-view-spec.js [new file with mode: 0644]