Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.

This commit is contained in:
Simon Sapin 2015-04-23 00:14:02 +02:00 committed by Josh Matthews
parent 7b87085c18
commit ef8edd4e87
168 changed files with 2247 additions and 2408 deletions

View file

@ -45,9 +45,6 @@ path = "../canvas"
[dependencies.webdriver_traits]
path = "../webdriver_traits"
[dependencies.cssparser]
git = "https://github.com/servo/rust-cssparser"
[dependencies.selectors]
git = "https://github.com/servo/rust-selectors"
@ -80,3 +77,6 @@ bitflags = "*"
rustc-serialize = "*"
libc = "*"
hyper = "0.3"
cssparser = "0.3.1"
unicase = "0.1"
num = "0.1.24"

View file

@ -30,6 +30,7 @@ use hyper::header::{ContentType, Host};
use hyper::method::Method;
use hyper::status::StatusClass::Success;
use unicase::UniCase;
use url::{SchemeData, Url};
use util::task::spawn_named;
@ -185,10 +186,10 @@ impl CORSRequest {
// Step 5 - 7
let mut header_names = vec!();
for header in self.headers.iter() {
header_names.push(header.name().to_ascii_lowercase());
header_names.push(header.name().to_owned());
}
header_names.sort();
preflight.headers.set(AccessControlRequestHeaders(header_names));
preflight.headers.set(AccessControlRequestHeaders(header_names.into_iter().map(UniCase).collect()));
// Step 8 unnecessary, we don't use the request body
// Step 9, 10 unnecessary, we're writing our own fetch code
@ -446,8 +447,8 @@ fn is_simple_method(m: &Method) -> bool {
pub fn allow_cross_origin_request(req: &CORSRequest, headers: &Headers) -> bool {
//FIXME(seanmonstar): use req.headers.get::<AccessControlAllowOrigin>()
match headers.get() {
Some(&AccessControlAllowOrigin::AllowStar) => true, // Not always true, depends on credentials mode
Some(&AccessControlAllowOrigin::AllowOrigin(ref url)) =>
Some(&AccessControlAllowOrigin::Any) => true, // Not always true, depends on credentials mode
Some(&AccessControlAllowOrigin::Value(ref url)) =>
url.scheme == req.origin.scheme &&
url.host() == req.origin.host() &&
url.port() == req.origin.port(),

View file

@ -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?

View file

@ -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

View file

@ -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);

View file

@ -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.

View file

@ -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();

View file

@ -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);

View file

@ -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();

View file

@ -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 {

View file

@ -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();

View file

@ -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();

View file

@ -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)]

View file

@ -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 {

View file

@ -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()

View file

@ -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)))

View file

@ -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;

View file

@ -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>>)
}
}

View file

@ -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);
}

View file

@ -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 {

View file

@ -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
}

View file

@ -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()
}

View file

@ -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;
}
}

View file

@ -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")

View file

@ -61,7 +61,6 @@ impl WebGLRenderingContext {
}
}
#[unsafe_destructor]
impl Drop for WebGLRenderingContext {
fn drop(&mut self) {
self.renderer.send(CanvasMsg::Common(CanvasCommonMsg::Close)).unwrap();

View file

@ -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};

View file

@ -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 {

View file

@ -0,0 +1,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// A quick hack to work around the removal of [`std::old_io::timer::Timer`](
/// http://doc.rust-lang.org/1.0.0-beta/std/old_io/timer/struct.Timer.html )
use std::sync::mpsc::{channel, Receiver};
use std::thread::{spawn, sleep_ms};
pub fn oneshot(duration_ms: u32) -> Receiver<()> {
let (tx, rx) = channel();
spawn(move || {
sleep_ms(duration_ms);
let _ = tx.send(());
});
rx
}
pub fn periodic(duration_ms: u32) -> Receiver<()> {
let (tx, rx) = channel();
spawn(move || {
loop {
sleep_ms(duration_ms);
if tx.send(()).is_err() {
break
}
}
});
rx
}

View file

@ -16,7 +16,6 @@ use profile_traits::mem::{Reporter, ReportsChan};
use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress};
use std::any::Any;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::boxed::BoxAny;
use style::animation::PropertyAnimation;
use style::media_queries::MediaQueryList;
use style::stylesheets::Stylesheet;
@ -88,7 +87,7 @@ pub struct HitTestResponse(pub UntrustedNodeAddress);
pub struct MouseOverResponse(pub Vec<UntrustedNodeAddress>);
/// Why we're doing reflow.
#[derive(PartialEq, Copy, Debug)]
#[derive(PartialEq, Copy, Clone, Debug)]
pub enum ReflowGoal {
/// We're reflowing in order to send a display list to the screen.
ForDisplay,
@ -185,15 +184,15 @@ pub struct Animation {
/// A description of the property animation that is occurring.
pub property_animation: PropertyAnimation,
/// The start time of the animation, as returned by `time::precise_time_s()`.
pub start_time: f64,
pub start_time: f32,
/// The end time of the animation, as returned by `time::precise_time_s()`.
pub end_time: f64,
pub end_time: f32,
}
impl Animation {
/// Returns the duration of this animation in seconds.
#[inline]
pub fn duration(&self) -> f64 {
pub fn duration(&self) -> f32 {
self.end_time - self.start_time
}
}

View file

@ -7,13 +7,9 @@
#![feature(collections)]
#![feature(core)]
#![feature(custom_attribute)]
#![feature(old_io)]
#![feature(path)]
#![feature(plugin)]
#![feature(rustc_private)]
#![feature(std_misc)]
#![feature(unicode)]
#![feature(unsafe_destructor)]
#![deny(unsafe_code)]
#![allow(non_snake_case)]
@ -39,8 +35,9 @@ extern crate js;
extern crate libc;
extern crate msg;
extern crate net_traits;
extern crate num;
extern crate png;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;
extern crate time;
extern crate canvas;
extern crate profile_traits;
@ -49,6 +46,7 @@ extern crate selectors;
extern crate util;
#[macro_use]
extern crate style;
extern crate unicase;
extern crate url;
extern crate uuid;
extern crate string_cache;
@ -68,4 +66,5 @@ pub mod script_task;
mod timers;
pub mod textinput;
mod devtools;
mod horribly_inefficient_timers;
mod webdriver_handlers;

View file

@ -9,7 +9,6 @@ use dom::node::NodeHelpers;
use dom::window::Window;
use msg::constellation_msg::PipelineId;
use util::smallvec::SmallVec;
use std::cell::Cell;
use std::rc::Rc;
use url::Url;

View file

@ -39,13 +39,13 @@ use util::str::DOMString;
use util::task_state;
use util::task_state::IN_HTML_PARSER;
use std::borrow::Cow;
use std::old_io::{Writer, IoResult};
use std::io::{self, Write};
use url::Url;
use html5ever::Attribute;
use html5ever::serialize::{Serializable, Serializer, AttrRef};
use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{IncludeNode, ChildrenOnly};
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText};
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText, NextParserState};
use string_cache::QualName;
use hyper::header::ContentType;
@ -179,10 +179,11 @@ impl<'a> TreeSink for servohtmlparser::Sink {
script.map(|script| script.mark_already_started());
}
fn complete_script(&mut self, node: JS<Node>) {
fn complete_script(&mut self, node: JS<Node>) -> NextParserState {
let node: Root<Node> = node.root();
let script: Option<JSRef<HTMLScriptElement>> = HTMLScriptElementCast::to_ref(node.r());
script.map(|script| script.prepare());
NextParserState::Continue
}
fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) {
@ -198,8 +199,8 @@ impl<'a> TreeSink for servohtmlparser::Sink {
}
impl<'a> Serializable for JSRef<'a, Node> {
fn serialize<'wr, Wr: Writer>(&self, serializer: &mut Serializer<'wr, Wr>,
traversal_scope: TraversalScope) -> IoResult<()> {
fn serialize<'wr, Wr: Write>(&self, serializer: &mut Serializer<'wr, Wr>,
traversal_scope: TraversalScope) -> io::Result<()> {
let node = *self;
match (traversal_scope, node.type_id()) {
(_, NodeTypeId::Element(..)) => {

View file

@ -71,7 +71,6 @@ use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageCacheRes
use net_traits::storage_task::StorageTask;
use string_cache::Atom;
use util::geometry::to_frac_px;
use util::smallvec::SmallVec;
use util::str::DOMString;
use util::task::{spawn_named, spawn_named_with_send_on_failure};
use util::task_state;
@ -86,11 +85,11 @@ use js::rust::{Runtime, RtUtils};
use url::Url;
use libc;
use num::ToPrimitive;
use std::any::Any;
use std::borrow::ToOwned;
use std::cell::{Cell, RefCell};
use std::collections::HashSet;
use std::num::ToPrimitive;
use std::option::Option;
use std::ptr;
use std::rc::Rc;
@ -98,7 +97,7 @@ use std::result::Result;
use std::sync::mpsc::{channel, Sender, Receiver, Select};
use time::Tm;
use hyper::header::ContentType;
use hyper::header::{ContentType, HttpDate};
use hyper::mime::{Mime, TopLevel, SubLevel};
thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None));
@ -340,7 +339,6 @@ impl<'a> ScriptMemoryFailsafe<'a> {
}
}
#[unsafe_destructor]
impl<'a> Drop for ScriptMemoryFailsafe<'a> {
#[allow(unrooted_must_root)]
fn drop(&mut self) {
@ -1088,7 +1086,6 @@ impl ScriptTask {
self.neutered = true;
}
}
#[unsafe_destructor]
impl<'a> Drop for AutoPageRemover<'a> {
fn drop(&mut self) {
if !self.neutered {
@ -1127,7 +1124,7 @@ impl ScriptTask {
incomplete.window_size).root();
let last_modified: Option<DOMString> = response.metadata.headers.as_ref().and_then(|headers| {
headers.get().map(|&LastModified(ref tm)| dom_last_modified(tm))
headers.get().map(|&LastModified(HttpDate(ref tm))| dom_last_modified(tm))
});
let content_type = match response.metadata.content_type {
@ -1458,7 +1455,6 @@ impl<'a> AutoDOMEventMarker<'a> {
}
}
#[unsafe_destructor]
impl<'a> Drop for AutoDOMEventMarker<'a> {
fn drop(&mut self) {
let marker = TimelineMarker::new("DOMEvent".to_owned(), TracingMetadata::IntervalEnd);

View file

@ -14,7 +14,6 @@ use util::str::DOMString;
use std::borrow::ToOwned;
use std::cmp::{min, max};
use std::default::Default;
use std::num::SignedInt;
use std::sync::mpsc::channel;
#[derive(Copy, Clone, PartialEq)]
@ -310,7 +309,7 @@ impl TextInput {
},
// printable characters have single-character key values
c if c.len() == 1 => {
self.insert_char(c.char_at(0));
self.insert_char(c.chars().next().unwrap());
KeyReaction::DispatchInput
}
"Space" => {

View file

@ -11,6 +11,7 @@ use dom::bindings::utils::Reflectable;
use dom::window::ScriptHelpers;
use script_task::{ScriptChan, ScriptMsg, TimerSource};
use horribly_inefficient_timers;
use util::task::spawn_named;
use util::str::DOMString;
@ -24,8 +25,6 @@ use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender};
use std::sync::mpsc::Select;
use std::hash::{Hash, Hasher};
use std::old_io::timer::Timer;
use std::time::duration::Duration;
#[derive(PartialEq, Eq)]
#[jstraceable]
@ -74,7 +73,6 @@ pub struct TimerManager {
}
#[unsafe_destructor]
impl Drop for TimerManager {
fn drop(&mut self) {
for (_, timer_handle) in self.active_timers.borrow_mut().iter_mut() {
@ -141,13 +139,12 @@ impl TimerManager {
source: TimerSource,
script_chan: Box<ScriptChan+Send>)
-> i32 {
let timeout = cmp::max(0, timeout) as u64;
let duration_ms = cmp::max(0, timeout) as u32;
let handle = self.next_timer_handle.get();
self.next_timer_handle.set(handle + 1);
// Spawn a new timer task; it will dispatch the `ScriptMsg::FireTimer`
// to the relevant script handler that will deal with it.
let tm = Timer::new().unwrap();
let (control_chan, control_port) = channel();
let spawn_name = match source {
TimerSource::FromWindow(_) if is_interval == IsInterval::Interval => "Window:SetInterval",
@ -156,12 +153,10 @@ impl TimerManager {
TimerSource::FromWorker => "Worker:SetTimeout",
}.to_owned();
spawn_named(spawn_name, move || {
let mut tm = tm;
let duration = Duration::milliseconds(timeout as i64);
let timeout_port = if is_interval == IsInterval::Interval {
tm.periodic(duration)
horribly_inefficient_timers::periodic(duration_ms)
} else {
tm.oneshot(duration)
horribly_inefficient_timers::oneshot(duration_ms)
};
let control_port = control_port;