mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fire 'input' event after 'keypress' in input and textarea elements
This commit is contained in:
parent
08662cc64e
commit
5f0b3bd53c
4 changed files with 24 additions and 24 deletions
|
@ -52,6 +52,7 @@ beforeunload
|
|||
message
|
||||
click
|
||||
keydown
|
||||
keypress
|
||||
abort
|
||||
beforescriptexecute
|
||||
afterscriptexecute
|
||||
|
|
|
@ -1334,7 +1334,6 @@ impl Document {
|
|||
let ev = event.upcast::<Event>();
|
||||
ev.fire(target);
|
||||
cancel_state = ev.get_cancel_state();
|
||||
// TODO: if keypress event is canceled, prevent firing input events
|
||||
}
|
||||
|
||||
if cancel_state == EventDefault::Allowed {
|
||||
|
|
|
@ -1105,17 +1105,6 @@ impl VirtualMethods for HTMLInputElement {
|
|||
DispatchInput => {
|
||||
self.value_changed.set(true);
|
||||
self.update_placeholder_shown_state();
|
||||
|
||||
if event.IsTrusted() {
|
||||
let window = window_from_node(self);
|
||||
let _ = window.user_interaction_task_source().queue_event(
|
||||
&self.upcast(),
|
||||
atom!("input"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
&window);
|
||||
}
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
event.mark_as_handled();
|
||||
}
|
||||
|
@ -1126,6 +1115,18 @@ impl VirtualMethods for HTMLInputElement {
|
|||
Nothing => (),
|
||||
}
|
||||
}
|
||||
} else if event.type_() == atom!("keypress") && !event.DefaultPrevented() &&
|
||||
(self.input_type.get() == InputType::InputText ||
|
||||
self.input_type.get() == InputType::InputPassword) {
|
||||
if event.IsTrusted() {
|
||||
let window = window_from_node(self);
|
||||
let _ = window.user_interaction_task_source()
|
||||
.queue_event(&self.upcast(),
|
||||
atom!("input"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
&window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,17 +403,6 @@ impl VirtualMethods for HTMLTextAreaElement {
|
|||
KeyReaction::DispatchInput => {
|
||||
self.value_changed.set(true);
|
||||
self.update_placeholder_shown_state();
|
||||
|
||||
if event.IsTrusted() {
|
||||
let window = window_from_node(self);
|
||||
let _ = window.user_interaction_task_source().queue_event(
|
||||
&self.upcast(),
|
||||
atom!("input"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
&window);
|
||||
}
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
event.mark_as_handled();
|
||||
}
|
||||
|
@ -424,6 +413,16 @@ impl VirtualMethods for HTMLTextAreaElement {
|
|||
KeyReaction::Nothing => (),
|
||||
}
|
||||
}
|
||||
} else if event.type_() == atom!("keypress") && !event.DefaultPrevented() {
|
||||
if event.IsTrusted() {
|
||||
let window = window_from_node(self);
|
||||
let _ = window.user_interaction_task_source()
|
||||
.queue_event(&self.upcast(),
|
||||
atom!("input"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
&window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue