Skip to content
Permalink
Browse files

#4508 Adding simple test and actually getting the event to dispatch

  • Loading branch information...
mattnenterprise committed Mar 17, 2015
1 parent 5938a4c commit 0bd717e4705f2a4124a6d5200395a6c1da849183
@@ -629,7 +629,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
ctrl, alt, shift, meta,
None, props.key_code).root();
let event = EventCast::from_ref(keyevent.r());
let _ = target.DispatchEvent(event);
event.fire(target);
let mut prevented = event.DefaultPrevented();

// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys-cancelable-keys
@@ -642,7 +642,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
ctrl, alt, shift, meta,
props.char_code, 0).root();
let ev = EventCast::from_ref(event.r());
let _ = target.DispatchEvent(ev);
ev.fire(target);
prevented = ev.DefaultPrevented();
// TODO: if keypress event is canceled, prevent firing input events
}
@@ -13,7 +13,7 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, HTMLEle
use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementDerived, HTMLFieldSetElementDerived};
use dom::bindings::codegen::InheritTypes::{KeyboardEventCast, TextDerived};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, JSRef, LayoutJS, Temporary, OptionalRootable};
use dom::bindings::js::{JSRef, LayoutJS, Temporary, OptionalRootable};
use dom::bindings::refcounted::Trusted;
use dom::document::{Document, DocumentHelpers};
use dom::element::{Element, AttributeHandlers};
@@ -347,15 +347,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
KeyReaction::DispatchInput => {
self.value_changed.set(true);

if event.IsTrusted() == true {
if event.IsTrusted() {
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));
let _ = chan.send(ScriptMsg::RunnableMsg(box dispatcher));
}

self.force_relayout();
@@ -382,4 +382,4 @@ impl Runnable for ChangeEventRunnable {
let target = self.element.to_temporary().root();
target.r().dispatch_change_event();
}
}
}
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<textarea id="textarea">
</textarea>
</body>
<script>
var area = document.getElementById('textarea');
area.addEventListener('input', function() {
alert('input detected');
});
</script>
</html>

5 comments on commit 0bd717e

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Mar 18, 2015

saw approval from jdm
at mattnenterprise@0bd717e

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Mar 18, 2015

merging mattnenterprise/servo/dispatch_input_event = 0bd717e into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Mar 18, 2015

mattnenterprise/servo/dispatch_input_event = 0bd717e merged ok, testing candidate = 65d4b12

@bors-servo

This comment has been minimized.

Copy link
Contributor

replied Mar 18, 2015

fast-forwarding master to auto = 65d4b12

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