diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-05-05 09:11:30 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-05-05 09:11:30 -0500 |
commit | 49aed6555dbc008c1a378c5cbb303f5467232b6b (patch) | |
tree | 9146cdd7126ead59c57cacbaa04eda0f16761f65 /components/script/dom | |
parent | 7b87085c1880c60aa3be5b3ec4572a0d93fd5537 (diff) | |
parent | ef8edd4e87aeb3cc71dfd9da2f69437080f5410e (diff) | |
download | servo-49aed6555dbc008c1a378c5cbb303f5467232b6b.tar.gz servo-49aed6555dbc008c1a378c5cbb303f5467232b6b.zip |
Auto merge of #5935 - servo:rustup_2015-04-25, r=Ms2ger
r? everybody
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5935)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
25 files changed, 46 insertions, 50 deletions
diff --git a/components/script/dom/activation.rs b/components/script/dom/activation.rs index 047d3a5c4df..dbbe4689e1b 100644 --- a/components/script/dom/activation.rs +++ b/components/script/dom/activation.rs @@ -14,7 +14,7 @@ use dom::node::window_from_node; use std::borrow::ToOwned; /// Trait for elements with defined activation behavior -pub trait Activatable : Copy { +pub trait Activatable { fn as_element(&self) -> Temporary<Element>; // Is this particular instance of the element activatable? diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 5055921bb3a..089193cca43 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -56,15 +56,14 @@ use js::jsval::{UndefinedValue, NullValue, BooleanValue, Int32Value, UInt32Value use js::jsval::{StringValue, ObjectValue, ObjectOrNullValue}; use libc; +use num::Float; use std::borrow::ToOwned; use std::default; -use std::marker::MarkerTrait; -use std::num::Float; use std::slice; /// A trait to retrieve the constants necessary to check if a `JSObject` /// implements a given interface. -pub trait IDLInterface: MarkerTrait { +pub trait IDLInterface { /// Returns the prototype ID. fn get_prototype_id() -> PrototypeList::ID; /// Returns the prototype depth, i.e., the number of interfaces this diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index 70dd88c1842..fc22078360f 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -641,7 +641,6 @@ impl<T: Reflectable> Root<T> { } } -#[unsafe_destructor] impl<T: Reflectable> Drop for Root<T> { fn drop(&mut self) { self.root_list.unroot(self); diff --git a/components/script/dom/bindings/num.rs b/components/script/dom/bindings/num.rs index 353a395784b..d0ceaae89f8 100644 --- a/components/script/dom/bindings/num.rs +++ b/components/script/dom/bindings/num.rs @@ -5,7 +5,7 @@ //! The `Finite<T>` struct. use core::nonzero::Zeroable; -use std::num::Float; +use num::Float; use std::ops::Deref; /// Encapsulates the IDL restricted float type. diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 204ef93e023..046ae913b50 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -110,7 +110,6 @@ impl<T: Reflectable> Clone for Trusted<T> { } } -#[unsafe_destructor] impl<T: Reflectable> Drop for Trusted<T> { fn drop(&mut self) { let mut refcount = self.refcount.lock().unwrap(); diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 14d23920ab9..ab325ab804b 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -56,7 +56,7 @@ use script_traits::UntrustedNodeAddress; use msg::compositor_msg::ScriptListener; use msg::constellation_msg::ConstellationChan; use net_traits::image::base::Image; -use util::smallvec::{SmallVec1, SmallVec}; +use util::smallvec::SmallVec1; use util::str::{LengthOrPercentageOrAuto}; use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; @@ -64,7 +64,6 @@ use std::collections::hash_state::HashState; use std::ffi::CString; use std::hash::{Hash, Hasher}; use std::intrinsics::return_address; -use std::old_io::timer::Timer; use std::ops::{Deref, DerefMut}; use std::rc::Rc; use std::sync::Arc; @@ -252,7 +251,7 @@ no_jsmanaged_fields!(Receiver<T>); no_jsmanaged_fields!(Rect<T>); no_jsmanaged_fields!(Arc<T>); no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask, ScriptControlChan); -no_jsmanaged_fields!(Atom, Namespace, Timer); +no_jsmanaged_fields!(Atom, Namespace); no_jsmanaged_fields!(Trusted<T>); no_jsmanaged_fields!(PropertyDeclarationBlock); no_jsmanaged_fields!(HashSet<T>); @@ -444,7 +443,6 @@ impl<T: VecRootableType> RootedVec<T> { } } -#[unsafe_destructor] impl<T: VecRootableType> Drop for RootedVec<T> { fn drop(&mut self) { RootedCollectionSet::remove(self); diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 2c96fa2c0dd..55933484165 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -639,7 +639,7 @@ pub fn validate_and_extract(namespace: Option<DOMString>, qualified_name: &str) let (prefix, local_name) = if qualified_name.contains(":") { // Step 5. - let mut parts = qualified_name.splitn(1, ':'); + let mut parts = qualified_name.splitn(2, ':'); let prefix = parts.next().unwrap(); debug_assert!(!prefix.is_empty()); let local_name = parts.next().unwrap(); diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index 47d03d72082..b27a0c3e7e9 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -12,10 +12,10 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use util::str::DOMString; +use num::ToPrimitive; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cmp::{min, max}; -use std::num::ToPrimitive; #[jstraceable] pub enum BlobTypeId { diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index cd02eb18f0e..9390e4db0fb 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -36,9 +36,9 @@ use net_traits::image::base::Image; use net_traits::image_cache_task::ImageCacheChan; use png::PixelsByColorType; +use num::{Float, ToPrimitive}; use std::borrow::ToOwned; use std::cell::RefCell; -use std::num::{Float, ToPrimitive}; use std::sync::{Arc}; use std::sync::mpsc::{channel, Sender}; @@ -977,7 +977,6 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> } } -#[unsafe_destructor] impl Drop for CanvasRenderingContext2D { fn drop(&mut self) { self.renderer.send(CanvasMsg::Common(CanvasCommonMsg::Close)).unwrap(); diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 97c25e56b9c..28ecf365848 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -84,7 +84,6 @@ impl<'a> AutoWorkerReset<'a> { } } -#[unsafe_destructor] impl<'a> Drop for AutoWorkerReset<'a> { fn drop(&mut self) { *self.workerscope.worker.borrow_mut() = self.old_worker.clone(); diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 32f6a23623c..f96dd134082 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -81,6 +81,7 @@ use string_cache::{Atom, QualName}; use url::Url; use js::jsapi::JSRuntime; +use num::ToPrimitive; use std::borrow::ToOwned; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; @@ -88,7 +89,6 @@ use std::ascii::AsciiExt; use std::cell::{Cell, Ref}; use std::default::Default; use std::sync::mpsc::channel; -use std::num::ToPrimitive; use time; #[derive(PartialEq)] diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index 08cacc09be2..45c325b3a2d 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -10,7 +10,6 @@ use dom::bindings::num::Finite; use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::window::Window; use util::geometry::Au; -use std::num::Float; #[dom_struct] pub struct DOMRect { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index deb2df56b84..bc3f76079eb 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -64,6 +64,7 @@ use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_sty use style::properties::DeclaredValue::SpecifiedValue; use style::values::specified::CSSColor; use util::namespace; +use util::smallvec::VecLike; use util::str::{DOMString, LengthOrPercentageOrAuto}; use cssparser::Color; @@ -74,16 +75,14 @@ use html5ever::serialize::TraversalScope::{IncludeNode, ChildrenOnly}; use html5ever::tree_builder::{NoQuirks, LimitedQuirks, Quirks}; use selectors::matching::{matches, DeclarationBlock}; use selectors::parser::parse_author_origin_selector_list_from_str; -use selectors::smallvec::VecLike; use string_cache::{Atom, Namespace, QualName}; use url::UrlParser; use std::ascii::AsciiExt; -use std::borrow::{IntoCow, ToOwned}; +use std::borrow::{Cow, ToOwned}; use std::cell::{Ref, RefMut}; use std::default::Default; use std::mem; -use std::old_io::Writer; use std::sync::Arc; #[dom_struct] @@ -257,7 +256,7 @@ impl RawLayoutElementHelpers for Element { }; if let Some(color) = bgcolor { - hints.vec_push(from_declaration( + hints.push(from_declaration( PropertyDeclaration::BackgroundColor(SpecifiedValue( CSSColor { parsed: Color::RGBA(color), authored: None })))); } @@ -1011,9 +1010,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> { fn TagName(self) -> DOMString { let qualified_name = match self.prefix { Some(ref prefix) => { - (format!("{}:{}", &**prefix, &*self.local_name)).into_cow() + Cow::Owned(format!("{}:{}", &**prefix, &*self.local_name)) }, - None => self.local_name.into_cow() + None => Cow::Borrowed(&*self.local_name) }; if self.html_element_in_html_document() { qualified_name.to_ascii_uppercase() diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index 98410ef02ef..068c0b591a5 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -87,7 +87,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> { // FIXME(https://github.com/rust-lang/rust/issues/23338) let data = self.data.borrow(); if data.contains_key(&name) { - match data[name][0].clone() { + match data[&name][0].clone() { FormDatum::StringData(ref s) => Some(eString(s.clone())), FormDatum::FileData(ref f) => { Some(eFile(Unrooted::from_js(*f))) diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 7a13b77b986..4a46235756e 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -25,8 +25,8 @@ use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_n use dom::virtualmethods::VirtualMethods; use dom::window::WindowHelpers; +use num::ToPrimitive; use std::default::Default; -use std::num::ToPrimitive; use string_cache::Atom; use util::str::DOMString; diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index e4520f6760c..68d8c9cf3e8 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -167,10 +167,12 @@ impl HTMLCollection { fn traverse(root: JSRef<Node>) -> FilterMap<Skip<TreeIterator>, fn(Temporary<Node>) -> Option<Temporary<Element>>> { + fn to_temporary(node: Temporary<Node>) -> Option<Temporary<Element>> { + ElementCast::to_temporary(node) + } root.traverse_preorder() .skip(1) - .filter_map(ElementCast::to_temporary as - fn(Temporary<Node>) -> Option<Temporary<Element>>) + .filter_map(to_temporary as fn(Temporary<Node>) -> Option<Temporary<Element>>) } } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index f42aceced3a..ce70535de74 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -176,7 +176,7 @@ fn to_snake_case(name: DOMString) -> DOMString { for ch in name.chars() { if ch.is_uppercase() { attr_name.push('\x2d'); - attr_name.push(ch.to_lowercase()); + attr_name.extend(ch.to_lowercase()); } else { attr_name.push(ch); } diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index 34bebafb082..99dfbc853a7 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -33,7 +33,7 @@ impl ImageData { if let Some(vec) = data { let js_object_data: *mut uint8_t = JS_GetUint8ClampedArrayData(js_object, cx); - ptr::copy_nonoverlapping(js_object_data, vec.as_ptr(), vec.len()) + ptr::copy_nonoverlapping(vec.as_ptr(), js_object_data, vec.len()) } ImageData { diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 08a268678f0..ab93eddbefa 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -450,7 +450,7 @@ fn key_location(key: constellation_msg::Key) -> u32 { fn key_charcode(key: constellation_msg::Key, mods: constellation_msg::KeyModifiers) -> Option<u32> { let key = key_value(key, mods); if key.len() == 1 { - Some(key.char_at(0) as u32) + Some(key.chars().next().unwrap() as u32) } else { None } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 9143677d1e0..bf9473b9d83 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -179,7 +179,6 @@ impl NodeFlags { } } -#[unsafe_destructor] impl Drop for Node { #[allow(unsafe_code)] fn drop(&mut self) { @@ -987,8 +986,11 @@ impl<'a> NodeHelpers for JSRef<'a, Node> { } fn child_elements(self) -> ChildElementIterator { + fn to_temporary(node: Temporary<Node>) -> Option<Temporary<Element>> { + ElementCast::to_temporary(node) + } self.children() - .filter_map(ElementCast::to_temporary as fn(_) -> _) + .filter_map(to_temporary as fn(_) -> _) .peekable() } diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 545402dc4a2..09aeb01c5e4 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -84,7 +84,7 @@ impl<'a> TextEncoderMethods for JSRef<'a, TextEncoder> { let js_object: *mut JSObject = JS_NewUint8Array(cx, length); let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, cx); - ptr::copy_nonoverlapping(js_object_data, encoded.as_ptr(), length as usize); + ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize); return js_object; } } diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs index 3f4a7e6f268..1910784b0c5 100644 --- a/components/script/dom/userscripts.rs +++ b/components/script/dom/userscripts.rs @@ -28,7 +28,7 @@ pub fn load_script(head: JSRef<HTMLHeadElement>) { p.push("user-agent-js"); p } else { - PathBuf::new(path_str) + PathBuf::from(path_str) }; let mut files = read_dir(&path).ok().expect("Bad path passed to --userscripts") diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index e470dca128f..82dfc614f52 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -61,7 +61,6 @@ impl WebGLRenderingContext { } } -#[unsafe_destructor] impl Drop for WebGLRenderingContext { fn drop(&mut self) { self.renderer.send(CanvasMsg::Common(CanvasCommonMsg::Close)).unwrap(); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 70046185981..37d79625334 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -61,7 +61,6 @@ use std::collections::HashSet; use std::default::Default; use std::ffi::CString; use std::mem; -use std::num::Float; use std::rc::Rc; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::mpsc::TryRecvError::{Empty, Disconnected}; diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index d9e0f57ad8d..4e038609fef 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -56,15 +56,16 @@ use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::{RefCell, Cell}; use std::default::Default; -use std::old_io::Timer; use std::str::FromStr; use std::sync::{Mutex, Arc}; -use std::time::duration::Duration; +use std::sync::mpsc::{channel, Sender, TryRecvError}; +use std::thread::sleep_ms; use time; use url::{Url, UrlParser}; use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams; use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams::{eString, eURLSearchParams}; + pub type SendParam = StringOrURLSearchParams; #[derive(PartialEq, Copy, Clone)] @@ -140,7 +141,7 @@ pub struct XMLHttpRequest { send_flag: Cell<bool>, global: GlobalField, - timer: DOMRefCell<Timer>, + timeout_cancel: DOMRefCell<Option<Sender<()>>>, fetch_time: Cell<i64>, timeout_target: DOMRefCell<Option<Box<ScriptChan+Send>>>, generation_id: Cell<GenerationId>, @@ -174,7 +175,7 @@ impl XMLHttpRequest { upload_events: Cell::new(false), global: GlobalField::from_rooted(&global), - timer: DOMRefCell::new(Timer::new().unwrap()), + timeout_cancel: DOMRefCell::new(None), fetch_time: Cell::new(0), timeout_target: DOMRefCell::new(None), generation_id: Cell::new(GenerationId(0)), @@ -963,7 +964,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { let total = self.response_headers.borrow().get::<ContentLength>().map(|x| {**x as u64}); self.dispatch_progress_event(false, type_, len, total); } - fn set_timeout(self, timeout: u32) { + fn set_timeout(self, duration_ms: u32) { struct XHRTimeout { xhr: TrustedXHRAddress, gen_id: GenerationId, @@ -981,22 +982,23 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { // Sets up the object to timeout in a given number of milliseconds // This will cancel all previous timeouts - let oneshot = self.timer.borrow_mut() - .oneshot(Duration::milliseconds(timeout as i64)); let timeout_target = (*self.timeout_target.borrow().as_ref().unwrap()).clone(); let global = self.global.root(); let xhr = Trusted::new(global.r().get_cx(), self, global.r().script_chan()); let gen_id = self.generation_id.get(); + let (cancel_tx, cancel_rx) = channel(); + *self.timeout_cancel.borrow_mut() = Some(cancel_tx); spawn_named("XHR:Timer".to_owned(), move || { - match oneshot.recv() { - Ok(_) => { + sleep_ms(duration_ms); + match cancel_rx.try_recv() { + Err(TryRecvError::Empty) => { timeout_target.send(ScriptMsg::RunnableMsg(box XHRTimeout { xhr: xhr, gen_id: gen_id, })).unwrap(); }, - Err(_) => { - // This occurs if xhr.timeout (the sender) goes out of scope (i.e, xhr went out of scope) + Err(TryRecvError::Disconnected) | Ok(()) => { + // This occurs if xhr.timeout_cancel (the sender) goes out of scope (i.e, xhr went out of scope) // or if the oneshot timer was overwritten. The former case should not happen due to pinning. debug!("XHR timeout was overwritten or canceled") } @@ -1006,8 +1008,9 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { } fn cancel_timeout(self) { - // oneshot() closes the previous channel, canceling the timeout - self.timer.borrow_mut().oneshot(Duration::zero()); + if let Some(cancel_tx) = self.timeout_cancel.borrow_mut().take() { + let _ = cancel_tx.send(()); + } } fn text_response(self) -> DOMString { |