diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-01-02 12:45:28 +0100 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2015-01-08 09:58:46 -0500 |
commit | 16c7060bc8ff91527ae97f8a3feee5706747b9c5 (patch) | |
tree | 0cc29f2cc50c729d3a8f9521a22991fad67b9afd /components/script/dom | |
parent | cf616b90a236f88058dbad74b568b4d4379d2829 (diff) | |
download | servo-16c7060bc8ff91527ae97f8a3feee5706747b9c5.tar.gz servo-16c7060bc8ff91527ae97f8a3feee5706747b9c5.zip |
Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.
Diffstat (limited to 'components/script/dom')
24 files changed, 146 insertions, 101 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index ec6071e0700..29741117383 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -16,6 +16,7 @@ use js::jsval::{JSVal, UndefinedValue}; use std::ptr; /// The exception handling used for a call. +#[deriving(Copy)] pub enum ExceptionHandling { /// Report any exception and don't throw it to the caller code. ReportExceptions, @@ -28,7 +29,7 @@ pub enum ExceptionHandling { } /// A common base class for representing IDL callback function types. -#[deriving(Clone,PartialEq)] +#[deriving(Copy, Clone,PartialEq)] #[jstraceable] pub struct CallbackFunction { object: CallbackObject @@ -46,7 +47,7 @@ impl CallbackFunction { } /// A common base class for representing IDL callback interface types. -#[deriving(Clone,PartialEq)] +#[deriving(Copy, Clone,PartialEq)] #[jstraceable] pub struct CallbackInterface { object: CallbackObject @@ -55,7 +56,7 @@ pub struct CallbackInterface { /// A common base class for representing IDL callback function and /// callback interface types. #[allow(raw_pointer_deriving)] -#[deriving(Clone,PartialEq)] +#[deriving(Copy, Clone,PartialEq)] #[jstraceable] struct CallbackObject { /// The underlying `JSObject`. diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 82b79eb1971..4d8dd7599c5 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2763,7 +2763,7 @@ class CGEnum(CGThing): decl = """\ #[repr(uint)] -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] #[jstraceable] pub enum %s { %s @@ -4693,7 +4693,7 @@ class CGCallback(CGClass): bases=[ClassBase(baseName)], constructors=self.getConstructors(), methods=realMethods+getters+setters, - decorators="#[deriving(PartialEq,Clone)]#[jstraceable]") + decorators="#[deriving(PartialEq,Copy,Clone)]#[jstraceable]") def getConstructors(self): return [ClassConstructor( @@ -5189,8 +5189,8 @@ class GlobalGenRoots(): return CGList([ CGGeneric(AUTOGENERATED_WARNING_COMMENT), CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength), - CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq"), - CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq"), + CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq, Copy"), + CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq, Copy"), ]) diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 8079c796094..0b65fabfec0 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -26,6 +26,7 @@ use url::Url; use std::ptr; /// A freely-copyable reference to a rooted global object. +#[deriving(Copy)] pub enum GlobalRef<'a> { Window(JSRef<'a, window::Window>), Worker(JSRef<'a, WorkerGlobalScope>), diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index f7208237cc1..a0c099769f0 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -70,6 +70,15 @@ pub struct Temporary<T> { _js_ptr: *mut JSObject, } +impl<T> Clone for Temporary<T> { + fn clone(&self) -> Temporary<T> { + Temporary { + inner: self.inner, + _js_ptr: self._js_ptr, + } + } +} + impl<T> PartialEq for Temporary<T> { fn eq(&self, other: &Temporary<T>) -> bool { self.inner == other.inner @@ -92,10 +101,12 @@ impl<T: Reflectable> Temporary<T> { /// Create a stack-bounded root for this value. pub fn root(self) -> Root<T> { - let collection = StackRoots.get().unwrap(); - unsafe { - Root::new(&**collection, &self.inner) - } + StackRoots.with(|ref collection| { + let RootCollectionPtr(collection) = collection.get().unwrap(); + unsafe { + Root::new(&*collection, &self.inner) + } + }) } unsafe fn inner(&self) -> JS<T> { @@ -114,6 +125,8 @@ pub struct JS<T> { ptr: *const T } +impl<T> Copy for JS<T> {} + impl<T> PartialEq for JS<T> { #[allow(unrooted_must_root)] fn eq(&self, other: &JS<T>) -> bool { @@ -151,10 +164,12 @@ impl<T: Reflectable> JS<T> { /// Root this JS-owned value to prevent its collection as garbage. pub fn root(&self) -> Root<T> { - let collection = StackRoots.get().unwrap(); - unsafe { - Root::new(&**collection, self) - } + StackRoots.with(|ref collection| { + let RootCollectionPtr(collection) = collection.get().unwrap(); + unsafe { + Root::new(&*collection, self) + } + }) } } @@ -270,7 +285,7 @@ impl<T: Reflectable> MutNullableJS<T> { Some(inner) => inner, None => { let inner = cb(); - self.assign(Some(inner)); + self.assign(Some(inner.clone())); inner }, } @@ -450,6 +465,10 @@ pub struct RootCollection { roots: UnsafeCell<SmallVec16<*mut JSObject>>, } +pub struct RootCollectionPtr(pub *const RootCollection); + +impl Copy for RootCollectionPtr {} + impl RootCollection { /// Create an empty collection of roots pub fn new() -> RootCollection { @@ -548,6 +567,8 @@ pub struct JSRef<'a, T> { chain: ContravariantLifetime<'a>, } +impl<'a, T> Copy for JSRef<'a, T> {} + impl<'a, T> Clone for JSRef<'a, T> { fn clone(&self) -> JSRef<'a, T> { JSRef { diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 7bffda2153d..1f6149394f2 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -33,9 +33,11 @@ use js::jsapi::{JS_AddObjectRoot, JS_RemoveObjectRoot, JSContext}; use libc; use std::cell::RefCell; use std::collections::hash_map::{HashMap, Vacant, Occupied}; +use std::rc::Rc; use std::sync::{Arc, Mutex}; -local_data_key!(pub LiveReferences: LiveDOMReferences) +thread_local!(pub static LiveReferences: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None))) + /// A safe wrapper around a raw pointer to a DOM object that can be /// shared among tasks for use in asynchronous operations. The underlying @@ -55,24 +57,28 @@ impl<T: Reflectable> Trusted<T> { /// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's /// lifetime. pub fn new(cx: *mut JSContext, ptr: JSRef<T>, script_chan: Box<ScriptChan + Send>) -> Trusted<T> { - let live_references = LiveReferences.get().unwrap(); - let refcount = live_references.addref(cx, &*ptr as *const T); - Trusted { - ptr: &*ptr as *const T as *const libc::c_void, - refcount: refcount, - script_chan: script_chan, - owner_thread: (&*live_references) as *const _ as *const libc::c_void, - } + LiveReferences.with(|ref r| { + let r = r.borrow(); + let live_references = r.as_ref().unwrap(); + let refcount = live_references.addref(cx, &*ptr as *const T); + Trusted { + ptr: &*ptr as *const T as *const libc::c_void, + refcount: refcount, + script_chan: script_chan.clone(), + owner_thread: (&*live_references) as *const _ as *const libc::c_void, + } + }) } /// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on /// a different thread than the original value from which this `Trusted<T>` was /// obtained. pub fn to_temporary(&self) -> Temporary<T> { - assert!({ - let live_references = LiveReferences.get().unwrap(); + assert!(LiveReferences.with(|ref r| { + let r = r.borrow(); + let live_references = r.as_ref().unwrap(); self.owner_thread == (&*live_references) as *const _ as *const libc::c_void - }); + })); unsafe { Temporary::new(JS::from_raw(self.ptr as *const T)) } @@ -117,9 +123,11 @@ pub struct LiveDOMReferences { impl LiveDOMReferences { /// Set up the task-local data required for storing the outstanding DOM references. pub fn initialize() { - LiveReferences.replace(Some(LiveDOMReferences { - table: RefCell::new(HashMap::new()), - })); + LiveReferences.with(|ref r| { + *r.borrow_mut() = Some(LiveDOMReferences { + table: RefCell::new(HashMap::new()), + }) + }); } fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<uint>> { @@ -144,30 +152,33 @@ impl LiveDOMReferences { /// Unpin the given DOM object if its refcount is 0. pub fn cleanup(cx: *mut JSContext, raw_reflectable: *const libc::c_void) { - let live_references = LiveReferences.get().unwrap(); - let reflectable = raw_reflectable as *const Reflector; - let mut table = live_references.table.borrow_mut(); - match table.entry(raw_reflectable) { - Occupied(entry) => { - if *entry.get().lock() != 0 { - // there could have been a new reference taken since - // this message was dispatched. - return; + LiveReferences.with(|ref r| { + let r = r.borrow(); + let live_references = r.as_ref().unwrap(); + let reflectable = raw_reflectable as *const Reflector; + let mut table = live_references.table.borrow_mut(); + match table.entry(raw_reflectable) { + Occupied(entry) => { + if *entry.get().lock() != 0 { + // there could have been a new reference taken since + // this message was dispatched. + return; + } + + unsafe { + JS_RemoveObjectRoot(cx, (*reflectable).rootable()); + } + let _ = entry.take(); } - - unsafe { - JS_RemoveObjectRoot(cx, (*reflectable).rootable()); + Vacant(_) => { + // there could be a cleanup message dispatched, then a new + // pinned reference obtained and released before the message + // is processed, at which point there would be no matching + // hashtable entry. + info!("attempt to cleanup an unrecognized reflector"); } - let _ = entry.take(); - } - Vacant(_) => { - // there could be a cleanup message dispatched, then a new - // pinned reference obtained and released before the message - // is processed, at which point there would be no matching - // hashtable entry. - info!("attempt to cleanup an unrecognized reflector"); } - } + }) } } diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index ec809144374..6986ddaf344 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -129,6 +129,7 @@ pub struct NativePropertyHooks { } /// The struct that holds inheritance information for DOM object reflectors. +#[deriving(Copy)] pub struct DOMClass { /// A list of interfaces that this object implements, in order of decreasing /// derivedness. @@ -139,6 +140,7 @@ pub struct DOMClass { } /// The JSClass used for DOM object reflectors. +#[deriving(Copy)] pub struct DOMJSClass { /// The actual JSClass. pub base: js::Class, @@ -586,18 +588,18 @@ pub fn xml_name_type(name: &str) -> XMLName { 'A' ... 'Z' | '_' | 'a' ... 'z' | - '\u00C0' ... '\u00D6' | - '\u00D8' ... '\u00F6' | - '\u00F8' ... '\u02FF' | - '\u0370' ... '\u037D' | - '\u037F' ... '\u1FFF' | - '\u200C' ... '\u200D' | - '\u2070' ... '\u218F' | - '\u2C00' ... '\u2FEF' | - '\u3001' ... '\uD7FF' | - '\uF900' ... '\uFDCF' | - '\uFDF0' ... '\uFFFD' | - '\U00010000' ... '\U000EFFFF' => true, + '\u{C0}' ... '\u{D6}' | + '\u{D8}' ... '\u{F6}' | + '\u{F8}' ... '\u{2FF}' | + '\u{370}' ... '\u{37D}' | + '\u{37F}' ... '\u{1FFF}' | + '\u{200C}' ... '\u{200D}' | + '\u{2070}' ... '\u{218F}' | + '\u{2C00}' ... '\u{2FEF}' | + '\u{3001}' ... '\u{D7FF}' | + '\u{F900}' ... '\u{FDCF}' | + '\u{FDF0}' ... '\u{FFFD}' | + '\u{10000}' ... '\u{EFFFF}' => true, _ => false, } } @@ -607,9 +609,9 @@ pub fn xml_name_type(name: &str) -> XMLName { '-' | '.' | '0' ... '9' | - '\u00B7' | - '\u0300' ... '\u036F' | - '\u203F' ... '\u2040' => true, + '\u{B7}' | + '\u{300}' ... '\u{36F}' | + '\u{203F}' ... '\u{2040}' => true, _ => false, } } diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 1361d388ebe..0af98e21e81 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -12,7 +12,7 @@ use dom::bindings::utils::{Reflector, reflect_dom_object}; use servo_util::str::DOMString; #[repr(uint)] -#[deriving(Show)] +#[deriving(Copy, Show)] #[jstraceable] pub enum DOMErrorName { IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR as uint, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 7730b657215..ec43612be70 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -86,7 +86,7 @@ impl ElementDerived for EventTarget { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum ElementTypeId { HTMLElement(HTMLElementTypeId), @@ -591,7 +591,7 @@ pub trait AttributeHandlers { impl<'a> AttributeHandlers for JSRef<'a, Element> { fn get_attribute(self, namespace: Namespace, local_name: &Atom) -> Option<Temporary<Attr>> { - self.get_attributes(local_name).iter().map(|attr| attr.root()) + self.get_attributes(local_name).into_iter().map(|attr| attr.root()) .find(|attr| *attr.r().namespace() == namespace) .map(|x| Temporary::from_rooted(x.r())) } @@ -841,9 +841,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> { Some(ref prefix) => { (format!("{}:{}", prefix.as_slice(), - self.local_name.as_slice())).into_maybe_owned() + self.local_name.as_slice())).into_cow() }, - None => self.local_name.as_slice().into_maybe_owned() + None => self.local_name.as_slice().into_cow() }; if self.html_element_in_html_document() { qualified_name.as_slice().to_ascii_upper() @@ -1290,7 +1290,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> { }) } fn get_attrs(self, attr: &Atom) -> Vec<&'a str> { - self.get_attributes(attr).iter().map(|attr| attr.root()).map(|attr| { + self.get_attributes(attr).into_iter().map(|attr| attr.root()).map(|attr| { // This transmute is used to cheat the lifetime restriction. unsafe { mem::transmute(attr.r().value().as_slice()) } }).collect() diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 0bfdb15336d..deba266ee23 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -17,6 +17,7 @@ use std::default::Default; use time; #[jstraceable] +#[deriving(Copy)] pub enum EventPhase { None = EventConstants::NONE as int, Capturing = EventConstants::CAPTURING_PHASE as int, diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 4ea2807b8c7..bc78affcc6c 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -28,14 +28,14 @@ use url::Url; use std::collections::HashMap; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum ListenerPhase { Capturing, Bubbling, } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum EventTargetTypeId { Node(NodeTypeId), @@ -46,7 +46,7 @@ pub enum EventTargetTypeId { XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId) } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum EventListenerType { Additive(EventListener), @@ -62,7 +62,7 @@ impl EventListenerType { } } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] #[privatize] pub struct EventListenerEntry { diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 2c889dcb1de..472ed51c081 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -119,7 +119,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> { if recreate { let (w, h) = (self.width.get() as i32, self.height.get() as i32); match self.context.get() { - Some(ref context) => context.root().r().recreate(Size2D(w, h)), + Some(context) => context.root().r().recreate(Size2D(w, h)), None => () } } @@ -147,7 +147,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> { if recreate { let (w, h) = (self.width.get() as i32, self.height.get() as i32); match self.context.get() { - Some(ref context) => context.root().r().recreate(Size2D(w, h)), + Some(context) => context.root().r().recreate(Size2D(w, h)), None => () } } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 0d5f610965c..d60591bb390 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -156,7 +156,7 @@ fn to_snake_case(name: DOMString) -> DOMString { impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> { fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult { if name.as_slice().chars() - .skip_while(|&ch| ch != '\u002d') + .skip_while(|&ch| ch != '\u{2d}') .nth(1).map_or(false, |ch| ch as u8 - b'a' < 26) { return Err(Syntax); } @@ -204,7 +204,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum HTMLElementTypeId { HTMLElement, diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 3720e107179..33313116161 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -129,11 +129,13 @@ impl<'a> HTMLFormElementMethods for JSRef<'a, HTMLFormElement> { } } +#[deriving(Copy)] pub enum SubmittedFrom { FromFormSubmitMethod, NotFromFormSubmitMethod } +#[deriving(Copy)] pub enum ResetFrom { FromFormResetMethod, NotFromFormResetMethod @@ -396,18 +398,21 @@ pub struct FormDatum { pub value: DOMString } +#[deriving(Copy)] pub enum FormEncType { TextPlainEncoded, UrlEncoded, FormDataEncoded } +#[deriving(Copy)] pub enum FormMethod { FormGet, FormPost, FormDialog } +#[deriving(Copy)] pub enum FormSubmitter<'a> { FormElement(JSRef<'a, HTMLFormElement>), InputElement(JSRef<'a, HTMLInputElement>) diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index ab50117b776..aeb480bdfbf 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -56,6 +56,7 @@ impl HTMLIFrameElementDerived for EventTarget { #[jstraceable] #[privatize] +#[deriving(Copy)] pub struct IFrameSize { pipeline_id: PipelineId, subpage_id: SubpageId, diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 81302d02c57..85e1a214666 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -45,7 +45,7 @@ const DEFAULT_SUBMIT_VALUE: &'static str = "Submit"; const DEFAULT_RESET_VALUE: &'static str = "Reset"; #[jstraceable] -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] #[allow(dead_code)] enum InputType { InputSubmit, diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 9346436eeb7..ea8dcfa4041 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -38,7 +38,7 @@ impl HTMLMediaElement { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum HTMLMediaElementTypeId { HTMLAudioElement, diff --git a/components/script/dom/htmlserializer.rs b/components/script/dom/htmlserializer.rs index 0ff300f97f1..b4c3662fd30 100644 --- a/components/script/dom/htmlserializer.rs +++ b/components/script/dom/htmlserializer.rs @@ -156,7 +156,7 @@ fn escape(string: &str, attr_mode: bool, html: &mut String) { for c in string.chars() { match c { '&' => html.push_str("&"), - '\u00A0' => html.push_str(" "), + '\u{A0}' => html.push_str(" "), '"' if attr_mode => html.push_str("""), '<' if !attr_mode => html.push_str("<"), '>' if !attr_mode => html.push_str(">"), diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 15f19561bb6..24450399f77 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -16,7 +16,7 @@ use cssparser::RGBA; use servo_util::str::{mod, DOMString, LengthOrPercentageOrAuto}; use std::cell::Cell; -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum HTMLTableCellElementTypeId { HTMLTableDataCellElement, diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index a47c7617066..155e3cb0fa8 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -59,7 +59,7 @@ use std::default::Default; use std::iter::{FilterMap, Peekable}; use std::mem; use style::{mod, ComputedValues}; -use sync::Arc; +use std::sync::Arc; use uuid; use string_cache::QualName; @@ -121,6 +121,7 @@ impl NodeDerived for EventTarget { bitflags! { #[doc = "Flags for node items."] #[jstraceable] + #[deriving(Copy)] flags NodeFlags: u16 { #[doc = "Specifies whether this node is in a document."] const IS_IN_DOC = 0x01, @@ -180,6 +181,7 @@ impl Drop for Node { /// suppress observers flag /// http://dom.spec.whatwg.org/#concept-node-insert /// http://dom.spec.whatwg.org/#concept-node-remove +#[deriving(Copy)] enum SuppressObserver { Suppressed, Unsuppressed @@ -252,7 +254,7 @@ impl LayoutDataRef { } /// The different types of nodes. -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum NodeTypeId { DocumentType, @@ -1146,7 +1148,7 @@ impl<'a> Iterator<JSRef<'a, Node>> for NodeIterator { } /// Specifies whether children must be recursively cloned or not. -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum CloneChildrenFlag { CloneChildren, DoNotCloneChildren @@ -2175,7 +2177,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { /// and are also used in the HTML parser interface. #[allow(raw_pointer_deriving)] -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, PartialEq, Eq, Copy)] pub struct TrustedNodeAddress(pub *const c_void); pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Document> { @@ -2284,7 +2286,7 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> { .map_or(false, |attr| test(attr.r().value().as_slice())) }, style::NamespaceConstraint::Any => { - self.as_element().get_attributes(name).iter() + self.as_element().get_attributes(name).into_iter() .map(|attr| attr.root()) .any(|attr| test(attr.r().value().as_slice())) } @@ -2357,7 +2359,7 @@ impl<'a> DisabledStateHelpers for JSRef<'a, Node> { } /// A summary of the changes that happened to a node. -#[deriving(Clone, PartialEq)] +#[deriving(Copy, Clone, PartialEq)] pub enum NodeDamage { /// The node's `style` attribute changed. NodeStyleDamaged, diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 252d82acbe9..8cae9d08269 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -256,9 +256,9 @@ impl<'a> PrivateTreeWalkerHelpers<'a> for JSRef<'a, TreeWalker> { // "5. If result is FILTER_REJECT or sibling is null, // then set sibling to node's next sibling if type is next, // and node's previous sibling if type is previous." - match (result, sibling_op) { + match (result, &sibling_op) { (Ok(NodeFilterConstants::FILTER_REJECT), _) - | (_, None) => sibling_op = next_sibling(node), + | (_, &None) => sibling_op = next_sibling(node), _ => {} } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 5f4517aff3f..b237f12593b 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -114,7 +114,7 @@ pub fn base64_btoa(btoa: DOMString) -> Fallible<DOMString> { // "The btoa() method must throw an InvalidCharacterError exception if // the method's first argument contains any character whose code point // is greater than U+00FF." - if input.chars().any(|c: char| c > '\u00FF') { + if input.chars().any(|c: char| c > '\u{FF}') { Err(InvalidCharacter) } else { // "Otherwise, the user agent must convert that argument to a diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 3cec2779de9..592ead2c083 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -30,7 +30,7 @@ use std::default::Default; use std::rc::Rc; use url::{Url, UrlParser}; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum WorkerGlobalScopeTypeId { DedicatedGlobalScope, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 2dc5b91b691..d2721cc7463 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -63,7 +63,7 @@ use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams; use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams::{eString, eURLSearchParams}; pub type SendParam = StringOrURLSearchParams; -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] #[jstraceable] enum XMLHttpRequestState { Unsent = 0, @@ -90,7 +90,7 @@ impl Runnable for XHRProgressHandler { } } -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Clone, Copy)] #[jstraceable] pub struct GenerationId(uint); @@ -560,10 +560,10 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { let n = "content-type"; match data { Some(eString(_)) => - request_headers.set_raw(n, vec![join_raw("text/plain", params)]), + request_headers.set_raw(n.into_string(), vec![join_raw("text/plain", params)]), Some(eURLSearchParams(_)) => request_headers.set_raw( - n, vec![join_raw("application/x-www-form-urlencoded", params)]), + n.into_string(), vec![join_raw("application/x-www-form-urlencoded", params)]), None => () } } @@ -813,7 +813,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { // Substep 2 status.map(|RawStatus(code, reason)| { self.status.set(code); - *self.status_text.borrow_mut() = ByteString::new(format!("{}", reason).into_bytes()); + *self.status_text.borrow_mut() = ByteString::new(reason.into_bytes()); }); headers.as_ref().map(|h| *self.response_headers.borrow_mut() = h.clone()); diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index 430dd158371..f596fe8419b 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived; use dom::bindings::js::JSRef; use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId}; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum XMLHttpRequestEventTargetTypeId { XMLHttpRequest, |