Dispatch keydown, keyup, and keypress events at appropriate times.

This commit is contained in:
Josh Matthews 2014-10-04 09:46:50 -04:00
parent e999843183
commit 329ba56fca
8 changed files with 124 additions and 19 deletions

View file

@ -14,6 +14,7 @@ use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::event::{Event, KeyboardEventTypeId};
use dom::uievent::UIEvent;
use dom::window::Window;
use servo_msg::constellation_msg;
use servo_util::str::DOMString;
use std::cell::{RefCell, Cell};
@ -109,6 +110,32 @@ impl KeyboardEvent {
None, 0);
Ok(event)
}
pub fn key_properties(key: constellation_msg::Key) -> KeyEventProperties {
match key {
_ => KeyEventProperties {
key: "".to_string(),
code: "".to_string(),
location: 0,
char_code: None,
key_code: 0,
}
}
}
}
pub struct KeyEventProperties {
pub key: DOMString,
pub code: DOMString,
pub location: u32,
pub char_code: Option<u32>,
pub key_code: u32,
}
impl KeyEventProperties {
pub fn is_printable(&self) -> bool {
self.char_code.is_some()
}
}
impl<'a> KeyboardEventMethods for JSRef<'a, KeyboardEvent> {