From c9eb3deab58f2562113866eaf89d094e60f8184a Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 20 Sep 2023 23:41:29 +0200 Subject: [PATCH] chore: remove deprecated `scroll-touch-{begin,end,edge}` events (#39814) * chore: remove deprecated `scroll-touch-{begin,end,edge}` events * update spec/ts-smoke --------- Co-authored-by: John Kleinschmidt --- docs/api/browser-window.md | 30 ------------------------------ lib/browser/api/browser-window.ts | 23 ----------------------- spec/ts-smoke/electron/main.ts | 7 +++++++ 3 files changed, 7 insertions(+), 53 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index dfd2ca677950..f3d621c9955d 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -367,36 +367,6 @@ The following app commands are explicitly supported on Linux: * `browser-backward` * `browser-forward` -#### Event: 'scroll-touch-begin' _macOS_ _Deprecated_ - -Emitted when scroll wheel event phase has begun. - -> **Note** -> This event is deprecated beginning in Electron 22.0.0. See [Breaking -> Changes](../breaking-changes.md#deprecated-browserwindow-scroll-touch--events) -> for details of how to migrate to using the [WebContents -> `input-event`](./web-contents.md#event-input-event) event. - -#### Event: 'scroll-touch-end' _macOS_ _Deprecated_ - -Emitted when scroll wheel event phase has ended. - -> **Note** -> This event is deprecated beginning in Electron 22.0.0. See [Breaking -> Changes](../breaking-changes.md#deprecated-browserwindow-scroll-touch--events) -> for details of how to migrate to using the [WebContents -> `input-event`](./web-contents.md#event-input-event) event. - -#### Event: 'scroll-touch-edge' _macOS_ _Deprecated_ - -Emitted when scroll wheel event phase filed upon reaching the edge of element. - -> **Note** -> This event is deprecated beginning in Electron 22.0.0. See [Breaking -> Changes](../breaking-changes.md#deprecated-browserwindow-scroll-touch--events) -> for details of how to migrate to using the [WebContents -> `input-event`](./web-contents.md#event-input-event) event. - #### Event: 'swipe' _macOS_ Returns: diff --git a/lib/browser/api/browser-window.ts b/lib/browser/api/browser-window.ts index a53129d726c1..2b052218c385 100644 --- a/lib/browser/api/browser-window.ts +++ b/lib/browser/api/browser-window.ts @@ -1,6 +1,5 @@ import { BaseWindow, WebContents, BrowserView, TouchBar } from 'electron/main'; import type { BrowserWindow as BWT } from 'electron/main'; -import * as deprecate from '@electron/internal/common/deprecate'; const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT }; Object.setPrototypeOf(BrowserWindow.prototype, BaseWindow.prototype); @@ -53,28 +52,6 @@ BrowserWindow.prototype._init = function (this: BWT) { this.on(event as any, visibilityChanged); } - const warn = deprecate.warnOnceMessage('\'scroll-touch-{begin,end,edge}\' are deprecated and will be removed. Please use the WebContents \'input-event\' event instead.'); - this.webContents.on('input-event', (_, e) => { - if (e.type === 'gestureScrollBegin') { - if (this.listenerCount('scroll-touch-begin') !== 0) { - warn(); - this.emit('scroll-touch-edge'); - this.emit('scroll-touch-begin'); - } - } else if (e.type === 'gestureScrollUpdate') { - if (this.listenerCount('scroll-touch-edge') !== 0) { - warn(); - this.emit('scroll-touch-edge'); - } - } else if (e.type === 'gestureScrollEnd') { - if (this.listenerCount('scroll-touch-end') !== 0) { - warn(); - this.emit('scroll-touch-edge'); - this.emit('scroll-touch-end'); - } - } - }); - // Notify the creation of the window. app.emit('browser-window-created', { preventDefault () {} }, this); diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index 16c37e96c4fd..11bc068af080 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -1284,6 +1284,13 @@ win4.loadURL('http://github.com'); // @ts-expect-error Removed API win4.webContents.getPrinters(); +// @ts-expect-error Removed API +win4.webContents.on('scroll-touch-begin', () => {}); +// @ts-expect-error Removed API +win4.webContents.on('scroll-touch-edge', () => {}); +// @ts-expect-error Removed API +win4.webContents.on('scroll-touch-end', () => {}); + // TouchBar // https://github.com/electron/electron/blob/main/docs/api/touch-bar.md