auto merge of #4542 : servo/servo/pre-rustup_20141221, r=saneyuki

In particular, this contains changes to qualify enums where rust will require it, and to stop using some features that will be removed.
This commit is contained in:
bors-servo 2015-01-04 12:39:47 -07:00
commit ba8cf6b0e6
63 changed files with 445 additions and 439 deletions

View file

@ -674,7 +674,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
default = "None"
else:
assert defaultValue.type.tag() == IDLType.Tags.domstring
value = "str::from_utf8(data).unwrap().into_string()"
value = "str::from_utf8(&data).unwrap().into_string()"
if type.nullable():
value = "Some(%s)" % value

View file

@ -39,7 +39,7 @@ use geom::rect::Rect;
use html5ever::tree_builder::QuirksMode;
use hyper::header::Headers;
use hyper::method::Method;
use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSTRACE_OBJECT};
use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSGCTraceKind};
use js::jsval::JSVal;
use js::rust::Cx;
use layout_interface::{LayoutRPC, LayoutChan};
@ -106,7 +106,7 @@ pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: *mut JSObject
(*tracer).debugPrintIndex = -1;
(*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void;
debug!("tracing {}", description);
JS_CallTracer(tracer, obj as *mut libc::c_void, JSTRACE_OBJECT);
JS_CallTracer(tracer, obj as *mut libc::c_void, JSGCTraceKind::JSTRACE_OBJECT);
}
}

View file

@ -13,7 +13,8 @@ use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use canvas::canvas_paint_task::{CanvasMsg, CanvasPaintTask, ClearRect, Close, FillRect, Recreate, StrokeRect};
use canvas::canvas_paint_task::{CanvasMsg, CanvasPaintTask};
use canvas::canvas_paint_task::CanvasMsg::{ClearRect, Close, FillRect, Recreate, StrokeRect};
#[dom_struct]
pub struct CanvasRenderingContext2D {

View file

@ -1396,7 +1396,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
}
pub trait ActivationElementHelpers<'a> {
fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a>;
fn as_maybe_activatable(&'a self) -> Option<&'a (Activatable + 'a)>;
fn click_in_progress(self) -> bool;
fn set_click_in_progress(self, click: bool);
fn nearest_activable_element(self) -> Option<Temporary<Element>>;
@ -1404,12 +1404,12 @@ pub trait ActivationElementHelpers<'a> {
}
impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a> {
fn as_maybe_activatable(&'a self) -> Option<&'a (Activatable + 'a)> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap();
Some(element as &'a Activatable + 'a)
Some(element as &'a (Activatable + 'a))
},
_ => {
None

View file

@ -21,7 +21,7 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlinputelement::HTMLInputElement;
use dom::htmltextareaelement::HTMLTextAreaElement;
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
use hyper::method::Post;
use hyper::method::Method;
use servo_msg::constellation_msg::LoadData;
use servo_util::str::DOMString;
use script_task::{ScriptChan, ScriptMsg};
@ -196,7 +196,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
load_data.url.query = Some(parsed_data);
},
("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => {
load_data.method = Post;
load_data.method = Method::Post;
load_data.data = Some(parsed_data.into_bytes());
},
// https://html.spec.whatwg.org/multipage/forms.html#submit-get-action

View file

@ -22,9 +22,9 @@ use dom::virtualmethods::VirtualMethods;
use dom::window::Window;
use page::IterablePage;
use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
use servo_msg::constellation_msg::{ConstellationChan, ScriptLoadedURLInIFrameMsg};
use servo_msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan};
use servo_msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use servo_msg::constellation_msg::Msg as ConstellationMsg;
use servo_util::str::DOMString;
use std::ascii::AsciiExt;
@ -123,7 +123,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
}));
let ConstellationChan(ref chan) = page.constellation_chan;
chan.send(ScriptLoadedURLInIFrameMsg(url, page.id, subpage_id, sandboxed));
chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(url, page.id, subpage_id, sandboxed));
}
}

View file

@ -61,7 +61,7 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
// inform the image cache to load this, but don't store a
// handle.
image_cache.send(image_cache_task::Prefetch(img_url));
image_cache.send(image_cache_task::Msg::Prefetch(img_url));
}
}
}

View file

@ -69,7 +69,7 @@ impl<'a> ProcessDataURL for JSRef<'a, HTMLObjectElement> {
if is_image_data(uri.as_slice()) {
let data_url = Url::parse(uri.as_slice()).unwrap();
// Issue #84
image_cache.send(image_cache_task::Prefetch(data_url));
image_cache.send(image_cache_task::Msg::Prefetch(data_url));
}
}
_ => { }

View file

@ -145,76 +145,76 @@ 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<'a, Node>) -> &'a VirtualMethods + 'a {
pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a (VirtualMethods + 'a) {
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => {
let element: &'a JSRef<'a, HTMLAnchorElement> = HTMLAnchorElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => {
let element: &'a JSRef<'a, HTMLAreaElement> = HTMLAreaElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) => {
let element: &'a JSRef<'a, HTMLBodyElement> = HTMLBodyElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) => {
let element: &'a JSRef<'a, HTMLButtonElement> = HTMLButtonElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLCanvasElement)) => {
let element: &'a JSRef<'a, HTMLCanvasElement> = HTMLCanvasElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFieldSetElement)) => {
let element: &'a JSRef<'a, HTMLFieldSetElement> = HTMLFieldSetElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLImageElement)) => {
let element: &'a JSRef<'a, HTMLImageElement> = HTMLImageElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLIFrameElement)) => {
let element: &'a JSRef<'a, HTMLIFrameElement> = HTMLIFrameElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => {
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => {
let element: &'a JSRef<'a, HTMLLinkElement> = HTMLLinkElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLObjectElement)) => {
let element: &'a JSRef<'a, HTMLObjectElement> = HTMLObjectElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptGroupElement)) => {
let element: &'a JSRef<'a, HTMLOptGroupElement> = HTMLOptGroupElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => {
let element: &'a JSRef<'a, HTMLOptionElement> = HTMLOptionElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLScriptElement)) => {
let element: &'a JSRef<'a, HTMLScriptElement> = HTMLScriptElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) => {
let element: &'a JSRef<'a, HTMLSelectElement> = HTMLSelectElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLStyleElement)) => {
let element: &'a JSRef<'a, HTMLStyleElement> = HTMLStyleElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableElement)) => {
let element: &'a JSRef<'a, HTMLTableElement> =
HTMLTableElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLTableCellElement(
@ -224,37 +224,37 @@ pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a VirtualMethods + 'a {
HTMLTableCellElementTypeId::HTMLTableHeaderCellElement))) => {
let element: &'a JSRef<'a, HTMLTableCellElement> =
HTMLTableCellElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)) => {
let element: &'a JSRef<'a, HTMLTableRowElement> =
HTMLTableRowElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableSectionElement)) => {
let element: &'a JSRef<'a, HTMLTableSectionElement> =
HTMLTableSectionElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => {
let element: &'a JSRef<'a, HTMLTextAreaElement> = HTMLTextAreaElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTitleElement)) => {
let element: &'a JSRef<'a, HTMLTitleElement> =
HTMLTitleElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(ElementTypeId::Element) => {
let element: &'a JSRef<'a, Element> = ElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
NodeTypeId::Element(_) => {
let element: &'a JSRef<'a, HTMLElement> = HTMLElementCast::to_borrowed_ref(node).unwrap();
element as &'a VirtualMethods + 'a
element as &'a (VirtualMethods + 'a)
}
_ => {
node as &'a VirtualMethods + 'a
node as &'a (VirtualMethods + 'a)
}
}
}

View file

@ -36,13 +36,15 @@ use hyper::header::Headers;
use hyper::header::common::{Accept, ContentLength, ContentType};
use hyper::http::RawStatus;
use hyper::mime::{mod, Mime};
use hyper::method::{Method, Get, Head, Connect, Trace, Extension};
use hyper::method::Method;
use js::jsapi::{JS_ParseJSON, JSContext};
use js::jsapi::JS_ClearPendingException;
use js::jsval::{JSVal, NullValue, UndefinedValue};
use net::resource_task::{ResourceTask, ResourceCORSData, Load, LoadData, LoadResponse, Payload, Done};
use net::resource_task::{ResourceTask, ResourceCORSData, LoadData, LoadResponse};
use net::resource_task::ControlMsg::Load;
use net::resource_task::ProgressMsg::{Payload, Done};
use cors::{allow_cross_origin_request, CORSRequest, RequestMode};
use servo_util::str::DOMString;
use servo_util::task::spawn_named;
@ -173,7 +175,7 @@ impl XMLHttpRequest {
response_xml: Default::default(),
response_headers: DOMRefCell::new(Headers::new()),
request_method: DOMRefCell::new(Get),
request_method: DOMRefCell::new(Method::Get),
request_url: DOMRefCell::new(None),
request_headers: DOMRefCell::new(Headers::new()),
request_body_len: Cell::new(0),
@ -360,8 +362,8 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
// Step 2
match maybe_method {
// Step 4
Some(Connect) | Some(Trace) => Err(Security),
Some(Extension(ref t)) if t.as_slice() == "TRACK" => Err(Security),
Some(Method::Connect) | Some(Method::Trace) => Err(Security),
Some(Method::Extension(ref t)) if t.as_slice() == "TRACK" => Err(Security),
Some(_) if method.is_token() => {
*self.request_method.borrow_mut() = maybe_method.unwrap();
@ -493,7 +495,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
}
let data = match *self.request_method.borrow() {
Get | Head => None, // Step 3
Method::Get | Method::Head => None, // Step 3
_ => data
};
let extracted = data.as_ref().map(|d| d.extract());
@ -955,7 +957,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
match self.response_headers.borrow().get() {
Some(&ContentType(mime::Mime(_, _, ref params))) => {
for &(ref name, ref value) in params.iter() {
if name == &mime::Charset {
if name == &mime::Attr::Charset {
encoding = encoding_from_whatwg_label(value.to_string().as_slice()).unwrap_or(encoding);
}
}