Skip to content

Commit

Permalink
chore: remove deprecated inputFieldType (electron#41239)
Browse files Browse the repository at this point in the history
chore: remove deprecated inputFieldType
  • Loading branch information
miniak authored Feb 26, 2024
1 parent 3394ee7 commit 3885011
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 57 deletions.
3 changes: 0 additions & 3 deletions docs/api/web-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,6 @@ Returns:
`input-text`, `input-time`, `input-url`, `input-week`, `output`, `reset-button`,
`select-list`, `select-list`, `select-multiple`, `select-one`, `submit-button`,
and `text-area`,
* `inputFieldType` string _Deprecated_ - If the context menu was invoked on an
input field, the type of that field. Possible values include `none`,
`plainText`, `password`, `other`.
* `spellcheckEnabled` boolean - If the context is editable, whether or not spellchecking is enabled.
* `menuSourceType` string - Input source that invoked the context menu.
Can be `none`, `mouse`, `keyboard`, `touch`, `touchMenu`, `longPress`, `longTap`, `touchHandle`, `stylus`, `adjustSelection`, or `adjustSelectionReset`.
Expand Down
3 changes: 0 additions & 3 deletions docs/api/webview-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -1111,9 +1111,6 @@ Returns:
`input-text`, `input-time`, `input-url`, `input-week`, `output`, `reset-button`,
`select-list`, `select-list`, `select-multiple`, `select-one`, `submit-button`,
and `text-area`,
* `inputFieldType` string _Deprecated_ - If the context menu was invoked on an
input field, the type of that field. Possible values include `none`,
`plainText`, `password`, `other`.
* `spellcheckEnabled` boolean - If the context is editable, whether or not spellchecking is enabled.
* `menuSourceType` string - Input source that invoked the context menu.
Can be `none`, `mouse`, `keyboard`, `touch`, `touchMenu`, `longPress`, `longTap`, `touchHandle`, `stylus`, `adjustSelection`, or `adjustSelectionReset`.
Expand Down
6 changes: 6 additions & 0 deletions docs/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ The autoresizing behavior is now standardized across all platforms.
If your app uses `BrowserView.setAutoResize` to do anything more complex than making a BrowserView fill the entire window, it's likely you already had custom logic in place to handle this difference in behavior on macOS.
If so, that logic will no longer be needed in Electron 30 as autoresizing behavior is consistent.

### Removed: `params.inputFormType` property on `context-menu` on `WebContents`

The `inputFormType` property of the params object in the `context-menu`
event from `WebContents` has been removed. Use the new `formControlType`
property instead.

## Planned Breaking API Changes (29.0)

### Behavior Changed: `ipcRenderer` can no longer be sent over the `contextBridge`
Expand Down
51 changes: 0 additions & 51 deletions shell/common/gin_converters/content_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,6 @@
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"

namespace {

[[nodiscard]] constexpr std::string_view FormControlToInputFieldTypeString(
const std::optional<blink::mojom::FormControlType> form_control_type) {
if (!form_control_type)
return "none";

switch (*form_control_type) {
case blink::mojom::FormControlType::kInputPassword:
return "password";

case blink::mojom::FormControlType::kInputText:
return "plainText";

// other input types:
case blink::mojom::FormControlType::kInputButton:
case blink::mojom::FormControlType::kInputCheckbox:
case blink::mojom::FormControlType::kInputColor:
case blink::mojom::FormControlType::kInputDate:
case blink::mojom::FormControlType::kInputDatetimeLocal:
case blink::mojom::FormControlType::kInputEmail:
case blink::mojom::FormControlType::kInputFile:
case blink::mojom::FormControlType::kInputHidden:
case blink::mojom::FormControlType::kInputImage:
case blink::mojom::FormControlType::kInputMonth:
case blink::mojom::FormControlType::kInputNumber:
case blink::mojom::FormControlType::kInputRadio:
case blink::mojom::FormControlType::kInputRange:
case blink::mojom::FormControlType::kInputReset:
case blink::mojom::FormControlType::kInputSearch:
case blink::mojom::FormControlType::kInputSubmit:
case blink::mojom::FormControlType::kInputTelephone:
case blink::mojom::FormControlType::kInputTime:
case blink::mojom::FormControlType::kInputUrl:
case blink::mojom::FormControlType::kInputWeek:
return "other";

// not an input type
default:
return "none";
}
}

} // namespace

namespace gin {

static constexpr auto MenuSourceTypes =
Expand Down Expand Up @@ -162,12 +117,6 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithRenderFrameHost>::ToV8(
dict.Set("frameCharset", params.frame_charset);
dict.Set("referrerPolicy", params.referrer_policy);
dict.Set("formControlType", params.form_control_type);

// NB: inputFieldType is deprecated because the upstream
// field was removed; we are emulating it now until removal
dict.Set("inputFieldType",
FormControlToInputFieldTypeString(params.form_control_type));

dict.Set("menuSourceType", params.source_type);

return gin::ConvertToV8(isolate, dict);
Expand Down
5 changes: 5 additions & 0 deletions spec/ts-smoke/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,11 @@ win4.webContents.on('scroll-touch-end', () => {});
// @ts-expect-error Removed API
win4.webContents.on('crashed', () => {});

win4.webContents.on('context-menu', (event, params) => {
// @ts-expect-error Removed API
console.log(params.inputFieldType);
});

// TouchBar
// https://github.com/electron/electron/blob/main/docs/api/touch-bar.md

Expand Down

0 comments on commit 3885011

Please sign in to comment.