Merge pull request #3468 from Manishearth/jstraceable

Replace our usage our Encodable with JSTraceable; r=jdm
This commit is contained in:
Manish Goregaokar 2014-09-24 21:25:41 +05:30
commit 95a4731c0e
135 changed files with 409 additions and 273 deletions

View file

@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMetho
use dom::bindings::codegen::InheritTypes::{ElementCast, NodeCast};
use dom::bindings::global::Window;
use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::element::{Element, AttributeHandlers, ElementHelpers};
use dom::node::{Node, NodeHelpers};
@ -15,27 +16,20 @@ use servo_util::atom::Atom;
use servo_util::namespace::Namespace;
use servo_util::str::{DOMString, split_html_space_chars};
use serialize::{Encoder, Encodable};
use std::ascii::StrAsciiExt;
pub trait CollectionFilter {
pub trait CollectionFilter : JSTraceable {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool;
}
impl<S: Encoder<E>, E> Encodable<S, E> for Box<CollectionFilter+'static> {
fn encode(&self, _s: &mut S) -> Result<(), E> {
Ok(())
}
}
#[deriving(Encodable)]
#[jstraceable]
#[must_root]
pub enum CollectionTypeId {
Static(Vec<JS<Element>>),
Live(JS<Node>, Box<CollectionFilter+'static>)
}
#[deriving(Encodable)]
#[jstraceable]
#[must_root]
pub struct HTMLCollection {
collection: CollectionTypeId,
@ -64,6 +58,7 @@ impl HTMLCollection {
fn all_elements(window: JSRef<Window>, root: JSRef<Node>,
namespace_filter: Option<Namespace>) -> Temporary<HTMLCollection> {
#[jstraceable]
struct AllElementFilter {
namespace_filter: Option<Namespace>
}
@ -85,6 +80,7 @@ impl HTMLCollection {
return HTMLCollection::all_elements(window, root, None);
}
#[jstraceable]
struct TagNameFilter {
tag: Atom,
ascii_lower_tag: Atom,
@ -115,6 +111,7 @@ impl HTMLCollection {
if tag.as_slice() == "*" {
return HTMLCollection::all_elements(window, root, namespace_filter);
}
#[jstraceable]
struct TagNameNSFilter {
tag: Atom,
namespace_filter: Option<Namespace>
@ -139,6 +136,7 @@ impl HTMLCollection {
pub fn by_class_name(window: JSRef<Window>, root: JSRef<Node>, classes: DOMString)
-> Temporary<HTMLCollection> {
#[jstraceable]
struct ClassNameFilter {
classes: Vec<DOMString>
}
@ -154,6 +152,7 @@ impl HTMLCollection {
}
pub fn children(window: JSRef<Window>, root: JSRef<Node>) -> Temporary<HTMLCollection> {
#[jstraceable]
struct ElementChildFilter;
impl CollectionFilter for ElementChildFilter {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {