Remove unneeded returns

This commit is contained in:
Kevin Sawicki 2016-11-03 10:19:52 -07:00
parent 8e834e9047
commit 3053be345b
4 changed files with 39 additions and 44 deletions

View file

@ -48,7 +48,7 @@ const embedderElementsMap = {}
// Moves the last element of array to the first one.
const moveLastToFirst = function (list) {
return list.unshift(list.pop())
list.unshift(list.pop())
}
// Generate guestInstanceId.
@ -227,7 +227,7 @@ const destroyGuest = function (embedder, guestInstanceId) {
delete guestInstances[guestInstanceId]
const key = embedder.getId() + '-' + guestInstance.elementInstanceId
return delete embedderElementsMap[key]
delete embedderElementsMap[key]
}
// Once an embedder has had a guest attached we watch it for destruction to
@ -281,7 +281,7 @@ ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', function (event, guestIn
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', function (event, guestInstanceId, params) {
const guestInstance = guestInstances[guestInstanceId]
return guestInstance != null ? guestInstance.guest.setSize(params) : void 0
guestInstance != null ? guestInstance.guest.setSize(params) : void 0
})
// Returns WebContents from its guest id.

View file

@ -57,7 +57,7 @@ var dispatchEvent = function (webView, eventName, eventKey, ...args) {
}
webView.dispatchEvent(domEvent)
if (eventName === 'load-commit') {
return webView.onLoadCommit(domEvent)
webView.onLoadCommit(domEvent)
}
}
@ -83,7 +83,7 @@ module.exports = {
webView.dispatchEvent(domEvent)
})
return ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId, function (event, ...args) {
ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId, function (event, ...args) {
var domEvent, f, i, j, len, ref1
domEvent = new Event('size-changed')
ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight']
@ -98,21 +98,21 @@ module.exports = {
ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_DESTROY_GUEST-' + viewInstanceId)
ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + viewInstanceId)
ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + viewInstanceId)
return ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId)
ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId)
},
createGuest: function (params, callback) {
requestId++
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId)
return ipcRenderer.once('ELECTRON_RESPONSE_' + requestId, callback)
ipcRenderer.once('ELECTRON_RESPONSE_' + requestId, callback)
},
attachGuest: function (elementInstanceId, guestInstanceId, params) {
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_ATTACH_GUEST', elementInstanceId, guestInstanceId, params)
return webFrame.attachGuest(elementInstanceId)
webFrame.attachGuest(elementInstanceId)
},
destroyGuest: function (guestInstanceId) {
return ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId)
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId)
},
setSize: function (guestInstanceId, params) {
return ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params)
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params)
}
}

View file

