feat: make zoomLevel/zoomFactor sync (#16410)
* feat: make zoomLevel/zoomFactor sync * update ts defs dep
This commit is contained in:
parent
dacf7f8bdc
commit
3ca87d205f
14 changed files with 112 additions and 124 deletions
|
@ -111,6 +111,7 @@ WebContents.prototype.send = function (channel, ...args) {
|
|||
|
||||
return this._send(internal, sendToAll, channel, args)
|
||||
}
|
||||
|
||||
WebContents.prototype.sendToAll = function (channel, ...args) {
|
||||
if (typeof channel !== 'string') {
|
||||
throw new Error('Missing required channel argument')
|
||||
|
@ -209,6 +210,30 @@ WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callba
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(codebytere): remove when promisifications is complete
|
||||
const nativeZoomLevel = WebContents.prototype.getZoomLevel
|
||||
WebContents.prototype.getZoomLevel = function (callback) {
|
||||
if (callback == null) {
|
||||
return nativeZoomLevel.call(this)
|
||||
} else {
|
||||
process.nextTick(() => {
|
||||
callback(nativeZoomLevel.call(this))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(codebytere): remove when promisifications is complete
|
||||
const nativeZoomFactor = WebContents.prototype.getZoomFactor
|
||||
WebContents.prototype.getZoomFactor = function (callback) {
|
||||
if (callback == null) {
|
||||
return nativeZoomFactor.call(this)
|
||||
} else {
|
||||
process.nextTick(() => {
|
||||
callback(nativeZoomFactor.call(this))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
WebContents.prototype.takeHeapSnapshot = function (filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const channel = `ELECTRON_TAKE_HEAP_SNAPSHOT_RESULT_${getNextId()}`
|
||||
|
@ -289,16 +314,6 @@ WebContents.prototype.getPrinters = function () {
|
|||
}
|
||||
}
|
||||
|
||||
WebContents.prototype.getZoomLevel = function (callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('Must pass function as an argument')
|
||||
}
|
||||
process.nextTick(() => {
|
||||
const zoomLevel = this._getZoomLevel()
|
||||
callback(zoomLevel)
|
||||
})
|
||||
}
|
||||
|
||||
WebContents.prototype.loadFile = function (filePath, options = {}) {
|
||||
if (typeof filePath !== 'string') {
|
||||
throw new Error('Must pass filePath as a string')
|
||||
|
@ -315,16 +330,6 @@ WebContents.prototype.loadFile = function (filePath, options = {}) {
|
|||
}))
|
||||
}
|
||||
|
||||
WebContents.prototype.getZoomFactor = function (callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('Must pass function as an argument')
|
||||
}
|
||||
process.nextTick(() => {
|
||||
const zoomFactor = this._getZoomFactor()
|
||||
callback(zoomFactor)
|
||||
})
|
||||
}
|
||||
|
||||
// Add JavaScript wrappers for WebContents class.
|
||||
WebContents.prototype._init = function () {
|
||||
// The navigation controller.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue