mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.
This commit is contained in:
parent
cf616b90a2
commit
16c7060bc8
153 changed files with 2095 additions and 1298 deletions
|
@ -48,9 +48,6 @@ git = "https://github.com/servo/rust-geom"
|
|||
[dependencies.html5ever]
|
||||
git = "https://github.com/servo/html5ever"
|
||||
|
||||
[dependencies.encoding]
|
||||
git = "https://github.com/lifthrasiir/rust-encoding"
|
||||
|
||||
[dependencies.hyper]
|
||||
git = "https://github.com/servo/hyper"
|
||||
branch = "servo"
|
||||
|
@ -72,3 +69,6 @@ git = "https://github.com/servo/string-cache"
|
|||
|
||||
[dependencies.time]
|
||||
git = "https://github.com/rust-lang/time"
|
||||
|
||||
[dependencies]
|
||||
encoding = "0.2"
|
||||
|
|
|
@ -40,7 +40,7 @@ pub struct CORSRequest {
|
|||
/// http://fetch.spec.whatwg.org/#concept-request-mode
|
||||
/// This only covers some of the request modes. The
|
||||
/// `same-origin` and `no CORS` modes are unnecessary for XHR.
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[deriving(PartialEq, Copy, Clone)]
|
||||
pub enum RequestMode {
|
||||
CORS, // CORS
|
||||
ForcedPreflight // CORS-with-forced-preflight
|
||||
|
|
|
@ -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`.
|
||||
|
|
|
@ -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"),
|
||||
])
|
||||
|
||||
|
||||
|
|
|
@ -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>),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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());
|
||||
unsafe {
|
||||
JS_RemoveObjectRoot(cx, (*reflectable).rootable());
|
||||
}
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 => ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>)
|
||||
|
|
|
@ -56,6 +56,7 @@ impl HTMLIFrameElementDerived for EventTarget {
|
|||
|
||||
#[jstraceable]
|
||||
#[privatize]
|
||||
#[deriving(Copy)]
|
||||
pub struct IFrameSize {
|
||||
pipeline_id: PipelineId,
|
||||
subpage_id: SubpageId,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -38,7 +38,7 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
#[deriving(Copy, PartialEq, Show)]
|
||||
#[jstraceable]
|
||||
pub enum HTMLMediaElementTypeId {
|
||||
HTMLAudioElement,
|
||||
|
|
|
@ -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(">"),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -34,7 +34,6 @@ extern crate "plugins" as servo_plugins;
|
|||
extern crate "net" as servo_net;
|
||||
extern crate "util" as servo_util;
|
||||
extern crate style;
|
||||
extern crate sync;
|
||||
extern crate "msg" as servo_msg;
|
||||
extern crate url;
|
||||
extern crate uuid;
|
||||
|
|
|
@ -25,7 +25,7 @@ use servo_net::resource_task::{ProgressMsg, LoadResponse};
|
|||
use servo_util::task_state;
|
||||
use servo_util::task_state::IN_HTML_PARSER;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::str::MaybeOwned;
|
||||
use std::str::CowString;
|
||||
use url::Url;
|
||||
use html5ever::Attribute;
|
||||
use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText};
|
||||
|
@ -110,7 +110,7 @@ impl<'a> TreeSink<TrustedNodeAddress> for servohtmlparser::Sink {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_error(&mut self, msg: MaybeOwned<'static>) {
|
||||
fn parse_error(&mut self, msg: CowString<'static>) {
|
||||
debug!("Parse error: {}", msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, NodeCas
|
|||
use dom::bindings::conversions::FromJSValConvertible;
|
||||
use dom::bindings::conversions::StringificationBehavior;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalRootable};
|
||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable};
|
||||
use dom::bindings::js::{RootCollection, RootCollectionPtr};
|
||||
use dom::bindings::refcounted::LiveDOMReferences;
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::utils::{wrap_for_same_compartment, pre_wrap};
|
||||
|
@ -76,6 +77,7 @@ use url::Url;
|
|||
use libc;
|
||||
use libc::size_t;
|
||||
use std::any::{Any, AnyRefExt};
|
||||
use std::cell::Cell;
|
||||
use std::comm::{channel, Sender, Receiver, Select};
|
||||
use std::fmt::{mod, Show};
|
||||
use std::mem::replace;
|
||||
|
@ -83,8 +85,9 @@ use std::rc::Rc;
|
|||
use std::u32;
|
||||
use time::{Tm, strptime};
|
||||
|
||||
local_data_key!(pub StackRoots: *const RootCollection)
|
||||
thread_local!(pub static StackRoots: Cell<Option<RootCollectionPtr>> = Cell::new(None))
|
||||
|
||||
#[deriving(Copy)]
|
||||
pub enum TimerSource {
|
||||
FromWindow(PipelineId),
|
||||
FromWorker
|
||||
|
@ -158,14 +161,16 @@ pub struct StackRootTLS;
|
|||
|
||||
impl StackRootTLS {
|
||||
pub fn new(roots: &RootCollection) -> StackRootTLS {
|
||||
StackRoots.replace(Some(roots as *const RootCollection));
|
||||
StackRoots.with(|ref r| {
|
||||
r.set(Some(RootCollectionPtr(roots as *const _)))
|
||||
});
|
||||
StackRootTLS
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for StackRootTLS {
|
||||
fn drop(&mut self) {
|
||||
let _ = StackRoots.replace(None);
|
||||
StackRoots.with(|ref r| r.set(None));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@ macro_rules! sizeof_checker (
|
|||
)
|
||||
|
||||
// Update the sizes here
|
||||
sizeof_checker!(size_event_target, EventTarget, 56)
|
||||
sizeof_checker!(size_node, Node, 304)
|
||||
sizeof_checker!(size_element, Element, 448)
|
||||
sizeof_checker!(size_htmlelement, HTMLElement, 480)
|
||||
sizeof_checker!(size_div, HTMLDivElement, 480)
|
||||
sizeof_checker!(size_span, HTMLSpanElement, 480)
|
||||
sizeof_checker!(size_text, Text, 336)
|
||||
sizeof_checker!(size_characterdata, CharacterData, 336)
|
||||
sizeof_checker!(size_event_target, EventTarget, 48)
|
||||
sizeof_checker!(size_node, Node, 288)
|
||||
sizeof_checker!(size_element, Element, 432)
|
||||
sizeof_checker!(size_htmlelement, HTMLElement, 464)
|
||||
sizeof_checker!(size_div, HTMLDivElement, 464)
|
||||
sizeof_checker!(size_span, HTMLSpanElement, 464)
|
||||
sizeof_checker!(size_text, Text, 320)
|
||||
sizeof_checker!(size_characterdata, CharacterData, 320)
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::default::Default;
|
|||
use std::num::SignedInt;
|
||||
|
||||
#[jstraceable]
|
||||
#[deriving(Copy)]
|
||||
struct TextPoint {
|
||||
/// 0-based line number
|
||||
line: uint,
|
||||
|
|
|
@ -25,6 +25,7 @@ use std::time::duration::Duration;
|
|||
|
||||
#[deriving(PartialEq, Eq)]
|
||||
#[jstraceable]
|
||||
#[deriving(Copy)]
|
||||
pub struct TimerId(i32);
|
||||
|
||||
#[jstraceable]
|
||||
|
@ -67,7 +68,7 @@ impl Drop for TimerManager {
|
|||
|
||||
// Enum allowing more descriptive values for the is_interval field
|
||||
#[jstraceable]
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[deriving(PartialEq, Copy, Clone)]
|
||||
pub enum IsInterval {
|
||||
Interval,
|
||||
NonInterval,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue