diff options
author | Josh Matthews <josh@joshmatthews.net> | 2014-10-06 11:51:44 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2014-11-13 12:53:54 -0500 |
commit | 80764f65e3e4895d3a012d6bc1d3bb8183ae15da (patch) | |
tree | 63438517484e439fbc62693a5e53a1029f5206ba /components/script/script_task.rs | |
parent | 84bc17e7ad99d11ff416f2126acb2031b680dc19 (diff) | |
download | servo-80764f65e3e4895d3a012d6bc1d3bb8183ae15da.tar.gz servo-80764f65e3e4895d3a012d6bc1d3bb8183ae15da.zip |
Add single-line text input with no visible cursor.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 26 |
1 files changed, 14 insertions, 12 deletions
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 |