mirror of
https://github.com/electron/electron.git
synced 2026-01-25 23:38:18 -05:00
Send cached visibility state when guest DOM is ready
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user