mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a
This commit is contained in:
parent
26045d7fcb
commit
d1b433a3b3
160 changed files with 1427 additions and 1162 deletions
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
#![deny(missing_doc)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
//! Base classes to work with IDL callbacks.
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::trace::JSTraceable;
|
|||
use js::jsapi::{JSTracer};
|
||||
|
||||
use servo_util::task_state;
|
||||
use servo_util::task_state::{Script, InGC};
|
||||
use servo_util::task_state::{SCRIPT, IN_GC};
|
||||
|
||||
use std::cell::{Cell, UnsafeCell};
|
||||
use std::kinds::marker;
|
||||
|
@ -39,7 +39,7 @@ impl<T> DOMRefCell<T> {
|
|||
/// This succeeds even if the object is mutably borrowed,
|
||||
/// so you have to be careful in trace code!
|
||||
pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T {
|
||||
debug_assert!(task_state::get().contains(Script | InGC));
|
||||
debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
|
||||
&*self.value.get()
|
||||
}
|
||||
|
||||
|
@ -87,8 +87,8 @@ impl<T: JSTraceable> JSTraceable for DOMRefCell<T> {
|
|||
// Values [1, MAX-1] represent the number of `Ref` active
|
||||
// (will not outgrow its range since `uint` is the size of the address space)
|
||||
type BorrowFlag = uint;
|
||||
static UNUSED: BorrowFlag = 0;
|
||||
static WRITING: BorrowFlag = -1;
|
||||
const UNUSED: BorrowFlag = 0;
|
||||
const WRITING: BorrowFlag = -1;
|
||||
|
||||
impl<T> DOMRefCell<T> {
|
||||
pub fn new(value: T) -> DOMRefCell<T> {
|
||||
|
@ -108,14 +108,14 @@ impl<T> DOMRefCell<T> {
|
|||
pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
|
||||
match self.try_borrow() {
|
||||
Some(ptr) => ptr,
|
||||
None => fail!("DOMRefCell<T> already mutably borrowed")
|
||||
None => panic!("DOMRefCell<T> already mutably borrowed")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
|
||||
match self.try_borrow_mut() {
|
||||
Some(ptr) => ptr,
|
||||
None => fail!("DOMRefCell<T> already borrowed")
|
||||
None => panic!("DOMRefCell<T> already borrowed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ class CGMethodCall(CGThing):
|
|||
nativeMethodName + '_'*signatureIndex,
|
||||
static, descriptor,
|
||||
method, argConversionStartsAt)
|
||||
|
||||
|
||||
|
||||
signatures = method.signatures()
|
||||
if len(signatures) == 1:
|
||||
|
@ -203,7 +203,7 @@ class CGMethodCall(CGThing):
|
|||
"}" % (requiredArgs, methodName))
|
||||
self.cgRoot.prepend(
|
||||
CGWrapper(CGGeneric(code), pre="\n", post="\n"))
|
||||
|
||||
|
||||
return
|
||||
|
||||
# Need to find the right overload
|
||||
|
@ -277,7 +277,7 @@ class CGMethodCall(CGThing):
|
|||
s[1][distinguishingIndex].type.isNonCallbackInterface()) ]
|
||||
# There might be more than one of these; we need to check
|
||||
# which ones we unwrap to.
|
||||
|
||||
|
||||
if len(interfacesSigs) > 0:
|
||||
# The spec says that we should check for "platform objects
|
||||
# implementing an interface", but it's enough to guard on these
|
||||
|
@ -381,7 +381,7 @@ class CGMethodCall(CGThing):
|
|||
"return 0;\n" % methodName)))
|
||||
#XXXjdm Avoid unreachable statement warnings
|
||||
#overloadCGThings.append(
|
||||
# CGGeneric('fail!("We have an always-returning default case");\n'
|
||||
# CGGeneric('panic!("We have an always-returning default case");\n'
|
||||
# 'return 0;'))
|
||||
self.cgRoot = CGWrapper(CGList(overloadCGThings, "\n"),
|
||||
pre="\n")
|
||||
|
@ -686,7 +686,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
value = "Some(%s)" % value
|
||||
|
||||
default = (
|
||||
"static data: [u8, ..%s] = [ %s ];\n"
|
||||
"const data: [u8, ..%s] = [ %s ];\n"
|
||||
"%s" %
|
||||
(len(defaultValue.value) + 1,
|
||||
", ".join(["'" + char + "' as u8" for char in defaultValue.value] + ["0"]),
|
||||
|
@ -724,7 +724,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
handleInvalidEnumValueCode = exceptionCode
|
||||
else:
|
||||
handleInvalidEnumValueCode = "return 1;"
|
||||
|
||||
|
||||
template = (
|
||||
"match FindEnumStringIndex(cx, ${val}, %(values)s) {\n"
|
||||
" Err(_) => { %(exceptionCode)s },\n"
|
||||
|
@ -1146,7 +1146,7 @@ class PropertyDefiner:
|
|||
if specTerminator:
|
||||
specs.append(specTerminator)
|
||||
|
||||
return (("static %s: &'static [%s] = &[\n" +
|
||||
return (("const %s: &'static [%s] = &[\n" +
|
||||
",\n".join(specs) + "\n" +
|
||||
"];\n\n") % (name, specType))
|
||||
|
||||
|
@ -1197,9 +1197,9 @@ class MethodDefiner(PropertyDefiner):
|
|||
return (m["name"], accessor, jitinfo, m["length"], m["flags"])
|
||||
|
||||
def stringDecl(m):
|
||||
return "static %s_name: [u8, ..%i] = %s;\n" % (m["name"], len(m["name"]) + 1,
|
||||
return "const %s_name: [u8, ..%i] = %s;\n" % (m["name"], len(m["name"]) + 1,
|
||||
str_to_const_array(m["name"]))
|
||||
|
||||
|
||||
decls = ''.join([stringDecl(m) for m in array])
|
||||
return decls + self.generatePrefableArray(
|
||||
array, name,
|
||||
|
@ -1265,9 +1265,9 @@ class AttrDefiner(PropertyDefiner):
|
|||
|
||||
def stringDecl(attr):
|
||||
name = attr.identifier.name
|
||||
return "static %s_name: [u8, ..%i] = %s;\n" % (name, len(name) + 1,
|
||||
return "const %s_name: [u8, ..%i] = %s;\n" % (name, len(name) + 1,
|
||||
str_to_const_array(name))
|
||||
|
||||
|
||||
decls = ''.join([stringDecl(m) for m in array])
|
||||
|
||||
return decls + self.generatePrefableArray(
|
||||
|
@ -1296,8 +1296,8 @@ class ConstDefiner(PropertyDefiner):
|
|||
|
||||
def stringDecl(const):
|
||||
name = const.identifier.name
|
||||
return "static %s_name: &'static [u8] = &%s;\n" % (name, str_to_const_array(name))
|
||||
|
||||
return "const %s_name: &'static [u8] = &%s;\n" % (name, str_to_const_array(name))
|
||||
|
||||
decls = ''.join([stringDecl(m) for m in array])
|
||||
|
||||
return decls + self.generatePrefableArray(
|
||||
|
@ -1362,13 +1362,13 @@ class CGImports(CGWrapper):
|
|||
# CallbackMember.getArgConversions.
|
||||
'unreachable_code',
|
||||
'non_camel_case_types',
|
||||
'non_uppercase_statics',
|
||||
'unnecessary_parens',
|
||||
'non_upper_case_globals',
|
||||
'unused_parens',
|
||||
'unused_imports',
|
||||
'unused_variable',
|
||||
'unused_variables',
|
||||
'unused_unsafe',
|
||||
'unused_mut',
|
||||
'dead_assignment',
|
||||
'unused_assignments',
|
||||
'dead_code',
|
||||
]
|
||||
|
||||
|
@ -1442,7 +1442,7 @@ class CGDOMJSClass(CGThing):
|
|||
flags = "0"
|
||||
slots = "1"
|
||||
return """
|
||||
static Class_name: [u8, ..%i] = %s;
|
||||
const Class_name: [u8, ..%i] = %s;
|
||||
static Class: DOMJSClass = DOMJSClass {
|
||||
base: js::Class {
|
||||
name: &Class_name as *const u8 as *const libc::c_char,
|
||||
|
@ -1526,7 +1526,7 @@ class CGPrototypeJSClass(CGThing):
|
|||
|
||||
def define(self):
|
||||
return """
|
||||
static PrototypeClassName__: [u8, ..%s] = %s;
|
||||
const PrototypeClassName__: [u8, ..%s] = %s;
|
||||
static PrototypeClass: JSClass = JSClass {
|
||||
name: &PrototypeClassName__ as *const u8 as *const libc::c_char,
|
||||
flags: (1 & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT as uint, //JSCLASS_HAS_RESERVED_SLOTS(1)
|
||||
|
@ -1559,7 +1559,7 @@ class CGInterfaceObjectJSClass(CGThing):
|
|||
ctorname = "0 as *const u8" if not self.descriptor.interface.ctor() else CONSTRUCT_HOOK_NAME
|
||||
hasinstance = HASINSTANCE_HOOK_NAME
|
||||
return """
|
||||
static InterfaceObjectClass: JSClass = {
|
||||
const InterfaceObjectClass: JSClass = {
|
||||
%s, 0,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
|
@ -2192,7 +2192,7 @@ class CGCallGenerator(CGThing):
|
|||
call = CGGeneric(nativeMethodName)
|
||||
if static:
|
||||
call = CGWrapper(call, pre="%s::" % descriptorProvider.interface.identifier.name)
|
||||
else:
|
||||
else:
|
||||
call = CGWrapper(call, pre="%s." % object)
|
||||
call = CGList([call, CGWrapper(args, pre="(", post=")")])
|
||||
|
||||
|
@ -2348,7 +2348,7 @@ class CGCase(CGList):
|
|||
bodyList = CGList([body], "\n")
|
||||
if fallThrough:
|
||||
raise TypeError("fall through required but unsupported")
|
||||
#bodyList.append(CGGeneric('fail!("fall through unsupported"); /* Fall through */'))
|
||||
#bodyList.append(CGGeneric('panic!("fall through unsupported"); /* Fall through */'))
|
||||
self.append(CGIndenter(bodyList));
|
||||
self.append(CGGeneric("}"))
|
||||
|
||||
|
@ -2683,7 +2683,7 @@ class CGMemberJITInfo(CGThing):
|
|||
depth = self.descriptor.interface.inheritanceDepth()
|
||||
failstr = "true" if infallible else "false"
|
||||
return ("\n"
|
||||
"static %s: JSJitInfo = JSJitInfo {\n"
|
||||
"const %s: JSJitInfo = JSJitInfo {\n"
|
||||
" op: %s as *const u8,\n"
|
||||
" protoID: %s,\n"
|
||||
" depth: %s,\n"
|
||||
|
@ -2760,7 +2760,7 @@ pub enum valuelist {
|
|||
%s
|
||||
}
|
||||
|
||||
pub static strings: &'static [&'static str] = &[
|
||||
pub const strings: &'static [&'static str] = &[
|
||||
%s,
|
||||
];
|
||||
|
||||
|
@ -2806,7 +2806,7 @@ class CGConstant(CGThing):
|
|||
def stringDecl(const):
|
||||
name = const.identifier.name
|
||||
value = convertConstIDLValueToRust(const.value)
|
||||
return CGGeneric("pub static %s: %s = %s;\n" % (name, builtinNames[const.value.type.tag()], value))
|
||||
return CGGeneric("pub const %s: %s = %s;\n" % (name, builtinNames[const.value.type.tag()], value))
|
||||
|
||||
return CGIndenter(CGList(stringDecl(m) for m in self.constants)).define()
|
||||
|
||||
|
@ -3889,7 +3889,7 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
|
|||
return call.define() + """
|
||||
|
||||
JSString* jsresult;
|
||||
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
|
||||
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
|
||||
|
||||
return """let s = "%s".to_c_str();
|
||||
_obj_toString(cx, s.as_ptr())""" % self.descriptor.name
|
||||
|
@ -5166,7 +5166,7 @@ class CallbackMember(CGNativeMember):
|
|||
if arg.optional and not arg.defaultValue:
|
||||
argval += ".clone().unwrap()"
|
||||
|
||||
conversion = wrapForType("*argv.get_mut(%s)" % jsvalIndex,
|
||||
conversion = wrapForType("argv[%s]" % jsvalIndex,
|
||||
result=argval,
|
||||
successCode="continue;" if arg.variadic else "break;")
|
||||
if arg.variadic:
|
||||
|
@ -5183,7 +5183,7 @@ class CallbackMember(CGNativeMember):
|
|||
" // This is our current trailing argument; reduce argc\n"
|
||||
" argc -= 1;\n"
|
||||
"} else {\n"
|
||||
" *argv.get_mut(%d) = UndefinedValue();\n"
|
||||
" argv[%d] = UndefinedValue();\n"
|
||||
"}" % (i+1, i))
|
||||
return conversion
|
||||
|
||||
|
@ -5397,7 +5397,7 @@ class GlobalGenRoots():
|
|||
|
||||
return CGList([
|
||||
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
|
||||
CGGeneric("pub static MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
|
||||
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
|
||||
CGNamespacedEnum('id', 'ID', protos, [0], deriving="PartialEq"),
|
||||
CGNamespacedEnum('proxies', 'Proxy', proxies, [0], deriving="PartialEq"),
|
||||
])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
#![deny(missing_doc)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
//! Conversions of Rust values to and from `JSVal`.
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl ToJSValConvertible for JSVal {
|
|||
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
|
||||
let mut value = *self;
|
||||
if unsafe { JS_WrapValue(cx, &mut value) } == 0 {
|
||||
fail!("JS_WrapValue failed.");
|
||||
panic!("JS_WrapValue failed.");
|
||||
}
|
||||
value
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ impl ToJSValConvertible for DOMString {
|
|||
let string_utf16: Vec<u16> = self.as_slice().utf16_units().collect();
|
||||
let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr(), string_utf16.len() as libc::size_t);
|
||||
if jsstr.is_null() {
|
||||
fail!("JS_NewUCStringCopyN failed");
|
||||
panic!("JS_NewUCStringCopyN failed");
|
||||
}
|
||||
StringValue(&*jsstr)
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ impl ToJSValConvertible for ByteString {
|
|||
let jsstr = JS_NewStringCopyN(cx, slice.as_ptr() as *const libc::c_char,
|
||||
slice.len() as libc::size_t);
|
||||
if jsstr.is_null() {
|
||||
fail!("JS_NewStringCopyN failed");
|
||||
panic!("JS_NewStringCopyN failed");
|
||||
}
|
||||
StringValue(&*jsstr)
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ impl ToJSValConvertible for Reflector {
|
|||
assert!(obj.is_not_null());
|
||||
let mut value = ObjectValue(unsafe { &*obj });
|
||||
if unsafe { JS_WrapValue(cx, &mut value) } == 0 {
|
||||
fail!("JS_WrapValue failed.");
|
||||
panic!("JS_WrapValue failed.");
|
||||
}
|
||||
value
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ impl<'a> GlobalRef<'a> {
|
|||
pub fn as_window<'b>(&'b self) -> JSRef<'b, window::Window> {
|
||||
match *self {
|
||||
Window(window) => window,
|
||||
Worker(_) => fail!("expected a Window scope"),
|
||||
Worker(_) => panic!("expected a Window scope"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,6 @@ pub fn global_object_for_js_object(obj: *mut JSObject) -> GlobalField {
|
|||
Err(_) => (),
|
||||
}
|
||||
|
||||
fail!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
|
||||
panic!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ impl<T: Reflectable> Temporary<T> {
|
|||
pub fn root<'a, 'b>(self) -> Root<'a, 'b, T> {
|
||||
let collection = StackRoots.get().unwrap();
|
||||
unsafe {
|
||||
(**collection).new_root(&self.inner)
|
||||
Root::new(&**collection, &self.inner)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ impl<T: Reflectable> JS<T> {
|
|||
pub fn root<'a, 'b>(&self) -> Root<'a, 'b, T> {
|
||||
let collection = StackRoots.get().unwrap();
|
||||
unsafe {
|
||||
(**collection).new_root(self)
|
||||
Root::new(&**collection, self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -431,18 +431,12 @@ impl RootCollection {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new stack-bounded root that will not outlive this collection
|
||||
#[allow(unrooted_must_root)]
|
||||
fn new_root<'b, 'a: 'b, T: Reflectable>(&'a self, unrooted: &JS<T>) -> Root<'a, 'b, T> {
|
||||
Root::new(self, unrooted)
|
||||
}
|
||||
|
||||
/// Track a stack-based root to ensure LIFO root ordering
|
||||
fn root<'a, 'b, T: Reflectable>(&self, untracked: &Root<'a, 'b, T>) {
|
||||
unsafe {
|
||||
let roots = self.roots.get();
|
||||
(*roots).push(untracked.js_ptr);
|
||||
debug!(" rooting {:?}", untracked.js_ptr);
|
||||
debug!(" rooting {}", untracked.js_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +444,7 @@ impl RootCollection {
|
|||
fn unroot<'a, 'b, T: Reflectable>(&self, rooted: &Root<'a, 'b, T>) {
|
||||
unsafe {
|
||||
let roots = self.roots.get();
|
||||
debug!("unrooting {:?} (expecting {:?}",
|
||||
debug!("unrooting {} (expecting {}",
|
||||
(*roots).as_slice().last().unwrap(),
|
||||
rooted.js_ptr);
|
||||
assert!(*(*roots).as_slice().last().unwrap() == rooted.js_ptr);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
use std::from_str::FromStr;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::path::BytesContainer;
|
||||
use std::str;
|
||||
|
||||
/// Encapsulates the IDL `ByteString` type.
|
||||
|
@ -67,7 +66,7 @@ impl ByteString {
|
|||
vec.iter().all(|&x| {
|
||||
// http://tools.ietf.org/html/rfc2616#section-2.2
|
||||
match x {
|
||||
0..31 | 127 => false, // CTLs
|
||||
0...31 | 127 => false, // CTLs
|
||||
40 | 41 | 60 | 62 | 64 |
|
||||
44 | 59 | 58 | 92 | 34 |
|
||||
47 | 91 | 93 | 63 | 61 |
|
||||
|
@ -132,7 +131,7 @@ impl ByteString {
|
|||
false
|
||||
}
|
||||
},
|
||||
0..31 | 127 => false, // CTLs
|
||||
0...31 | 127 => false, // CTLs
|
||||
x if x > 127 => false, // non ASCII
|
||||
_ if prev == Other || prev == SPHT => {
|
||||
prev = Other;
|
||||
|
@ -153,6 +152,6 @@ impl Hash for ByteString {
|
|||
|
||||
impl FromStr for ByteString {
|
||||
fn from_str(s: &str) -> Option<ByteString> {
|
||||
Some(ByteString::new(s.container_into_owned_bytes()))
|
||||
Some(ByteString::new(s.to_string().into_bytes()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
#![deny(missing_doc)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
//! Utilities for tracing JS-managed values.
|
||||
//!
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
#![deny(missing_doc)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
//! Various utilities to glue JavaScript and the DOM implementation together.
|
||||
|
||||
|
@ -19,7 +19,6 @@ use libc;
|
|||
use libc::c_uint;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::cmp::PartialEq;
|
||||
use std::ptr;
|
||||
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
|
||||
use js::glue::{UnwrapObject, GetProxyHandlerExtra};
|
||||
|
@ -167,23 +166,23 @@ pub unsafe fn squirrel_away_unique<T>(x: Box<T>) -> *const T {
|
|||
/// stored for non-proxy bindings.
|
||||
// We use slot 0 for holding the raw object. This is safe for both
|
||||
// globals and non-globals.
|
||||
pub static DOM_OBJECT_SLOT: uint = 0;
|
||||
static DOM_PROXY_OBJECT_SLOT: uint = js::JSSLOT_PROXY_PRIVATE as uint;
|
||||
pub const DOM_OBJECT_SLOT: uint = 0;
|
||||
const DOM_PROXY_OBJECT_SLOT: uint = js::JSSLOT_PROXY_PRIVATE as uint;
|
||||
|
||||
// NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
|
||||
// LSetDOMProperty. Those constants need to be changed accordingly if this value
|
||||
// changes.
|
||||
static DOM_PROTO_INSTANCE_CLASS_SLOT: u32 = 0;
|
||||
const DOM_PROTO_INSTANCE_CLASS_SLOT: u32 = 0;
|
||||
|
||||
/// The index of the slot that contains a reference to the ProtoOrIfaceArray.
|
||||
// All DOM globals must have a slot at DOM_PROTOTYPE_SLOT.
|
||||
pub static DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT;
|
||||
pub const DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT;
|
||||
|
||||
/// The flag set on the `JSClass`es for DOM global objects.
|
||||
// NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
|
||||
// LSetDOMProperty. Those constants need to be changed accordingly if this value
|
||||
// changes.
|
||||
pub static JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1;
|
||||
pub const JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1;
|
||||
|
||||
/// Representation of an IDL constant value.
|
||||
#[deriving(Clone)]
|
||||
|
@ -677,7 +676,7 @@ pub unsafe fn delete_property_by_id(cx: *mut JSContext, object: *mut JSObject,
|
|||
|
||||
/// Results of `xml_name_type`.
|
||||
#[deriving(PartialEq)]
|
||||
#[allow(missing_doc)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum XMLName {
|
||||
QName,
|
||||
Name,
|
||||
|
@ -690,21 +689,21 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
fn is_valid_start(c: char) -> bool {
|
||||
match c {
|
||||
':' |
|
||||
'A' .. 'Z' |
|
||||
'A' ... 'Z' |
|
||||
'_' |
|
||||
'a' .. 'z' |
|
||||
'\xC0' .. '\xD6' |
|
||||
'\xD8' .. '\xF6' |
|
||||
'\xF8' .. '\u02FF' |
|
||||
'\u0370' .. '\u037D' |
|
||||
'\u037F' .. '\u1FFF' |
|
||||
'\u200C' .. '\u200D' |
|
||||
'\u2070' .. '\u218F' |
|
||||
'\u2C00' .. '\u2FEF' |
|
||||
'\u3001' .. '\uD7FF' |
|
||||
'\uF900' .. '\uFDCF' |
|
||||
'\uFDF0' .. '\uFFFD' |
|
||||
'\U00010000' .. '\U000EFFFF' => true,
|
||||
'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,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -713,10 +712,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
is_valid_start(c) || match c {
|
||||
'-' |
|
||||
'.' |
|
||||
'0' .. '9' |
|
||||
'\xB7' |
|
||||
'\u0300' .. '\u036F' |
|
||||
'\u203F' .. '\u2040' => true,
|
||||
'0' ... '9' |
|
||||
'\u00B7' |
|
||||
'\u0300' ... '\u036F' |
|
||||
'\u203F' ... '\u2040' => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ impl SessionHistoryEntry {
|
|||
}
|
||||
}
|
||||
|
||||
static proxy_handler: ProxyTraps = ProxyTraps {
|
||||
static PROXY_HANDLER: ProxyTraps = ProxyTraps {
|
||||
getPropertyDescriptor: None,
|
||||
getOwnPropertyDescriptor: None,
|
||||
defineProperty: None,
|
||||
|
@ -114,6 +114,6 @@ static proxy_handler: ProxyTraps = ProxyTraps {
|
|||
|
||||
pub fn new_window_proxy_handler() -> WindowProxyHandler {
|
||||
unsafe {
|
||||
WindowProxyHandler(CreateWrapperProxyHandler(&proxy_handler))
|
||||
WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use script_task::StackRootTLS;
|
|||
use servo_net::resource_task::{ResourceTask, load_whole_resource};
|
||||
use servo_util::task::spawn_named_native;
|
||||
use servo_util::task_state;
|
||||
use servo_util::task_state::{Script, InWorker};
|
||||
use servo_util::task_state::{SCRIPT, IN_WORKER};
|
||||
|
||||
use js::glue::JS_STRUCTURED_CLONE_VERSION;
|
||||
use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_WriteStructuredClone, JS_ClearPendingException};
|
||||
|
@ -89,7 +89,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
receiver: Receiver<ScriptMsg>) {
|
||||
spawn_named_native(format!("WebWorker for {}", worker_url.serialize()), proc() {
|
||||
|
||||
task_state::initialize(Script | InWorker);
|
||||
task_state::initialize(SCRIPT | IN_WORKER);
|
||||
|
||||
let roots = RootCollection::new();
|
||||
let _stack_roots_tls = StackRootTLS::new(&roots);
|
||||
|
@ -148,7 +148,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
Ok(FireTimerMsg(FromWorker, timer_id)) => {
|
||||
scope.handle_fire_timer(timer_id, js_context.ptr);
|
||||
}
|
||||
Ok(_) => fail!("Unexpected message"),
|
||||
Ok(_) => panic!("Unexpected message"),
|
||||
Err(_) => break,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,9 @@ use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
|||
use string_cache::{Atom, QualName};
|
||||
use url::Url;
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Vacant, Occupied};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
use time;
|
||||
|
@ -233,7 +234,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
to_unregister: JSRef<Element>,
|
||||
id: Atom) {
|
||||
let mut idmap = self.idmap.borrow_mut();
|
||||
let is_empty = match idmap.find_mut(&id) {
|
||||
let is_empty = match idmap.get_mut(&id) {
|
||||
None => false,
|
||||
Some(elements) => {
|
||||
let position = elements.iter()
|
||||
|
@ -262,29 +263,35 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
let mut idmap = self.idmap.borrow_mut();
|
||||
|
||||
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
|
||||
idmap.find_with_or_insert_with(id, element,
|
||||
|_key, elements, element| {
|
||||
|
||||
match idmap.entry(id) {
|
||||
Vacant(entry) => {
|
||||
entry.set(vec!(element.unrooted()));
|
||||
}
|
||||
Occupied(entry) => {
|
||||
let elements = entry.into_mut();
|
||||
|
||||
let new_node: JSRef<Node> = NodeCast::from_ref(element);
|
||||
let mut head : uint = 0u;
|
||||
let mut head: uint = 0u;
|
||||
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
||||
for node in root.traverse_preorder() {
|
||||
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
|
||||
match elem {
|
||||
None => {},
|
||||
Some(elem) => {
|
||||
if *(*elements)[head].root() == elem {
|
||||
head = head + 1;
|
||||
head += 1;
|
||||
}
|
||||
if new_node == node || head == elements.len() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
elements.insert_unrooted(head, &element);
|
||||
},
|
||||
|_key, element| vec![element.unrooted()]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_anchor_href(self, href: DOMString) {
|
||||
|
@ -514,7 +521,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||
fn GetElementById(self, id: DOMString) -> Option<Temporary<Element>> {
|
||||
let id = Atom::from_slice(id.as_slice());
|
||||
match self.idmap.borrow().find(&id) {
|
||||
match self.idmap.borrow().get(&id) {
|
||||
None => None,
|
||||
Some(ref elements) => Some(Temporary::new((*elements)[0].clone())),
|
||||
}
|
||||
|
@ -660,7 +667,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
fn LastModified(self) -> DOMString {
|
||||
match *self.last_modified.borrow() {
|
||||
Some(ref t) => t.clone(),
|
||||
None => time::now().strftime("%m/%d/%Y %H:%M:%S"),
|
||||
None => time::now().strftime("%m/%d/%Y %H:%M:%S").unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ impl DOMErrorName {
|
|||
error::Abort => AbortError,
|
||||
error::Timeout => TimeoutError,
|
||||
error::DataClone => DataCloneError,
|
||||
error::FailureUnknown => fail!(),
|
||||
error::FailureUnknown => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::js::{JSRef, Temporary};
|
|||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct DOMStringMap {
|
||||
|
@ -46,7 +46,7 @@ impl<'a> DOMStringMapMethods for JSRef<'a, DOMStringMap> {
|
|||
}
|
||||
|
||||
fn NamedGetter(self, name: DOMString, found: &mut bool) -> DOMString {
|
||||
match self.map.borrow().find(&name) {
|
||||
match self.map.borrow().get(&name) {
|
||||
Some(value) => {
|
||||
*found = true;
|
||||
value.clone()
|
||||
|
|
|
@ -40,7 +40,7 @@ use style;
|
|||
use servo_util::namespace;
|
||||
use servo_util::str::{DOMString, LengthOrPercentageOrAuto};
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::default::Default;
|
||||
use std::mem;
|
||||
use string_cache::{Atom, Namespace, QualName};
|
||||
|
@ -311,7 +311,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
match length_attribute {
|
||||
WidthLengthAttribute => {
|
||||
if !self.is_htmltablecellelement() {
|
||||
fail!("I'm not a table cell!")
|
||||
panic!("I'm not a table cell!")
|
||||
}
|
||||
let this: &HTMLTableCellElement = mem::transmute(self);
|
||||
this.get_width()
|
||||
|
@ -326,7 +326,7 @@ impl RawLayoutElementHelpers for Element {
|
|||
match integer_attribute {
|
||||
SizeIntegerAttribute => {
|
||||
if !self.is_htmlinputelement() {
|
||||
fail!("I'm not a form input!")
|
||||
panic!("I'm not a form input!")
|
||||
}
|
||||
let this: &HTMLInputElement = mem::transmute(self);
|
||||
Some(this.get_size_for_layout() as i32)
|
||||
|
@ -624,7 +624,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
Some(attribute) => {
|
||||
match *attribute.value() {
|
||||
UIntAttrValue(_, value) => value,
|
||||
_ => fail!("Expected a UIntAttrValue"),
|
||||
_ => panic!("Expected a UIntAttrValue"),
|
||||
}
|
||||
}
|
||||
None => 0,
|
||||
|
@ -1131,7 +1131,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
|||
let attr = attr.root();
|
||||
match *attr.value() {
|
||||
AtomAttrValue(ref val) => val.clone(),
|
||||
_ => fail!("`id` attribute should be AtomAttrValue"),
|
||||
_ => panic!("`id` attribute should be AtomAttrValue"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -21,10 +21,11 @@ use js::jsapi::{JSContext, JSObject};
|
|||
use servo_util::fnv::FnvHasher;
|
||||
use servo_util::str::DOMString;
|
||||
use libc::{c_char, size_t};
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use std::ptr;
|
||||
use url::Url;
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[jstraceable]
|
||||
|
@ -83,14 +84,14 @@ impl EventTarget {
|
|||
}
|
||||
|
||||
pub fn get_listeners(&self, type_: &str) -> Option<Vec<EventListener>> {
|
||||
self.handlers.borrow().find_equiv(&type_).map(|listeners| {
|
||||
self.handlers.borrow().find_equiv(type_).map(|listeners| {
|
||||
listeners.iter().map(|entry| entry.listener.get_listener()).collect()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_listeners_for(&self, type_: &str, desired_phase: ListenerPhase)
|
||||
-> Option<Vec<EventListener>> {
|
||||
self.handlers.borrow().find_equiv(&type_).map(|listeners| {
|
||||
self.handlers.borrow().find_equiv(type_).map(|listeners| {
|
||||
let filtered = listeners.iter().filter(|entry| entry.phase == desired_phase);
|
||||
filtered.map(|entry| entry.listener.get_listener()).collect()
|
||||
})
|
||||
|
@ -137,7 +138,11 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
ty: DOMString,
|
||||
listener: Option<EventListener>) {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entries = handlers.find_or_insert_with(ty, |_| vec!());
|
||||
let entries = match handlers.entry(ty) {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.set(vec!()),
|
||||
};
|
||||
|
||||
let idx = entries.iter().position(|&entry| {
|
||||
match entry.listener {
|
||||
Inline(_) => true,
|
||||
|
@ -148,7 +153,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
match idx {
|
||||
Some(idx) => {
|
||||
match listener {
|
||||
Some(listener) => entries.get_mut(idx).listener = Inline(listener),
|
||||
Some(listener) => entries[idx].listener = Inline(listener),
|
||||
None => {
|
||||
entries.remove(idx);
|
||||
}
|
||||
|
@ -167,7 +172,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
|
||||
fn get_inline_event_listener(self, ty: DOMString) -> Option<EventListener> {
|
||||
let handlers = self.handlers.borrow();
|
||||
let entries = handlers.find(&ty);
|
||||
let entries = handlers.get(&ty);
|
||||
entries.and_then(|entries| entries.iter().find(|entry| {
|
||||
match entry.listener {
|
||||
Inline(_) => true,
|
||||
|
@ -187,21 +192,21 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
let lineno = 0; //XXXjdm need to get a real number here
|
||||
|
||||
let nargs = 1; //XXXjdm not true for onerror
|
||||
static arg_name: [c_char, ..6] =
|
||||
static ARG_NAME: [c_char, ..6] =
|
||||
['e' as c_char, 'v' as c_char, 'e' as c_char, 'n' as c_char, 't' as c_char, 0];
|
||||
static arg_names: [*const c_char, ..1] = [&arg_name as *const c_char];
|
||||
static ARG_NAMES: [*const c_char, ..1] = [&ARG_NAME as *const c_char];
|
||||
|
||||
let source: Vec<u16> = source.as_slice().utf16_units().collect();
|
||||
let handler = unsafe {
|
||||
JS_CompileUCFunction(cx,
|
||||
ptr::null_mut(),
|
||||
name.as_ptr(),
|
||||
nargs,
|
||||
&arg_names as *const *const i8 as *mut *const i8,
|
||||
source.as_ptr(),
|
||||
source.len() as size_t,
|
||||
url.as_ptr(),
|
||||
lineno)
|
||||
JS_CompileUCFunction(cx,
|
||||
ptr::null_mut(),
|
||||
name.as_ptr(),
|
||||
nargs,
|
||||
&ARG_NAMES as *const *const i8 as *mut *const i8,
|
||||
source.as_ptr(),
|
||||
source.len() as size_t,
|
||||
url.as_ptr(),
|
||||
lineno)
|
||||
};
|
||||
if handler.is_null() {
|
||||
report_pending_exception(cx, self.reflector().get_jsobject());
|
||||
|
@ -241,7 +246,11 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
|
|||
match listener {
|
||||
Some(listener) => {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entry = handlers.find_or_insert_with(ty, |_| vec!());
|
||||
let entry = match handlers.entry(ty) {
|
||||
Occupied(entry) => entry.into_mut(),
|
||||
Vacant(entry) => entry.set(vec!()),
|
||||
};
|
||||
|
||||
let phase = if capture { Capturing } else { Bubbling };
|
||||
let new_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
|
@ -262,7 +271,7 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
|
|||
match listener {
|
||||
Some(listener) => {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let mut entry = handlers.find_mut(&ty);
|
||||
let mut entry = handlers.get_mut(&ty);
|
||||
for entry in entry.iter_mut() {
|
||||
let phase = if capture { Capturing } else { Bubbling };
|
||||
let old_entry = EventListenerEntry {
|
||||
|
|
|
@ -15,7 +15,8 @@ use dom::blob::Blob;
|
|||
use dom::file::File;
|
||||
use dom::htmlformelement::HTMLFormElement;
|
||||
use servo_util::str::DOMString;
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
|
||||
#[deriving(Clone)]
|
||||
#[jstraceable]
|
||||
|
@ -57,13 +58,21 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
|
|||
#[allow(unrooted_must_root)]
|
||||
fn Append(self, name: DOMString, value: JSRef<Blob>, filename: Option<DOMString>) {
|
||||
let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename)));
|
||||
self.data.borrow_mut().insert_or_update_with(name.clone(), vec!(file.clone()),
|
||||
|_k, v| {v.push(file.clone());});
|
||||
let mut data = self.data.borrow_mut();
|
||||
match data.entry(name) {
|
||||
Occupied(entry) => entry.into_mut().push(file),
|
||||
Vacant(entry) => {
|
||||
entry.set(vec!(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn Append_(self, name: DOMString, value: DOMString) {
|
||||
self.data.borrow_mut().insert_or_update_with(name, vec!(StringData(value.clone())),
|
||||
|_k, v| {v.push(StringData(value.clone()));});
|
||||
let mut data = self.data.borrow_mut();
|
||||
match data.entry(name) {
|
||||
Occupied(entry) => entry.into_mut().push(StringData(value)),
|
||||
Vacant (entry) => { entry.set(vec!(StringData(value))); },
|
||||
}
|
||||
}
|
||||
|
||||
fn Delete(self, name: DOMString) {
|
||||
|
|
|
@ -72,7 +72,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
|||
|
||||
let name = attr.local_name().as_slice();
|
||||
if name.starts_with("on") {
|
||||
static forwarded_events: &'static [&'static str] =
|
||||
static FORWARDED_EVENTS: &'static [&'static str] =
|
||||
&["onfocus", "onload", "onscroll", "onafterprint", "onbeforeprint",
|
||||
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
|
||||
"onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate",
|
||||
|
@ -82,7 +82,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
|||
window.get_url(),
|
||||
window.reflector().get_jsobject());
|
||||
let evtarget: JSRef<EventTarget> =
|
||||
if forwarded_events.iter().any(|&event| name == event) {
|
||||
if FORWARDED_EVENTS.iter().any(|&event| name == event) {
|
||||
EventTargetCast::from_ref(*window)
|
||||
} else {
|
||||
EventTargetCast::from_ref(*self)
|
||||
|
|
|
@ -18,7 +18,7 @@ use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, wind
|
|||
use dom::validitystate::ValidityState;
|
||||
use dom::virtualmethods::VirtualMethods;
|
||||
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
use servo_util::str::DOMString;
|
||||
use string_cache::Atom;
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ use geom::size::Size2D;
|
|||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
|
||||
static DefaultWidth: u32 = 300;
|
||||
static DefaultHeight: u32 = 150;
|
||||
const DEFAULT_WIDTH: u32 = 300;
|
||||
const DEFAULT_HEIGHT: u32 = 150;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLCanvasElement {
|
||||
|
@ -48,8 +48,8 @@ impl HTMLCanvasElement {
|
|||
HTMLCanvasElement {
|
||||
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, prefix, document),
|
||||
context: Default::default(),
|
||||
width: Cell::new(DefaultWidth),
|
||||
height: Cell::new(DefaultHeight),
|
||||
width: Cell::new(DEFAULT_WIDTH),
|
||||
height: Cell::new(DEFAULT_HEIGHT),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,11 +108,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
|||
|
||||
let recreate = match attr.local_name() {
|
||||
&atom!("width") => {
|
||||
self.width.set(DefaultWidth);
|
||||
self.width.set(DEFAULT_WIDTH);
|
||||
true
|
||||
}
|
||||
&atom!("height") => {
|
||||
self.height.set(DefaultHeight);
|
||||
self.height.set(DEFAULT_HEIGHT);
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
|
@ -136,11 +136,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
|||
let value = attr.value();
|
||||
let recreate = match attr.local_name() {
|
||||
&atom!("width") => {
|
||||
self.width.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultWidth));
|
||||
self.width.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DEFAULT_WIDTH));
|
||||
true
|
||||
}
|
||||
&atom!("height") => {
|
||||
self.height.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultHeight));
|
||||
self.height.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DEFAULT_HEIGHT));
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
|
|
|
@ -15,11 +15,11 @@ use dom::window::Window;
|
|||
use servo_util::namespace;
|
||||
use servo_util::str::{DOMString, split_html_space_chars};
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use string_cache::{Atom, Namespace};
|
||||
|
||||
pub trait CollectionFilter : JSTraceable {
|
||||
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool;
|
||||
fn filter<'a>(&self, elem: JSRef<'a, Element>, root: JSRef<'a, Node>) -> bool;
|
||||
}
|
||||
|
||||
#[jstraceable]
|
||||
|
|
|
@ -54,11 +54,11 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
|
|||
#[jstraceable]
|
||||
struct ElementsFilter;
|
||||
impl CollectionFilter for ElementsFilter {
|
||||
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {
|
||||
static tag_names: StaticStringVec = &["button", "fieldset", "input",
|
||||
fn filter<'a>(&self, elem: JSRef<'a, Element>, root: JSRef<'a, Node>) -> bool {
|
||||
static TAG_NAMES: StaticStringVec = &["button", "fieldset", "input",
|
||||
"keygen", "object", "output", "select", "textarea"];
|
||||
let root: JSRef<Element> = ElementCast::to_ref(root).unwrap();
|
||||
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.local_name().as_slice())
|
||||
elem != root && TAG_NAMES.iter().any(|&tag_name| tag_name == elem.local_name().as_slice())
|
||||
}
|
||||
}
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
|
|
|
@ -24,8 +24,7 @@ use http::method::Post;
|
|||
use servo_msg::constellation_msg::LoadData;
|
||||
use servo_util::str::DOMString;
|
||||
use script_task::{ScriptChan, TriggerLoadMsg};
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
use std::str::StrSlice;
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
use url::UrlParser;
|
||||
use url::form_urlencoded::serialize;
|
||||
use string_cache::Atom;
|
||||
|
@ -200,26 +199,26 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
|
|||
for ch in s.chars() {
|
||||
match ch {
|
||||
'\n' if prev != '\r' => {
|
||||
buf.push_char('\r');
|
||||
buf.push_char('\n');
|
||||
buf.push('\r');
|
||||
buf.push('\n');
|
||||
},
|
||||
'\n' => {
|
||||
buf.push_char('\n');
|
||||
buf.push('\n');
|
||||
},
|
||||
// This character isn't LF but is
|
||||
// preceded by CR
|
||||
_ if prev == '\r' => {
|
||||
buf.push_char('\r');
|
||||
buf.push_char('\n');
|
||||
buf.push_char(ch);
|
||||
buf.push('\r');
|
||||
buf.push('\n');
|
||||
buf.push(ch);
|
||||
},
|
||||
_ => buf.push_char(ch)
|
||||
_ => buf.push(ch)
|
||||
};
|
||||
prev = ch;
|
||||
}
|
||||
// In case the last character was CR
|
||||
if prev == '\r' {
|
||||
buf.push_char('\n');
|
||||
buf.push('\n');
|
||||
}
|
||||
buf
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
|
|||
use servo_msg::constellation_msg::{ConstellationChan, ScriptLoadedURLInIFrameMsg};
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use url::{Url, UrlParser};
|
||||
|
||||
|
|
|
@ -27,14 +27,15 @@ use dom::virtualmethods::VirtualMethods;
|
|||
use servo_util::str::DOMString;
|
||||
use string_cache::Atom;
|
||||
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
use std::cell::Cell;
|
||||
|
||||
static DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
|
||||
static DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||
const DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
|
||||
const DEFAULT_RESET_VALUE: &'static str = "Reset";
|
||||
|
||||
#[jstraceable]
|
||||
#[deriving(PartialEq)]
|
||||
#[allow(dead_code)]
|
||||
enum InputType {
|
||||
InputButton(Option<&'static str>),
|
||||
InputText,
|
||||
|
@ -284,7 +285,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
|||
&atom!("size") => {
|
||||
match *attr.value() {
|
||||
UIntAttrValue(_, value) => self.size.set(value),
|
||||
_ => fail!("Expected a UIntAttrValue"),
|
||||
_ => panic!("Expected a UIntAttrValue"),
|
||||
}
|
||||
self.force_relayout();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ use dom::virtualmethods::VirtualMethods;
|
|||
use layout_interface::{LayoutChan, LoadStylesheetMsg};
|
||||
use servo_util::str::{DOMString, HTML_SPACE_CHARACTERS};
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use url::UrlParser;
|
||||
use string_cache::Atom;
|
||||
|
||||
|
@ -121,7 +121,7 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
|
|||
let LayoutChan(ref layout_chan) = window.page().layout_chan;
|
||||
layout_chan.send(LoadStylesheetMsg(url));
|
||||
}
|
||||
Err(e) => debug!("Parsing url {:s} failed: {:?}", href, e)
|
||||
Err(e) => debug!("Parsing url {:s} failed: {}", href, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@ impl<'a> ProcessDataURL for JSRef<'a, HTMLObjectElement> {
|
|||
}
|
||||
|
||||
pub fn is_image_data(uri: &str) -> bool {
|
||||
static types: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
|
||||
types.iter().any(|&type_| uri.starts_with(type_))
|
||||
static TYPES: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
|
||||
TYPES.iter().any(|&type_| uri.starts_with(type_))
|
||||
}
|
||||
|
||||
impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> {
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
|
|||
}
|
||||
DocumentFragmentNodeTypeId => {}
|
||||
DocumentNodeTypeId => {
|
||||
fail!("It shouldn't be possible to serialize a document node")
|
||||
panic!("It shouldn't be possible to serialize a document node")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInst
|
|||
html: &mut String) {
|
||||
html.push_str("<?");
|
||||
html.push_str(processing_instruction.target().as_slice());
|
||||
html.push_char(' ');
|
||||
html.push(' ');
|
||||
html.push_str(processing_instruction.characterdata().data().as_slice());
|
||||
html.push_str("?>");
|
||||
}
|
||||
|
@ -102,17 +102,17 @@ fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInst
|
|||
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
||||
html.push_str("<!DOCTYPE");
|
||||
html.push_str(doctype.name().as_slice());
|
||||
html.push_char('>');
|
||||
html.push('>');
|
||||
}
|
||||
|
||||
fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
|
||||
html.push_char('<');
|
||||
html.push('<');
|
||||
html.push_str(elem.local_name().as_slice());
|
||||
for attr in elem.attrs().iter() {
|
||||
let attr = attr.root();
|
||||
serialize_attr(*attr, html);
|
||||
};
|
||||
html.push_char('>');
|
||||
html.push('>');
|
||||
|
||||
match elem.local_name().as_slice() {
|
||||
"pre" | "listing" | "textarea" if *elem.namespace() == ns!(HTML) => {
|
||||
|
@ -121,7 +121,7 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
|||
Some(ref child) if child.is_text() => {
|
||||
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
|
||||
if text.data().len() > 0 && text.data().as_slice().char_at(0) == '\n' {
|
||||
html.push_char('\x0A');
|
||||
html.push('\x0A');
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
|
@ -136,7 +136,7 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
|||
}
|
||||
|
||||
fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
|
||||
html.push_char(' ');
|
||||
html.push(' ');
|
||||
if *attr.namespace() == ns!(XML) {
|
||||
html.push_str("xml:");
|
||||
html.push_str(attr.local_name().as_slice());
|
||||
|
@ -154,18 +154,18 @@ fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
|
|||
};
|
||||
html.push_str("=\"");
|
||||
escape(attr.value().as_slice(), true, html);
|
||||
html.push_char('"');
|
||||
html.push('"');
|
||||
}
|
||||
|
||||
fn escape(string: &str, attr_mode: bool, html: &mut String) {
|
||||
for c in string.chars() {
|
||||
match c {
|
||||
'&' => html.push_str("&"),
|
||||
'\xA0' => html.push_str(" "),
|
||||
'\u00A0' => html.push_str(" "),
|
||||
'"' if attr_mode => html.push_str("""),
|
||||
'<' if !attr_mode => html.push_str("<"),
|
||||
'>' if !attr_mode => html.push_str(">"),
|
||||
c => html.push_char(c),
|
||||
c => html.push(c),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ macro_rules! make_getter(
|
|||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
element.get_string_attribute(&Atom::from_slice($htmlname.to_ascii_lower().as_slice()))
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ macro_rules! make_bool_getter(
|
|||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not runtime.
|
||||
element.has_attribute(&Atom::from_slice($htmlname))
|
||||
|
@ -44,7 +44,7 @@ macro_rules! make_uint_getter(
|
|||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not runtime.
|
||||
element.get_uint_attribute(&Atom::from_slice($htmlname))
|
||||
|
@ -62,7 +62,7 @@ macro_rules! make_url_getter(
|
|||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
// FIXME(pcwalton): Do this at compile time, not runtime.
|
||||
element.get_url_attribute(&Atom::from_slice($htmlname))
|
||||
|
@ -81,7 +81,7 @@ macro_rules! make_url_or_base_getter(
|
|||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let url = element.get_url_attribute(&Atom::from_slice($htmlname));
|
||||
match url.as_slice() {
|
||||
|
@ -105,7 +105,7 @@ macro_rules! make_enumerated_getter(
|
|||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
let val = element.get_string_attribute(&Atom::from_slice($htmlname))
|
||||
.into_ascii_lower();
|
||||
|
|
|
@ -126,31 +126,31 @@ bitflags! {
|
|||
#[jstraceable]
|
||||
flags NodeFlags: u8 {
|
||||
#[doc = "Specifies whether this node is in a document."]
|
||||
static IsInDoc = 0x01,
|
||||
const IS_IN_DOC = 0x01,
|
||||
#[doc = "Specifies whether this node is in hover state."]
|
||||
static InHoverState = 0x02,
|
||||
const IN_HOVER_STATE = 0x02,
|
||||
#[doc = "Specifies whether this node is in disabled state."]
|
||||
static InDisabledState = 0x04,
|
||||
const IN_DISABLED_STATE = 0x04,
|
||||
#[doc = "Specifies whether this node is in enabled state."]
|
||||
static InEnabledState = 0x08,
|
||||
const IN_ENABLED_STATE = 0x08,
|
||||
#[doc = "Specifies whether this node _must_ be reflowed regardless of style differences."]
|
||||
static HasChanged = 0x10,
|
||||
const HAS_CHANGED = 0x10,
|
||||
#[doc = "Specifies whether this node needs style recalc on next reflow."]
|
||||
static IsDirty = 0x20,
|
||||
const IS_DIRTY = 0x20,
|
||||
#[doc = "Specifies whether this node has siblings (inclusive of itself) which \
|
||||
changed since the last reflow."]
|
||||
static HasDirtySiblings = 0x40,
|
||||
const HAS_DIRTY_SIBLINGS = 0x40,
|
||||
#[doc = "Specifies whether this node has descendants (inclusive of itself) which \
|
||||
have changed since the last reflow."]
|
||||
static HasDirtyDescendants = 0x80,
|
||||
const HAS_DIRTY_DESCENDANTS = 0x80,
|
||||
}
|
||||
}
|
||||
|
||||
impl NodeFlags {
|
||||
pub fn new(type_id: NodeTypeId) -> NodeFlags {
|
||||
let dirty = HasChanged | IsDirty | HasDirtySiblings | HasDirtyDescendants;
|
||||
let dirty = HAS_CHANGED | IS_DIRTY | HAS_DIRTY_SIBLINGS | HAS_DIRTY_DESCENDANTS;
|
||||
match type_id {
|
||||
DocumentNodeTypeId => IsInDoc | dirty,
|
||||
DocumentNodeTypeId => IS_IN_DOC | dirty,
|
||||
// The following elements are enabled by default.
|
||||
ElementNodeTypeId(HTMLButtonElementTypeId) |
|
||||
ElementNodeTypeId(HTMLInputElementTypeId) |
|
||||
|
@ -159,7 +159,7 @@ impl NodeFlags {
|
|||
ElementNodeTypeId(HTMLOptGroupElementTypeId) |
|
||||
ElementNodeTypeId(HTMLOptionElementTypeId) |
|
||||
//ElementNodeTypeId(HTMLMenuItemElementTypeId) |
|
||||
ElementNodeTypeId(HTMLFieldSetElementTypeId) => InEnabledState | dirty,
|
||||
ElementNodeTypeId(HTMLFieldSetElementTypeId) => IN_ENABLED_STATE | dirty,
|
||||
_ => dirty,
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ pub trait NodeHelpers<'a> {
|
|||
fn child_elements(self) -> ChildElementIterator<'a>;
|
||||
fn following_siblings(self) -> NodeChildrenIterator<'a>;
|
||||
fn is_in_doc(self) -> bool;
|
||||
fn is_inclusive_ancestor_of(self, parent: JSRef<Node>) -> bool;
|
||||
fn is_inclusive_ancestor_of(self, parent: JSRef<'a, Node>) -> bool; // FIXME: See #3960
|
||||
fn is_parent_of(self, child: JSRef<Node>) -> bool;
|
||||
|
||||
fn type_id(self) -> NodeTypeId;
|
||||
|
@ -431,9 +431,9 @@ pub trait NodeHelpers<'a> {
|
|||
fn get_has_dirty_descendants(self) -> bool;
|
||||
fn set_has_dirty_descendants(self, state: bool);
|
||||
|
||||
/// Marks the given node as `IsDirty`, its siblings as `IsDirty` (to deal
|
||||
/// with sibling selectors), its ancestors as `HasDirtyDescendants`, and its
|
||||
/// descendants as `IsDirty`.
|
||||
/// Marks the given node as `IS_DIRTY`, its siblings as `IS_DIRTY` (to deal
|
||||
/// with sibling selectors), its ancestors as `HAS_DIRTY_DESCENDANTS`, and its
|
||||
/// descendants as `IS_DIRTY`.
|
||||
fn dirty(self);
|
||||
|
||||
fn dump(self);
|
||||
|
@ -482,11 +482,11 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
|
||||
/// Returns a string that describes this node.
|
||||
fn debug_str(self) -> String {
|
||||
format!("{:?}", self.type_id)
|
||||
format!("{}", self.type_id)
|
||||
}
|
||||
|
||||
fn is_in_doc(self) -> bool {
|
||||
self.deref().flags.get().contains(IsInDoc)
|
||||
self.deref().flags.get().contains(IS_IN_DOC)
|
||||
}
|
||||
|
||||
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
|
||||
|
@ -561,59 +561,59 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
fn get_hover_state(self) -> bool {
|
||||
self.get_flag(InHoverState)
|
||||
self.get_flag(IN_HOVER_STATE)
|
||||
}
|
||||
|
||||
fn set_hover_state(self, state: bool) {
|
||||
self.set_flag(InHoverState, state)
|
||||
self.set_flag(IN_HOVER_STATE, state)
|
||||
}
|
||||
|
||||
fn get_disabled_state(self) -> bool {
|
||||
self.get_flag(InDisabledState)
|
||||
self.get_flag(IN_DISABLED_STATE)
|
||||
}
|
||||
|
||||
fn set_disabled_state(self, state: bool) {
|
||||
self.set_flag(InDisabledState, state)
|
||||
self.set_flag(IN_DISABLED_STATE, state)
|
||||
}
|
||||
|
||||
fn get_enabled_state(self) -> bool {
|
||||
self.get_flag(InEnabledState)
|
||||
self.get_flag(IN_ENABLED_STATE)
|
||||
}
|
||||
|
||||
fn set_enabled_state(self, state: bool) {
|
||||
self.set_flag(InEnabledState, state)
|
||||
self.set_flag(IN_ENABLED_STATE, state)
|
||||
}
|
||||
|
||||
fn get_has_changed(self) -> bool {
|
||||
self.get_flag(HasChanged)
|
||||
self.get_flag(HAS_CHANGED)
|
||||
}
|
||||
|
||||
fn set_has_changed(self, state: bool) {
|
||||
self.set_flag(HasChanged, state)
|
||||
self.set_flag(HAS_CHANGED, state)
|
||||
}
|
||||
|
||||
fn get_is_dirty(self) -> bool {
|
||||
self.get_flag(IsDirty)
|
||||
self.get_flag(IS_DIRTY)
|
||||
}
|
||||
|
||||
fn set_is_dirty(self, state: bool) {
|
||||
self.set_flag(IsDirty, state)
|
||||
self.set_flag(IS_DIRTY, state)
|
||||
}
|
||||
|
||||
fn get_has_dirty_siblings(self) -> bool {
|
||||
self.get_flag(HasDirtySiblings)
|
||||
self.get_flag(HAS_DIRTY_SIBLINGS)
|
||||
}
|
||||
|
||||
fn set_has_dirty_siblings(self, state: bool) {
|
||||
self.set_flag(HasDirtySiblings, state)
|
||||
self.set_flag(HAS_DIRTY_SIBLINGS, state)
|
||||
}
|
||||
|
||||
fn get_has_dirty_descendants(self) -> bool {
|
||||
self.get_flag(HasDirtyDescendants)
|
||||
self.get_flag(HAS_DIRTY_DESCENDANTS)
|
||||
}
|
||||
|
||||
fn set_has_dirty_descendants(self, state: bool) {
|
||||
self.set_flag(HasDirtyDescendants, state)
|
||||
self.set_flag(HAS_DIRTY_DESCENDANTS, state)
|
||||
}
|
||||
|
||||
fn dirty(self) {
|
||||
|
@ -629,7 +629,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
// Stop if this subtree is already dirty.
|
||||
if node.get_is_dirty() { return }
|
||||
|
||||
node.set_flag(IsDirty | HasDirtySiblings | HasDirtyDescendants, true);
|
||||
node.set_flag(IS_DIRTY | HAS_DIRTY_SIBLINGS | HAS_DIRTY_DESCENDANTS, true);
|
||||
|
||||
for kid in node.children() {
|
||||
dirty_subtree(kid);
|
||||
|
@ -670,7 +670,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_inclusive_ancestor_of(self, parent: JSRef<Node>) -> bool {
|
||||
fn is_inclusive_ancestor_of(self, parent: JSRef<'a, Node>) -> bool {
|
||||
self == parent || parent.ancestors().any(|ancestor| ancestor == self)
|
||||
}
|
||||
|
||||
|
@ -840,7 +840,7 @@ pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: Untrusted
|
|||
let object: *mut JSObject = jsfriendapi::bindgen::JS_GetAddressableObject(runtime,
|
||||
candidate);
|
||||
if object.is_null() {
|
||||
fail!("Attempted to create a `JS<Node>` from an invalid pointer!")
|
||||
panic!("Attempted to create a `JS<Node>` from an invalid pointer!")
|
||||
}
|
||||
let boxed_node: *const Node = utils::unwrap(object);
|
||||
Temporary::new(JS::from_raw(boxed_node))
|
||||
|
@ -934,15 +934,15 @@ pub trait RawLayoutNodeHelpers {
|
|||
impl RawLayoutNodeHelpers for Node {
|
||||
#[inline]
|
||||
unsafe fn get_hover_state_for_layout(&self) -> bool {
|
||||
self.flags.get().contains(InHoverState)
|
||||
self.flags.get().contains(IN_HOVER_STATE)
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn get_disabled_state_for_layout(&self) -> bool {
|
||||
self.flags.get().contains(InDisabledState)
|
||||
self.flags.get().contains(IN_DISABLED_STATE)
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn get_enabled_state_for_layout(&self) -> bool {
|
||||
self.flags.get().contains(InEnabledState)
|
||||
self.flags.get().contains(IN_ENABLED_STATE)
|
||||
}
|
||||
#[inline]
|
||||
fn type_id_for_layout(&self) -> NodeTypeId {
|
||||
|
@ -1311,7 +1311,7 @@ impl Node {
|
|||
|
||||
// Step 7-8.
|
||||
let referenceChild = match child {
|
||||
Some(child) if child == node => node.next_sibling().map(|node| (*node.root()).clone()),
|
||||
Some(child) if child.clone() == node => node.next_sibling().map(|node| (*node.root()).clone()),
|
||||
_ => child
|
||||
};
|
||||
|
||||
|
@ -1337,9 +1337,9 @@ impl Node {
|
|||
for kid in node.traverse_preorder() {
|
||||
let mut flags = kid.flags.get();
|
||||
if is_in_doc {
|
||||
flags.insert(IsInDoc);
|
||||
flags.insert(IS_IN_DOC);
|
||||
} else {
|
||||
flags.remove(IsInDoc);
|
||||
flags.remove(IS_IN_DOC);
|
||||
}
|
||||
kid.flags.set(flags);
|
||||
}
|
||||
|
@ -1460,7 +1460,7 @@ impl Node {
|
|||
// Step 8.
|
||||
parent.remove_child(node);
|
||||
|
||||
node.set_flag(IsInDoc, false);
|
||||
node.set_flag(IS_IN_DOC, false);
|
||||
|
||||
// Step 9.
|
||||
match suppress_observers {
|
||||
|
@ -1903,7 +1903,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
// Ok if not caught by previous error checks.
|
||||
if node == child {
|
||||
if node.clone() == child {
|
||||
return Ok(Temporary::from_rooted(child));
|
||||
}
|
||||
|
||||
|
@ -2059,7 +2059,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
|
||||
// http://dom.spec.whatwg.org/#dom-node-comparedocumentposition
|
||||
fn CompareDocumentPosition(self, other: JSRef<Node>) -> u16 {
|
||||
if self == other {
|
||||
if self.clone() == other { // FIXME: See issue #3960
|
||||
// step 2.
|
||||
0
|
||||
} else {
|
||||
|
|
|
@ -109,7 +109,7 @@ impl JSTraceable for ServoHTMLParser {
|
|||
unsafe {
|
||||
// Assertion: If the parser is mutably borrowed, we're in the
|
||||
// parsing code paths.
|
||||
debug_assert!(task_state::get().contains(task_state::InHTMLParser)
|
||||
debug_assert!(task_state::get().contains(task_state::IN_HTML_PARSER)
|
||||
|| !self.tokenizer.is_mutably_borrowed());
|
||||
|
||||
let tokenizer = self.tokenizer.borrow_for_gc_trace();
|
||||
|
|
|
@ -78,7 +78,7 @@ impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> {
|
|||
match self.filter {
|
||||
FilterNone => None,
|
||||
FilterJS(nf) => Some(nf),
|
||||
FilterNative(_) => fail!("Cannot convert native node filter to DOM NodeFilter")
|
||||
FilterNative(_) => panic!("Cannot convert native node filter to DOM NodeFilter")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,20 +559,20 @@ pub enum Filter {
|
|||
// FIXME: NodeFilterConstants will be defined in NodeFilterBindings.rs
|
||||
// when codegen supports a callback interface with constants (#3149).
|
||||
pub mod NodeFilterConstants {
|
||||
pub static FILTER_ACCEPT: u16 = 1;
|
||||
pub static FILTER_REJECT: u16 = 2;
|
||||
pub static FILTER_SKIP: u16 = 3;
|
||||
pub static SHOW_ALL: u32 = 4294967295;
|
||||
pub static SHOW_ELEMENT: u32 = 1;
|
||||
pub static SHOW_ATTRIBUTE: u32 = 2;
|
||||
pub static SHOW_TEXT: u32 = 4;
|
||||
pub static SHOW_CDATA_SECTION: u32 = 8;
|
||||
pub static SHOW_ENTITY_REFERENCE: u32 = 16;
|
||||
pub static SHOW_ENTITY: u32 = 32;
|
||||
pub static SHOW_PROCESSING_INSTRUCTION: u32 = 64;
|
||||
pub static SHOW_COMMENT: u32 = 128;
|
||||
pub static SHOW_DOCUMENT: u32 = 256;
|
||||
pub static SHOW_DOCUMENT_TYPE: u32 = 512;
|
||||
pub static SHOW_DOCUMENT_FRAGMENT: u32 = 1024;
|
||||
pub static SHOW_NOTATION: u32 = 2048;
|
||||
pub const FILTER_ACCEPT: u16 = 1;
|
||||
pub const FILTER_REJECT: u16 = 2;
|
||||
pub const FILTER_SKIP: u16 = 3;
|
||||
pub const SHOW_ALL: u32 = 4294967295;
|
||||
pub const SHOW_ELEMENT: u32 = 1;
|
||||
pub const SHOW_ATTRIBUTE: u32 = 2;
|
||||
pub const SHOW_TEXT: u32 = 4;
|
||||
pub const SHOW_CDATA_SECTION: u32 = 8;
|
||||
pub const SHOW_ENTITY_REFERENCE: u32 = 16;
|
||||
pub const SHOW_ENTITY: u32 = 32;
|
||||
pub const SHOW_PROCESSING_INSTRUCTION: u32 = 64;
|
||||
pub const SHOW_COMMENT: u32 = 128;
|
||||
pub const SHOW_DOCUMENT: u32 = 256;
|
||||
pub const SHOW_DOCUMENT_TYPE: u32 = 512;
|
||||
pub const SHOW_DOCUMENT_FRAGMENT: u32 = 1024;
|
||||
pub const SHOW_NOTATION: u32 = 2048;
|
||||
} // mod NodeFilterConstants
|
||||
|
|
|
@ -16,9 +16,10 @@ use servo_util::str::DOMString;
|
|||
use encoding::all::UTF_8;
|
||||
use encoding::types::{EncodingRef, EncodeReplace};
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use std::fmt::radix;
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
use std::ascii::OwnedAsciiExt;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct URLSearchParams {
|
||||
|
@ -60,8 +61,15 @@ impl URLSearchParams {
|
|||
|
||||
impl<'a> URLSearchParamsMethods for JSRef<'a, URLSearchParams> {
|
||||
fn Append(self, name: DOMString, value: DOMString) {
|
||||
self.data.borrow_mut().insert_or_update_with(name, vec!(value.clone()),
|
||||
|_k, v| v.push(value.clone()));
|
||||
let mut data = self.data.borrow_mut();
|
||||
|
||||
match data.entry(name) {
|
||||
Occupied(entry) => entry.into_mut().push(value),
|
||||
Vacant(entry) => {
|
||||
entry.set(vec!(value));
|
||||
}
|
||||
}
|
||||
|
||||
self.update_steps();
|
||||
}
|
||||
|
||||
|
@ -109,8 +117,8 @@ impl URLSearchParamsHelpers for URLSearchParams {
|
|||
let append = match *i {
|
||||
0x20 => vec!(0x2B),
|
||||
0x2A | 0x2D | 0x2E |
|
||||
0x30 .. 0x39 | 0x41 .. 0x5A |
|
||||
0x5F | 0x61..0x7A => vec!(*i),
|
||||
0x30 ... 0x39 | 0x41 ... 0x5A |
|
||||
0x5F | 0x61...0x7A => vec!(*i),
|
||||
a => {
|
||||
// http://url.spec.whatwg.org/#percent-encode
|
||||
let mut encoded = vec!(0x25); // %
|
||||
|
|
|
@ -367,7 +367,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
|||
/// Commence a new URL load which will either replace this window or scroll to a fragment.
|
||||
fn load_url(self, href: DOMString) {
|
||||
let base_url = self.page().get_url();
|
||||
debug!("current page url is {:?}", base_url);
|
||||
debug!("current page url is {}", base_url);
|
||||
let url = UrlParser::new().base_url(&base_url).parse(href.as_slice());
|
||||
// FIXME: handle URL parse errors more gracefully.
|
||||
let url = url.unwrap();
|
||||
|
|
|
@ -50,13 +50,12 @@ use script_task::{ScriptChan, XHRProgressMsg, XHRReleaseMsg};
|
|||
use servo_util::str::DOMString;
|
||||
use servo_util::task::spawn_named;
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::cell::Cell;
|
||||
use std::comm::{Sender, Receiver, channel};
|
||||
use std::default::Default;
|
||||
use std::io::{BufReader, MemWriter, Timer};
|
||||
use std::from_str::FromStr;
|
||||
use std::path::BytesContainer;
|
||||
use std::time::duration::Duration;
|
||||
use std::num::Zero;
|
||||
use time;
|
||||
|
@ -454,7 +453,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
let mut buf = h.header_value();
|
||||
buf.as_mut_vec().push_all(&[0x2C, 0x20]);
|
||||
buf.as_mut_vec().push_all(value.as_slice());
|
||||
value = ByteString::new(buf.container_into_owned_bytes());
|
||||
value = ByteString::new(buf.into_bytes());
|
||||
|
||||
}
|
||||
},
|
||||
|
@ -875,7 +874,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
|
|||
// Part of step 13, send() (processing response)
|
||||
// XXXManishearth handle errors, if any (substep 1)
|
||||
// Substep 2
|
||||
*self.status_text.borrow_mut() = ByteString::new(status.reason().container_into_owned_bytes());
|
||||
*self.status_text.borrow_mut() = ByteString::new(status.reason().into_bytes());
|
||||
self.status.set(status.code());
|
||||
match headers {
|
||||
Some(ref h) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue