Add a guestinstance attribute to webviews reflecting their current guest
instance ID and allowing moving a guest instance to a new webview.
This commit is contained in:
parent
01fa9827b4
commit
313b2faa3c
12 changed files with 424 additions and 63 deletions
|
@ -71,12 +71,13 @@ var WebViewImpl = (function () {
|
|||
// that we don't end up allocating a second guest.
|
||||
if (this.guestInstanceId) {
|
||||
guestViewInternal.destroyGuest(this.guestInstanceId)
|
||||
this.webContents = null
|
||||
this.guestInstanceId = void 0
|
||||
this.beforeFirstNavigation = true
|
||||
this.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId = true
|
||||
}
|
||||
this.internalInstanceId = 0
|
||||
|
||||
this.webContents = null
|
||||
this.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].setValueIgnoreMutation(undefined)
|
||||
this.beforeFirstNavigation = true
|
||||
this.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId = true
|
||||
}
|
||||
|
||||
// Sets the <webview>.request property.
|
||||
|
@ -184,7 +185,7 @@ var WebViewImpl = (function () {
|
|||
|
||||
WebViewImpl.prototype.createGuest = function () {
|
||||
return guestViewInternal.createGuest(this.buildParams(), (event, guestInstanceId) => {
|
||||
this.attachWindow(guestInstanceId)
|
||||
this.attachGuestInstance(guestInstanceId)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -257,8 +258,9 @@ var WebViewImpl = (function () {
|
|||
return params
|
||||
}
|
||||
|
||||
WebViewImpl.prototype.attachWindow = function (guestInstanceId) {
|
||||
WebViewImpl.prototype.attachGuestInstance = function (guestInstanceId) {
|
||||
this.guestInstanceId = guestInstanceId
|
||||
this.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].setValueIgnoreMutation(guestInstanceId)
|
||||
this.webContents = remote.getGuestWebContents(this.guestInstanceId)
|
||||
if (!this.internalInstanceId) {
|
||||
return true
|
||||
|
@ -324,10 +326,11 @@ var registerWebViewElement = function () {
|
|||
}
|
||||
guestViewInternal.deregisterEvents(internal.viewInstanceId)
|
||||
internal.elementAttached = false
|
||||
return internal.reset()
|
||||
internal.reset()
|
||||
this.internalInstanceId = 0
|
||||
}
|
||||
proto.attachedCallback = function () {
|
||||
var internal
|
||||
var internal, instance
|
||||
internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (!internal) {
|
||||
return
|
||||
|
@ -335,6 +338,10 @@ var registerWebViewElement = function () {
|
|||
if (!internal.elementAttached) {
|
||||
guestViewInternal.registerEvents(internal, internal.viewInstanceId)
|
||||
internal.elementAttached = true
|
||||
instance = internal.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].getValue()
|
||||
if (instance) {
|
||||
return internal.attachGuestInstance(instance)
|
||||
}
|
||||
return internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue