auto merge of #4979 : Ms2ger/servo/audit-ints, r=Manishearth

This commit is contained in:
bors-servo 2015-02-20 07:09:54 -07:00
commit 276f74b1dd
17 changed files with 73 additions and 73 deletions

View file

@ -1014,7 +1014,7 @@ class CGArgumentConverter(CGThing):
seqType = CGTemplatedType("Vec", declType) seqType = CGTemplatedType("Vec", declType)
variadicConversion = string.Template( variadicConversion = string.Template(
"let mut vector: ${seqType} = Vec::with_capacity((${argc} - ${index}) as uint);\n" "let mut vector: ${seqType} = Vec::with_capacity((${argc} - ${index}) as usize);\n"
"for variadicArg in range(${index}, ${argc}) {\n" "for variadicArg in range(${index}, ${argc}) {\n"
"${inner}\n" "${inner}\n"
" vector.push(slot);\n" " vector.push(slot);\n"
@ -1484,7 +1484,7 @@ const Class_name: [u8; %i] = %s;
static Class: DOMJSClass = DOMJSClass { static Class: DOMJSClass = DOMJSClass {
base: js::Class { base: js::Class {
name: &Class_name as *const u8 as *const libc::c_char, name: &Class_name as *const u8 as *const libc::c_char,
flags: JSCLASS_IS_DOMJSCLASS | %s | (((%s) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT as uint), //JSCLASS_HAS_RESERVED_SLOTS(%s), flags: JSCLASS_IS_DOMJSCLASS | %s | (((%s) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT), //JSCLASS_HAS_RESERVED_SLOTS(%s),
addProperty: Some(JS_PropertyStub), addProperty: Some(JS_PropertyStub),
delProperty: Some(JS_PropertyStub), delProperty: Some(JS_PropertyStub),
getProperty: Some(JS_PropertyStub), getProperty: Some(JS_PropertyStub),
@ -1567,7 +1567,7 @@ class CGPrototypeJSClass(CGThing):
const PrototypeClassName__: [u8; %s] = %s; const PrototypeClassName__: [u8; %s] = %s;
static PrototypeClass: JSClass = JSClass { static PrototypeClass: JSClass = JSClass {
name: &PrototypeClassName__ as *const u8 as *const libc::c_char, name: &PrototypeClassName__ as *const u8 as *const libc::c_char,
flags: (1 & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT as uint, //JSCLASS_HAS_RESERVED_SLOTS(1) flags: (1 & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT, //JSCLASS_HAS_RESERVED_SLOTS(1)
addProperty: Some(JS_PropertyStub), addProperty: Some(JS_PropertyStub),
delProperty: Some(JS_PropertyStub), delProperty: Some(JS_PropertyStub),
getProperty: Some(JS_PropertyStub), getProperty: Some(JS_PropertyStub),
@ -1835,7 +1835,7 @@ def CreateBindingJSObject(descriptor, parent=None):
if descriptor.proxy: if descriptor.proxy:
assert not descriptor.isGlobal() assert not descriptor.isGlobal()
create += """ create += """
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint]; let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as usize];
let mut private = PrivateValue(boxed::into_raw(object) as *const libc::c_void); let mut private = PrivateValue(boxed::into_raw(object) as *const libc::c_void);
let obj = with_compartment(cx, proto, || { let obj = with_compartment(cx, proto, || {
NewProxyObject(cx, handler, NewProxyObject(cx, handler,
@ -1855,7 +1855,7 @@ assert!(!obj.is_null());\
create += """\ create += """\
assert!(!obj.is_null()); assert!(!obj.is_null());
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32, JS_SetReservedSlot(obj, DOM_OBJECT_SLOT,
PrivateValue(boxed::into_raw(object) as *const libc::c_void));""" PrivateValue(boxed::into_raw(object) as *const libc::c_void));"""
return create return create
@ -1923,7 +1923,7 @@ impl IDLInterface for ${type} {
fn get_prototype_id() -> PrototypeList::ID { fn get_prototype_id() -> PrototypeList::ID {
PrototypeList::ID::${type} PrototypeList::ID::${type}
} }
fn get_prototype_depth() -> uint { fn get_prototype_depth() -> usize {
${depth} ${depth}
} }
} }
@ -2071,11 +2071,11 @@ assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
/* Check to see whether the interface objects are already installed */ /* Check to see whether the interface objects are already installed */
let proto_or_iface_array = get_proto_or_iface_array(global); let proto_or_iface_array = get_proto_or_iface_array(global);
let cached_object: *mut JSObject = *proto_or_iface_array.offset(%s as int); let cached_object: *mut JSObject = *proto_or_iface_array.offset(%s as isize);
if cached_object.is_null() { if cached_object.is_null() {
let tmp: *mut JSObject = CreateInterfaceObjects(cx, global, receiver); let tmp: *mut JSObject = CreateInterfaceObjects(cx, global, receiver);
assert!(!tmp.is_null()); assert!(!tmp.is_null());
*proto_or_iface_array.offset(%s as int) = tmp; *proto_or_iface_array.offset(%s as isize) = tmp;
tmp tmp
} else { } else {
cached_object cached_object
@ -2800,7 +2800,7 @@ class CGEnum(CGThing):
CGThing.__init__(self) CGThing.__init__(self)
decl = """\ decl = """\
#[repr(uint)] #[repr(usize)]
#[derive(PartialEq, Copy)] #[derive(PartialEq, Copy)]
#[jstraceable] #[jstraceable]
pub enum %s { pub enum %s {
@ -2819,7 +2819,7 @@ pub const strings: &'static [&'static str] = &[
impl ToJSValConvertible for super::%s { impl ToJSValConvertible for super::%s {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal { fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
strings[*self as uint].to_jsval(cx) strings[*self as usize].to_jsval(cx)
} }
} }
""" % (",\n ".join(['"%s"' % val for val in enum.values()]), enum.identifier.name) """ % (",\n ".join(['"%s"' % val for val in enum.values()]), enum.identifier.name)
@ -4496,7 +4496,7 @@ class CGRegisterProxyHandlersMethod(CGAbstractMethod):
def definition_body(self): def definition_body(self):
return CGList([ return CGList([
CGGeneric("proxy_handlers[Proxies::%s as uint] = codegen::Bindings::%sBinding::DefineProxyHandler();" % (desc.name, desc.name)) CGGeneric("proxy_handlers[Proxies::%s as usize] = codegen::Bindings::%sBinding::DefineProxyHandler();" % (desc.name, desc.name))
for desc in self.descriptors for desc in self.descriptors
], "\n") ], "\n")
@ -5225,7 +5225,7 @@ class GlobalGenRoots():
return CGList([ return CGList([
CGGeneric(AUTOGENERATED_WARNING_COMMENT), CGGeneric(AUTOGENERATED_WARNING_COMMENT),
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength), CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: usize = %d;\n\n" % config.maxProtoChainLength),
CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq, Copy"), CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq, Copy"),
CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq, Copy"), CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq, Copy"),
]) ])

View file

@ -62,7 +62,7 @@ pub trait IDLInterface {
fn get_prototype_id() -> PrototypeList::ID; fn get_prototype_id() -> PrototypeList::ID;
/// Returns the prototype depth, i.e., the number of interfaces this /// Returns the prototype depth, i.e., the number of interfaces this
/// interface inherits from. /// interface inherits from.
fn get_prototype_depth() -> uint; fn get_prototype_depth() -> usize;
} }
/// A trait to convert Rust types to `JSVal`s. /// A trait to convert Rust types to `JSVal`s.
@ -306,7 +306,7 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
unsafe { unsafe {
let mut length = 0; let mut length = 0;
let chars = JS_GetStringCharsAndLength(cx, s, &mut length); let chars = JS_GetStringCharsAndLength(cx, s, &mut length);
let char_vec = slice::from_raw_parts(chars, length as uint); let char_vec = slice::from_raw_parts(chars, length as usize);
String::from_utf16(char_vec).unwrap() String::from_utf16(char_vec).unwrap()
} }
} }
@ -365,7 +365,7 @@ impl FromJSValConvertible for ByteString {
let mut length = 0; let mut length = 0;
let chars = JS_GetStringCharsAndLength(cx, string, &mut length); let chars = JS_GetStringCharsAndLength(cx, string, &mut length);
let char_vec = slice::from_raw_parts(chars, length as uint); let char_vec = slice::from_raw_parts(chars, length as usize);
if char_vec.iter().any(|&c| c > 0xFF) { if char_vec.iter().any(|&c| c > 0xFF) {
// XXX Throw // XXX Throw
@ -410,8 +410,8 @@ pub fn is_dom_proxy(obj: *mut JSObject) -> bool {
/// stored for non-proxy bindings. /// stored for non-proxy bindings.
// We use slot 0 for holding the raw object. This is safe for both // We use slot 0 for holding the raw object. This is safe for both
// globals and non-globals. // globals and non-globals.
pub const DOM_OBJECT_SLOT: uint = 0; pub const DOM_OBJECT_SLOT: u32 = 0;
const DOM_PROXY_OBJECT_SLOT: uint = js::JSSLOT_PROXY_PRIVATE as uint; const DOM_PROXY_OBJECT_SLOT: u32 = js::JSSLOT_PROXY_PRIVATE;
/// Returns the index of the slot wherein a pointer to the reflected DOM object /// Returns the index of the slot wherein a pointer to the reflected DOM object
/// is stored. /// is stored.
@ -420,10 +420,10 @@ const DOM_PROXY_OBJECT_SLOT: uint = js::JSSLOT_PROXY_PRIVATE as uint;
pub unsafe fn dom_object_slot(obj: *mut JSObject) -> u32 { pub unsafe fn dom_object_slot(obj: *mut JSObject) -> u32 {
let clasp = JS_GetClass(obj); let clasp = JS_GetClass(obj);
if is_dom_class(&*clasp) { if is_dom_class(&*clasp) {
DOM_OBJECT_SLOT as u32 DOM_OBJECT_SLOT
} else { } else {
assert!(is_dom_proxy(obj)); assert!(is_dom_proxy(obj));
DOM_PROXY_OBJECT_SLOT as u32 DOM_PROXY_OBJECT_SLOT
} }
} }

View file

@ -585,7 +585,7 @@ pub trait TemporaryPushable<T> {
/// Push a new value onto this container. /// Push a new value onto this container.
fn push_unrooted(&mut self, val: &T); fn push_unrooted(&mut self, val: &T);
/// Insert a new value into this container. /// Insert a new value into this container.
fn insert_unrooted(&mut self, index: uint, val: &T); fn insert_unrooted(&mut self, index: usize, val: &T);
} }
impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> { impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> {
@ -593,7 +593,7 @@ impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> {
self.push(unsafe { val.get_js() }); self.push(unsafe { val.get_js() });
} }
fn insert_unrooted(&mut self, index: uint, val: &T) { fn insert_unrooted(&mut self, index: usize, val: &T) {
self.insert(index, unsafe { val.get_js() }); self.insert(index, unsafe { val.get_js() });
} }
} }

View file

@ -50,7 +50,7 @@ pub struct Trusted<T> {
/// A pointer to the Rust DOM object of type T, but void to allow /// A pointer to the Rust DOM object of type T, but void to allow
/// sending `Trusted<T>` between tasks, regardless of T's sendability. /// sending `Trusted<T>` between tasks, regardless of T's sendability.
ptr: *const libc::c_void, ptr: *const libc::c_void,
refcount: Arc<Mutex<uint>>, refcount: Arc<Mutex<usize>>,
script_chan: Box<ScriptChan + Send>, script_chan: Box<ScriptChan + Send>,
owner_thread: *const libc::c_void, owner_thread: *const libc::c_void,
} }
@ -123,7 +123,7 @@ impl<T: Reflectable> Drop for Trusted<T> {
/// from being garbage collected due to outstanding references. /// from being garbage collected due to outstanding references.
pub struct LiveDOMReferences { pub struct LiveDOMReferences {
// keyed on pointer to Rust DOM object // keyed on pointer to Rust DOM object
table: RefCell<HashMap<*const libc::c_void, Arc<Mutex<uint>>>> table: RefCell<HashMap<*const libc::c_void, Arc<Mutex<usize>>>>
} }
impl LiveDOMReferences { impl LiveDOMReferences {
@ -136,7 +136,7 @@ impl LiveDOMReferences {
}); });
} }
fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<uint>> { fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<usize>> {
let mut table = self.table.borrow_mut(); let mut table = self.table.borrow_mut();
match table.entry(ptr as *const libc::c_void) { match table.entry(ptr as *const libc::c_void) {
Occupied(mut entry) => { Occupied(mut entry) => {

View file

@ -34,7 +34,7 @@ impl ByteString {
} }
/// Returns the length. /// Returns the length.
pub fn len(&self) -> uint { pub fn len(&self) -> usize {
let ByteString(ref vector) = *self; let ByteString(ref vector) = *self;
vector.len() vector.len()
} }

View file

@ -204,8 +204,8 @@ impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
no_jsmanaged_fields!(bool, f32, f64, String, Url); no_jsmanaged_fields!(bool, f32, f64, String, Url);
no_jsmanaged_fields!(uint, u8, u16, u32, u64); no_jsmanaged_fields!(usize, u8, u16, u32, u64);
no_jsmanaged_fields!(int, i8, i16, i32, i64); no_jsmanaged_fields!(isize, i8, i16, i32, i64);
no_jsmanaged_fields!(Sender<T>); no_jsmanaged_fields!(Sender<T>);
no_jsmanaged_fields!(Receiver<T>); no_jsmanaged_fields!(Receiver<T>);
no_jsmanaged_fields!(Rect<T>); no_jsmanaged_fields!(Rect<T>);

View file

@ -335,7 +335,7 @@ pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint,
/// Fails if the argument is not a DOM global. /// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) { pub fn initialize_global(global: *mut JSObject) {
let proto_array = box () let proto_array = box ()
([0 as *mut JSObject; PrototypeList::ID::Count as uint]); ([0 as *mut JSObject; PrototypeList::ID::Count as usize]);
unsafe { unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
let box_ = boxed::into_raw(proto_array); let box_ = boxed::into_raw(proto_array);
@ -460,7 +460,7 @@ pub fn get_array_index_from_id(_cx: *mut JSContext, id: jsid) -> Option<u32> {
pub fn find_enum_string_index(cx: *mut JSContext, pub fn find_enum_string_index(cx: *mut JSContext,
v: JSVal, v: JSVal,
values: &[&'static str]) values: &[&'static str])
-> Result<Option<uint>, ()> { -> Result<Option<usize>, ()> {
unsafe { unsafe {
let jsstr = JS_ValueToString(cx, v); let jsstr = JS_ValueToString(cx, v);
if jsstr.is_null() { if jsstr.is_null() {
@ -474,9 +474,9 @@ pub fn find_enum_string_index(cx: *mut JSContext,
} }
Ok(values.iter().position(|value| { Ok(values.iter().position(|value| {
value.len() == length as uint && value.len() == length as usize &&
range(0, length as uint).all(|j| { range(0, length as usize).all(|j| {
value.as_bytes()[j] as u16 == *chars.offset(j as int) value.as_bytes()[j] as u16 == *chars.offset(j as isize)
}) })
})) }))
} }

View file

@ -81,7 +81,7 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
} }
fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> { fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> {
Ok(self.data.borrow()[offset as uint .. count as uint].to_owned()) Ok(self.data.borrow()[offset as usize .. count as usize].to_owned())
} }
fn AppendData(self, arg: DOMString) -> ErrorResult { fn AppendData(self, arg: DOMString) -> ErrorResult {
@ -107,9 +107,9 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
} else { } else {
count count
}; };
let mut data = self.data.borrow()[..offset as uint].to_owned(); let mut data = self.data.borrow()[..offset as usize].to_owned();
data.push_str(arg.as_slice()); data.push_str(arg.as_slice());
data.push_str(&self.data.borrow()[(offset + count) as uint..]); data.push_str(&self.data.borrow()[(offset + count) as usize..]);
*self.data.borrow_mut() = data; *self.data.borrow_mut() = data;
// FIXME: Once we have `Range`, we should implement step7 to step11 // FIXME: Once we have `Range`, we should implement step7 to step11
Ok(()) Ok(())

View file

@ -109,17 +109,18 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
} }
fn Item(self, index: u32) -> DOMString { fn Item(self, index: u32) -> DOMString {
let index = index as usize;
let owner = self.owner.root(); let owner = self.owner.root();
let elem: JSRef<Element> = ElementCast::from_ref(owner.r()); let elem: JSRef<Element> = ElementCast::from_ref(owner.r());
let style_attribute = elem.style_attribute().borrow(); let style_attribute = elem.style_attribute().borrow();
let result = style_attribute.as_ref().and_then(|declarations| { let result = style_attribute.as_ref().and_then(|declarations| {
if index as uint > declarations.normal.len() { if index > declarations.normal.len() {
declarations.important declarations.important
.get(index as uint - declarations.normal.len()) .get(index - declarations.normal.len())
.map(|decl| format!("{:?} !important", decl)) .map(|decl| format!("{:?} !important", decl))
} else { } else {
declarations.normal declarations.normal
.get(index as uint) .get(index)
.map(|decl| format!("{:?}", decl)) .map(|decl| format!("{:?}", decl))
} }
}); });

View file

@ -13,30 +13,30 @@ use util::str::DOMString;
use std::borrow::ToOwned; use std::borrow::ToOwned;
#[repr(uint)] #[repr(u16)]
#[derive(Copy, Debug)] #[derive(Copy, Debug)]
#[jstraceable] #[jstraceable]
pub enum DOMErrorName { pub enum DOMErrorName {
IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR as uint, IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR,
HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR as uint, HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR,
WrongDocumentError = DOMExceptionConstants::WRONG_DOCUMENT_ERR as uint, WrongDocumentError = DOMExceptionConstants::WRONG_DOCUMENT_ERR,
InvalidCharacterError = DOMExceptionConstants::INVALID_CHARACTER_ERR as uint, InvalidCharacterError = DOMExceptionConstants::INVALID_CHARACTER_ERR,
NoModificationAllowedError = DOMExceptionConstants::NO_MODIFICATION_ALLOWED_ERR as uint, NoModificationAllowedError = DOMExceptionConstants::NO_MODIFICATION_ALLOWED_ERR,
NotFoundError = DOMExceptionConstants::NOT_FOUND_ERR as uint, NotFoundError = DOMExceptionConstants::NOT_FOUND_ERR,
NotSupportedError = DOMExceptionConstants::NOT_SUPPORTED_ERR as uint, NotSupportedError = DOMExceptionConstants::NOT_SUPPORTED_ERR,
InvalidStateError = DOMExceptionConstants::INVALID_STATE_ERR as uint, InvalidStateError = DOMExceptionConstants::INVALID_STATE_ERR,
SyntaxError = DOMExceptionConstants::SYNTAX_ERR as uint, SyntaxError = DOMExceptionConstants::SYNTAX_ERR,
InvalidModificationError = DOMExceptionConstants::INVALID_MODIFICATION_ERR as uint, InvalidModificationError = DOMExceptionConstants::INVALID_MODIFICATION_ERR,
NamespaceError = DOMExceptionConstants::NAMESPACE_ERR as uint, NamespaceError = DOMExceptionConstants::NAMESPACE_ERR,
InvalidAccessError = DOMExceptionConstants::INVALID_ACCESS_ERR as uint, InvalidAccessError = DOMExceptionConstants::INVALID_ACCESS_ERR,
SecurityError = DOMExceptionConstants::SECURITY_ERR as uint, SecurityError = DOMExceptionConstants::SECURITY_ERR,
NetworkError = DOMExceptionConstants::NETWORK_ERR as uint, NetworkError = DOMExceptionConstants::NETWORK_ERR,
AbortError = DOMExceptionConstants::ABORT_ERR as uint, AbortError = DOMExceptionConstants::ABORT_ERR,
URLMismatchError = DOMExceptionConstants::URL_MISMATCH_ERR as uint, URLMismatchError = DOMExceptionConstants::URL_MISMATCH_ERR,
QuotaExceededError = DOMExceptionConstants::QUOTA_EXCEEDED_ERR as uint, QuotaExceededError = DOMExceptionConstants::QUOTA_EXCEEDED_ERR,
TimeoutError = DOMExceptionConstants::TIMEOUT_ERR as uint, TimeoutError = DOMExceptionConstants::TIMEOUT_ERR,
InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR as uint, InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR,
DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR as uint, DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR,
EncodingError EncodingError
} }

View file

@ -51,7 +51,7 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
-> Fallible<Temporary<Document>> { -> Fallible<Temporary<Document>> {
let window = self.window.root(); let window = self.window.root();
let url = window.r().get_url(); let url = window.r().get_url();
let content_type = DOMParserBinding::SupportedTypeValues::strings[ty as uint].to_owned(); let content_type = DOMParserBinding::SupportedTypeValues::strings[ty as usize].to_owned();
match ty { match ty {
Text_html => { Text_html => {
let document = Document::new(window.r(), Some(url.clone()), let document = Document::new(window.r(), Some(url.clone()),

View file

@ -43,7 +43,7 @@ impl<'a> DOMRectListMethods for JSRef<'a, DOMRectList> {
fn Item(self, index: u32) -> Option<Temporary<DOMRect>> { fn Item(self, index: u32) -> Option<Temporary<DOMRect>> {
let rects = &self.rects; let rects = &self.rects;
if index < rects.len() as u32 { if index < rects.len() as u32 {
Some(Temporary::new(rects[index as uint].clone())) Some(Temporary::new(rects[index as usize].clone()))
} else { } else {
None None
} }

View file

@ -74,7 +74,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
// http://dom.spec.whatwg.org/#dom-domtokenlist-item // http://dom.spec.whatwg.org/#dom-domtokenlist-item
fn Item(self, index: u32) -> Option<DOMString> { fn Item(self, index: u32) -> Option<DOMString> {
self.attribute().root().and_then(|attr| attr.r().value().tokens().and_then(|tokens| { self.attribute().root().and_then(|attr| attr.r().value().tokens().and_then(|tokens| {
tokens.get(index as uint).map(|token| token.as_slice().to_owned()) tokens.get(index as usize).map(|token| token.as_slice().to_owned())
})) }))
} }

View file

@ -20,11 +20,12 @@ use time;
#[jstraceable] #[jstraceable]
#[derive(Copy)] #[derive(Copy)]
#[repr(u16)]
pub enum EventPhase { pub enum EventPhase {
None = EventConstants::NONE as int, None = EventConstants::NONE,
Capturing = EventConstants::CAPTURING_PHASE as int, Capturing = EventConstants::CAPTURING_PHASE,
AtTarget = EventConstants::AT_TARGET as int, AtTarget = EventConstants::AT_TARGET,
Bubbling = EventConstants::BUBBLING_PHASE as int, Bubbling = EventConstants::BUBBLING_PHASE,
} }
#[derive(PartialEq)] #[derive(PartialEq)]

View file

@ -189,16 +189,17 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
// http://dom.spec.whatwg.org/#dom-htmlcollection-item // http://dom.spec.whatwg.org/#dom-htmlcollection-item
fn Item(self, index: u32) -> Option<Temporary<Element>> { fn Item(self, index: u32) -> Option<Temporary<Element>> {
let index = index as usize;
match self.collection { match self.collection {
CollectionTypeId::Static(ref elems) => elems CollectionTypeId::Static(ref elems) => elems
.as_slice() .as_slice()
.get(index as uint) .get(index)
.map(|elem| Temporary::new(elem.clone())), .map(|elem| Temporary::new(elem.clone())),
CollectionTypeId::Live(ref root, ref filter) => { CollectionTypeId::Live(ref root, ref filter) => {
let root = root.root(); let root = root.root();
HTMLCollection::traverse(root.r()) HTMLCollection::traverse(root.r())
.filter(|element| filter.filter(*element, root.r())) .filter(|element| filter.filter(*element, root.r()))
.nth(index as uint) .nth(index)
.clone() .clone()
.map(Temporary::from_rooted) .map(Temporary::from_rooted)
} }

View file

@ -60,10 +60,10 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> {
fn Item(self, index: u32) -> Option<Temporary<Node>> { fn Item(self, index: u32) -> Option<Temporary<Node>> {
match self.list_type { match self.list_type {
_ if index >= self.Length() => None, _ if index >= self.Length() => None,
NodeListType::Simple(ref elems) => Some(Temporary::new(elems[index as uint].clone())), NodeListType::Simple(ref elems) => Some(Temporary::new(elems[index as usize].clone())),
NodeListType::Children(ref node) => { NodeListType::Children(ref node) => {
let node = node.root(); let node = node.root();
node.r().children().nth(index as uint) node.r().children().nth(index as usize)
.map(|child| Temporary::from_rooted(child)) .map(|child| Temporary::from_rooted(child))
} }
} }

View file

@ -28,7 +28,6 @@ use js::jsval::{JSVal, UndefinedValue};
use url::UrlParser; use url::UrlParser;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::Cell;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
pub type TrustedWorkerAddress = Trusted<Worker>; pub type TrustedWorkerAddress = Trusted<Worker>;
@ -36,7 +35,6 @@ pub type TrustedWorkerAddress = Trusted<Worker>;
#[dom_struct] #[dom_struct]
pub struct Worker { pub struct Worker {
eventtarget: EventTarget, eventtarget: EventTarget,
refcount: Cell<uint>,
global: GlobalField, global: GlobalField,
/// Sender to the Receiver associated with the DedicatedWorkerGlobalScope /// Sender to the Receiver associated with the DedicatedWorkerGlobalScope
/// this Worker created. /// this Worker created.
@ -47,7 +45,6 @@ impl Worker {
fn new_inherited(global: GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Worker { fn new_inherited(global: GlobalRef, sender: Sender<(TrustedWorkerAddress, ScriptMsg)>) -> Worker {
Worker { Worker {
eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker), eventtarget: EventTarget::new_inherited(EventTargetTypeId::Worker),
refcount: Cell::new(0),
global: GlobalField::from_rooted(&global), global: GlobalField::from_rooted(&global),
sender: sender, sender: sender,
} }