aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_traits/lib.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-05-25 04:25:50 -0500
committerbors-servo <lbergstrom+bors@mozilla.com>2016-05-25 04:25:50 -0500
commit586c0702a0c80174d19c1eacb49c8295f2963ecc (patch)
treeb159bcdfa07c6bb4d9b5e0307e87db033f945597 /components/script_traits/lib.rs
parentaffc110fa0aac70d2e676d75bd5e54875ad8d941 (diff)
parent49d244d39cd6facc7b24000d67cda46a13517af5 (diff)
downloadservo-586c0702a0c80174d19c1eacb49c8295f2963ecc.tar.gz
servo-586c0702a0c80174d19c1eacb49c8295f2963ecc.zip
Auto merge of #11373 - servo:threadfactory, r=larsbergstrom
Use associated types to improve LayoutThreadFactory and ScriptThreadFactory. Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy --faster` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). Either: - [ ] There are tests for these changes OR - [x] These changes do not require tests because refactoring Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11373) <!-- Reviewable:end -->
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r--components/script_traits/lib.rs15
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