diff options
author | Keith Yeung <kungfukeith11@gmail.com> | 2015-02-04 00:04:12 +0800 |
---|---|---|
committer | Keith Yeung <kungfukeith11@gmail.com> | 2015-02-04 00:04:12 +0800 |
commit | b262fc16e0eed30347df2590c14e7ebc74de2bb4 (patch) | |
tree | 39b8aa52b396b5318a78c1f0e8b561ec25342f1d | |
parent | 2ae7ed327d0b442d32b01c1cf92c69bda2089111 (diff) | |
download | servo-b262fc16e0eed30347df2590c14e7ebc74de2bb4.tar.gz servo-b262fc16e0eed30347df2590c14e7ebc74de2bb4.zip |
Modified constellation key event handler to deal with missing frames
-rw-r--r-- | components/compositing/constellation.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 45324165d0d..c59184f8631 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -885,11 +885,17 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { } fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) { - self.current_frame().as_ref().map(|frame| { - let ScriptControlChan(ref chan) = frame.pipeline.borrow().script_chan; - chan.send(ConstellationControlMsg::SendEvent( - frame.pipeline.borrow().id, CompositorEvent::KeyEvent(key, state, mods))).unwrap(); - }); + match *self.current_frame() { + Some(ref frame) => { + let ScriptControlChan(ref chan) = frame.pipeline.borrow().script_chan; + chan.send(ConstellationControlMsg::SendEvent( + frame.pipeline.borrow().id, + CompositorEvent::KeyEvent(key, state, mods))).unwrap(); + }, + None => self.compositor_proxy.clone_compositor_proxy() + .send(CompositorMsg::KeyEvent(key, mods)) + } + } fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) { |