diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-05-24 17:50:06 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-05-24 17:50:06 +0200 |
commit | 49d244d39cd6facc7b24000d67cda46a13517af5 (patch) | |
tree | 4f7d075c46a3ed3f294ebfd299e4af854c3d8391 /components/script_traits/lib.rs | |
parent | cd1396fa9ae72bebf13115ed0d752fb21ce0df19 (diff) | |
download | servo-49d244d39cd6facc7b24000d67cda46a13517af5.tar.gz servo-49d244d39cd6facc7b24000d67cda46a13517af5.zip |
Use associated types to improve LayoutThreadFactory and ScriptThreadFactory.
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r-- | components/script_traits/lib.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 8d39895ed46..7ee96092aba 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -53,6 +53,7 @@ use net_traits::response::HttpsState; use profile_traits::mem; use std::any::Any; use std::collections::HashMap; +use std::sync::mpsc::{Sender, Receiver}; use url::Url; use util::ipc::OptionalOpaqueIpcSender; @@ -246,10 +247,6 @@ pub enum TouchpadPressurePhase { AfterSecondClick, } -/// An opaque wrapper around script<->layout channels to avoid leaking message types into -/// crates that don't need to know about them. -pub struct OpaqueScriptLayoutChannel(pub (Box<Any + Send>, Box<Any + Send>)); - /// Requests a TimerEvent-Message be sent after the given duration. #[derive(Deserialize, Serialize)] pub struct TimerEventRequest(pub IpcSender<TimerEvent>, @@ -344,14 +341,12 @@ pub struct InitialScriptState { /// This trait allows creating a `ScriptThread` without depending on the `script` /// crate. pub trait ScriptThreadFactory { + /// Type of message sent from script to layout. + type Message; /// Create a `ScriptThread`. fn create(state: InitialScriptState, - layout_chan: &OpaqueScriptLayoutChannel, - load_data: LoadData); - /// Create a script -> layout channel (`Sender`, `Receiver` pair). - fn create_layout_channel() -> OpaqueScriptLayoutChannel; - /// Clone the `Sender` in `pair`. - fn clone_layout_channel(pair: &OpaqueScriptLayoutChannel) -> Box<Any + Send>; + load_data: LoadData) + -> (Sender<Self::Message>, Receiver<Self::Message>); } /// Messages sent from the script thread to the compositor |