From ca5e7097a0f2737520591e24371d539e5af5e5ba Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 13 Sep 2015 16:43:28 +0200 Subject: [PATCH 1/2] Stop requiring that the type argument to RootedVec implements Reflectable. It is sufficient that it implements JSTraceable. --- components/script/dom/bindings/trace.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index e514e180486..ed16d5a2515 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -455,19 +455,17 @@ impl<'a, T: JSTraceable> Drop for RootedTraceable<'a, T> { } } -/// A vector of items that are rooted for the lifetime -/// of this struct. -/// Must be a reflectable +/// A vector of items that are rooted for the lifetime of this struct. #[allow(unrooted_must_root)] #[no_move] #[derive(JSTraceable)] #[allow_unrooted_interior] -pub struct RootedVec { +pub struct RootedVec { v: Vec } -impl RootedVec { +impl RootedVec { /// Create a vector of items of type T that is rooted for /// the lifetime of this struct pub fn new() -> RootedVec { @@ -495,20 +493,20 @@ impl RootedVec> { } } -impl Drop for RootedVec { +impl Drop for RootedVec { fn drop(&mut self) { RootedTraceableSet::remove(self); } } -impl Deref for RootedVec { +impl Deref for RootedVec { type Target = Vec; fn deref(&self) -> &Vec { &self.v } } -impl DerefMut for RootedVec { +impl DerefMut for RootedVec { fn deref_mut(&mut self) -> &mut Vec { &mut self.v } From 3781567c199512ce2f257d1b2ccf465e634e12ec Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 13 Sep 2015 16:47:06 +0200 Subject: [PATCH 2/2] Stop implementing Reflectable for JS (fixes #2285). It's not generally safe to expose the contents of a JS. --- components/script/dom/bindings/js.rs | 13 ++++++------- components/script/dom/bindings/trace.rs | 6 ------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 5345d08ee9e..e50bf68e478 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -88,6 +88,12 @@ impl JS { } } +impl JSTraceable for JS { + fn trace(&self, trc: *mut JSTracer) { + trace_reflector(trc, "", unsafe { (**self.ptr).reflector() }); + } +} + /// An unrooted reference to a DOM object for use in layout. `Layout*Helpers` /// traits must be implemented on this. #[allow_unrooted_interior] @@ -148,13 +154,6 @@ impl LayoutJS { } } -impl Reflectable for JS { - fn reflector(&self) -> &Reflector { - unsafe { - (**self.ptr).reflector() - } - } -} /// A trait to be implemented for JS-managed types that can be stored in /// mutable member fields. diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index ed16d5a2515..5a9aa5b2abb 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -88,12 +88,6 @@ pub trait JSTraceable { fn trace(&self, trc: *mut JSTracer); } -impl JSTraceable for JS { - fn trace(&self, trc: *mut JSTracer) { - trace_reflector(trc, "", self.reflector()); - } -} - no_jsmanaged_fields!(EncodingRef); no_jsmanaged_fields!(Reflector);