Support document visiblity state and events in webviews

This commit is contained in:
Kevin Sawicki 2016-05-24 12:44:09 -07:00
parent 1e15ce6ccd
commit 73b07f76a3
6 changed files with 25 additions and 4 deletions

View file

@ -42,6 +42,11 @@ var WebViewImpl = (function () {
this.webviewNode.setZoomLevel(zoomLevel)
}
webFrame.on('zoom-level-changed', this.onZoomLevelChanged)
this.onVisibilityChanged = (event, visibilityState) => {
this.webviewNode.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', visibilityState)
}
ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged)
}
WebViewImpl.prototype.createBrowserPluginNode = function () {
@ -56,6 +61,7 @@ var WebViewImpl = (function () {
WebViewImpl.prototype.reset = function () {
// Unlisten the zoom-level-changed event.
webFrame.removeListener('zoom-level-changed', this.onZoomLevelChanged)
ipcRenderer.removeListener('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged)
// If guestInstanceId is defined then the <webview> has navigated and has
// already picked up a partition ID. Thus, we need to reset the initialization
@ -224,7 +230,8 @@ var WebViewImpl = (function () {
params = {
instanceId: this.viewInstanceId,
userAgentOverride: this.userAgentOverride,
zoomFactor: webFrame.getZoomFactor()
zoomFactor: webFrame.getZoomFactor(),
hiddenPage: document.hidden
}
ref1 = this.attributes
for (attributeName in ref1) {