Add a JSTraceable bound on ScriptChan

This commit is contained in:
Anthony Ramine 2016-12-02 00:12:22 +01:00
parent 620a67ff14
commit 58919f17a6
3 changed files with 5 additions and 12 deletions

View file

@ -5,6 +5,7 @@
use dom::abstractworker::WorkerScriptMsg; use dom::abstractworker::WorkerScriptMsg;
use dom::bindings::refcounted::Trusted; use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::Reflectable; use dom::bindings::reflector::Reflectable;
use dom::bindings::trace::JSTraceable;
use script_runtime::{ScriptChan, CommonScriptMsg, ScriptPort}; use script_runtime::{ScriptChan, CommonScriptMsg, ScriptPort};
use std::sync::mpsc::{Receiver, Sender}; use std::sync::mpsc::{Receiver, Sender};
@ -17,7 +18,7 @@ pub struct SendableWorkerScriptChan<T: Reflectable> {
pub worker: Trusted<T>, pub worker: Trusted<T>,
} }
impl<T: Reflectable + 'static> ScriptChan for SendableWorkerScriptChan<T> { impl<T: JSTraceable + Reflectable + 'static> ScriptChan for SendableWorkerScriptChan<T> {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
self.sender.send((self.worker.clone(), msg)).map_err(|_| ()) self.sender.send((self.worker.clone(), msg)).map_err(|_| ())
} }
@ -39,7 +40,7 @@ pub struct WorkerThreadWorkerChan<T: Reflectable> {
pub worker: Trusted<T>, pub worker: Trusted<T>,
} }
impl<T: Reflectable + 'static> ScriptChan for WorkerThreadWorkerChan<T> { impl<T: JSTraceable + Reflectable + 'static> ScriptChan for WorkerThreadWorkerChan<T> {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
self.sender self.sender
.send((self.worker.clone(), WorkerScriptMsg::Common(msg))) .send((self.worker.clone(), WorkerScriptMsg::Common(msg)))

View file

@ -75,7 +75,6 @@ use profile_traits::time::ProfilerChan as TimeProfilerChan;
use script_layout_interface::OpaqueStyleAndLayoutData; use script_layout_interface::OpaqueStyleAndLayoutData;
use script_layout_interface::reporter::CSSErrorReporter; use script_layout_interface::reporter::CSSErrorReporter;
use script_layout_interface::rpc::LayoutRPC; use script_layout_interface::rpc::LayoutRPC;
use script_runtime::ScriptChan;
use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase}; use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase};
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType}; use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -372,13 +371,6 @@ unsafe_no_jsmanaged_fields!(WebGLShaderId);
unsafe_no_jsmanaged_fields!(WebGLTextureId); unsafe_no_jsmanaged_fields!(WebGLTextureId);
unsafe_no_jsmanaged_fields!(MediaList); unsafe_no_jsmanaged_fields!(MediaList);
unsafe impl JSTraceable for Box<ScriptChan + Send> {
#[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
}
}
unsafe impl JSTraceable for Box<FnBox(f64, )> { unsafe impl JSTraceable for Box<FnBox(f64, )> {
#[inline] #[inline]
unsafe fn trace(&self, _trc: *mut JSTracer) { unsafe fn trace(&self, _trc: *mut JSTracer) {

View file

@ -10,7 +10,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback; use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback;
use dom::bindings::js::{Root, RootCollection, RootCollectionPtr, trace_roots}; use dom::bindings::js::{Root, RootCollection, RootCollectionPtr, trace_roots};
use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects}; use dom::bindings::refcounted::{LiveDOMReferences, trace_refcounted_objects};
use dom::bindings::trace::trace_traceables; use dom::bindings::trace::{JSTraceable, trace_traceables};
use dom::bindings::utils::DOM_CALLBACKS; use dom::bindings::utils::DOM_CALLBACKS;
use dom::globalscope::GlobalScope; use dom::globalscope::GlobalScope;
use js::glue::CollectServoSizes; use js::glue::CollectServoSizes;
@ -48,7 +48,7 @@ pub enum CommonScriptMsg {
} }
/// A cloneable interface for communicating with an event loop. /// A cloneable interface for communicating with an event loop.
pub trait ScriptChan { pub trait ScriptChan: JSTraceable {
/// Send a message to the associated event loop. /// Send a message to the associated event loop.
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>; fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>;
/// Clone this handle. /// Clone this handle.