mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Solve #22346
keypress event should be triggered for keys representing character values. So, we should trigger this event for enter key. This event should not trigger for IME inputs.
This commit is contained in:
parent
65bcf633ea
commit
b30fc2d19e
1 changed files with 9 additions and 1 deletions
|
@ -1435,7 +1435,8 @@ impl Document {
|
|||
|
||||
// https://w3c.github.io/uievents/#keys-cancelable-keys
|
||||
if keyboard_event.state == KeyState::Down &&
|
||||
keyboard_event.key.legacy_charcode() != 0 &&
|
||||
is_character_value_key(&(keyboard_event.key)) &&
|
||||
!keyboard_event.is_composing &&
|
||||
cancel_state != EventDefault::Prevented
|
||||
{
|
||||
// https://w3c.github.io/uievents/#keypress-event-order
|
||||
|
@ -2505,6 +2506,13 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_character_value_key(key: &Key) -> bool {
|
||||
match key {
|
||||
Key::Character(_) | Key::Enter => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(MallocSizeOf, PartialEq)]
|
||||
pub enum DocumentSource {
|
||||
FromParser,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue