Send cached visibility state when guest DOM is ready
This commit is contained in:
parent
f1a72ad108
commit
626a1550dc
1 changed files with 9 additions and 0 deletions
|
@ -143,6 +143,14 @@ const createGuest = function (embedder, params) {
|
||||||
sendToEmbedder('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED', ...args)
|
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
|
// Forward internal web contents event to embedder to handle
|
||||||
// native window.open setup
|
// native window.open setup
|
||||||
guest.on('-add-new-contents', (...args) => {
|
guest.on('-add-new-contents', (...args) => {
|
||||||
|
@ -280,6 +288,7 @@ const watchEmbedder = function (embedder) {
|
||||||
const onVisibilityChange = function (visibilityState) {
|
const onVisibilityChange = function (visibilityState) {
|
||||||
for (const guestInstanceId of Object.keys(guestInstances)) {
|
for (const guestInstanceId of Object.keys(guestInstances)) {
|
||||||
const guestInstance = guestInstances[guestInstanceId]
|
const guestInstance = guestInstances[guestInstanceId]
|
||||||
|
guestInstance.visibilityState = visibilityState
|
||||||
if (guestInstance.embedder === embedder) {
|
if (guestInstance.embedder === embedder) {
|
||||||
guestInstance.guest.send('ELECTRON_GUEST_INSTANCE_VISIBILITY_CHANGE', visibilityState)
|
guestInstance.guest.send('ELECTRON_GUEST_INSTANCE_VISIBILITY_CHANGE', visibilityState)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue