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
|
@ -130,6 +130,46 @@ class PartitionAttribute extends WebViewAttribute {
|
|||
}
|
||||
}
|
||||
|
||||
// An attribute that controls the guest instance this webview is connected to
|
||||
class GuestInstanceAttribute extends WebViewAttribute {
|
||||
constructor (webViewImpl) {
|
||||
super(webViewConstants.ATTRIBUTE_GUESTINSTANCE, webViewImpl)
|
||||
}
|
||||
|
||||
// Retrieves and returns the attribute's value.
|
||||
getValue () {
|
||||
if (this.webViewImpl.webviewNode.hasAttribute(this.name)) {
|
||||
return parseInt(this.webViewImpl.webviewNode.getAttribute(this.name))
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
// Sets the attribute's value.
|
||||
setValue (value) {
|
||||
if (!value) {
|
||||
return this.webViewImpl.webviewNode.removeAttribute(this.name)
|
||||
}
|
||||
if (isNaN(value)) {
|
||||
return
|
||||
}
|
||||
return this.webViewImpl.webviewNode.setAttribute(this.name, value)
|
||||
}
|
||||
|
||||
handleMutation (oldValue, newValue) {
|
||||
if (!newValue) {
|
||||
this.webViewImpl.reset()
|
||||
return
|
||||
}
|
||||
|
||||
const intVal = parseInt(newValue)
|
||||
if (!isNaN(newValue) && remote.getGuestWebContents(intVal)) {
|
||||
this.webViewImpl.attachGuestInstance(intVal)
|
||||
} else {
|
||||
this.setValueIgnoreMutation(oldValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attribute that handles the location and navigation of the webview.
|
||||
class SrcAttribute extends WebViewAttribute {
|
||||
constructor (webViewImpl) {
|
||||
|
@ -287,6 +327,7 @@ WebViewImpl.prototype.setupWebViewAttributes = function () {
|
|||
this.attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this)
|
||||
this.attributes[webViewConstants.ATTRIBUTE_BLINKFEATURES] = new BlinkFeaturesAttribute(this)
|
||||
this.attributes[webViewConstants.ATTRIBUTE_DISABLEBLINKFEATURES] = new DisableBlinkFeaturesAttribute(this)
|
||||
this.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE] = new GuestInstanceAttribute(this)
|
||||
|
||||
const autosizeAttributes = [webViewConstants.ATTRIBUTE_MAXHEIGHT, webViewConstants.ATTRIBUTE_MAXWIDTH, webViewConstants.ATTRIBUTE_MINHEIGHT, webViewConstants.ATTRIBUTE_MINWIDTH]
|
||||
autosizeAttributes.forEach((attribute) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue