mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
De-duplicate input event send code
This commit is contained in:
parent
12a0884f51
commit
0e663e0f2f
2 changed files with 17 additions and 21 deletions
|
@ -695,14 +695,7 @@ impl VirtualMethods for HTMLInputElement {
|
|||
self.value_changed.set(true);
|
||||
|
||||
if event.IsTrusted() {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let chan = window.user_interaction_task_source();
|
||||
let handler = Trusted::new(self.upcast::<Node>(), chan.clone());
|
||||
let dispatcher = ChangeEventRunnable {
|
||||
element: handler,
|
||||
};
|
||||
let _ = chan.send(CommonScriptMsg::RunnableMsg(InputEvent, box dispatcher));
|
||||
ChangeEventRunnable::send(self.upcast::<Node>());
|
||||
}
|
||||
|
||||
self.force_relayout();
|
||||
|
@ -937,7 +930,20 @@ impl Activatable for HTMLInputElement {
|
|||
}
|
||||
|
||||
pub struct ChangeEventRunnable {
|
||||
pub element: Trusted<Node>,
|
||||
element: Trusted<Node>,
|
||||
}
|
||||
|
||||
impl ChangeEventRunnable {
|
||||
pub fn send(node: &Node) {
|
||||
let window = window_from_node(node);
|
||||
let window = window.r();
|
||||
let chan = window.user_interaction_task_source();
|
||||
let handler = Trusted::new(node, chan.clone());
|
||||
let dispatcher = ChangeEventRunnable {
|
||||
element: handler,
|
||||
};
|
||||
let _ = chan.send(CommonScriptMsg::RunnableMsg(InputEvent, box dispatcher));
|
||||
}
|
||||
}
|
||||
|
||||
impl Runnable for ChangeEventRunnable {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue