aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2014-09-24 06:07:07 +0530
committerManish Goregaokar <manishsmail@gmail.com>2014-09-24 19:35:41 +0530
commit6f6a62e9671cb562e0d29b82a2604ba44c0af6d0 (patch)
treec1a68fbc46894539fe58778c2696e97502eb90ff
parent5336dd98539a2129b2cce73e9488d570f930ac05 (diff)
downloadservo-6f6a62e9671cb562e0d29b82a2604ba44c0af6d0.tar.gz
servo-6f6a62e9671cb562e0d29b82a2604ba44c0af6d0.zip
Address review comments
-rw-r--r--components/plugins/jstraceable.rs15
-rw-r--r--components/script/dom/bindings/trace.rs10
-rw-r--r--components/script/dom/htmlcollection.rs10
-rw-r--r--components/script/dom/htmldatalistelement.rs2
-rw-r--r--components/script/dom/htmlfieldsetelement.rs2
-rw-r--r--components/script/dom/macros.rs2
-rw-r--r--components/script/dom/node.rs2
-rw-r--r--components/script/dom/treewalker.rs1
-rw-r--r--components/script/page.rs2
9 files changed, 20 insertions, 26 deletions
diff --git a/components/plugins/jstraceable.rs b/components/plugins/jstraceable.rs
index 6c3998f2d52..19171a6ded1 100644
--- a/components/plugins/jstraceable.rs
+++ b/components/plugins/jstraceable.rs
@@ -31,7 +31,7 @@ use syntax::ext::deriving::generic::{combine_substructure, EnumMatching, FieldIn
}
)
};
- trait_def.expand(cx, mitem, item, push)
+ trait_def.expand(cx, mitem, item, push)
}
// Mostly copied from syntax::ext::deriving::hash
@@ -40,23 +40,20 @@ fn jstraceable_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substru
[ref state_expr] => state_expr,
_ => cx.span_bug(trait_span, "incorrect number of arguments in `jstraceable`")
};
- let hash_ident = substr.method_ident;
- let call_hash = |span, thing_expr| {
- let expr = cx.expr_method_call(span, thing_expr, hash_ident, vec!(state_expr.clone()));
+ let trace_ident = substr.method_ident;
+ let call_trace = |span, thing_expr| {
+ let expr = cx.expr_method_call(span, thing_expr, trace_ident, vec!(state_expr.clone()));
cx.stmt_expr(expr)
};
let mut stmts = Vec::new();
let fields = match *substr.fields {
- Struct(ref fs) => fs,
- EnumMatching(_, _, ref fs) => {
- fs
- }
+ Struct(ref fs) | EnumMatching(_, _, ref fs) => fs,
_ => cx.span_bug(trait_span, "impossible substructure in `jstraceable`")
};
for &FieldInfo { ref self_, span, .. } in fields.iter() {
- stmts.push(call_hash(span, self_.clone()));
+ stmts.push(call_trace(span, self_.clone()));
}
cx.expr_block(cx.block(trait_span, stmts, None))
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index f0b4e5af237..5fcb1c78673 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -21,7 +21,7 @@
//! reflector.
//! 5. `trace_object()` calls `JS_CallTracer()` to notify the GC, which will
//! add the object to the graph, and will trace that object as well.
-//!
+//!
//! The untraceable!() macro adds an empty implementation of JSTraceable to
//! a datatype.
@@ -158,13 +158,13 @@ impl<T: JSTraceable> JSTraceable for RefCell<T> {
impl<T: JSTraceable> JSTraceable for Rc<T> {
fn trace(&self, trc: *mut JSTracer) {
- self.trace(trc)
+ self.deref().trace(trc)
}
}
impl<T: JSTraceable> JSTraceable for Box<T> {
fn trace(&self, trc: *mut JSTracer) {
- self.trace(trc)
+ (**self).trace(trc)
}
}
@@ -221,13 +221,15 @@ impl<K: Eq+Hash, V: JSTraceable> JSTraceable for HashMap<K, V> {
}
untraceable!(bool, f32, f64, String, Url)
-untraceable!(SubpageId, WindowSizeData, PipelineId)
untraceable!(uint, u8, u16, u32, u64)
untraceable!(int, i8, i16, i32, i64)
untraceable!(Untraceable<T>)
untraceable!(ImageCacheTask, ScriptControlChan)
untraceable!(Atom, Namespace)
untraceable!(PropertyDeclarationBlock)
+// These three are interdependent, if you plan to put jsmanaged data
+// in one of these make sure it is propagated properly to containing structs
+untraceable!(SubpageId, WindowSizeData, PipelineId)
impl<'a> JSTraceable for &'a str {
#[inline]
diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs
index 7a3a68fe2b0..d27ce7e8de2 100644
--- a/components/script/dom/htmlcollection.rs
+++ b/components/script/dom/htmlcollection.rs
@@ -60,7 +60,7 @@ impl HTMLCollection {
fn all_elements(window: JSRef<Window>, root: JSRef<Node>,
namespace_filter: Option<Namespace>) -> Temporary<HTMLCollection> {
#[jstraceable]
-struct AllElementFilter {
+ struct AllElementFilter {
namespace_filter: Option<Namespace>
}
impl CollectionFilter for AllElementFilter {
@@ -82,7 +82,7 @@ struct AllElementFilter {
}
#[jstraceable]
-struct TagNameFilter {
+ struct TagNameFilter {
tag: Atom,
ascii_lower_tag: Atom,
}
@@ -118,7 +118,7 @@ struct TagNameFilter {
return HTMLCollection::all_elements(window, root, namespace_filter);
}
#[jstraceable]
-struct TagNameNSFilter {
+ struct TagNameNSFilter {
tag: Atom,
namespace_filter: Option<Namespace>
}
@@ -143,7 +143,7 @@ struct TagNameNSFilter {
pub fn by_class_name(window: JSRef<Window>, root: JSRef<Node>, classes: DOMString)
-> Temporary<HTMLCollection> {
#[jstraceable]
-struct ClassNameFilter {
+ struct ClassNameFilter {
classes: Vec<DOMString>
}
impl CollectionFilter for ClassNameFilter {
@@ -159,7 +159,7 @@ struct ClassNameFilter {
pub fn children(window: JSRef<Window>, root: JSRef<Node>) -> Temporary<HTMLCollection> {
#[jstraceable]
-struct ElementChildFilter;
+ struct ElementChildFilter;
impl CollectionFilter for ElementChildFilter {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {
root.is_parent_of(NodeCast::from_ref(elem))
diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs
index 841378ae065..76ff7449263 100644
--- a/components/script/dom/htmldatalistelement.rs
+++ b/components/script/dom/htmldatalistelement.rs
@@ -45,7 +45,7 @@ impl HTMLDataListElement {
impl<'a> HTMLDataListElementMethods for JSRef<'a, HTMLDataListElement> {
fn Options(self) -> Temporary<HTMLCollection> {
#[jstraceable]
-struct HTMLDataListOptionsFilter;
+ struct HTMLDataListOptionsFilter;
impl CollectionFilter for HTMLDataListOptionsFilter {
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
elem.is_htmloptionelement()
diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs
index 3e08dfee22f..55322a5001e 100644
--- a/components/script/dom/htmlfieldsetelement.rs
+++ b/components/script/dom/htmlfieldsetelement.rs
@@ -51,7 +51,7 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
// http://www.whatwg.org/html/#dom-fieldset-elements
fn Elements(self) -> Temporary<HTMLCollection> {
#[jstraceable]
-struct ElementsFilter;
+ struct ElementsFilter;
impl CollectionFilter for ElementsFilter {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {
static tag_names: StaticStringVec = &["button", "fieldset", "input",
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 6e52b4f763f..0f85dafc5a1 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -46,7 +46,7 @@ macro_rules! make_uint_getter(
/// Use #[jstraceable] on JS managed types
macro_rules! untraceable(
($($ty:ident),+) => (
- $(
+ $(
impl JSTraceable for $ty {
#[inline]
fn trace(&self, _: *mut JSTracer) {
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 96f0377880a..1a0c17ef6e4 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -64,8 +64,6 @@ use style::ComputedValues;
use sync::Arc;
use uuid;
-
-
//
// The basic Node structure
//
diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs
index 6af92828539..6dc8463037a 100644
--- a/components/script/dom/treewalker.rs
+++ b/components/script/dom/treewalker.rs
@@ -19,7 +19,6 @@ use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::document::Document;
use dom::node::{Node, NodeHelpers};
-
use std::cell::Cell;
// http://dom.spec.whatwg.org/#interface-treewalker
diff --git a/components/script/page.rs b/components/script/page.rs
index 8ece5145133..da2b99c0c6f 100644
--- a/components/script/page.rs
+++ b/components/script/page.rs
@@ -35,8 +35,6 @@ use std::mem::replace;
use std::rc::Rc;
use url::Url;
-
-
/// Encapsulates a handle to a frame and its associated layout information.
#[jstraceable]
pub struct Page {