Upgrade to rustc 0.12.0-pre (4d2af3861 2014-09-17 15:51:11 +0000)

This commit is contained in:
Keegan McAllister 2014-09-16 13:00:18 -07:00
parent 8a7eefefd5
commit a640a7c5c3
74 changed files with 459 additions and 449 deletions

View file

@ -16,9 +16,9 @@ use std::str::StrSlice;
use time;
use time::{now, Timespec};
use ResponseHeaderCollection = http::headers::response::HeaderCollection;
use RequestHeaderCollection = http::headers::request::HeaderCollection;
use RequestHeader = http::headers::request::Header;
use http::headers::response::HeaderCollection as ResponseHeaderCollection;
use http::headers::request::HeaderCollection as RequestHeaderCollection;
use http::headers::request::Header as RequestHeader;
use http::client::{RequestWriter, NetworkStream};
use http::headers::{HeaderConvertible, HeaderEnum, HeaderValueByteIterator};
@ -146,7 +146,7 @@ impl CORSRequest {
};
let host = writer.headers.host.clone();
writer.headers = box preflight.headers.clone();
writer.headers = preflight.headers.clone();
writer.headers.host = host;
let response = match writer.read_response() {
Ok(r) => r,
@ -158,19 +158,19 @@ impl CORSRequest {
200 .. 299 => {}
_ => return error
}
cors_response.headers = *response.headers.clone();
cors_response.headers = response.headers.clone();
// Substeps 1-3 (parsing rules: http://fetch.spec.whatwg.org/#http-new-header-syntax)
fn find_header(headers: &ResponseHeaderCollection, name: &str) -> Option<String> {
headers.iter().find(|h| h.header_name().as_slice()
.eq_ignore_ascii_case(name))
.map(|h| h.header_value())
}
let methods_string = match find_header(&*response.headers, "Access-Control-Allow-Methods") {
let methods_string = match find_header(&response.headers, "Access-Control-Allow-Methods") {
Some(s) => s,
_ => return error
};
let methods = methods_string.as_slice().split(',');
let headers_string = match find_header(&*response.headers, "Access-Control-Allow-Headers") {
let headers_string = match find_header(&response.headers, "Access-Control-Allow-Headers") {
Some(s) => s,
_ => return error
};
@ -197,7 +197,7 @@ impl CORSRequest {
}
}
// Substep 7, 8
let max_age: uint = find_header(&*response.headers, "Access-Control-Max-Age")
let max_age: uint = find_header(&response.headers, "Access-Control-Max-Age")
.and_then(|h| FromStr::from_str(h.as_slice())).unwrap_or(0);
// Substep 9: Impose restrictions on max-age, if any (unimplemented)
// Substeps 10-12: Add a cache (partially implemented, XXXManishearth)

View file

@ -121,7 +121,7 @@ pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext,
unsafe {
if JS_WrapObject(cx, &mut obj) == 0 {
return ptr::mut_null();
return ptr::null_mut();
}
}

View file

@ -1757,6 +1757,7 @@ class CGAbstractMethod(CGThing):
decorators.append('#[inline(always)]')
if self.extern:
decorators.append('unsafe')
decorators.append('extern')
if self.pub:
@ -4538,7 +4539,6 @@ class CGBindingRoot(CGThing):
'dom::bindings::conversions::{Default, Empty}',
'dom::bindings::codegen::*',
'dom::bindings::codegen::Bindings::*',
'dom::bindings::codegen::RegisterBindings',
'dom::bindings::codegen::UnionTypes::*',
'dom::bindings::error::{FailureUnknown, Fallible, Error, ErrorResult}',
'dom::bindings::error::throw_dom_exception',
@ -5477,12 +5477,12 @@ class GlobalGenRoots():
}
#[inline(always)]
fn from_ref<'a, T: ${fromBound}>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: JSRef<'a, T>) -> JSRef<'a, Self> {
unsafe { derived.transmute() }
}
#[inline(always)]
fn from_borrowed_ref<'a, 'b, T: ${fromBound}>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> {
fn from_borrowed_ref<'a, 'b, T: ${fromBound}+Reflectable>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, Self> {
unsafe { derived.transmute_borrowed() }
}

View file

@ -97,7 +97,7 @@ static ERROR_FORMAT_STRING: JSErrorFormatString = JSErrorFormatString {
};
/// Callback used to throw `TypeError`s.
extern fn get_error_message(_user_ref: *mut libc::c_void,
unsafe extern fn get_error_message(_user_ref: *mut libc::c_void,
_locale: *const libc::c_char,
error_number: libc::c_uint) -> *const JSErrorFormatString
{
@ -109,6 +109,6 @@ extern fn get_error_message(_user_ref: *mut libc::c_void,
pub fn throw_type_error(cx: *mut JSContext, error: &str) {
let error = error.to_c_str();
unsafe {
JS_ReportErrorNumber(cx, Some(get_error_message), ptr::mut_null(), 0, error.as_ptr());
JS_ReportErrorNumber(cx, Some(get_error_message), ptr::null_mut(), 0, error.as_ptr());
}
}

View file

@ -255,7 +255,7 @@ impl<T> Assignable<T> for JS<T> {
}
}
impl<'a, T> Assignable<T> for JSRef<'a, T> {
impl<'a, T: Reflectable> Assignable<T> for JSRef<'a, T> {
unsafe fn get_js(&self) -> JS<T> {
self.unrooted()
}

View file

@ -26,11 +26,10 @@ use std::mem::size_of;
static JSPROXYSLOT_EXPANDO: u32 = 0;
pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
id: jsid, set: bool,
desc: *mut JSPropertyDescriptor)
-> bool {
unsafe {
pub unsafe extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
id: jsid, set: bool,
desc: *mut JSPropertyDescriptor)
-> bool {
let handler = GetProxyHandler(proxy);
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) {
return false;
@ -42,55 +41,50 @@ pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
//let proto = JS_GetPrototype(proxy);
let proto = GetObjectProto(proxy);
if proto.is_null() {
(*desc).obj = ptr::mut_null();
(*desc).obj = ptr::null_mut();
return true;
}
JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc) != 0
}
}
pub fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
pub unsafe fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
static JSMSG_GETTER_ONLY: libc::c_uint = 160;
unsafe {
//FIXME: Workaround for https://github.com/mozilla/rust/issues/13385
let setter: *const libc::c_void = mem::transmute((*desc).setter);
let setter_stub: *const libc::c_void = mem::transmute(JS_StrictPropertyStub);
if ((*desc).attrs & JSPROP_GETTER) != 0 && setter == setter_stub {
return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
Some(RUST_js_GetErrorMessage), ptr::mut_null(),
JSMSG_GETTER_ONLY) != 0;
}
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
(*desc).setter, (*desc).attrs) != 0;
//FIXME: Workaround for https://github.com/mozilla/rust/issues/13385
let setter: *const libc::c_void = mem::transmute((*desc).setter);
let setter_stub: *const libc::c_void = mem::transmute(JS_StrictPropertyStub);
if ((*desc).attrs & JSPROP_GETTER) != 0 && setter == setter_stub {
return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
Some(RUST_js_GetErrorMessage), ptr::null_mut(),
JSMSG_GETTER_ONLY) != 0;
}
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
(*desc).setter, (*desc).attrs) != 0;
}
pub extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
pub unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
desc: *mut JSPropertyDescriptor) -> bool {
defineProperty_(cx, proxy, id, desc)
}
pub extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
bp: *mut bool) -> bool {
unsafe {
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return delete_property_by_id(cx, expando, id, &mut *bp);
pub unsafe extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
bp: *mut bool) -> bool {
let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return delete_property_by_id(cx, expando, id, &mut *bp);
}
pub fn _obj_toString(cx: *mut JSContext, className: *const libc::c_char) -> *mut JSString {
@ -99,7 +93,7 @@ pub fn _obj_toString(cx: *mut JSContext, className: *const libc::c_char) -> *mut
let nchars = "[object ]".len() + name.len();
let chars: *mut jschar = JS_malloc(cx, (nchars + 1) as libc::size_t * (size_of::<jschar>() as libc::size_t)) as *mut jschar;
if chars.is_null() {
return ptr::mut_null();
return ptr::null_mut();
}
let result = format!("[object {}]", name);
@ -121,7 +115,7 @@ pub fn GetExpandoObject(obj: *mut JSObject) -> *mut JSObject {
assert!(is_dom_proxy(obj));
let val = GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
if val.is_undefined() {
ptr::mut_null()
ptr::null_mut()
} else {
val.to_object()
}
@ -133,11 +127,11 @@ pub fn EnsureExpandoObject(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObj
assert!(is_dom_proxy(obj));
let mut expando = GetExpandoObject(obj);
if expando.is_null() {
expando = JS_NewObjectWithGivenProto(cx, ptr::mut_null(),
ptr::mut_null(),
expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(),
ptr::null_mut(),
GetObjectParent(obj));
if expando.is_null() {
return ptr::mut_null();
return ptr::null_mut();
}
SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(&*expando));

View file

@ -129,7 +129,7 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject,
let dom_class = get_dom_class(obj).or_else(|_| {
if IsWrapper(obj) == 1 {
debug!("found wrapper");
obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::mut_null());
obj = UnwrapObject(obj, /* stopAtOuter = */ 0, ptr::null_mut());
if obj.is_null() {
debug!("unwrapping security wrapper failed");
Err(())
@ -421,7 +421,7 @@ fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject,
/// A throwing constructor, for those interfaces that have neither
/// `NoInterfaceObject` nor `Constructor`.
pub extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool {
pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool {
throw_type_error(cx, "Illegal constructor.");
return 0;
}
@ -488,7 +488,7 @@ impl Reflector {
/// Create an uninitialized `Reflector`.
pub fn new() -> Reflector {
Reflector {
object: Cell::new(ptr::mut_null()),
object: Cell::new(ptr::null_mut()),
}
}
}
@ -613,7 +613,7 @@ pub fn get_dictionary_property(cx: *mut JSContext,
pub fn HasPropertyOnPrototype(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> bool {
// MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler);
let mut found = false;
return !GetPropertyOnPrototype(cx, proxy, id, &mut found, ptr::mut_null()) || found;
return !GetPropertyOnPrototype(cx, proxy, id, &mut found, ptr::null_mut()) || found;
}
/// Returns whether `obj` can be converted to a callback interface per IDL.
@ -626,9 +626,9 @@ pub fn IsConvertibleToCallbackInterface(cx: *mut JSContext, obj: *mut JSObject)
/// Create a DOM global object with the given class.
pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObject {
unsafe {
let obj = JS_NewGlobalObject(cx, class, ptr::mut_null());
let obj = JS_NewGlobalObject(cx, class, ptr::null_mut());
if obj.is_null() {
return ptr::mut_null();
return ptr::null_mut();
}
with_compartment(cx, obj, || {
JS_InitStandardClasses(cx, obj);
@ -639,18 +639,14 @@ pub fn CreateDOMGlobal(cx: *mut JSContext, class: *const JSClass) -> *mut JSObje
}
/// Callback to outerize windows when wrapping.
pub extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
unsafe {
JS_ObjectToOuterObject(cx, obj)
}
pub unsafe extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
JS_ObjectToOuterObject(cx, obj)
}
/// Callback to outerize windows before wrapping.
pub extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject,
pub unsafe extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject,
obj: *mut JSObject, _flags: c_uint) -> *mut JSObject {
unsafe {
JS_ObjectToOuterObject(cx, obj)
}
JS_ObjectToOuterObject(cx, obj)
}
/// Callback to outerize windows.
@ -675,12 +671,12 @@ pub fn global_object_for_js_object(obj: *mut JSObject) -> GlobalField {
let global = GetGlobalForObjectCrossCompartment(obj);
let clasp = JS_GetClass(global);
assert!(((*clasp).flags & (JSCLASS_IS_DOMJSCLASS | JSCLASS_IS_GLOBAL)) != 0);
match FromJSValConvertible::from_jsval(ptr::mut_null(), ObjectOrNullValue(global), ()) {
match FromJSValConvertible::from_jsval(ptr::null_mut(), ObjectOrNullValue(global), ()) {
Ok(window) => return WindowField(window),
Err(_) => (),
}
match FromJSValConvertible::from_jsval(ptr::mut_null(), ObjectOrNullValue(global), ()) {
match FromJSValConvertible::from_jsval(ptr::null_mut(), ObjectOrNullValue(global), ()) {
Ok(worker) => return WorkerField(worker),
Err(_) => (),
}

View file

@ -28,7 +28,7 @@ impl BrowserContext {
let mut context = BrowserContext {
history: vec!(SessionHistoryEntry::new(document)),
active_index: 0,
window_proxy: Traceable::new(ptr::mut_null()),
window_proxy: Traceable::new(ptr::null_mut()),
};
context.create_window_proxy();
context

View file

@ -127,7 +127,7 @@ impl DedicatedWorkerGlobalScope {
assert!(JS_ReadStructuredClone(
js_context.ptr, data as *const u64, nbytes,
JS_STRUCTURED_CLONE_VERSION, &mut message,
ptr::null(), ptr::mut_null()) != 0);
ptr::null(), ptr::null_mut()) != 0);
}
MessageEvent::dispatch_jsval(target, &Worker(scope), message);
@ -152,11 +152,11 @@ impl DedicatedWorkerGlobalScope {
impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalScope> {
fn PostMessage(self, cx: *mut JSContext, message: JSVal) {
let mut data = ptr::mut_null();
let mut data = ptr::null_mut();
let mut nbytes = 0;
unsafe {
assert!(JS_WriteStructuredClone(cx, message, &mut data, &mut nbytes,
ptr::null(), ptr::mut_null()) != 0);
ptr::null(), ptr::null_mut()) != 0);
}
let ScriptChan(ref sender) = self.parent_sender;

View file

@ -830,7 +830,7 @@ pub fn get_attribute_parts<'a>(name: &'a str) -> (Option<&'a str>, &'a str) {
//FIXME: Throw for XML-invalid names
//FIXME: Throw for XMLNS-invalid names
let (prefix, local_name) = if name.contains(":") {
let mut parts = name.splitn(':', 1);
let mut parts = name.splitn(1, ':');
(Some(parts.next().unwrap()), parts.next().unwrap())
} else {
(None, name)

View file

@ -185,7 +185,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
let source: Vec<u16> = source.as_slice().utf16_units().collect();
let handler = unsafe {
JS_CompileUCFunction(cx,
ptr::mut_null(),
ptr::null_mut(),
name.as_ptr(),
nargs,
&arg_names as *const *const i8 as *mut *const i8,

View file

@ -23,7 +23,7 @@ pub trait CollectionFilter {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool;
}
impl<S: Encoder<E>, E> Encodable<S, E> for Box<CollectionFilter> {
impl<S: Encoder<E>, E> Encodable<S, E> for Box<CollectionFilter+'static> {
fn encode(&self, _s: &mut S) -> Result<(), E> {
Ok(())
}
@ -33,7 +33,7 @@ impl<S: Encoder<E>, E> Encodable<S, E> for Box<CollectionFilter> {
#[must_root]
pub enum CollectionTypeId {
Static(Vec<JS<Element>>),
Live(JS<Node>, Box<CollectionFilter>)
Live(JS<Node>, Box<CollectionFilter+'static>)
}
#[deriving(Encodable)]
@ -59,7 +59,7 @@ impl HTMLCollection {
impl HTMLCollection {
pub fn create(window: JSRef<Window>, root: JSRef<Node>,
filter: Box<CollectionFilter>) -> Temporary<HTMLCollection> {
filter: Box<CollectionFilter+'static>) -> Temporary<HTMLCollection> {
HTMLCollection::new(window, Live(JS::from_rooted(root), filter))
}

View file

@ -2023,12 +2023,12 @@ impl Reflectable for Node {
}
}
pub fn document_from_node<T: NodeBase>(derived: JSRef<T>) -> Temporary<Document> {
pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Document> {
let node: JSRef<Node> = NodeCast::from_ref(derived);
node.owner_doc()
}
pub fn window_from_node<T: NodeBase>(derived: JSRef<T>) -> Temporary<Window> {
pub fn window_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Window> {
let document = document_from_node(derived).root();
Temporary::new(document.deref().window.clone())
}

View file

@ -14,7 +14,7 @@ use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use servo_util::str::DOMString;
use encoding::all::UTF_8;
use encoding::types::{Encoding, EncodeReplace};
use encoding::types::{EncodingRef, EncodeReplace};
use std::cell::RefCell;
use std::collections::hashmap::HashMap;
@ -93,14 +93,14 @@ impl Reflectable for URLSearchParams {
}
pub trait URLSearchParamsHelpers {
fn serialize(&self, encoding: Option<&'static Encoding>) -> Vec<u8>;
fn serialize(&self, encoding: Option<EncodingRef>) -> Vec<u8>;
fn update_steps(&self);
}
impl URLSearchParamsHelpers for URLSearchParams {
fn serialize(&self, encoding: Option<&'static Encoding>) -> Vec<u8> {
fn serialize(&self, encoding: Option<EncodingRef>) -> Vec<u8> {
// http://url.spec.whatwg.org/#concept-urlencoded-serializer
fn serialize_string(value: &DOMString, encoding: &'static Encoding) -> Vec<u8> {
fn serialize_string(value: &DOMString, encoding: EncodingRef) -> Vec<u8> {
// http://url.spec.whatwg.org/#concept-urlencoded-byte-serializer
let value = value.as_slice();
@ -126,7 +126,7 @@ impl URLSearchParamsHelpers for URLSearchParams {
}
buf
}
let encoding = encoding.unwrap_or(UTF_8 as &'static Encoding);
let encoding = encoding.unwrap_or(UTF_8 as EncodingRef);
let mut buf = vec!();
let mut first_pair = true;
for (k, v) in self.data.deref().borrow().iter() {

View file

@ -138,82 +138,82 @@ pub trait VirtualMethods {
/// method call on the trait object will invoke the corresponding method on the
/// concrete type, propagating up the parent hierarchy unless otherwise
/// interrupted.
pub fn vtable_for<'a>(node: &'a JSRef<Node>) -> &'a VirtualMethods {
pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a VirtualMethods + 'a {
match node.type_id() {
ElementNodeTypeId(HTMLAnchorElementTypeId) => {
let element: &JSRef<HTMLAnchorElement> = HTMLAnchorElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLAnchorElement> = HTMLAnchorElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLAreaElementTypeId) => {
let element: &JSRef<HTMLAreaElement> = HTMLAreaElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLAreaElement> = HTMLAreaElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLBodyElementTypeId) => {
let element: &JSRef<HTMLBodyElement> = HTMLBodyElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLBodyElement> = HTMLBodyElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLButtonElementTypeId) => {
let element: &JSRef<HTMLButtonElement> = HTMLButtonElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLButtonElement> = HTMLButtonElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLCanvasElementTypeId) => {
let element: &JSRef<HTMLCanvasElement> = HTMLCanvasElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLCanvasElement> = HTMLCanvasElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLFieldSetElementTypeId) => {
let element: &JSRef<HTMLFieldSetElement> = HTMLFieldSetElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLFieldSetElement> = HTMLFieldSetElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLImageElementTypeId) => {
let element: &JSRef<HTMLImageElement> = HTMLImageElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLImageElement> = HTMLImageElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLIFrameElementTypeId) => {
let element: &JSRef<HTMLIFrameElement> = HTMLIFrameElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLIFrameElement> = HTMLIFrameElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLInputElementTypeId) => {
let element: &JSRef<HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLLinkElementTypeId) => {
let element: &JSRef<HTMLLinkElement> = HTMLLinkElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLLinkElement> = HTMLLinkElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLObjectElementTypeId) => {
let element: &JSRef<HTMLObjectElement> = HTMLObjectElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLObjectElement> = HTMLObjectElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLOptGroupElementTypeId) => {
let element: &JSRef<HTMLOptGroupElement> = HTMLOptGroupElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLOptGroupElement> = HTMLOptGroupElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLOptionElementTypeId) => {
let element: &JSRef<HTMLOptionElement> = HTMLOptionElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLOptionElement> = HTMLOptionElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLSelectElementTypeId) => {
let element: &JSRef<HTMLSelectElement> = HTMLSelectElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLSelectElement> = HTMLSelectElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLStyleElementTypeId) => {
let element: &JSRef<HTMLStyleElement> = HTMLStyleElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLStyleElement> = HTMLStyleElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(HTMLTextAreaElementTypeId) => {
let element: &JSRef<HTMLTextAreaElement> = HTMLTextAreaElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLTextAreaElement> = HTMLTextAreaElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(ElementTypeId) => {
let element: &JSRef<Element> = ElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, Element> = ElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
ElementNodeTypeId(_) => {
let element: &JSRef<HTMLElement> = HTMLElementCast::to_borrowed_ref(node).unwrap();
element as &VirtualMethods
let element: &'a JSRef<'a, HTMLElement> = HTMLElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
}
_ => {
node as &VirtualMethods
node as &'a VirtualMethods + 'a
}
}
}

View file

@ -48,6 +48,7 @@ use std::hash::{Hash, sip};
use std::io::timer::Timer;
use std::ptr;
use std::rc::Rc;
use std::time::duration::Duration;
use time;
#[deriving(PartialEq, Encodable, Eq)]
@ -85,7 +86,7 @@ pub struct Window {
pub image_cache_task: ImageCacheTask,
pub active_timers: Traceable<RefCell<HashMap<TimerId, TimerHandle>>>,
next_timer_handle: Traceable<Cell<i32>>,
pub compositor: Untraceable<Box<ScriptListener>>,
pub compositor: Untraceable<Box<ScriptListener+'static>>,
pub browser_context: Traceable<RefCell<Option<BrowserContext>>>,
pub page: Rc<Page>,
performance: Cell<Option<JS<Performance>>>,
@ -444,7 +445,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
let mut rval = NullValue();
unsafe {
JS_CallFunctionValue(cx, this_value, *data.funval,
0, ptr::mut_null(), &mut rval);
0, ptr::null_mut(), &mut rval);
}
});
@ -473,10 +474,11 @@ impl<'a> PrivateWindowHelpers for JSRef<'a, Window> {
};
spawn_named(spawn_name, proc() {
let mut tm = tm;
let duration = Duration::milliseconds(timeout as i64);
let timeout_port = if is_interval {
tm.periodic(timeout)
tm.periodic(duration)
} else {
tm.oneshot(timeout)
tm.oneshot(duration)
};
let cancel_port = cancel_port;
@ -519,7 +521,7 @@ impl Window {
page: Rc<Page>,
script_chan: ScriptChan,
control_chan: ScriptControlChan,
compositor: Box<ScriptListener>,
compositor: Box<ScriptListener+'static>,
image_cache_task: ImageCacheTask)
-> Temporary<Window> {
let win = box Window {

View file

@ -89,7 +89,7 @@ impl Worker {
assert!(JS_ReadStructuredClone(
global.root_ref().get_cx(), data as *const u64, nbytes,
JS_STRUCTURED_CLONE_VERSION, &mut message,
ptr::null(), ptr::mut_null()) != 0);
ptr::null(), ptr::null_mut()) != 0);
}
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*worker);
@ -131,11 +131,11 @@ impl Worker {
impl<'a> WorkerMethods for JSRef<'a, Worker> {
fn PostMessage(self, cx: *mut JSContext, message: JSVal) {
let mut data = ptr::mut_null();
let mut data = ptr::null_mut();
let mut nbytes = 0;
unsafe {
assert!(JS_WriteStructuredClone(cx, message, &mut data, &mut nbytes,
ptr::null(), ptr::mut_null()) != 0);
ptr::null(), ptr::null_mut()) != 0);
}
self.addref();

View file

@ -28,8 +28,8 @@ use encoding::all::UTF_8;
use encoding::label::encoding_from_whatwg_label;
use encoding::types::{DecodeReplace, Encoding, EncodingRef, EncodeReplace};
use ResponseHeaderCollection = http::headers::response::HeaderCollection;
use RequestHeaderCollection = http::headers::request::HeaderCollection;
use http::headers::response::HeaderCollection as ResponseHeaderCollection;
use http::headers::request::HeaderCollection as RequestHeaderCollection;
use http::headers::content_type::MediaType;
use http::headers::{HeaderEnum, HeaderValueByteIterator};
use http::headers::request::Header;
@ -56,6 +56,8 @@ use std::io::{BufReader, MemWriter, Timer};
use std::from_str::FromStr;
use std::path::BytesContainer;
use std::task::TaskBuilder;
use std::time::duration::Duration;
use std::num::Zero;
use time;
use url::{Url, UrlParser};
@ -538,7 +540,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
referer_url.serialize_host().map(|ref h| buf.push_str(h.as_slice()));
referer_url.port().as_ref().map(|&p| {
buf.push_str(":".as_slice());
buf.push_str(p);
buf.push_str(format!("{:u}", p).as_slice());
});
referer_url.serialize_path().map(|ref h| buf.push_str(h.as_slice()));
self.request_headers.deref().borrow_mut().referer = Some(buf);
@ -888,7 +890,8 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
fn set_timeout(self, timeout: u32) {
// Sets up the object to timeout in a given number of milliseconds
// This will cancel all previous timeouts
let oneshot = self.timer.deref().borrow_mut().oneshot(timeout as u64);
let oneshot = self.timer.deref().borrow_mut()
.oneshot(Duration::milliseconds(timeout as i64));
let addr = unsafe {
self.to_trusted() // This will increment the pin counter by one
};
@ -923,7 +926,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
self.release_once();
}
// oneshot() closes the previous channel, canceling the timeout
self.timer.deref().borrow_mut().oneshot(0);
self.timer.deref().borrow_mut().oneshot(Zero::zero());
}
fn text_response(self) -> DOMString {
let mut encoding = UTF_8 as EncodingRef;

View file

@ -33,12 +33,12 @@ extern crate time;
extern crate canvas;
extern crate script_traits;
#[phase(plugin)]
extern crate servo_macros = "macros";
extern crate servo_net = "net";
extern crate servo_util = "util";
extern crate "macros" as servo_macros;
extern crate "net" as servo_net;
extern crate "util" as servo_util;
extern crate style;
extern crate sync;
extern crate servo_msg = "msg";
extern crate "msg" as servo_msg;
extern crate url;
extern crate uuid;

View file

@ -56,7 +56,7 @@ pub struct Page {
pub layout_chan: Untraceable<LayoutChan>,
/// A handle to perform RPC calls into the layout, quickly.
layout_rpc: Untraceable<Box<LayoutRPC>>,
layout_rpc: Untraceable<Box<LayoutRPC+'static>>,
/// The port that we will use to join layout. If this is `None`, then layout is not running.
pub layout_join_port: Untraceable<RefCell<Option<Receiver<()>>>>,
@ -170,7 +170,7 @@ impl Page {
if damaged {
let frame = self.frame();
let window = frame.get_ref().window.root();
self.reflow(goal, window.control_chan.clone(), *window.compositor);
self.reflow(goal, window.control_chan.clone(), &**window.compositor);
} else {
self.avoided_reflows.set(self.avoided_reflows.get() + 1);
}
@ -182,7 +182,7 @@ impl Page {
// doing a query reflow.
self.flush_layout(ReflowForDisplay);
self.join_layout(); //FIXME: is this necessary, or is layout_rpc's mutex good enough?
let layout_rpc: &LayoutRPC = *self.layout_rpc;
let layout_rpc: &LayoutRPC = &**self.layout_rpc;
layout_rpc
}

View file

@ -163,7 +163,7 @@ pub struct ScriptTask {
/// For communicating load url messages to the constellation
constellation_chan: ConstellationChan,
/// A handle to the compositor for communicating ready state messages.
compositor: Box<ScriptListener>,
compositor: Box<ScriptListener+'static>,
/// For providing instructions to an optional devtools server.
devtools_chan: Option<DevtoolsControlChan>,
@ -243,7 +243,7 @@ impl ScriptTaskFactory for ScriptTask {
box pair.sender() as Box<Any+Send>
}
fn create<C:ScriptListener + Send>(
fn create<C:ScriptListener + Send + 'static>(
_phantom: Option<&mut ScriptTask>,
id: PipelineId,
compositor: Box<C>,
@ -284,7 +284,7 @@ impl ScriptTaskFactory for ScriptTask {
impl ScriptTask {
/// Creates a new script task.
pub fn new(id: PipelineId,
compositor: Box<ScriptListener>,
compositor: Box<ScriptListener+'static>,
layout_chan: LayoutChan,
port: Receiver<ScriptMsg>,
chan: ScriptChan,
@ -638,7 +638,7 @@ impl ScriptTask {
if page.pending_reflows.get() > 0 {
page.pending_reflows.set(0);
page.damage(MatchSelectorsDocumentDamage);
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor);
page.reflow(ReflowForDisplay, self.control_chan.clone(), &*self.compositor);
}
}
@ -718,7 +718,7 @@ impl ScriptTask {
*page.mut_url() = Some((loaded.clone(), false));
if needs_reflow {
page.damage(ContentChangedDocumentDamage);
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor);
page.reflow(ReflowForDisplay, self.control_chan.clone(), &*self.compositor);
}
return;
},
@ -879,7 +879,7 @@ impl ScriptTask {
let frame = page.frame();
if frame.is_some() {
page.damage(ReflowDocumentDamage);
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor)
page.reflow(ReflowForDisplay, self.control_chan.clone(), &*self.compositor)
}
let mut fragment_node = page.fragment_node.get();
@ -919,7 +919,7 @@ impl ScriptTask {
page.pending_reflows.set(page.pending_reflows.get() + 1);
} else {
page.damage(MatchSelectorsDocumentDamage);
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor)
page.reflow(ReflowForDisplay, self.control_chan.clone(), &*self.compositor)
}
}
}
@ -1018,7 +1018,7 @@ impl ScriptTask {
if target_compare {
if mouse_over_targets.is_some() {
page.damage(MatchSelectorsDocumentDamage);
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor);
page.reflow(ReflowForDisplay, self.control_chan.clone(), &*self.compositor);
}
*mouse_over_targets = Some(target_list);
}