diff options
author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2019-10-17 19:41:47 +0900 |
---|---|---|
committer | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2019-10-19 12:01:00 +0900 |
commit | e81b6786457b076a06c945835a3080fa33fa81ca (patch) | |
tree | 8e0808ea45ced9929b43b868717e80a634136adf /components/script | |
parent | 118a9ecdfe5005a0f3328c362ce8d7a7f1b52912 (diff) | |
download | servo-e81b6786457b076a06c945835a3080fa33fa81ca.tar.gz servo-e81b6786457b076a06c945835a3080fa33fa81ca.zip |
Support [LegacyWindowAlias]
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 21 | ||||
-rw-r--r-- | components/script/dom/bindings/interface.rs | 7 | ||||
-rw-r--r-- | components/script/dom/webidls/DOMMatrix.webidl | 3 | ||||
-rw-r--r-- | components/script/dom/webidls/URL.webidl | 3 |
4 files changed, 29 insertions, 5 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index ad76ef5d8d3..a644e352e7a 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2925,13 +2925,14 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod): properties should be a PropertyArrays instance. """ - def __init__(self, descriptor, properties, haveUnscopables): + def __init__(self, descriptor, properties, haveUnscopables, haveLegacyWindowAliases): args = [Argument('SafeJSContext', 'cx'), Argument('HandleObject', 'global'), Argument('*mut ProtoOrIfaceArray', 'cache')] CGAbstractMethod.__init__(self, descriptor, 'CreateInterfaceObjects', 'void', args, unsafe=True) self.properties = properties self.haveUnscopables = haveUnscopables + self.haveLegacyWindowAliases = haveLegacyWindowAliases def definition_body(self): name = self.descriptor.interface.identifier.name @@ -2990,7 +2991,8 @@ assert!(!prototype_proto.is_null());""" % getPrototypeProto)] properties = { "id": name, - "unscopables": "unscopable_names" if self.haveUnscopables else "&[]" + "unscopables": "unscopable_names" if self.haveUnscopables else "&[]", + "legacyWindowAliases": "legacy_window_aliases" if self.haveLegacyWindowAliases else "&[]" } for arrayName in self.properties.arrayNames(): array = getattr(self.properties, arrayName) @@ -3058,6 +3060,7 @@ create_noncallback_interface_object(cx, prototype.handle(), %(name)s, %(length)s, + %(legacyWindowAliases)s, interface.handle_mut()); assert!(!interface.is_null());""" % properties)) if self.descriptor.shouldCacheConstructor(): @@ -6266,6 +6269,15 @@ class CGDescriptor(CGThing): if descriptor.weakReferenceable: cgThings.append(CGWeakReferenceableTrait(descriptor)) + legacyWindowAliases = descriptor.interface.legacyWindowAliases + haveLegacyWindowAliases = len(legacyWindowAliases) != 0 + if haveLegacyWindowAliases: + cgThings.append( + CGList([CGGeneric("const legacy_window_aliases: &'static [&'static [u8]] = &["), + CGIndenter(CGList([CGGeneric(str_to_const_array(name)) for + name in legacyWindowAliases], ",\n")), + CGGeneric("];\n")], "\n")) + cgThings.append(CGGeneric(str(properties))) if not descriptor.interface.getExtendedAttribute("Inline"): @@ -6287,7 +6299,8 @@ class CGDescriptor(CGThing): cgThings.append(CGDefineDOMInterfaceMethod(descriptor)) reexports.append('DefineDOMInterface') cgThings.append(CGConstructorEnabled(descriptor)) - cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties, haveUnscopables)) + cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties, haveUnscopables, + haveLegacyWindowAliases)) cgThings = generate_imports(config, CGList(cgThings, '\n'), [descriptor]) cgThings = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name), @@ -7453,6 +7466,8 @@ class GlobalGenRoots(): for d in config.getDescriptors(hasInterfaceObject=True, isInline=False): binding = toBindingNamespace(d.name) pairs.append((d.name, binding, binding)) + for alias in d.interface.legacyWindowAliases: + pairs.append((alias, binding, binding)) for ctor in d.interface.namedConstructors: pairs.append((ctor.identifier.name, binding, binding)) pairs.sort(key=operator.itemgetter(0)) diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs index 0a5ee24fb23..2514efcf063 100644 --- a/components/script/dom/bindings/interface.rs +++ b/components/script/dom/bindings/interface.rs @@ -238,6 +238,7 @@ pub fn create_noncallback_interface_object( interface_prototype_object: HandleObject, name: &[u8], length: u32, + legacy_window_alias_names: &[&[u8]], rval: MutableHandleObject, ) { create_object( @@ -260,6 +261,12 @@ pub fn create_noncallback_interface_object( define_name(cx, rval.handle(), name); define_length(cx, rval.handle(), i32::try_from(length).expect("overflow")); define_on_global_object(cx, global, name, rval.handle()); + + if is_exposed_in(global, Globals::WINDOW) { + for legacy_window_alias in legacy_window_alias_names { + define_on_global_object(cx, global, legacy_window_alias, rval.handle()); + } + } } /// Create and define the named constructors of a non-callback interface. diff --git a/components/script/dom/webidls/DOMMatrix.webidl b/components/script/dom/webidls/DOMMatrix.webidl index 9911f868710..1731116c051 100644 --- a/components/script/dom/webidls/DOMMatrix.webidl +++ b/components/script/dom/webidls/DOMMatrix.webidl @@ -10,7 +10,8 @@ * related or neighboring rights to this work. */ -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker), + LegacyWindowAlias=WebKitCSSMatrix] interface DOMMatrix : DOMMatrixReadOnly { [Throws] constructor(optional (DOMString or sequence<unrestricted double>) init); diff --git a/components/script/dom/webidls/URL.webidl b/components/script/dom/webidls/URL.webidl index 31425fcd843..d51f675ec0a 100644 --- a/components/script/dom/webidls/URL.webidl +++ b/components/script/dom/webidls/URL.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://url.spec.whatwg.org/#url -[Exposed=(Window,Worker)] +[Exposed=(Window,Worker), + LegacyWindowAlias=webkitURL] interface URL { [Throws] constructor(USVString url, optional USVString base); [SetterThrows] |