Fix interfaces test

This commit is contained in:
Keegan McAllister 2014-11-03 17:21:18 -08:00 committed by Josh Matthews
parent 89a27dd11a
commit 642a3592c7
7 changed files with 169 additions and 138 deletions

View file

@ -1,5 +1,14 @@
--- WebIDL.py --- WebIDL.py
+++ WebIDL.py +++ WebIDL.py
@@ -1422,6 +1422,9 @@ class IDLDictionary(IDLObjectWithScope):
self.identifier.name,
[member.location] + locations)
+ def module(self):
+ return self.location.filename().split('/')[-1].split('.webidl')[0] + 'Binding'
+
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
@@ -3398,6 +3398,9 @@ class IDLCallbackType(IDLType, IDLObjectWithScope): @@ -3398,6 +3398,9 @@ class IDLCallbackType(IDLType, IDLObjectWithScope):
self._treatNonCallableAsNull = False self._treatNonCallableAsNull = False
self._treatNonObjectAsNull = False self._treatNonObjectAsNull = False

View file

@ -438,7 +438,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
let doc = document_from_node(*self).root(); let doc = document_from_node(*self).root();
doc.request_focus(ElementCast::from_ref(*self)); doc.request_focus(ElementCast::from_ref(*self));
} else if "keydown" == event.Type().as_slice() && !event.DefaultPrevented() && } else if "keydown" == event.Type().as_slice() && !event.DefaultPrevented() &&
(self.input_type.get() == InputText|| self.input_type.get() == InputPassword) { (self.input_type.get() == InputText || self.input_type.get() == InputPassword) {
let keyevent: Option<JSRef<KeyboardEvent>> = KeyboardEventCast::to_ref(event); let keyevent: Option<JSRef<KeyboardEvent>> = KeyboardEventCast::to_ref(event);
keyevent.map(|event| { keyevent.map(|event| {
match self.textinput.borrow_mut().handle_keydown(event) { match self.textinput.borrow_mut().handle_keydown(event) {

View file

@ -117,8 +117,8 @@ impl KeyboardEvent {
key: key_value(key, mods), key: key_value(key, mods),
code: code_value(key), code: code_value(key),
location: key_location(key), location: key_location(key),
char_code: key_char_code(key, mods), char_code: key_charcode(key, mods),
key_code: key_key_code(key), key_code: key_keycode(key),
} }
} }
} }
@ -215,7 +215,7 @@ fn key_value(key: constellation_msg::Key, mods: constellation_msg::KeyModifiers)
constellation_msg::KeyZ if shift => "Z", constellation_msg::KeyZ if shift => "Z",
constellation_msg::KeyZ => "z", constellation_msg::KeyZ => "z",
constellation_msg::KeyLeftBracket if shift => "{", constellation_msg::KeyLeftBracket if shift => "{",
constellation_msg::KeyLeftBracket => "{", constellation_msg::KeyLeftBracket => "[",
constellation_msg::KeyBackslash if shift => "|", constellation_msg::KeyBackslash if shift => "|",
constellation_msg::KeyBackslash => "\\", constellation_msg::KeyBackslash => "\\",
constellation_msg::KeyRightBracket if shift => "}", constellation_msg::KeyRightBracket if shift => "}",
@ -444,7 +444,7 @@ fn key_location(key: constellation_msg::Key) -> u32 {
} }
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-charCode // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-charCode
fn key_char_code(key: constellation_msg::Key, mods: constellation_msg::KeyModifiers) -> Option<u32> { fn key_charcode(key: constellation_msg::Key, mods: constellation_msg::KeyModifiers) -> Option<u32> {
let key = key_value(key, mods); let key = key_value(key, mods);
if key.len() == 1 { if key.len() == 1 {
Some(key.char_at(0) as u32) Some(key.char_at(0) as u32)
@ -454,7 +454,7 @@ fn key_char_code(key: constellation_msg::Key, mods: constellation_msg::KeyModifi
} }
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models
fn key_key_code(key: constellation_msg::Key) -> u32 { fn key_keycode(key: constellation_msg::Key) -> u32 {
match key { match key {
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models
constellation_msg::KeyBackspace => 8, constellation_msg::KeyBackspace => 8,
@ -601,13 +601,15 @@ impl<'a> KeyboardEventMethods for JSRef<'a, KeyboardEvent> {
self.is_composing.get() self.is_composing.get()
} }
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#widl-KeyboardEvent-getModifierState
fn GetModifierState(self, keyArg: DOMString) -> bool { fn GetModifierState(self, keyArg: DOMString) -> bool {
match keyArg.as_slice() { match keyArg.as_slice() {
"Ctrl" => self.CtrlKey(), "Ctrl" => self.CtrlKey(),
"Alt" => self.AltKey(), "Alt" => self.AltKey(),
"Shift" => self.ShiftKey(), "Shift" => self.ShiftKey(),
"Meta" => self.MetaKey(), "Meta" => self.MetaKey(),
"AltGraph" | "CapsLock" | "NumLock" | "ScrollLock" => false, //FIXME "AltGraph" | "CapsLock" | "NumLock" | "ScrollLock" | "Accel" |
"Fn" | "FnLock" | "Hyper" | "OS" | "Symbol" | "SymbolLock" => false, //FIXME
_ => false, _ => false,
} }
} }

View file

@ -9,6 +9,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyStateValues}; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyStateValues};
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, EventCast, ElementCast}; use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, EventCast, ElementCast};
@ -950,19 +951,25 @@ impl ScriptTask {
let props = KeyboardEvent::key_properties(key, modifiers); let props = KeyboardEvent::key_properties(key, modifiers);
let event = KeyboardEvent::new(*window, ev_type, true, true, Some(*window), 0, let keyevent = KeyboardEvent::new(*window, ev_type, true, true, Some(*window), 0,
props.key.to_string(), props.code.to_string(), props.location, props.key.to_string(), props.code.to_string(),
is_repeating, is_composing, ctrl, alt, shift, meta, props.location, is_repeating, is_composing,
None, props.key_code).root(); ctrl, alt, shift, meta,
let _ = target.DispatchEvent(EventCast::from_ref(*event)); None, props.key_code).root();
let event = EventCast::from_ref(*keyevent);
let _ = target.DispatchEvent(event);
if state != Released && props.is_printable() { // https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keys-cancelable-keys
if state != Released && props.is_printable() && !event.DefaultPrevented() {
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#keypress-event-order
let event = KeyboardEvent::new(*window, "keypress".to_string(), true, true, Some(*window), let event = KeyboardEvent::new(*window, "keypress".to_string(), true, true, Some(*window),
0, props.key.to_string(), props.code.to_string(), 0, props.key.to_string(), props.code.to_string(),
props.location, is_repeating, is_composing, props.location, is_repeating, is_composing,
ctrl, alt, shift, meta, ctrl, alt, shift, meta,
props.char_code, 0).root(); props.char_code, 0).root();
let _ = target.DispatchEvent(EventCast::from_ref(*event)); let _ = target.DispatchEvent(EventCast::from_ref(*event));
// TODO: if keypress event is canceled, prevent firing input events
} }
window.flush_layout(); window.flush_layout();

View file

@ -106,9 +106,11 @@ impl TextInput {
let prefix_end = if forward { let prefix_end = if forward {
self.edit_point.index self.edit_point.index
} else { } else {
//TODO: handle backspacing from position 0 of current line
if self.multiline { if self.multiline {
assert!(self.edit_point.index > 0); //TODO: handle backspacing from position 0 of current line
if self.edit_point.index == 0 {
return;
}
} else if self.edit_point.index == 0 { } else if self.edit_point.index == 0 {
return; return;
} }
@ -118,7 +120,9 @@ impl TextInput {
let is_eol = self.edit_point.index == self.current_line_length() - 1; let is_eol = self.edit_point.index == self.current_line_length() - 1;
if self.multiline { if self.multiline {
//TODO: handle deleting from end position of current line //TODO: handle deleting from end position of current line
assert!(!is_eol); if is_eol {
return;
}
} else if is_eol { } else if is_eol {
return; return;
} }

View file

@ -454,127 +454,135 @@ fn glfw_mods_to_script_mods(mods: glfw::Modifiers) -> constellation_msg::KeyModi
result result
} }
macro_rules! glfw_keys_to_script_keys(
($key:expr, $($name:ident),+) => (
match $key {
$(glfw::$name => constellation_msg::$name,)+
}
);
)
fn glfw_key_to_script_key(key: glfw::Key) -> constellation_msg::Key { fn glfw_key_to_script_key(key: glfw::Key) -> constellation_msg::Key {
match key { glfw_keys_to_script_keys!(key,
glfw::KeySpace => constellation_msg::KeySpace, KeySpace,
glfw::KeyApostrophe => constellation_msg::KeyApostrophe, KeyApostrophe,
glfw::KeyComma => constellation_msg::KeyComma, KeyComma,
glfw::KeyMinus => constellation_msg::KeyMinus, KeyMinus,
glfw::KeyPeriod => constellation_msg::KeyPeriod, KeyPeriod,
glfw::KeySlash => constellation_msg::KeySlash, KeySlash,
glfw::Key0 => constellation_msg::Key0, Key0,
glfw::Key1 => constellation_msg::Key1, Key1,
glfw::Key2 => constellation_msg::Key2, Key2,
glfw::Key3 => constellation_msg::Key3, Key3,
glfw::Key4 => constellation_msg::Key4, Key4,
glfw::Key5 => constellation_msg::Key5, Key5,
glfw::Key6 => constellation_msg::Key6, Key6,
glfw::Key7 => constellation_msg::Key7, Key7,
glfw::Key8 => constellation_msg::Key8, Key8,
glfw::Key9 => constellation_msg::Key9, Key9,
glfw::KeySemicolon => constellation_msg::KeySemicolon, KeySemicolon,
glfw::KeyEqual => constellation_msg::KeyEqual, KeyEqual,
glfw::KeyA => constellation_msg::KeyA, KeyA,
glfw::KeyB => constellation_msg::KeyB, KeyB,
glfw::KeyC => constellation_msg::KeyC, KeyC,
glfw::KeyD => constellation_msg::KeyD, KeyD,
glfw::KeyE => constellation_msg::KeyE, KeyE,
glfw::KeyF => constellation_msg::KeyF, KeyF,
glfw::KeyG => constellation_msg::KeyG, KeyG,
glfw::KeyH => constellation_msg::KeyH, KeyH,
glfw::KeyI => constellation_msg::KeyI, KeyI,
glfw::KeyJ => constellation_msg::KeyJ, KeyJ,
glfw::KeyK => constellation_msg::KeyK, KeyK,
glfw::KeyL => constellation_msg::KeyL, KeyL,
glfw::KeyM => constellation_msg::KeyM, KeyM,
glfw::KeyN => constellation_msg::KeyN, KeyN,
glfw::KeyO => constellation_msg::KeyO, KeyO,
glfw::KeyP => constellation_msg::KeyP, KeyP,
glfw::KeyQ => constellation_msg::KeyQ, KeyQ,
glfw::KeyR => constellation_msg::KeyR, KeyR,
glfw::KeyS => constellation_msg::KeyS, KeyS,
glfw::KeyT => constellation_msg::KeyT, KeyT,
glfw::KeyU => constellation_msg::KeyU, KeyU,
glfw::KeyV => constellation_msg::KeyV, KeyV,
glfw::KeyW => constellation_msg::KeyW, KeyW,
glfw::KeyX => constellation_msg::KeyX, KeyX,
glfw::KeyY => constellation_msg::KeyY, KeyY,
glfw::KeyZ => constellation_msg::KeyZ, KeyZ,
glfw::KeyLeftBracket => constellation_msg::KeyLeftBracket, KeyLeftBracket,
glfw::KeyBackslash => constellation_msg::KeyBackslash, KeyBackslash,
glfw::KeyRightBracket => constellation_msg::KeyRightBracket, KeyRightBracket,
glfw::KeyGraveAccent => constellation_msg::KeyGraveAccent, KeyGraveAccent,
glfw::KeyWorld1 => constellation_msg::KeyWorld1, KeyWorld1,
glfw::KeyWorld2 => constellation_msg::KeyWorld2, KeyWorld2,
glfw::KeyEscape => constellation_msg::KeyEscape,
glfw::KeyEnter => constellation_msg::KeyEnter, KeyEscape,
glfw::KeyTab => constellation_msg::KeyTab, KeyEnter,
glfw::KeyBackspace => constellation_msg::KeyBackspace, KeyTab,
glfw::KeyInsert => constellation_msg::KeyInsert, KeyBackspace,
glfw::KeyDelete => constellation_msg::KeyDelete, KeyInsert,
glfw::KeyRight => constellation_msg::KeyRight, KeyDelete,
glfw::KeyLeft => constellation_msg::KeyLeft, KeyRight,
glfw::KeyDown => constellation_msg::KeyDown, KeyLeft,
glfw::KeyUp => constellation_msg::KeyUp, KeyDown,
glfw::KeyPageUp => constellation_msg::KeyPageUp, KeyUp,
glfw::KeyPageDown => constellation_msg::KeyPageDown, KeyPageUp,
glfw::KeyHome => constellation_msg::KeyHome, KeyPageDown,
glfw::KeyEnd => constellation_msg::KeyEnd, KeyHome,
glfw::KeyCapsLock => constellation_msg::KeyCapsLock, KeyEnd,
glfw::KeyScrollLock => constellation_msg::KeyScrollLock, KeyCapsLock,
glfw::KeyNumLock => constellation_msg::KeyNumLock, KeyScrollLock,
glfw::KeyPrintScreen => constellation_msg::KeyPrintScreen, KeyNumLock,
glfw::KeyPause => constellation_msg::KeyPause, KeyPrintScreen,
glfw::KeyF1 => constellation_msg::KeyF1, KeyPause,
glfw::KeyF2 => constellation_msg::KeyF2, KeyF1,
glfw::KeyF3 => constellation_msg::KeyF3, KeyF2,
glfw::KeyF4 => constellation_msg::KeyF4, KeyF3,
glfw::KeyF5 => constellation_msg::KeyF5, KeyF4,
glfw::KeyF6 => constellation_msg::KeyF6, KeyF5,
glfw::KeyF7 => constellation_msg::KeyF7, KeyF6,
glfw::KeyF8 => constellation_msg::KeyF8, KeyF7,
glfw::KeyF9 => constellation_msg::KeyF9, KeyF8,
glfw::KeyF10 => constellation_msg::KeyF10, KeyF9,
glfw::KeyF11 => constellation_msg::KeyF11, KeyF10,
glfw::KeyF12 => constellation_msg::KeyF12, KeyF11,
glfw::KeyF13 => constellation_msg::KeyF13, KeyF12,
glfw::KeyF14 => constellation_msg::KeyF14, KeyF13,
glfw::KeyF15 => constellation_msg::KeyF15, KeyF14,
glfw::KeyF16 => constellation_msg::KeyF16, KeyF15,
glfw::KeyF17 => constellation_msg::KeyF17, KeyF16,
glfw::KeyF18 => constellation_msg::KeyF18, KeyF17,
glfw::KeyF19 => constellation_msg::KeyF19, KeyF18,
glfw::KeyF20 => constellation_msg::KeyF20, KeyF19,
glfw::KeyF21 => constellation_msg::KeyF21, KeyF20,
glfw::KeyF22 => constellation_msg::KeyF22, KeyF21,
glfw::KeyF23 => constellation_msg::KeyF23, KeyF22,
glfw::KeyF24 => constellation_msg::KeyF24, KeyF23,
glfw::KeyF25 => constellation_msg::KeyF25, KeyF24,
glfw::KeyKp0 => constellation_msg::KeyKp0, KeyF25,
glfw::KeyKp1 => constellation_msg::KeyKp1, KeyKp0,
glfw::KeyKp2 => constellation_msg::KeyKp2, KeyKp1,
glfw::KeyKp3 => constellation_msg::KeyKp3, KeyKp2,
glfw::KeyKp4 => constellation_msg::KeyKp4, KeyKp3,
glfw::KeyKp5 => constellation_msg::KeyKp5, KeyKp4,
glfw::KeyKp6 => constellation_msg::KeyKp6, KeyKp5,
glfw::KeyKp7 => constellation_msg::KeyKp7, KeyKp6,
glfw::KeyKp8 => constellation_msg::KeyKp8, KeyKp7,
glfw::KeyKp9 => constellation_msg::KeyKp9, KeyKp8,
glfw::KeyKpDecimal => constellation_msg::KeyKpDecimal, KeyKp9,
glfw::KeyKpDivide => constellation_msg::KeyKpDivide, KeyKpDecimal,
glfw::KeyKpMultiply => constellation_msg::KeyKpMultiply, KeyKpDivide,
glfw::KeyKpSubtract => constellation_msg::KeyKpSubtract, KeyKpMultiply,
glfw::KeyKpAdd => constellation_msg::KeyKpAdd, KeyKpSubtract,
glfw::KeyKpEnter => constellation_msg::KeyKpEnter, KeyKpAdd,
glfw::KeyKpEqual => constellation_msg::KeyKpEqual, KeyKpEnter,
glfw::KeyLeftShift => constellation_msg::KeyLeftShift, KeyKpEqual,
glfw::KeyLeftControl => constellation_msg::KeyLeftControl, KeyLeftShift,
glfw::KeyLeftAlt => constellation_msg::KeyLeftAlt, KeyLeftControl,
glfw::KeyLeftSuper => constellation_msg::KeyLeftSuper, KeyLeftAlt,
glfw::KeyRightShift => constellation_msg::KeyRightShift, KeyLeftSuper,
glfw::KeyRightControl => constellation_msg::KeyRightControl, KeyRightShift,
glfw::KeyRightAlt => constellation_msg::KeyRightAlt, KeyRightControl,
glfw::KeyRightSuper => constellation_msg::KeyRightSuper, KeyRightAlt,
glfw::KeyMenu => constellation_msg::KeyMenu, KeyRightSuper,
} KeyMenu)
} }

View file

@ -142,6 +142,7 @@ var interfaceNamesInGlobalScope = [
"HTMLUListElement", "HTMLUListElement",
"HTMLUnknownElement", "HTMLUnknownElement",
"HTMLVideoElement", "HTMLVideoElement",
"KeyboardEvent",
"Location", "Location",
"MessageEvent", "MessageEvent",
"MouseEvent", "MouseEvent",