From 80764f65e3e4895d3a012d6bc1d3bb8183ae15da Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Mon, 6 Oct 2014 11:51:44 -0400 Subject: Add single-line text input with no visible cursor. --- components/script/script_task.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'components/script/script_task.rs') diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 684ae327ad2..5ed9023b5e5 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -49,7 +49,7 @@ use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading}; use servo_msg::compositor_msg::{ScriptListener}; use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg, LoadUrlMsg, NavigationDirection}; use servo_msg::constellation_msg::{LoadData, PipelineId, Failure, FailureMsg, WindowSizeData, Key, KeyState}; -use servo_msg::constellation_msg::{KeyModifiers, Super, Shift, Control, Alt, Repeated, Pressed}; +use servo_msg::constellation_msg::{KeyModifiers, SUPER, SHIFT, CONTROL, ALT, Repeated, Pressed}; use servo_msg::constellation_msg::{Released}; use servo_msg::constellation_msg; use servo_net::image_cache_task::ImageCacheTask; @@ -923,7 +923,6 @@ impl ScriptTask { state: KeyState, modifiers: KeyModifiers, pipeline_id: PipelineId) { - println!("key {} is {}", key as int, state as int); let page = get_page(&*self.page.borrow(), pipeline_id); let frame = page.frame(); let window = frame.as_ref().unwrap().window.root(); @@ -937,10 +936,10 @@ impl ScriptTask { (&None, &None) => EventTargetCast::from_ref(*window), }; - let ctrl = modifiers.contains(Control); - let alt = modifiers.contains(Alt); - let shift = modifiers.contains(Shift); - let meta = modifiers.contains(Super); + let ctrl = modifiers.contains(CONTROL); + let alt = modifiers.contains(ALT); + let shift = modifiers.contains(SHIFT); + let meta = modifiers.contains(SUPER); let is_composing = false; let is_repeating = state == Repeated; @@ -949,21 +948,24 @@ impl ScriptTask { Released => "keyup", }.to_string(); - let props = KeyboardEvent::key_properties(key); + let props = KeyboardEvent::key_properties(key, modifiers); let event = KeyboardEvent::new(*window, ev_type, true, true, Some(*window), 0, - props.key.clone(), props.code.clone(), props.location, + props.key.to_string(), props.code.to_string(), props.location, is_repeating, is_composing, ctrl, alt, shift, meta, - props.char_code, props.key_code).root(); + None, props.key_code).root(); let _ = target.DispatchEvent(EventCast::from_ref(*event)); if state != Released && props.is_printable() { let event = KeyboardEvent::new(*window, "keypress".to_string(), true, true, Some(*window), - 0, props.key.clone(), props.code.clone(), props.location, - is_repeating, is_composing, ctrl, alt, shift, meta, - props.char_code, props.key_code).root(); + 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)); } + + window.flush_layout(); } /// The entry point for content to notify that a new load has been requested -- cgit v1.2.3