Send cached visibility state when guest DOM is ready

This commit is contained in:
Kevin Sawicki 2017-06-12 12:58:26 -07:00
parent f1a72ad108
commit 626a1550dc

View file

@ -143,6 +143,14 @@ const createGuest = function (embedder, params) {
sendToEmbedder('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED', ...args)
})
// Notify guest of embedder window visibility when it is ready
guest.on('dom-ready', function () {
const guestInstance = guestInstances[guestInstanceId]
if (guestInstance != null && guestInstance.visibilityState != null) {
guest.send('ELECTRON_GUEST_INSTANCE_VISIBILITY_CHANGE', guestInstance.visibilityState)
}
})
// Forward internal web contents event to embedder to handle
// native window.open setup
guest.on('-add-new-contents', (...args) => {
@ -280,6 +288,7 @@ const watchEmbedder = function (embedder) {
const onVisibilityChange = function (visibilityState) {
for (const guestInstanceId of Object.keys(guestInstances)) {
const guestInstance = guestInstances[guestInstanceId]
guestInstance.visibilityState = visibilityState
if (guestInstance.embedder === embedder) {
guestInstance.guest.send('ELECTRON_GUEST_INSTANCE_VISIBILITY_CHANGE', visibilityState)
}