diff options
Diffstat (limited to 'components/script/dom')
45 files changed, 630 insertions, 239 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 63f9d010729..08370974cca 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -339,7 +339,7 @@ class CGMethodCall(CGThing): code = ( "if argc < %d {\n" " throw_type_error(cx, \"Not enough arguments to %s.\");\n" - " return 0;\n" + " return JSFalse;\n" "}" % (requiredArgs, methodName)) self.cgRoot.prepend( CGWrapper(CGGeneric(code), pre="\n", post="\n")) @@ -512,11 +512,11 @@ class CGMethodCall(CGThing): CGSwitch("argcount", argCountCases, CGGeneric("throw_type_error(cx, \"Not enough arguments to %s.\");\n" - "return 0;" % methodName))) + "return JSFalse;" % methodName))) # XXXjdm Avoid unreachable statement warnings # overloadCGThings.append( # CGGeneric('panic!("We have an always-returning default case");\n' - # 'return 0;')) + # 'return JSFalse;')) self.cgRoot = CGWrapper(CGList(overloadCGThings, "\n"), pre="\n") @@ -888,7 +888,11 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, if invalidEnumValueFatal: handleInvalidEnumValueCode = exceptionCode else: - handleInvalidEnumValueCode = "return 1;" + handleInvalidEnumValueCode = "return JSTrue;" + + transmute = "mem::transmute(index)" + if isMember == 'Dictionary': + transmute = 'unsafe { ' + transmute + ' }' template = ( "match find_enum_string_index(cx, ${val}, %(values)s) {\n" @@ -896,10 +900,11 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, " Ok(None) => { %(handleInvalidEnumValueCode)s },\n" " Ok(Some(index)) => {\n" " //XXXjdm need some range checks up in here.\n" - " unsafe { mem::transmute(index) }\n" + " %(transmute)s\n" " },\n" "}" % {"values": enum + "Values::strings", "exceptionCode": exceptionCode, + "transmute": transmute, "handleInvalidEnumValueCode": handleInvalidEnumValueCode}) if defaultValue is not None: @@ -1012,7 +1017,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, declType = CGGeneric(typeName) template = ("match %s::new(cx, ${val}) {\n" " Ok(dictionary) => dictionary,\n" - " Err(_) => return 0,\n" + " Err(_) => return JSFalse,\n" "}" % typeName) return handleOptional(template, declType, handleDefaultNull("%s::empty(cx)" % typeName)) @@ -1037,7 +1042,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, conversionBehavior = "()" if failureCode is None: - failureCode = 'return 0' + failureCode = 'return JSFalse' declType = CGGeneric(builtinNames[type.tag()]) if type.nullable(): @@ -1216,7 +1221,7 @@ class CGArgumentConverter(CGThing): return self.converter.define() -def wrapForType(jsvalRef, result='result', successCode='return 1;', pre=''): +def wrapForType(jsvalRef, result='result', successCode='return JSTrue;', pre=''): """ Reflect a Rust value into JS. @@ -1472,6 +1477,7 @@ class AttrDefiner(PropertyDefiner): def __init__(self, descriptor, name, static): PropertyDefiner.__init__(self, descriptor, name) self.name = name + self.descriptor = descriptor self.regular = [ m for m in descriptor.interface.members @@ -1488,14 +1494,14 @@ class AttrDefiner(PropertyDefiner): def getter(attr): if self.static: - accessor = 'get_' + attr.identifier.name + accessor = 'get_' + self.descriptor.internalNameFor(attr.identifier.name) jitinfo = "0 as *const JSJitInfo" else: if attr.hasLenientThis(): accessor = "generic_lenient_getter" else: accessor = "generic_getter" - jitinfo = "&%s_getterinfo" % attr.identifier.name + jitinfo = "&%s_getterinfo" % self.descriptor.internalNameFor(attr.identifier.name) return ("JSNativeWrapper { op: Some(%(native)s), info: %(info)s }" % {"info": jitinfo, @@ -1506,14 +1512,14 @@ class AttrDefiner(PropertyDefiner): return "JSNativeWrapper { op: None, info: 0 as *const JSJitInfo }" if self.static: - accessor = 'set_' + attr.identifier.name + accessor = 'set_' + self.descriptor.internalNameFor(attr.identifier.name) jitinfo = "0 as *const JSJitInfo" else: if attr.hasLenientThis(): accessor = "generic_lenient_setter" else: accessor = "generic_setter" - jitinfo = "&%s_setterinfo" % attr.identifier.name + jitinfo = "&%s_setterinfo" % self.descriptor.internalNameFor(attr.identifier.name) return ("JSNativeWrapper { op: Some(%(native)s), info: %(info)s }" % {"info": jitinfo, @@ -1620,19 +1626,11 @@ class CGImports(CGWrapper): """ if ignored_warnings is None: ignored_warnings = [ - # Allow unreachable_code because we use 'break' in a way that - # sometimes produces two 'break's in a row. See for example - # CallbackMember.getArgConversions. - 'unreachable_code', 'non_camel_case_types', 'non_upper_case_globals', - 'unused_parens', 'unused_imports', 'unused_variables', - 'unused_unsafe', - 'unused_mut', 'unused_assignments', - 'dead_code', ] def componentTypes(type): @@ -2049,7 +2047,7 @@ class CGAbstractMethod(CGThing): """ def __init__(self, descriptor, name, returnType, args, inline=False, alwaysInline=False, extern=False, pub=False, templateArgs=None, - unsafe=True): + unsafe=False): CGThing.__init__(self) self.descriptor = descriptor self.name = name @@ -2111,7 +2109,7 @@ class CGAbstractMethod(CGThing): def CreateBindingJSObject(descriptor, parent=None): - create = "let mut raw = Box::into_raw(object);\nlet _rt = RootedTraceable::new(&*raw);\n" + create = "let raw = Box::into_raw(object);\nlet _rt = RootedTraceable::new(&*raw);\n" if descriptor.proxy: assert not descriptor.isGlobal() create += """ @@ -2160,12 +2158,13 @@ class CGWrapMethod(CGAbstractMethod): assert not descriptor.interface.isCallback() if not descriptor.isGlobal(): args = [Argument('*mut JSContext', 'cx'), Argument('GlobalRef', 'scope'), - Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)] + Argument("Box<%s>" % descriptor.concreteType, 'object')] else: args = [Argument('*mut JSContext', 'cx'), - Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)] + Argument("Box<%s>" % descriptor.concreteType, 'object')] retval = 'Root<%s>' % descriptor.concreteType - CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True) + CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, + pub=True, unsafe=True) def definition_body(self): if not self.descriptor.isGlobal(): @@ -2309,6 +2308,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): def definition_body(self): protoChain = self.descriptor.prototypeChain if len(protoChain) == 1: + self.unsafe = True getParentProto = "parent_proto.ptr = JS_GetObjectPrototype(cx, global)" else: parentProtoName = self.descriptor.prototypeChain[-2] @@ -2382,7 +2382,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod): Argument('HandleObject', 'receiver'), Argument('MutableHandleObject', 'rval')] CGAbstractMethod.__init__(self, descriptor, name, - 'void', args, pub=pub) + 'void', args, pub=pub, unsafe=True) self.id = idPrefix + "ID::" + self.descriptor.name def definition_body(self): @@ -2452,7 +2452,9 @@ class CGDefineProxyHandler(CGAbstractMethod): """ def __init__(self, descriptor): assert descriptor.proxy - CGAbstractMethod.__init__(self, descriptor, 'DefineProxyHandler', '*const libc::c_void', [], pub=True) + CGAbstractMethod.__init__(self, descriptor, 'DefineProxyHandler', + '*const libc::c_void', [], + pub=True, unsafe=True) def define(self): return CGAbstractMethod.define(self) @@ -2778,7 +2780,7 @@ class CGSetterCall(CGPerSignatureCall): def wrap_return_value(self): # We have no return value - return "\nreturn 1;" + return "\nreturn JSTrue;" def getArgc(self): return "1" @@ -2835,7 +2837,10 @@ class CGSpecializedMethod(CGAbstractExternMethod): @staticmethod def makeNativeName(descriptor, method): name = method.identifier.name - return MakeNativeName(descriptor.binaryNameFor(name)) + nativeName = descriptor.binaryNameFor(name) + if nativeName == name: + nativeName = descriptor.internalNameFor(name) + return MakeNativeName(nativeName) class CGStaticMethod(CGAbstractStaticBindingMethod): @@ -2850,7 +2855,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod): def generate_code(self): nativeName = CGSpecializedMethod.makeNativeName(self.descriptor, self.method) - setupArgs = CGGeneric("let mut args = CallArgs::from_vp(vp, argc);\n") + setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n") call = CGMethodCall(["global.r()"], nativeName, True, self.descriptor, self.method) return CGList([setupArgs, call]) @@ -2862,7 +2867,7 @@ class CGSpecializedGetter(CGAbstractExternMethod): """ def __init__(self, descriptor, attr): self.attr = attr - name = 'get_' + attr.identifier.name + name = 'get_' + descriptor.internalNameFor(attr.identifier.name) args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', '_obj'), Argument('*const %s' % descriptor.concreteType, 'this'), @@ -2880,7 +2885,10 @@ class CGSpecializedGetter(CGAbstractExternMethod): @staticmethod def makeNativeName(descriptor, attr): name = attr.identifier.name - nativeName = MakeNativeName(descriptor.binaryNameFor(name)) + nativeName = descriptor.binaryNameFor(name) + if nativeName == name: + nativeName = descriptor.internalNameFor(name) + nativeName = MakeNativeName(nativeName) infallible = ('infallible' in descriptor.getExtendedAttributes(attr, getter=True)) if attr.type.nullable() or not infallible: @@ -2901,7 +2909,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod): def generate_code(self): nativeName = CGSpecializedGetter.makeNativeName(self.descriptor, self.attr) - setupArgs = CGGeneric("let mut args = CallArgs::from_vp(vp, argc);\n") + setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n") call = CGGetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor, self.attr) return CGList([setupArgs, call]) @@ -2914,7 +2922,7 @@ class CGSpecializedSetter(CGAbstractExternMethod): """ def __init__(self, descriptor, attr): self.attr = attr - name = 'set_' + attr.identifier.name + name = 'set_' + descriptor.internalNameFor(attr.identifier.name) args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'obj'), Argument('*const %s' % descriptor.concreteType, 'this'), @@ -2931,7 +2939,10 @@ class CGSpecializedSetter(CGAbstractExternMethod): @staticmethod def makeNativeName(descriptor, attr): name = attr.identifier.name - return "Set" + MakeNativeName(descriptor.binaryNameFor(name)) + nativeName = descriptor.binaryNameFor(name) + if nativeName == name: + nativeName = descriptor.internalNameFor(name) + return "Set" + MakeNativeName(nativeName) class CGStaticSetter(CGAbstractStaticBindingMethod): @@ -2948,9 +2959,9 @@ class CGStaticSetter(CGAbstractStaticBindingMethod): self.attr) checkForArg = CGGeneric( "let args = CallArgs::from_vp(vp, argc);\n" - "if (argc == 0) {\n" + "if argc == 0 {\n" " throw_type_error(cx, \"Not enough arguments to %s setter.\");\n" - " return 0;\n" + " return JSFalse;\n" "}" % self.attr.identifier.name) call = CGSetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor, self.attr) @@ -3045,8 +3056,9 @@ class CGMemberJITInfo(CGThing): def define(self): if self.member.isAttr(): - getterinfo = ("%s_getterinfo" % self.member.identifier.name) - getter = ("get_%s" % self.member.identifier.name) + internalMemberName = self.descriptor.internalNameFor(self.member.identifier.name) + getterinfo = ("%s_getterinfo" % internalMemberName) + getter = ("get_%s" % internalMemberName) getterinfal = "infallible" in self.descriptor.getExtendedAttributes(self.member, getter=True) movable = self.mayBeMovable() and getterinfal @@ -3070,8 +3082,8 @@ class CGMemberJITInfo(CGThing): slotIndex, [self.member.type], None) if (not self.member.readonly or self.member.getExtendedAttribute("PutForwards")): - setterinfo = ("%s_setterinfo" % self.member.identifier.name) - setter = ("set_%s" % self.member.identifier.name) + setterinfo = ("%s_setterinfo" % internalMemberName) + setter = ("set_%s" % internalMemberName) # Setters are always fallible, since they have to do a typed unwrap. result += self.defineJitInfo(setterinfo, setter, "Setter", False, False, "AliasEverything", @@ -4021,7 +4033,8 @@ class CGProxyUnwrap(CGAbstractMethod): def __init__(self, descriptor): args = [Argument('HandleObject', 'obj')] CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", - '*const ' + descriptor.concreteType, args, alwaysInline=True) + '*const ' + descriptor.concreteType, args, + alwaysInline=True, unsafe=True) def definition_body(self): return CGGeneric("""\ @@ -4218,7 +4231,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod): for name in (*unwrapped_proxy).SupportedPropertyNames() { let cstring = CString::new(name).unwrap(); let jsstring = JS_InternString(cx, cstring.as_ptr()); - let mut rooted = RootedString::new(cx, jsstring); + let rooted = RootedString::new(cx, jsstring); let jsid = INTERNED_STRING_TO_JSID(cx, rooted.handle().get()); let rooted_jsid = RootedId::new(cx, jsid); AppendToAutoIdVector(props, rooted_jsid.handle().get()); @@ -4338,7 +4351,7 @@ if !expando.ptr.is_null() { namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: - getNamed = ("if (RUST_JSID_IS_STRING(id) != 0) {\n" + + getNamed = ("if RUST_JSID_IS_STRING(id) != 0 {\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "}\n") else: @@ -5506,7 +5519,7 @@ class CallbackMember(CGNativeMember): conversion = ( CGIfWrapper(CGGeneric(conversion), "%s.is_some()" % arg.identifier.name).define() + - " else if (argc == %d) {\n" + " else if argc == %d {\n" " // This is our current trailing argument; reduce argc\n" " argc -= 1;\n" "} else {\n" @@ -5539,6 +5552,8 @@ class CallbackMember(CGNativeMember): "}\n") def getArgcDecl(self): + if self.argCount <= 1: + return CGGeneric("let argc = %s;" % self.argCountStr) return CGGeneric("let mut argc = %s;" % self.argCountStr) @staticmethod diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index 4e740f83a16..1a88968619b 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -263,6 +263,8 @@ class Descriptor(DescriptorProvider): self._binaryNames.setdefault('__legacycaller', 'LegacyCall') self._binaryNames.setdefault('__stringifier', 'Stringifier') + self._internalNames = desc.get('internalNames', {}) + for member in self.interface.members: if not member.isAttr() and not member.isMethod(): continue @@ -272,6 +274,8 @@ class Descriptor(DescriptorProvider): assert len(binaryName) == 1 self._binaryNames.setdefault(member.identifier.name, binaryName[0]) + self._internalNames.setdefault(member.identifier.name, + member.identifier.name.replace('-', '_')) # Build the prototype chain. self.prototypeChain = [] @@ -285,6 +289,9 @@ class Descriptor(DescriptorProvider): def binaryNameFor(self, name): return self._binaryNames.get(name, name) + def internalNameFor(self, name): + return self._internalNames.get(name, name) + def getExtendedAttributes(self, member, getter=False, setter=False): def maybeAppendInfallibleToAttrs(attrs, throws): if throws is None: diff --git a/components/script/dom/bindings/codegen/GlobalGen.py b/components/script/dom/bindings/codegen/GlobalGen.py index b3ed1e25b12..537883fae57 100644 --- a/components/script/dom/bindings/codegen/GlobalGen.py +++ b/components/script/dom/bindings/codegen/GlobalGen.py @@ -28,7 +28,7 @@ def generate_file(config, name, filename): def main(): # Parse arguments. from optparse import OptionParser - usageString = "usage: %prog [options] webidldir [files]" + usageString = "usage: %prog [options] configFile outputdir webidldir [files]" o = OptionParser(usage=usageString) o.add_option("--cachedir", dest='cachedir', default=None, help="Directory in which to cache lex/parse tables.") @@ -40,8 +40,9 @@ def main(): o.error(usageString) configFile = args[0] - baseDir = args[1] - fileList = args[2:] + outputdir = args[1] + baseDir = args[2] + fileList = args[3:] # Parse the WebIDL. parser = WebIDL.Parser(options.cachedir) @@ -59,22 +60,17 @@ def main(): # Load the configuration. config = Configuration(configFile, parserResults) - # Generate the prototype list. - generate_file(config, 'PrototypeList', 'PrototypeList.rs') - - # Generate the common code. - generate_file(config, 'RegisterBindings', 'RegisterBindings.rs') - - # Generate the type list. - generate_file(config, 'InterfaceTypes', 'InterfaceTypes.rs') - - # Generate the type list. - generate_file(config, 'InheritTypes', 'InheritTypes.rs') - - # Generate the module declarations. - generate_file(config, 'Bindings', 'Bindings/mod.rs') - - generate_file(config, 'UnionTypes', 'UnionTypes.rs') + to_generate = [ + ('PrototypeList', 'PrototypeList.rs'), + ('RegisterBindings', 'RegisterBindings.rs'), + ('InterfaceTypes', 'InterfaceTypes.rs'), + ('InheritTypes', 'InheritTypes.rs'), + ('Bindings', 'Bindings/mod.rs'), + ('UnionTypes', 'UnionTypes.rs'), + ] + + for name, filename in to_generate: + generate_file(config, name, os.path.join(outputdir, filename)) if __name__ == '__main__': main() diff --git a/components/script/dom/bindings/codegen/pythonpath.py b/components/script/dom/bindings/codegen/pythonpath.py deleted file mode 100644 index 793089551b5..00000000000 --- a/components/script/dom/bindings/codegen/pythonpath.py +++ /dev/null @@ -1,61 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -""" -Run a python script, adding extra directories to the python path. -""" - - -def main(args): - def usage(): - print >>sys.stderr, "pythonpath.py -I directory script.py [args...]" - sys.exit(150) - - paths = [] - - while True: - try: - arg = args[0] - except IndexError: - usage() - - if arg == '-I': - args.pop(0) - try: - path = args.pop(0) - except IndexError: - usage() - - paths.append(os.path.abspath(path)) - continue - - if arg.startswith('-I'): - paths.append(os.path.abspath(args.pop(0)[2:])) - continue - - if arg.startswith('-D'): - os.chdir(args.pop(0)[2:]) - continue - - break - - script = args[0] - - sys.path[0:0] = [os.path.abspath(os.path.dirname(script))] + paths - sys.argv = args - sys.argc = len(args) - - frozenglobals['__name__'] = '__main__' - frozenglobals['__file__'] = script - - execfile(script, frozenglobals) - -# Freeze scope here ... why this makes things work I have no idea ... -frozenglobals = globals() - -import sys -import os - -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/components/script/dom/bindings/mod.rs b/components/script/dom/bindings/mod.rs index 283dc9b08c9..1ded213d0f4 100644 --- a/components/script/dom/bindings/mod.rs +++ b/components/script/dom/bindings/mod.rs @@ -168,15 +168,13 @@ pub mod codegen { pub mod PrototypeList { include!(concat!(env!("OUT_DIR"), "/PrototypeList.rs")); } - #[allow(unreachable_code, non_camel_case_types, non_upper_case_globals, unused_parens, - unused_imports, unused_variables, unused_unsafe, unused_mut, unused_assignments, - dead_code)] + #[allow(non_camel_case_types, non_upper_case_globals, + unused_imports, unused_variables, unused_assignments)] pub mod RegisterBindings { include!(concat!(env!("OUT_DIR"), "/RegisterBindings.rs")); } - #[allow(unreachable_code, non_camel_case_types, non_upper_case_globals, unused_parens, - unused_imports, unused_variables, unused_unsafe, unused_mut, unused_assignments, - dead_code)] + #[allow(non_camel_case_types, non_upper_case_globals, + unused_imports, unused_variables, unused_assignments)] pub mod UnionTypes { include!(concat!(env!("OUT_DIR"), "/UnionTypes.rs")); } diff --git a/components/script/dom/bindings/num.rs b/components/script/dom/bindings/num.rs index 87c5e38a3bb..1169ccdec7f 100644 --- a/components/script/dom/bindings/num.rs +++ b/components/script/dom/bindings/num.rs @@ -9,7 +9,7 @@ use num::Float; use std::ops::Deref; /// Encapsulates the IDL restricted float type. -#[derive(JSTraceable,Clone,Eq,PartialEq)] +#[derive(JSTraceable, Clone, Eq, PartialEq)] pub struct Finite<T: Float>(T); unsafe impl<T: Float> Zeroable for Finite<T> {} diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index b1dcbbce163..8e48de2c680 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -29,7 +29,7 @@ //! The `no_jsmanaged_fields!()` macro adds an empty implementation of `JSTraceable` to //! a datatype. -use dom::bindings::js::JS; +use dom::bindings::js::{JS, Root}; use dom::bindings::refcounted::Trusted; use dom::bindings::utils::{Reflectable, Reflector, WindowProxyHandler}; use script_task::ScriptChan; @@ -69,6 +69,7 @@ use std::collections::{HashMap, HashSet}; use std::ffi::CString; use std::hash::{Hash, Hasher}; use std::intrinsics::return_address; +use std::iter::{FromIterator, IntoIterator}; use std::mem; use std::ops::{Deref, DerefMut}; use std::rc::Rc; @@ -511,6 +512,17 @@ impl<T: JSTraceable + Reflectable> DerefMut for RootedVec<T> { } } +impl<A: JSTraceable + Reflectable> FromIterator<Root<A>> for RootedVec<JS<A>> { + #[allow(moved_no_move)] + fn from_iter<T>(iterable: T) -> RootedVec<JS<A>> where T: IntoIterator<Item=Root<A>> { + let mut vec = RootedVec::new_with_destination_address(unsafe { + return_address() as *const libc::c_void + }); + vec.extend(iterable.into_iter().map(|item| JS::from_rooted(&item))); + vec + } +} + /// SM Callback that traces the rooted traceables pub unsafe fn trace_traceables(tracer: *mut JSTracer) { ROOTED_TRACEABLES.with(|ref traceables| { diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index e44e17d39de..247de62b23f 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -334,5 +334,6 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { rval } + // https://drafts.csswg.org/cssom/#cssstyledeclaration css_properties_accessors!(css_properties); } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index bc179a82133..d4a3b216914 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -357,6 +357,7 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope { Ok(()) } + // https://html.spec.whatwg.org/multipage/#handler-dedicatedworkerglobalscope-onmessage event_handler!(message, GetOnmessage, SetOnmessage); } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 0ff28055e9d..196ea7af438 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1842,7 +1842,10 @@ impl DocumentMethods for Document { // This method intentionally does nothing } + // https://html.spec.whatwg.org/multipage/#globaleventhandlers global_event_handlers!(); + + // https://html.spec.whatwg.org/multipage/#handler-onreadystatechange event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange); } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 83b7c24ed3a..4e03dff4086 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1867,10 +1867,10 @@ impl Element { } } // Step 6 - None => {event.fire(target);} + None => { event.fire(target); } }, // Step 6 - None => {event.fire(target);} + None => { event.fire(target); } } // Step 7 self.set_click_in_progress(false); diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 384ab976be3..ffd74806c04 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -253,11 +253,22 @@ impl FileReader { } impl FileReaderMethods for FileReader { + // https://w3c.github.io/FileAPI/#dfn-onloadstart event_handler!(loadstart, GetOnloadstart, SetOnloadstart); + + // https://w3c.github.io/FileAPI/#dfn-onprogress event_handler!(progress, GetOnprogress, SetOnprogress); + + // https://w3c.github.io/FileAPI/#dfn-onload event_handler!(load, GetOnload, SetOnload); + + // https://w3c.github.io/FileAPI/#dfn-onabort event_handler!(abort, GetOnabort, SetOnabort); + + // https://w3c.github.io/FileAPI/#dfn-onerror event_handler!(error, GetOnerror, SetOnerror); + + // https://w3c.github.io/FileAPI/#dfn-onloadend event_handler!(loadend, GetOnloadend, SetOnloadend); //TODO https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index 8390430c39e..8631cefbd4a 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -85,21 +85,14 @@ impl FormDataMethods for FormData { self.data.borrow_mut().remove(&name); } - #[allow(unsafe_code)] // https://xhr.spec.whatwg.org/#dom-formdata-get fn Get(&self, name: DOMString) -> Option<FileOrString> { - // FIXME(https://github.com/rust-lang/rust/issues/23338) - let data = self.data.borrow(); - if data.contains_key(&name) { - match data[&name][0].clone() { - FormDatum::StringData(ref s) => Some(eString(s.clone())), - FormDatum::FileData(ref f) => { - Some(eFile(f.root())) - } - } - } else { - None - } + self.data.borrow() + .get(&name) + .map(|entry| match entry[0] { + FormDatum::StringData(ref s) => eString(s.clone()), + FormDatum::FileData(ref f) => eFile(f.root()), + }) } // https://xhr.spec.whatwg.org/#dom-formdata-has diff --git a/components/script/dom/htmlappletelement.rs b/components/script/dom/htmlappletelement.rs index a3cb281497b..988aa36e9ee 100644 --- a/components/script/dom/htmlappletelement.rs +++ b/components/script/dom/htmlappletelement.rs @@ -54,6 +54,8 @@ impl HTMLAppletElement { impl HTMLAppletElementMethods for HTMLAppletElement { // https://html.spec.whatwg.org/#the-applet-element:dom-applet-name make_getter!(Name); + + // https://html.spec.whatwg.org/#the-applet-element:dom-applet-name make_atomic_setter!(SetName, "name"); } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index a38e385bc9c..3016966fc10 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -71,6 +71,8 @@ impl HTMLBodyElement { impl HTMLBodyElementMethods for HTMLBodyElement { // https://html.spec.whatwg.org/multipage#dom-body-bgcolor make_getter!(BgColor, "bgcolor"); + + // https://html.spec.whatwg.org/multipage#dom-body-bgcolor make_setter!(SetBgColor, "bgcolor"); // https://html.spec.whatwg.org/multipage/#the-body-element diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index a8c95eb6d3b..c7f3e71807e 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -98,22 +98,29 @@ impl HTMLButtonElementMethods for HTMLButtonElement { // https://html.spec.whatwg.org/multipage/#dom-button-type make_setter!(SetType, "type"); - // https://html.spec.whatwg.org/multipage/#htmlbuttonelement + // https://html.spec.whatwg.org/multipage/#dom-fs-formaction make_url_or_base_getter!(FormAction); + // https://html.spec.whatwg.org/multipage/#dom-fs-formaction make_setter!(SetFormAction, "formaction"); + // https://html.spec.whatwg.org/multipage/#dom-fs-formenctype make_enumerated_getter!( FormEnctype, "application/x-www-form-urlencoded", ("text/plain") | ("multipart/form-data")); + // https://html.spec.whatwg.org/multipage/#dom-fs-formenctype make_setter!(SetFormEnctype, "formenctype"); + // https://html.spec.whatwg.org/multipage/#dom-fs-formmethod make_enumerated_getter!(FormMethod, "get", ("post") | ("dialog")); + // https://html.spec.whatwg.org/multipage/#dom-fs-formmethod make_setter!(SetFormMethod, "formmethod"); + // https://html.spec.whatwg.org/multipage/#dom-fs-formtarget make_getter!(FormTarget); + // https://html.spec.whatwg.org/multipage/#dom-fs-formtarget make_setter!(SetFormTarget, "formtarget"); // https://html.spec.whatwg.org/multipage/#dom-fe-name diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 6aee8645ad8..ad16e70afa2 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -64,7 +64,7 @@ impl HTMLCollection { } } } - let filter = AllElementFilter {namespace_filter: namespace_filter}; + let filter = AllElementFilter { namespace_filter: namespace_filter }; HTMLCollection::create(window, root, box filter) } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 0b9ea1e6b8c..80e6f93d36e 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -130,16 +130,22 @@ impl HTMLElementMethods for HTMLElement { }) } + // https://html.spec.whatwg.org/multipage/#attr-title make_getter!(Title); + // https://html.spec.whatwg.org/multipage/#attr-title make_setter!(SetTitle, "title"); + // https://html.spec.whatwg.org/multipage/#attr-lang make_getter!(Lang); + // https://html.spec.whatwg.org/multipage/#attr-lang make_setter!(SetLang, "lang"); // https://html.spec.whatwg.org/multipage/#dom-hidden make_bool_getter!(Hidden); + // https://html.spec.whatwg.org/multipage/#dom-hidden make_bool_setter!(SetHidden, "hidden"); + // https://html.spec.whatwg.org/multipage/#globaleventhandlers global_event_handlers!(NoOnload); // https://html.spec.whatwg.org/multipage/#dom-dataset diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index 03750d382b8..6b745617b94 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -50,7 +50,10 @@ impl HTMLFontElement { } impl HTMLFontElementMethods for HTMLFontElement { + // https://html.spec.whatwg.org/multipage/#dom-font-color make_getter!(Color, "color"); + + // https://html.spec.whatwg.org/multipage/#dom-font-color make_setter!(SetColor, "color"); } diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 11613d866b2..05f7442bbcc 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -122,6 +122,8 @@ impl HTMLFormElementMethods for HTMLFormElement { // https://html.spec.whatwg.org/multipage/#dom-form-name make_getter!(Name); + + // https://html.spec.whatwg.org/multipage/#dom-form-name make_atomic_setter!(SetName, "name"); // https://html.spec.whatwg.org/multipage/#dom-fs-novalidate diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 6abf4f7b877..e4665847468 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -339,12 +339,14 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { Err(NotSupported) } + // https://html.spec.whatwg.org/multipage/#dom-dim-width make_getter!(Width); - + // https://html.spec.whatwg.org/multipage/#dom-dim-width make_setter!(SetWidth, "width"); + // https://html.spec.whatwg.org/multipage/#dom-dim-height make_getter!(Height); - + // https://html.spec.whatwg.org/multipage/#dom-dim-height make_setter!(SetHeight, "height"); } diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index dcb69a44104..bfd6ca2fdd8 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -197,18 +197,22 @@ impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> { } impl HTMLImageElementMethods for HTMLImageElement { + // https://html.spec.whatwg.org/multipage/#dom-img-alt make_getter!(Alt); - + // https://html.spec.whatwg.org/multipage/#dom-img-alt make_setter!(SetAlt, "alt"); + // https://html.spec.whatwg.org/multipage/#dom-img-src make_url_getter!(Src); - + // https://html.spec.whatwg.org/multipage/#dom-img-src make_setter!(SetSrc, "src"); + // https://html.spec.whatwg.org/multipage/#dom-img-usemap make_getter!(UseMap); - + // https://html.spec.whatwg.org/multipage/#dom-img-usemap make_setter!(SetUseMap, "usemap"); + // https://html.spec.whatwg.org/multipage/#dom-img-ismap make_bool_getter!(IsMap); // https://html.spec.whatwg.org/multipage/#dom-img-ismap @@ -269,28 +273,40 @@ impl HTMLImageElementMethods for HTMLImageElement { image.is_some() } - // https://html.spec.whatwg.org/#dom-img-name + // https://html.spec.whatwg.org/multipage/#dom-img-name make_getter!(Name); + + // https://html.spec.whatwg.org/multipage/#dom-img-name make_atomic_setter!(SetName, "name"); + // https://html.spec.whatwg.org/multipage/#dom-img-align make_getter!(Align); + // https://html.spec.whatwg.org/multipage/#dom-img-align make_setter!(SetAlign, "align"); + // https://html.spec.whatwg.org/multipage/#dom-img-hspace make_uint_getter!(Hspace); + // https://html.spec.whatwg.org/multipage/#dom-img-hspace make_uint_setter!(SetHspace, "hspace"); + // https://html.spec.whatwg.org/multipage/#dom-img-vspace make_uint_getter!(Vspace); + // https://html.spec.whatwg.org/multipage/#dom-img-vspace make_uint_setter!(SetVspace, "vspace"); + // https://html.spec.whatwg.org/multipage/#dom-img-longdesc make_getter!(LongDesc); + // https://html.spec.whatwg.org/multipage/#dom-img-longdesc make_setter!(SetLongDesc, "longdesc"); + // https://html.spec.whatwg.org/multipage/#dom-img-border make_getter!(Border); + // https://html.spec.whatwg.org/multipage/#dom-img-border make_setter!(SetBorder, "border"); } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index becbf7c4947..9204e20ab22 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -247,6 +247,8 @@ impl HTMLInputElementMethods for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#dom-input-size make_uint_getter!(Size, "size", DEFAULT_INPUT_SIZE); + + // https://html.spec.whatwg.org/multipage/#dom-input-size make_limited_uint_setter!(SetSize, "size", DEFAULT_INPUT_SIZE); // https://html.spec.whatwg.org/multipage/#dom-input-type diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 072e14bab3b..b9e3d0e081b 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -209,19 +209,34 @@ impl HTMLLinkElement { } impl HTMLLinkElementMethods for HTMLLinkElement { + // https://html.spec.whatwg.org/multipage/#dom-link-href make_url_getter!(Href); + + // https://html.spec.whatwg.org/multipage/#dom-link-href make_setter!(SetHref, "href"); + // https://html.spec.whatwg.org/multipage/#dom-link-rel make_getter!(Rel); + + // https://html.spec.whatwg.org/multipage/#dom-link-rel make_setter!(SetRel, "rel"); + // https://html.spec.whatwg.org/multipage/#dom-link-media make_getter!(Media); + + // https://html.spec.whatwg.org/multipage/#dom-link-media make_setter!(SetMedia, "media"); + // https://html.spec.whatwg.org/multipage/#dom-link-hreflang make_getter!(Hreflang); + + // https://html.spec.whatwg.org/multipage/#dom-link-hreflang make_setter!(SetHreflang, "hreflang"); + // https://html.spec.whatwg.org/multipage/#dom-link-type make_getter!(Type); + + // https://html.spec.whatwg.org/multipage/#dom-link-type make_setter!(SetType, "type"); // https://html.spec.whatwg.org/multipage/#dom-link-rellist diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 82908e2d78f..97cd6573fda 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -571,8 +571,9 @@ impl VirtualMethods for HTMLScriptElement { } impl HTMLScriptElementMethods for HTMLScriptElement { + // https://html.spec.whatwg.org/multipage/#dom-script-src make_url_getter!(Src); - + // https://html.spec.whatwg.org/multipage/#dom-script-src make_setter!(SetSrc, "src"); // https://www.whatwg.org/html/#dom-script-text diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 153593f5e58..db4a08a00c5 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -77,6 +77,8 @@ impl HTMLTableCellElement { impl HTMLTableCellElementMethods for HTMLTableCellElement { // https://html.spec.whatwg.org/multipage/#dom-tdth-colspan make_uint_getter!(ColSpan, "colspan", DEFAULT_COLSPAN); + + // https://html.spec.whatwg.org/multipage/#dom-tdth-colspan make_uint_setter!(SetColSpan, "colspan"); } diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 333e5259394..a0a0c12b705 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -121,6 +121,8 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { // https://html.spec.whatwg.org/multipage/#dom-textarea-cols make_uint_getter!(Cols, "cols", DEFAULT_COLS); + + // https://html.spec.whatwg.org/multipage/#dom-textarea-cols make_limited_uint_setter!(SetCols, "cols", DEFAULT_COLS); // https://www.whatwg.org/html/#dom-fe-disabled @@ -155,6 +157,8 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { // https://html.spec.whatwg.org/multipage/#dom-textarea-rows make_uint_getter!(Rows, "rows", DEFAULT_ROWS); + + // https://html.spec.whatwg.org/multipage/#dom-textarea-rows make_limited_uint_setter!(SetRows, "rows", DEFAULT_ROWS); // https://html.spec.whatwg.org/multipage/#dom-textarea-wrap diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index 22c250bbb55..8b5cf37965e 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -4,6 +4,7 @@ use dom::bindings::codegen::Bindings::LocationBinding; use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods; +use dom::bindings::error::ErrorResult; use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, Root}; use dom::bindings::str::USVString; @@ -33,6 +34,18 @@ impl Location { GlobalRef::Window(window), LocationBinding::Wrap) } + + fn get_url(&self) -> Url { + self.window.root().get_url() + } + + fn set_url_component(&self, value: USVString, + setter: fn(&mut Url, USVString)) { + let window = self.window.root(); + let mut url = window.get_url(); + setter(&mut url, value); + window.load_url(url); + } } impl LocationMethods for Location { @@ -52,9 +65,9 @@ impl LocationMethods for Location { UrlHelper::Hash(&self.get_url()) } - // https://url.spec.whatwg.org/#dom-urlutils-href - fn Href(&self) -> USVString { - UrlHelper::Href(&self.get_url()) + // https://url.spec.whatwg.org/#dom-urlutils-hash + fn SetHash(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetHash); } // https://url.spec.whatwg.org/#dom-urlutils-host @@ -62,31 +75,75 @@ impl LocationMethods for Location { UrlHelper::Host(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-host + fn SetHost(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetHost); + } + // https://url.spec.whatwg.org/#dom-urlutils-hostname fn Hostname(&self) -> USVString { UrlHelper::Hostname(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-hostname + fn SetHostname(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetHostname); + } + + // https://url.spec.whatwg.org/#dom-urlutils-href + fn Href(&self) -> USVString { + UrlHelper::Href(&self.get_url()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-href + fn SetHref(&self, value: USVString) -> ErrorResult { + let window = self.window.root(); + if let Ok(url) = UrlParser::new().base_url(&window.get_url()).parse(&value.0) { + window.load_url(url); + }; + Ok(()) + } + // https://url.spec.whatwg.org/#dom-urlutils-password fn Password(&self) -> USVString { UrlHelper::Password(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-password + fn SetPassword(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetPassword); + } + // https://url.spec.whatwg.org/#dom-urlutils-pathname fn Pathname(&self) -> USVString { UrlHelper::Pathname(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-pathname + fn SetPathname(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetPathname); + } + // https://url.spec.whatwg.org/#dom-urlutils-port fn Port(&self) -> USVString { UrlHelper::Port(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-port + fn SetPort(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetPort); + } + // https://url.spec.whatwg.org/#dom-urlutils-protocol fn Protocol(&self) -> USVString { UrlHelper::Protocol(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-protocol + fn SetProtocol(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetProtocol); + } + // https://url.spec.whatwg.org/#URLUtils-stringification-behavior fn Stringifier(&self) -> DOMString { self.Href().0 @@ -97,16 +154,18 @@ impl LocationMethods for Location { UrlHelper::Search(&self.get_url()) } + // https://url.spec.whatwg.org/#dom-urlutils-search + fn SetSearch(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetSearch); + } + // https://url.spec.whatwg.org/#dom-urlutils-username fn Username(&self) -> USVString { UrlHelper::Username(&self.get_url()) } -} - -impl Location { - fn get_url(&self) -> Url { - let window = self.window.root(); - window.r().get_url() + // https://url.spec.whatwg.org/#dom-urlutils-username + fn SetUsername(&self, value: USVString) { + self.set_url_component(value, UrlHelper::SetUsername); } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index ac21c9eefc2..f46cbc0be11 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1629,8 +1629,7 @@ impl Node { Node::adopt(node, &*parent.owner_doc()); } // Step 2. - let mut removed_nodes = RootedVec::new(); - removed_nodes.extend(parent.children().map(|child| JS::from_rooted(&child))); + let removed_nodes = parent.children().collect::<RootedVec<_>>(); // Step 3. let mut added_nodes = RootedVec::new(); let added_nodes = if let Some(node) = node.as_ref() { diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 01bc27d3a08..3e2bc5145c6 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -215,7 +215,10 @@ impl ChildrenList { }, }; list.last_visited.set(Some(JS::from_ref(visited))); - } else { + } else if added.len() != 1 { + // The replaced child isn't the last visited one, and there are + // 0 or more than 1 nodes to replace it. Special care must be + // given to update the state of that ChildrenList. match (prev, next) { (Some(_), None) => {}, (None, Some(next)) => { diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index 88a369606ae..b715330edae 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -52,9 +52,9 @@ impl ProgressEvent { type_: DOMString, init: &ProgressEventBinding::ProgressEventInit) -> Fallible<Root<ProgressEvent>> { - let bubbles = if init.parent.bubbles {EventBubbles::Bubbles} else {EventBubbles::DoesNotBubble}; - let cancelable = if init.parent.cancelable {EventCancelable::Cancelable} - else {EventCancelable::NotCancelable}; + let bubbles = if init.parent.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble }; + let cancelable = if init.parent.cancelable { EventCancelable::Cancelable } + else { EventCancelable::NotCancelable }; let ev = ProgressEvent::new(global, type_, bubbles, cancelable, init.lengthComputable, init.loaded, init.total); Ok(ev) diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 335e261634b..e050f799c8f 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -120,6 +120,10 @@ impl TestBindingMethods for TestBinding { fn SetBinaryRenamedAttribute(&self, _: DOMString) {} fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) } fn BinaryRenamedAttribute(&self) -> DOMString { "".to_owned() } + fn SetBinaryRenamedAttribute2(&self, _: DOMString) {} + fn BinaryRenamedAttribute2(&self) -> DOMString { "".to_owned() } + fn Attr_to_automatically_rename(&self) -> DOMString { "".to_owned() } + fn SetAttr_to_automatically_rename(&self, _: DOMString) {} fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) } fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> { let global = self.global.root(); diff --git a/components/script/dom/testbindingproxy.rs b/components/script/dom/testbindingproxy.rs index 3c1f23c8ae1..5ca27eae735 100644 --- a/components/script/dom/testbindingproxy.rs +++ b/components/script/dom/testbindingproxy.rs @@ -15,20 +15,20 @@ pub struct TestBindingProxy { } impl TestBindingProxyMethods for TestBindingProxy { - fn Length(&self) -> u32 {0} - fn SupportedPropertyNames(&self) -> Vec<DOMString> {vec![]} - fn GetNamedItem(&self, _: DOMString) -> DOMString {"".to_owned()} + fn Length(&self) -> u32 { 0 } + fn SupportedPropertyNames(&self) -> Vec<DOMString> { vec![] } + fn GetNamedItem(&self, _: DOMString) -> DOMString { "".to_owned() } fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {} - fn GetItem(&self, _: u32) -> DOMString {"".to_owned()} + fn GetItem(&self, _: u32) -> DOMString { "".to_owned() } fn SetItem(&self, _: u32, _: DOMString) -> () {} fn RemoveItem(&self, _: DOMString) -> () {} - fn Stringifier(&self) -> DOMString {"".to_owned()} + fn Stringifier(&self) -> DOMString { "".to_owned() } fn NamedCreator(&self, _: DOMString, _: DOMString) -> () {} - fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString {"".to_owned()} + fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { "".to_owned() } fn NamedDeleter(&self, _: DOMString) -> () {} fn IndexedSetter(&self, _: u32, _: DOMString) -> () {} fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {} fn IndexedCreator(&self, _: u32, _: DOMString) -> () {} - fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString {"".to_owned()} + fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { "".to_owned() } } diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index ec44fe2fdf9..f34428d4bbb 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -3,17 +3,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods}; -use dom::bindings::error::{Error, Fallible}; +use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::global::GlobalRef; use dom::bindings::js::Root; use dom::bindings::str::USVString; use dom::bindings::utils::{Reflector, reflect_dom_object}; use dom::urlhelper::UrlHelper; -use url::{Host, Url, UrlParser}; +use url::{Host, ParseResult, Url, UrlParser}; use util::str::DOMString; use std::borrow::ToOwned; +use std::cell::RefCell; // https://url.spec.whatwg.org/#url #[dom_struct] @@ -21,19 +22,23 @@ pub struct URL { reflector_: Reflector, // https://url.spec.whatwg.org/#concept-urlutils-url - url: Url, + url: RefCell<Url>, + + // https://url.spec.whatwg.org/#concept-urlutils-get-the-base + base: Option<Url>, } impl URL { - fn new_inherited(url: Url) -> URL { + fn new_inherited(url: Url, base: Option<Url>) -> URL { URL { reflector_: Reflector::new(), - url: url, + url: RefCell::new(url), + base: base, } } - pub fn new(global: GlobalRef, url: Url) -> Root<URL> { - reflect_dom_object(box URL::new_inherited(url), + pub fn new(global: GlobalRef, url: Url, base: Option<Url>) -> Root<URL> { + reflect_dom_object(box URL::new_inherited(url, base), global, URLBinding::Wrap) } } @@ -59,7 +64,7 @@ impl URL { } }; // Step 3. - let parsed_url = match parser_with_base(parsed_base.as_ref()).parse(&url.0) { + let parsed_url = match parse_with_base(url, parsed_base.as_ref()) { Ok(url) => url, Err(error) => { // Step 4. @@ -67,7 +72,7 @@ impl URL { } }; // Steps 5-8. - Ok(URL::new(global, parsed_url)) + Ok(URL::new(global, parsed_url, parsed_base)) } // https://url.spec.whatwg.org/#dom-url-domaintoasciidomain @@ -87,47 +92,100 @@ impl URL { impl URLMethods for URL { // https://url.spec.whatwg.org/#dom-urlutils-hash fn Hash(&self) -> USVString { - UrlHelper::Hash(&self.url) + UrlHelper::Hash(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-hash + fn SetHash(&self, value: USVString) { + UrlHelper::SetHash(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-host fn Host(&self) -> USVString { - UrlHelper::Host(&self.url) + UrlHelper::Host(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-host + fn SetHost(&self, value: USVString) { + UrlHelper::SetHost(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-hostname fn Hostname(&self) -> USVString { - UrlHelper::Hostname(&self.url) + UrlHelper::Hostname(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-hostname + fn SetHostname(&self, value: USVString) { + UrlHelper::SetHostname(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-href fn Href(&self) -> USVString { - UrlHelper::Href(&self.url) + UrlHelper::Href(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-href + fn SetHref(&self, value: USVString) -> ErrorResult { + match parse_with_base(value, self.base.as_ref()) { + Ok(url) => { + *self.url.borrow_mut() = url; + Ok(()) + }, + Err(error) => { + Err(Error::Type(format!("could not parse URL: {}", error))) + }, + } } // https://url.spec.whatwg.org/#dom-urlutils-password fn Password(&self) -> USVString { - UrlHelper::Password(&self.url) + UrlHelper::Password(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-password + fn SetPassword(&self, value: USVString) { + UrlHelper::SetPassword(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-pathname fn Pathname(&self) -> USVString { - UrlHelper::Pathname(&self.url) + UrlHelper::Pathname(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-pathname + fn SetPathname(&self, value: USVString) { + UrlHelper::SetPathname(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-port fn Port(&self) -> USVString { - UrlHelper::Port(&self.url) + UrlHelper::Port(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-port + fn SetPort(&self, value: USVString) { + UrlHelper::SetPort(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-protocol fn Protocol(&self) -> USVString { - UrlHelper::Protocol(&self.url) + UrlHelper::Protocol(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-protocol + fn SetProtocol(&self, value: USVString) { + UrlHelper::SetProtocol(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#dom-urlutils-search fn Search(&self) -> USVString { - UrlHelper::Search(&self.url) + UrlHelper::Search(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-search + fn SetSearch(&self, value: USVString) { + UrlHelper::SetSearch(&mut self.url.borrow_mut(), value); } // https://url.spec.whatwg.org/#URLUtils-stringification-behavior @@ -137,14 +195,19 @@ impl URLMethods for URL { // https://url.spec.whatwg.org/#dom-urlutils-username fn Username(&self) -> USVString { - UrlHelper::Username(&self.url) + UrlHelper::Username(&self.url.borrow()) + } + + // https://url.spec.whatwg.org/#dom-urlutils-username + fn SetUsername(&self, value: USVString) { + UrlHelper::SetUsername(&mut self.url.borrow_mut(), value); } } -fn parser_with_base(base: Option<&Url>) -> UrlParser { +fn parse_with_base(input: USVString, base: Option<&Url>) -> ParseResult<Url> { let mut parser = UrlParser::new(); if let Some(base) = base { parser.base_url(base); } - parser + parser.parse(&input.0) } diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index 4376a85e390..684d6666e0c 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -4,7 +4,9 @@ use dom::bindings::str::USVString; -use url::{Url, SchemeData}; +use url::{Url, UrlParser, SchemeData}; + +use url::urlutils::{UrlUtils, UrlUtilsWrapper}; use std::borrow::ToOwned; use std::fmt::Write; @@ -22,6 +24,12 @@ impl UrlHelper { }) } + // https://url.spec.whatwg.org/#dom-urlutils-hash + pub fn SetHash(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_fragment(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-host pub fn Host(url: &Url) -> USVString { USVString(match url.scheme_data { @@ -36,11 +44,23 @@ impl UrlHelper { }) } + // https://url.spec.whatwg.org/#dom-urlutils-host + pub fn SetHost(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_host(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-hostname pub fn Hostname(url: &Url) -> USVString { USVString(url.serialize_host().unwrap_or_else(|| "".to_owned())) } + // https://url.spec.whatwg.org/#dom-urlutils-hostname + pub fn SetHostname(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_host_and_port(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-href pub fn Href(url: &Url) -> USVString { USVString(url.serialize()) @@ -51,15 +71,26 @@ impl UrlHelper { USVString(url.password().unwrap_or("").to_owned()) } + // https://url.spec.whatwg.org/#dom-urlutils-password + pub fn SetPassword(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_password(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-pathname pub fn Pathname(url: &Url) -> USVString { - // FIXME: Url null check is skipped for now USVString(match url.scheme_data { SchemeData::NonRelative(ref scheme_data) => scheme_data.clone(), SchemeData::Relative(..) => url.serialize_path().unwrap() }) } + // https://url.spec.whatwg.org/#dom-urlutils-pathname + pub fn SetPathname(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_path(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-port pub fn Port(url: &Url) -> USVString { USVString(match url.port() { @@ -68,11 +99,23 @@ impl UrlHelper { }) } + // https://url.spec.whatwg.org/#dom-urlutils-port + pub fn SetPort(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_port(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-protocol pub fn Protocol(url: &Url) -> USVString { USVString(format!("{}:", url.scheme.clone())) } + // https://url.spec.whatwg.org/#dom-urlutils-protocol + pub fn SetProtocol(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_scheme(&value.0); + } + // https://html.spec.whatwg.org/multipage/#same-origin pub fn SameOrigin(urlA: &Url, urlB: &Url) -> bool { if urlA.host() != urlB.host() { @@ -96,8 +139,20 @@ impl UrlHelper { }) } + // https://url.spec.whatwg.org/#dom-urlutils-search + pub fn SetSearch(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_query(&value.0); + } + // https://url.spec.whatwg.org/#dom-urlutils-username pub fn Username(url: &Url) -> USVString { USVString(url.username().unwrap_or("").to_owned()) } + + // https://url.spec.whatwg.org/#dom-urlutils-username + pub fn SetUsername(url: &mut Url, value: USVString) { + let mut wrapper = UrlUtilsWrapper { url: url, parser: &UrlParser::new() }; + let _ = wrapper.set_username(&value.0); + } } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 3920bcb7b7c..bcad061853f 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -11,10 +11,19 @@ use dom::webglobject::WebGLObject; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; +use angle::hl::{BuiltInResources, Output, ShaderValidator}; use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLResult, WebGLError, WebGLShaderParameter}; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; use std::cell::RefCell; +use std::sync::{Once, ONCE_INIT}; + +#[derive(Clone, Copy, PartialEq, Debug, JSTraceable, HeapSizeOf)] +pub enum ShaderCompilationStatus { + NotCompiled, + Succeeded, + Failed, +} #[dom_struct] pub struct WebGLShader { @@ -22,20 +31,32 @@ pub struct WebGLShader { id: u32, gl_type: u32, source: RefCell<Option<String>>, + info_log: RefCell<Option<String>>, is_deleted: Cell<bool>, - // TODO(ecoal95): Evaluate moving this to `WebGLObject` + compilation_status: Cell<ShaderCompilationStatus>, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: IpcSender<CanvasMsg>, } +#[cfg(not(target_os = "android"))] +const SHADER_OUTPUT_FORMAT: Output = Output::Glsl; + +#[cfg(target_os = "android")] +const SHADER_OUTPUT_FORMAT: Output = Output::Essl; + +static GLSLANG_INITIALIZATION: Once = ONCE_INIT; + impl WebGLShader { fn new_inherited(renderer: IpcSender<CanvasMsg>, id: u32, shader_type: u32) -> WebGLShader { + GLSLANG_INITIALIZATION.call_once(|| ::angle::hl::initialize().unwrap()); WebGLShader { webgl_object: WebGLObject::new_inherited(), id: id, gl_type: shader_type, source: RefCell::new(None), + info_log: RefCell::new(None), is_deleted: Cell::new(false), + compilation_status: Cell::new(ShaderCompilationStatus::NotCompiled), renderer: renderer, } } @@ -69,10 +90,33 @@ impl WebGLShader { self.gl_type } - // TODO(ecoal95): Validate shaders to be conforming to the WebGL spec /// glCompileShader pub fn compile(&self) { - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::CompileShader(self.id))).unwrap() + if self.compilation_status.get() != ShaderCompilationStatus::NotCompiled { + debug!("Compiling already compiled shader {}", self.id); + } + + if let Some(ref source) = *self.source.borrow() { + let validator = ShaderValidator::for_webgl(self.gl_type, + SHADER_OUTPUT_FORMAT, + &BuiltInResources::default()).unwrap(); + match validator.compile_and_translate(&[source.as_bytes()]) { + Ok(translated_source) => { + // NOTE: At this point we should be pretty sure that the compilation in the paint task + // will succeed. + // It could be interesting to retrieve the info log from the paint task though + let msg = CanvasWebGLMsg::CompileShader(self.id, translated_source); + self.renderer.send(CanvasMsg::WebGL(msg)).unwrap(); + self.compilation_status.set(ShaderCompilationStatus::Succeeded); + }, + Err(error) => { + self.compilation_status.set(ShaderCompilationStatus::Failed); + debug!("Shader {} compilation failed: {}", self.id, error); + }, + } + + *self.info_log.borrow_mut() = Some(validator.info_log()); + } } /// Mark this shader as deleted (if it wasn't previously) @@ -86,9 +130,7 @@ impl WebGLShader { /// glGetShaderInfoLog pub fn info_log(&self) -> Option<String> { - let (sender, receiver) = ipc::channel().unwrap(); - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetShaderInfoLog(self.id, sender))).unwrap(); - receiver.recv().unwrap() + self.info_log.borrow().clone() } /// glGetShaderParameter @@ -110,7 +152,6 @@ impl WebGLShader { /// glShaderSource pub fn set_source(&self, source: String) { - *self.source.borrow_mut() = Some(source.clone()); - self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::ShaderSource(self.id, source))).unwrap() + *self.source.borrow_mut() = Some(source); } } diff --git a/components/script/dom/webidls/CSSStyleDeclaration.webidl b/components/script/dom/webidls/CSSStyleDeclaration.webidl index 014e12740bf..dba69a515b0 100644 --- a/components/script/dom/webidls/CSSStyleDeclaration.webidl +++ b/components/script/dom/webidls/CSSStyleDeclaration.webidl @@ -34,40 +34,73 @@ interface CSSStyleDeclaration { partial interface CSSStyleDeclaration { [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundPosition; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-position; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundRepeat; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-repeat; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundImage; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-image; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundAttachment; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-attachment; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-size; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundOrigin; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-origin; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backgroundClip; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString background-clip; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderRadius; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-radius; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderSpacing; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-spacing; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBottom; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-bottom; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBottomColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-bottom-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBottomLeftRadius; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-bottom-left-radius; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBottomRightRadius; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-bottom-right-radius; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBottomStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-bottom-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderBottomWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-bottom-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderLeft; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-left; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderLeftColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-left-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderLeftStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-left-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderLeftWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-left-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderRight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-right; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderRightColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-right-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderRightStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-right-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderRightWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-right-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderTop; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-top; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderTopColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-top-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderTopLeftRadius; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-top-left-radius; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderTopRightRadius; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-top-right-radius; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderTopStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-top-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderTopWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-top-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString content; @@ -82,8 +115,11 @@ partial interface CSSStyleDeclaration { [SetterThrows, TreatNullAs=EmptyString] attribute DOMString cursor; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString boxSizing; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString box-sizing; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString boxShadow; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString box-shadow; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textShadow; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-shadow; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString _float; @@ -93,89 +129,143 @@ partial interface CSSStyleDeclaration { [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transform; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transformOrigin; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transform-origin; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString perspective; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString perspectiveOrigin; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString perspective-origin; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transformStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transform-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backfaceVisibility; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString backface-visibility; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString direction; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString unicodeBidi; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString unicode-bidi; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString filter; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString lineHeight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString line-height; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString mixBlendMode; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString mix-blend-mode; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString verticalAlign; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString vertical-align; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString listStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString list-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString listStylePosition; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString list-style-position; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString listStyleType; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString list-style-type; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString listStyleImage; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString list-style-image; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString quotes; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString counterIncrement; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString counter-increment; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString counterReset; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString counter-reset; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflow; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflowX; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflow-x; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflowY; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflow-y; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflowWrap; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString overflow-wrap; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString tableLayout; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString table-layout; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString borderCollapse; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString border-collapse; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString emptyCells; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString empty-cells; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString captionSide; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString caption-side; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString whiteSpace; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString white-space; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString writingMode; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString writing-mode; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString letterSpacing; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString letter-spacing; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString wordBreak; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString word-break; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString wordSpacing; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString word-spacing; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString wordWrap; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString word-wrap; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textOverflow; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-overflow; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textAlign; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-align; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textDecoration; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-decoration; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textIndent; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-indent; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textJustify; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-justify; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textOrientation; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-orientation; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textRendering; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-rendering; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString textTransform; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString text-transform; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontFamily; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-family; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontSize; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-size; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontStretch; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-stretch; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontVariant; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-variant; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString fontWeight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString font-weight; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginBottom; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-bottom; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginLeft; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-left; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginRight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-right; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString marginTop; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString margin-top; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingBottom; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-bottom; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingLeft; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-left; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingRight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-right; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString paddingTop; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString padding-top; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outline; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outlineColor; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outline-color; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outlineStyle; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outline-style; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outlineWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outline-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outlineOffset; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString outline-offset; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString position; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString pointerEvents; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString pointer-events; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString top; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString right; @@ -184,26 +274,40 @@ partial interface CSSStyleDeclaration { [SetterThrows, TreatNullAs=EmptyString] attribute DOMString height; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString minHeight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString min-height; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString maxHeight; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString max-height; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString minWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString min-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString maxWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString max-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString zIndex; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString z-index; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString imageRendering; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString image-rendering; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString columnCount; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString column-count; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString columnWidth; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString column-width; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString columns; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString columnGap; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString column-gap; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transition; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transitionDuration; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transition-duration; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transitionTimingFunction; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transition-timing-function; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transitionProperty; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transition-property; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transitionDelay; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString transition-delay; [SetterThrows, TreatNullAs=EmptyString] attribute DOMString flexDirection; + [SetterThrows, TreatNullAs=EmptyString] attribute DOMString flex-direction; }; diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 08221f2ccc0..181909721aa 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -115,6 +115,8 @@ interface TestBinding { attribute (HTMLElement or long)? unionAttributeNullable; attribute (Event or DOMString)? union2AttributeNullable; [BinaryName="BinaryRenamedAttribute"] attribute DOMString attrToBinaryRename; + [BinaryName="BinaryRenamedAttribute2"] attribute DOMString attr-to-binary-rename; + attribute DOMString attr-to-automatically-rename; [PutForwards=booleanAttribute] readonly attribute TestBinding forwardedAttribute; diff --git a/components/script/dom/webidls/URLUtils.webidl b/components/script/dom/webidls/URLUtils.webidl index 86e5140311b..1b8965f3d37 100644 --- a/components/script/dom/webidls/URLUtils.webidl +++ b/components/script/dom/webidls/URLUtils.webidl @@ -7,27 +7,19 @@ [NoInterfaceObject] interface URLUtils { //stringifier attribute USVString href; - readonly attribute USVString href; + [SetterThrows] + attribute USVString href; //readonly attribute USVString origin; - // attribute USVString protocol; - readonly attribute USVString protocol; - // attribute USVString username; - readonly attribute USVString username; - // attribute USVString password; - readonly attribute USVString password; - // attribute USVString host; - readonly attribute USVString host; - // attribute USVString hostname; - readonly attribute USVString hostname; - // attribute USVString port; - readonly attribute USVString port; - // attribute USVString pathname; - readonly attribute USVString pathname; - // attribute USVString search; - readonly attribute USVString search; + attribute USVString protocol; + attribute USVString username; + attribute USVString password; + attribute USVString host; + attribute USVString hostname; + attribute USVString port; + attribute USVString pathname; + attribute USVString search; // attribute URLSearchParams searchParams; - // attribute USVString hash; - readonly attribute USVString hash; + attribute USVString hash; // This is only doing as well as gecko right now, bug 824857 is on file for // adding attribute stringifier support. diff --git a/components/script/dom/webidls/Worker.webidl b/components/script/dom/webidls/Worker.webidl index 9e5d2c36ad9..481c2d44849 100644 --- a/components/script/dom/webidls/Worker.webidl +++ b/components/script/dom/webidls/Worker.webidl @@ -6,7 +6,7 @@ // https://www.whatwg.org/html/#abstractworker [NoInterfaceObject/*, Exposed=Window,Worker*/] interface AbstractWorker { - // attribute EventHandler onerror; + attribute EventHandler onerror; }; // https://www.whatwg.org/html/#worker diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 25b8d832fe4..4b614786efa 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -228,9 +228,16 @@ impl WebSocket { } impl WebSocketMethods for WebSocket { + // https://html.spec.whatwg.org/multipage/#handler-websocket-onopen event_handler!(open, GetOnopen, SetOnopen); + + // https://html.spec.whatwg.org/multipage/#handler-websocket-onclose event_handler!(close, GetOnclose, SetOnclose); + + // https://html.spec.whatwg.org/multipage/#handler-websocket-onerror event_handler!(error, GetOnerror, SetOnerror); + + // https://html.spec.whatwg.org/multipage/#handler-websocket-onmessage event_handler!(message, GetOnmessage, SetOnmessage); // https://html.spec.whatwg.org/multipage/#dom-websocket-url diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 8bce4247a4a..c463efa9f69 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -40,7 +40,6 @@ use timers::{IsInterval, TimerId, TimerManager, TimerCallback}; use webdriver_handlers::jsval_to_webdriver; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; -use devtools_traits::{TracingMetadata}; use msg::compositor_msg::ScriptToCompositorMsg; use msg::constellation_msg::{LoadData, PipelineId, SubpageId, ConstellationChan, WindowSizeData, WorkerId}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; @@ -504,8 +503,13 @@ impl WindowMethods for Window { }) } + // https://html.spec.whatwg.org/multipage/#globaleventhandlers global_event_handlers!(); + + // https://html.spec.whatwg.org/multipage/#handler-window-onunload event_handler!(unload, GetOnunload, SetOnunload); + + // https://html.spec.whatwg.org/multipage/#handler-onerror error_event_handler!(error, GetOnerror, SetOnerror); // https://developer.mozilla.org/en-US/docs/Web/API/Window/screen @@ -681,10 +685,11 @@ impl Window { debug!("script: performing reflow for goal {:?} reason {:?}", goal, reason); - if self.need_emit_timeline_marker(TimelineMarkerType::Reflow) { - let marker = TimelineMarker::new("Reflow".to_owned(), TracingMetadata::IntervalStart); - self.emit_timeline_marker(marker); - } + let marker = if self.need_emit_timeline_marker(TimelineMarkerType::Reflow) { + Some(TimelineMarker::start("Reflow".to_owned())) + } else { + None + }; // Layout will let us know when it's done. let (join_chan, join_port) = channel(); @@ -725,9 +730,8 @@ impl Window { self.pending_reflow_count.set(0); - if self.need_emit_timeline_marker(TimelineMarkerType::Reflow) { - let marker = TimelineMarker::new("Reflow".to_owned(), TracingMetadata::IntervalEnd); - self.emit_timeline_marker(marker); + if let Some(marker) = marker { + self.emit_timeline_marker(marker.end()); } } diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 435de83ecff..2711e8502db 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -162,7 +162,11 @@ impl WorkerMethods for Worker { Ok(()) } + // https://html.spec.whatwg.org/multipage/#handler-dedicatedworkerglobalscope-onmessage event_handler!(message, GetOnmessage, SetOnmessage); + + // https://html.spec.whatwg.org/multipage/#handler-workerglobalscope-onerror + event_handler!(error, GetOnerror, SetOnerror); } pub struct WorkerMessageHandler { diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 1d7a097fd9e..5ab625c1d48 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -293,6 +293,7 @@ impl XMLHttpRequest { } impl XMLHttpRequestMethods for XMLHttpRequest { + // https://xhr.spec.whatwg.org/#handler-xhr-onreadystatechange event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange); // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-readystate @@ -959,7 +960,7 @@ impl XMLHttpRequest { fn dispatch_response_progress_event(&self, type_: DOMString) { let len = self.response.borrow().len() as u64; - let total = self.response_headers.borrow().get::<ContentLength>().map(|x| {**x as u64}); + let total = self.response_headers.borrow().get::<ContentLength>().map(|x| { **x as u64 }); self.dispatch_progress_event(false, type_, len, total); } fn set_timeout(&self, duration_ms: u32) { diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index 0e443d65041..627e4882dde 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -38,11 +38,24 @@ impl XMLHttpRequestEventTargetDerived for EventTarget { } impl XMLHttpRequestEventTargetMethods for XMLHttpRequestEventTarget { + // https://xhr.spec.whatwg.org/#handler-xhr-onloadstart event_handler!(loadstart, GetOnloadstart, SetOnloadstart); + + // https://xhr.spec.whatwg.org/#handler-xhr-onprogress event_handler!(progress, GetOnprogress, SetOnprogress); + + // https://xhr.spec.whatwg.org/#handler-xhr-onabort event_handler!(abort, GetOnabort, SetOnabort); + + // https://xhr.spec.whatwg.org/#handler-xhr-onerror event_handler!(error, GetOnerror, SetOnerror); + + // https://xhr.spec.whatwg.org/#handler-xhr-onload event_handler!(load, GetOnload, SetOnload); + + // https://xhr.spec.whatwg.org/#handler-xhr-ontimeout event_handler!(timeout, GetOntimeout, SetOntimeout); + + // https://xhr.spec.whatwg.org/#handler-xhr-onloadend event_handler!(loadend, GetOnloadend, SetOnloadend); } |