This commit is contained in:
Kevin Sawicki 2016-06-07 10:24:48 -07:00
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ 3bcb411e28
ΠšΠΎΠΌΠΌΠΈΡ‚ ce1a9740f6
1 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 12 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 13 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -57,12 +57,12 @@ var getNextInstanceId = function () {
// Create a new guest instance.
var createGuest = function (embedder, params) {
var destroy, destroyEvents, event, fn, guest, i, id, j, len, len1, listeners
if (webViewManager == null) {
webViewManager = process.atomBinding('web_view_manager')
}
id = getNextInstanceId(embedder)
guest = webContents.create({
const id = getNextInstanceId(embedder)
const guest = webContents.create({
isGuest: true,
partition: params.partition,
embedder: embedder
@ -73,20 +73,19 @@ var createGuest = function (embedder, params) {
}
// Destroy guest when the embedder is gone or navigated.
destroyEvents = ['will-destroy', 'crashed', 'did-navigate']
destroy = function () {
const destroyEvents = ['will-destroy', 'crashed', 'did-navigate']
const destroy = function () {
if (guestInstances[id] != null) {
return destroyGuest(embedder, id)
destroyGuest(embedder, id)
}
}
for (i = 0, len = destroyEvents.length; i < len; i++) {
event = destroyEvents[i]
for (const event of destroyEvents) {
embedder.once(event, destroy)
// Users might also listen to the crashed event, so We must ensure the guest
// is destroyed before users' listener gets called. It is done by moving our
// listener to the first one in queue.
listeners = embedder._events[event]
const listeners = embedder._events[event]
if (Array.isArray(listeners)) {
moveLastToFirst(listeners)
}
@ -132,13 +131,12 @@ var createGuest = function (embedder, params) {
})
// Dispatch events to embedder.
fn = function (event) {
return guest.on(event, function (_, ...args) {
const fn = function (event) {
guest.on(event, function (_, ...args) {
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args))
})
}
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
event = supportedWebViewEvents[j]
for (const event of supportedWebViewEvents) {
fn(event)
}
@ -151,6 +149,7 @@ var createGuest = function (embedder, params) {
guest.on('size-changed', function (_, ...args) {
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
})
return id
}