Skip to content
Permalink
Browse files

#4508 Ranaming the runnable and making sure the event is trusted

  • Loading branch information...
mattnenterprise committed Mar 17, 2015
1 parent a481c8f commit 5938a4c0f54cfaca37fa4bec867c7eedc4e84975
Showing with 15 additions and 13 deletions.
  1. +15 −13 components/script/dom/htmltextareaelement.rs
@@ -341,20 +341,22 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
doc.r().request_focus(ElementCast::from_ref(*self));
} else if "keydown" == event.Type().as_slice() && !event.DefaultPrevented() {
let keyevent: Option<JSRef<KeyboardEvent>> = KeyboardEventCast::to_ref(event);
keyevent.map(|event| {
match self.textinput.borrow_mut().handle_keydown(event) {
keyevent.map(|kevent| {
match self.textinput.borrow_mut().handle_keydown(kevent) {
KeyReaction::TriggerDefaultAction => (),
KeyReaction::DispatchInput => {
self.value_changed.set(true);

let window = window_from_node(*self).root();
let window = window.r();
let chan = window.script_chan();
let handler = Trusted::new(window.get_cx(), *self , chan.clone());
let dispatcher = TrustedHTMLTextAreaElement {
element: handler,
};
chan.send(ScriptMsg::RunnableMsg(box dispatcher));
if event.IsTrusted() == true {
let window = window_from_node(*self).root();
let window = window.r();
let chan = window.script_chan();
let handler = Trusted::new(window.get_cx(), *self , chan.clone());
let dispatcher = ChangeEventRunnable {
element: handler,
};
chan.send(ScriptMsg::RunnableMsg(box dispatcher));
}

self.force_relayout();
}
@@ -371,12 +373,12 @@ impl<'a> FormControl<'a> for JSRef<'a, HTMLTextAreaElement> {
}
}

pub struct TrustedHTMLTextAreaElement {
pub struct ChangeEventRunnable {
element: Trusted<HTMLTextAreaElement>,
}

impl Runnable for TrustedHTMLTextAreaElement {
fn handler(self: Box<TrustedHTMLTextAreaElement>) {
impl Runnable for ChangeEventRunnable {
fn handler(self: Box<ChangeEventRunnable>) {
let target = self.element.to_temporary().root();
target.r().dispatch_change_event();
}

0 comments on commit 5938a4c

Please sign in to comment.
You can’t perform that action at this time.