Skip to content
Permalink
Browse files

Fix interfaces test

  • Loading branch information
kmcallister authored and jdm committed Nov 13, 2014
1 parent 89a27dd commit 642a3592c7ea1b82e3a3a660370b9871aa5b5e96
@@ -1,5 +1,14 @@
--- 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):
self._treatNonCallableAsNull = False
self._treatNonObjectAsNull = False
@@ -438,7 +438,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
let doc = document_from_node(*self).root();
doc.request_focus(ElementCast::from_ref(*self));
} 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);
keyevent.map(|event| {
match self.textinput.borrow_mut().handle_keydown(event) {
@@ -117,8 +117,8 @@ impl KeyboardEvent {
key: key_value(key, mods),
code: code_value(key),
location: key_location(key),
char_code: key_char_code(key, mods),
key_code: key_key_code(key),
char_code: key_charcode(key, mods),
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 => "z",
constellation_msg::KeyLeftBracket if shift => "{",
constellation_msg::KeyLeftBracket => "{",
constellation_msg::KeyLeftBracket => "[",
constellation_msg::KeyBackslash if shift => "|",
constellation_msg::KeyBackslash => "\\",
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
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);
if key.len() == 1 {
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
fn key_key_code(key: constellation_msg::Key) -> u32 {
fn key_keycode(key: constellation_msg::Key) -> u32 {
match key {
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#legacy-key-models
constellation_msg::KeyBackspace => 8,
@@ -601,13 +601,15 @@ impl<'a> KeyboardEventMethods for JSRef<'a, KeyboardEvent> {
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 {
match keyArg.as_slice() {
"Ctrl" => self.CtrlKey(),
"Alt" => self.AltKey(),
"Shift" => self.ShiftKey(),
"Meta" => self.MetaKey(),
"AltGraph" | "CapsLock" | "NumLock" | "ScrollLock" => false, //FIXME
"AltGraph" | "CapsLock" | "NumLock" | "ScrollLock" | "Accel" |
"Fn" | "FnLock" | "Hyper" | "OS" | "Symbol" | "SymbolLock" => false, //FIXME
_ => false,
}
}
@@ -9,6 +9,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyStateValues};
use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods;
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::WindowBinding::WindowMethods;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, EventCast, ElementCast};
@@ -950,19 +951,25 @@ impl ScriptTask {

let props = KeyboardEvent::key_properties(key, modifiers);

let event = KeyboardEvent::new(*window, ev_type, true, true, Some(*window), 0,
props.key.to_string(), props.code.to_string(), props.location,
is_repeating, is_composing, ctrl, alt, shift, meta,
None, props.key_code).root();
let _ = target.DispatchEvent(EventCast::from_ref(*event));

if state != Released && props.is_printable() {
let keyevent = KeyboardEvent::new(*window, ev_type, true, true, Some(*window), 0,
props.key.to_string(), props.code.to_string(),
props.location, is_repeating, is_composing,
ctrl, alt, shift, meta,
None, props.key_code).root();
let event = EventCast::from_ref(*keyevent);
let _ = target.DispatchEvent(event);

// 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),
0, props.key.to_string(), props.code.to_string(),
props.location, is_repeating, is_composing,
ctrl, alt, shift, meta,
props.char_code, 0).root();
let _ = target.DispatchEvent(EventCast::from_ref(*event));

// TODO: if keypress event is canceled, prevent firing input events
}

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

0 comments on commit 642a359

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