@ -32,7 +32,7 @@ class WebViewAttribute {
// Sets the attribute's value.
setValue (value) {
return this.webViewImpl.webviewNode.setAttribute(this.name, value || '')
this.webViewImpl.webviewNode.setAttribute(this.name, value || '')
}
// Changes the attribute's value without triggering its mutation handler.
@ -67,9 +67,9 @@ class BooleanAttribute extends WebViewAttribute {
setValue (value) {
if (!value) {
return this.webViewImpl.webviewNode.removeAttribute(this.name)
this.webViewImpl.webviewNode.removeAttribute(this.name)
} else {
return this.webViewImpl.webviewNode.setAttribute(this.name, '')
this.webViewImpl.webviewNode.setAttribute(this.name, '')
}
}
}
@ -84,7 +84,7 @@ class AutosizeDimensionAttribute extends WebViewAttribute {
if (!this.webViewImpl.guestInstanceId) {
return
}
return guestViewInternal.setSize(this.webViewImpl.guestInstanceId, {
guestViewInternal.setSize(this.webViewImpl.guestInstanceId, {
enableAutoSize: this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue(),
min: {
width: parseInt(this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() || 0),
@ -125,7 +125,7 @@ class PartitionAttribute extends WebViewAttribute {
}
if (newValue === 'persist:') {
this.validPartitionId = false
return window.console.error(webViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE)
window.console.error(webViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE)
}
}
}
@ -141,18 +141,15 @@ class GuestInstanceAttribute extends WebViewAttribute {
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)
this.webViewImpl.webviewNode.removeAttribute(this.name)
} else if (!isNaN(value)) {
this.webViewImpl.webviewNode.setAttribute(this.name, value)
}
if (isNaN(value)) {
return
}
return this.webViewImpl.webviewNode.setAttribute(this.name, value)
}
handleMutation (oldValue, newValue) {
@ -192,7 +189,7 @@ class SrcAttribute extends WebViewAttribute {
// is possible for this change to get picked up asyncronously by src's
// mutation observer |observer|, and then get handled even though we do not
// want to handle this mutation.
return this.observer.takeRecords()
this.observer.takeRecords()
}
handleMutation (oldValue, newValue) {
@ -206,7 +203,7 @@ class SrcAttribute extends WebViewAttribute {
this.setValueIgnoreMutation(oldValue)
return
}
return this.parse()
this.parse()
}
// The purpose of this mutation observer is to catch assignment to the src
@ -232,7 +229,7 @@ class SrcAttribute extends WebViewAttribute {
attributeOldValue: true,
attributeFilter: [this.name]
}
return this.observer.observe(this.webViewImpl.webviewNode, params)
this.observer.observe(this.webViewImpl.webviewNode, params)
}
parse () {
@ -259,7 +256,7 @@ class SrcAttribute extends WebViewAttribute {
opts.userAgent = useragent
}
guestContents = remote.getGuestWebContents(this.webViewImpl.guestInstanceId)
return guestContents.loadURL(this.getValue(), opts)
guestContents.loadURL(this.getValue(), opts)
}
}

View file

@ -82,7 +82,7 @@ var WebViewImpl = (function () {
// Sets the <webview>.request property.
WebViewImpl.prototype.setRequestPropertyOnWebViewNode = function (request) {
return Object.defineProperty(this.webviewNode, 'request', {
Object.defineProperty(this.webviewNode, 'request', {
value: request,
enumerable: true
})
@ -119,7 +119,7 @@ var WebViewImpl = (function () {
}
// Let the changed attribute handle its own mutation
return this.attributes[attributeName].handleMutation(oldValue, newValue)
this.attributes[attributeName].handleMutation(oldValue, newValue)
}
WebViewImpl.prototype.handleBrowserPluginAttributeMutation = function (attributeName, oldValue, newValue) {
@ -129,10 +129,9 @@ var WebViewImpl = (function () {
// Track when the element resizes using the element resize callback.
webFrame.registerElementResizeCallback(this.internalInstanceId, this.onElementResize.bind(this))
if (!this.guestInstanceId) {
return
if (this.guestInstanceId) {
guestViewInternal.attachGuest(this.internalInstanceId, this.guestInstanceId, this.buildParams())
}
return guestViewInternal.attachGuest(this.internalInstanceId, this.guestInstanceId, this.buildParams())
}
}
@ -157,7 +156,7 @@ var WebViewImpl = (function () {
// Only fire the DOM event if the size of the <webview> has actually
// changed.
return this.dispatchEvent(webViewEvent)
this.dispatchEvent(webViewEvent)
}
}
@ -177,7 +176,7 @@ var WebViewImpl = (function () {
resizeEvent.newHeight = newSize.height
this.dispatchEvent(resizeEvent)
if (this.guestInstanceId) {
return guestViewInternal.setSize(this.guestInstanceId, {
guestViewInternal.setSize(this.guestInstanceId, {
normal: newSize
})
}
@ -190,7 +189,7 @@ var WebViewImpl = (function () {
}
WebViewImpl.prototype.dispatchEvent = function (webViewEvent) {
return this.webviewNode.dispatchEvent(webViewEvent)
this.webviewNode.dispatchEvent(webViewEvent)
}
// Adds an 'on<event>' property on the webview, which can be used to set/unset
@ -284,10 +283,9 @@ var registerBrowserPluginElement = function () {
proto.attributeChangedCallback = function (name, oldValue, newValue) {
var internal
internal = v8Util.getHiddenValue(this, 'internal')
if (!internal) {
return
if (internal) {
internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue)
}
return internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue)
}
proto.attachedCallback = function () {
// Load the plugin immediately.
@ -313,10 +311,9 @@ var registerWebViewElement = function () {
proto.attributeChangedCallback = function (name, oldValue, newValue) {
var internal
internal = v8Util.getHiddenValue(this, 'internal')
if (!internal) {
return
if (internal) {
internal.handleWebviewAttributeMutation(name, oldValue, newValue)
}
return internal.handleWebviewAttributeMutation(name, oldValue, newValue)
}
proto.detachedCallback = function () {
var internal
@ -340,9 +337,10 @@ var registerWebViewElement = function () {
internal.elementAttached = true
instance = internal.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].getValue()
if (instance) {
return internal.attachGuestInstance(instance)
internal.attachGuestInstance(instance)
} else {
internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
}
return internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
}
}
@ -424,7 +422,7 @@ var registerWebViewElement = function () {
createNonBlockHandler = function (m) {
return function (...args) {
const internal = v8Util.getHiddenValue(this, 'internal')
return ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args))
ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args))
}
}
for (j = 0, len1 = nonblockMethods.length; j < len1; j++) {
@ -460,7 +458,7 @@ var registerWebViewElement = function () {
delete proto.createdCallback
delete proto.attachedCallback
delete proto.detachedCallback
return delete proto.attributeChangedCallback
delete proto.attributeChangedCallback
}
var useCapture = true
@ -471,7 +469,7 @@ var listener = function (event) {
}
registerBrowserPluginElement()
registerWebViewElement()
return window.removeEventListener(event.type, listener, useCapture)
window.removeEventListener(event.type, listener, useCapture)
}
window.addEventListener('readystatechange', listener, true)