Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] optimize: input and textarea #695

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a5ea58b
fix: fix input[type="checkbox"] disabled attribute invalid
drugsloveyou Mar 26, 2024
22639ab
Merge branch 'main' into feature/fix-checkbox-disabled
drugsloveyou Mar 27, 2024
9b8be50
feat: support input[type=radio]
drugsloveyou Mar 26, 2024
dcc9a8e
fix: add super.initState() to FlutterInputElement
drugsloveyou Mar 26, 2024
a153857
fix: fix flex items didn't get adjusted by inner contents's size
drugsloveyou Apr 2, 2024
5644443
Committing clang-format changes
Sep 13, 2024
01edd37
feat(input): maxlength not work
ChrisCindy Dec 8, 2024
10523d0
feat(input): support keyup and keydown event
ChrisCindy Dec 8, 2024
5a3a83b
feat(input): support selection-start and selection-end
ChrisCindy Dec 8, 2024
a3053f7
feat(input): support enterkeyhint and inputmode
ChrisCindy Dec 8, 2024
421e173
feat(input): hide counter to align with web
ChrisCindy Dec 8, 2024
f18641e
fix(input): can't align vertically
ChrisCindy Dec 8, 2024
47cb43f
fix(input): set maxLength property
ChrisCindy Dec 8, 2024
eced3b1
fix(input): set disabled attribute is invalid
ChrisCindy Dec 8, 2024
258cbbc
feat(input): finish support selectionStart and selectionEnd
ChrisCindy Dec 8, 2024
0cce192
fix(input): remove selection when user input something
ChrisCindy Dec 8, 2024
09fd539
feat: support keyboard event.
andycall Dec 8, 2024
28d0d4f
Committing clang-format changes
Dec 8, 2024
399b6d3
test(input): add test cases
ChrisCindy Dec 9, 2024
3ed3830
feat(input): adjust checkbox style
ChrisCindy Dec 10, 2024
fe37058
Merge branch 'fix/input-and-textarea' into feature/fix-checkbox-disabled
ChrisCindy Dec 11, 2024
37febf2
fix: input[type="checkbox"] disabled attribute invalid (#582)
ChrisCindy Dec 11, 2024
0f19e8d
Merge branch 'fix/input-and-textarea' into feature/input-type-radio
ChrisCindy Dec 11, 2024
8ee6295
feat: support input[type=radio] (#581)
ChrisCindy Dec 11, 2024
8d12e48
test(input): add radio test cases
ChrisCindy Dec 12, 2024
584f184
feat(input): finish radio and checkbox element
ChrisCindy Dec 15, 2024
96a7dbe
chore(input): remove wrong comments
ChrisCindy Dec 15, 2024
0971887
Merge remote-tracking branch 'origin/main' into fix/input-and-textarea
Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bridge/core/binding_call_methods.json5
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"max",
"minLength",
"maxLength",
"selectionStart",
"selectionEnd",
"size",
"multiple",
"name",
Expand Down
18 changes: 9 additions & 9 deletions bridge/core/events/dart_created_events.json5
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@
"intersectionchange"
]
},
// {
// "class": "KeyboardEvent",
// "types": [
// "keydown",
// "keypress",
// "keystatuseschange",
// "keyup"
// ]
// },
{
"class": "KeyboardEvent",
"types": [
"keydown",
"keypress",
"keystatuseschange",
"keyup"
]
},
"message",
// {
// "class": "PointerEvent",
Expand Down
42 changes: 22 additions & 20 deletions bridge/core/events/keyboard_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@ KeyboardEvent::KeyboardEvent(ExecutingContext* context,
const std::shared_ptr<KeyboardEventInit>& initializer,
ExceptionState& exception_state)
: UIEvent(context, type, initializer, exception_state),
alt_key_(initializer->hasAltKey() && initializer->altKey()),
char_code_(initializer->hasCharCode() ? initializer->charCode() : 0.0),
// alt_key_(initializer->hasAltKey() && initializer->altKey()),
// char_code_(initializer->hasCharCode() ? initializer->charCode() : 0.0),
code_(initializer->hasCode() ? initializer->code() : AtomicString::Empty()),
ctrl_key_(initializer->hasCtrlKey() && initializer->ctrlKey()),
is_composing_(initializer->hasComposed() && initializer->isComposing()),
key_(initializer->hasKey() ? initializer->key() : AtomicString::Empty()),
key_code_(initializer->hasKeyCode() ? initializer->keyCode() : 0.0),
location_(initializer->hasLocation() ? initializer->location() : 0.0),
meta_key_(initializer->hasMetaKey() && initializer->metaKey()),
repeat_(initializer->hasRepeat() && initializer->repeat()),
shift_key_(initializer->hasShiftKey() && initializer->shiftKey()) {}
// ctrl_key_(initializer->hasCtrlKey() && initializer->ctrlKey()),
// is_composing_(initializer->hasComposed() && initializer->isComposing()),
key_(initializer->hasKey() ? initializer->key() : AtomicString::Empty())
// key_code_(initializer->hasKeyCode() ? initializer->keyCode() : 0.0),
// location_(initializer->hasLocation() ? initializer->location() : 0.0),
// meta_key_(initializer->hasMetaKey() && initializer->metaKey()),
// repeat_(initializer->hasRepeat() && initializer->repeat()),
// shift_key_(initializer->hasShiftKey() && initializer->shiftKey())
{}

KeyboardEvent::KeyboardEvent(ExecutingContext* context,
const AtomicString& type,
NativeKeyboardEvent* native_keyboard_event)
: UIEvent(context, type, &native_keyboard_event->native_event),
alt_key_(native_keyboard_event->altKey),
char_code_(native_keyboard_event->charCode),
// alt_key_(native_keyboard_event->altKey),
// char_code_(native_keyboard_event->charCode),
#if ANDROID_32_BIT
code_(AtomicString(
ctx(),
Expand All @@ -65,15 +66,16 @@ KeyboardEvent::KeyboardEvent(ExecutingContext* context,
std::unique_ptr<AutoFreeNativeString>(reinterpret_cast<AutoFreeNativeString*>(native_keyboard_event->code)))),
key_(AtomicString(
ctx(),
std::unique_ptr<AutoFreeNativeString>(reinterpret_cast<AutoFreeNativeString*>(native_keyboard_event->key)))),
std::unique_ptr<AutoFreeNativeString>(reinterpret_cast<AutoFreeNativeString*>(native_keyboard_event->key))))
#endif
ctrl_key_(native_keyboard_event->ctrlKey),
is_composing_(native_keyboard_event->isComposing),
key_code_(native_keyboard_event->keyCode),
location_(native_keyboard_event->location),
meta_key_(native_keyboard_event->metaKey),
repeat_(native_keyboard_event->repeat),
shift_key_(native_keyboard_event->shiftKey) {
// ctrl_key_(native_keyboard_event->ctrlKey),
// is_composing_(native_keyboard_event->isComposing),
// key_code_(native_keyboard_event->keyCode),
// location_(native_keyboard_event->location),
// meta_key_(native_keyboard_event->metaKey),
// repeat_(native_keyboard_event->repeat),
// shift_key_(native_keyboard_event->shiftKey)
{
}

bool KeyboardEvent::getModifierState(const AtomicString& key_args, ExceptionState& exception_state) {
Expand Down
35 changes: 18 additions & 17 deletions bridge/core/events/keyboard_event.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import {KeyboardEventInit} from "./keyboard_event_init";

/** KeyboardEvent objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard. */
interface KeyboardEvent extends UIEvent {
readonly altKey: boolean;
/** @deprecated */
readonly charCode: number;
readonly code: string;
readonly ctrlKey: boolean;
readonly isComposing: boolean;
// readonly altKey: boolean;
// /** @deprecated */
// readonly charCode: number;
readonly key: string;
/** @deprecated */
readonly keyCode: number;
readonly location: number;
readonly metaKey: boolean;
readonly repeat: boolean;
readonly shiftKey: boolean;
// getModifierState(keyArg: string): boolean;
readonly DOM_KEY_LOCATION_LEFT: StaticMember<number>;
readonly DOM_KEY_LOCATION_NUMPAD: StaticMember<number>;
readonly DOM_KEY_LOCATION_RIGHT: StaticMember<number>;
readonly DOM_KEY_LOCATION_STANDARD: StaticMember<number>;
readonly code: string;
// readonly ctrlKey: boolean;
// readonly isComposing: boolean;

// /** @deprecated */
// readonly keyCode: number;
// readonly location: number;
// readonly metaKey: boolean;
// readonly repeat: boolean;
// readonly shiftKey: boolean;
// // getModifierState(keyArg: string): boolean;
// readonly DOM_KEY_LOCATION_LEFT: StaticMember<number>;
// readonly DOM_KEY_LOCATION_NUMPAD: StaticMember<number>;
// readonly DOM_KEY_LOCATION_RIGHT: StaticMember<number>;
// readonly DOM_KEY_LOCATION_STANDARD: StaticMember<number>;
[key: string]: any;

new(type: string, init?: KeyboardEventInit): KeyboardEvent;
Expand Down
24 changes: 12 additions & 12 deletions bridge/core/events/keyboard_event_init.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import {UIEventInit} from "./ui_event_init";
// @ts-ignore
@Dictionary()
export interface KeyboardEventInit extends UIEventInit {
altKey?: boolean;
/** @deprecated */
charCode?: number;
code?: string;
ctrlKey?: boolean;
isComposing?: boolean;
// altKey?: boolean;
// /** @deprecated */
// charCode?: number;
key?: string;
/** @deprecated */
keyCode?: number;
location?: number;
metaKey?: boolean;
repeat?: boolean;
shiftKey?: boolean;
code?: string;
// ctrlKey?: boolean;
// isComposing?: boolean;
// /** @deprecated */
// keyCode?: number;
// location?: number;
// metaKey?: boolean;
// repeat?: boolean;
// shiftKey?: boolean;
}
2 changes: 2 additions & 0 deletions bridge/core/html/forms/html_input_element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ interface HTMLInputElement extends HTMLElement {
max: DartImpl<string>;
minLength: DartImpl<double>;
maxLength: DartImpl<double>;
selectionStart: DartImpl<double>;
selectionEnd: DartImpl<double>;
size: DartImpl<double>;
multiple: DartImpl<boolean>;
name: DartImpl<string>;
Expand Down
2 changes: 2 additions & 0 deletions bridge/core/html/forms/html_textarea_element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface HTMLTextareaElement extends HTMLElement {
disabled: DartImpl<boolean>;
minLength: DartImpl<double>;
maxLength: DartImpl<double>;
selectionStart: DartImpl<double>;
selectionEnd: DartImpl<double>;
name: DartImpl<string>;
placeholder: DartImpl<string>;
readonly: DartImpl<boolean>;
Expand Down
11 changes: 1 addition & 10 deletions bridge/include/plugin_api/keyboard_event_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,8 @@ struct WebFKeyboardEventInit {
double detail;
WebFValue<Window, WindowPublicMethods> view;
double which;
int32_t alt_key;
double char_code;
const char* code;
int32_t ctrl_key;
int32_t is_composing;
const char* key;
double key_code;
double location;
int32_t meta_key;
int32_t repeat;
int32_t shift_key;
const char* code;
};
} // namespace webf
#endif // WEBF_CORE_WEBF_API_PLUGIN_API_KEYBOARD_EVENT_INIT_H_
11 changes: 1 addition & 10 deletions bridge/rusty_webf_sys/src/events/keyboard_event_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ pub struct KeyboardEventInit {
pub detail: c_double,
pub view: RustValue<WindowRustMethods>,
pub which: c_double,
pub alt_key: i32,
pub char_code: c_double,
pub code: *const c_char,
pub ctrl_key: i32,
pub is_composing: i32,
pub key: *const c_char,
pub key_code: c_double,
pub location: c_double,
pub meta_key: i32,
pub repeat: i32,
pub shift_key: i32,
pub code: *const c_char,
}
Loading
Loading