mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Add infrastructure for supporting dashed CSS property names on CSSStyleDeclaration.
This commit is contained in:
parent
6431e8da43
commit
40806977b5
4 changed files with 37 additions and 13 deletions
|
@ -1472,6 +1472,7 @@ class AttrDefiner(PropertyDefiner):
|
||||||
def __init__(self, descriptor, name, static):
|
def __init__(self, descriptor, name, static):
|
||||||
PropertyDefiner.__init__(self, descriptor, name)
|
PropertyDefiner.__init__(self, descriptor, name)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.descriptor = descriptor
|
||||||
self.regular = [
|
self.regular = [
|
||||||
m
|
m
|
||||||
for m in descriptor.interface.members
|
for m in descriptor.interface.members
|
||||||
|
@ -1488,14 +1489,14 @@ class AttrDefiner(PropertyDefiner):
|
||||||
|
|
||||||
def getter(attr):
|
def getter(attr):
|
||||||
if self.static:
|
if self.static:
|
||||||
accessor = 'get_' + attr.identifier.name
|
accessor = 'get_' + self.descriptor.internalNameFor(attr.identifier.name)
|
||||||
jitinfo = "0 as *const JSJitInfo"
|
jitinfo = "0 as *const JSJitInfo"
|
||||||
else:
|
else:
|
||||||
if attr.hasLenientThis():
|
if attr.hasLenientThis():
|
||||||
accessor = "generic_lenient_getter"
|
accessor = "generic_lenient_getter"
|
||||||
else:
|
else:
|
||||||
accessor = "generic_getter"
|
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 }"
|
return ("JSNativeWrapper { op: Some(%(native)s), info: %(info)s }"
|
||||||
% {"info": jitinfo,
|
% {"info": jitinfo,
|
||||||
|
@ -1506,14 +1507,14 @@ class AttrDefiner(PropertyDefiner):
|
||||||
return "JSNativeWrapper { op: None, info: 0 as *const JSJitInfo }"
|
return "JSNativeWrapper { op: None, info: 0 as *const JSJitInfo }"
|
||||||
|
|
||||||
if self.static:
|
if self.static:
|
||||||
accessor = 'set_' + attr.identifier.name
|
accessor = 'set_' + self.descriptor.internalNameFor(attr.identifier.name)
|
||||||
jitinfo = "0 as *const JSJitInfo"
|
jitinfo = "0 as *const JSJitInfo"
|
||||||
else:
|
else:
|
||||||
if attr.hasLenientThis():
|
if attr.hasLenientThis():
|
||||||
accessor = "generic_lenient_setter"
|
accessor = "generic_lenient_setter"
|
||||||
else:
|
else:
|
||||||
accessor = "generic_setter"
|
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 }"
|
return ("JSNativeWrapper { op: Some(%(native)s), info: %(info)s }"
|
||||||
% {"info": jitinfo,
|
% {"info": jitinfo,
|
||||||
|
@ -2835,7 +2836,10 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, method):
|
def makeNativeName(descriptor, method):
|
||||||
name = method.identifier.name
|
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):
|
class CGStaticMethod(CGAbstractStaticBindingMethod):
|
||||||
|
@ -2862,7 +2866,7 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, attr):
|
def __init__(self, descriptor, attr):
|
||||||
self.attr = attr
|
self.attr = attr
|
||||||
name = 'get_' + attr.identifier.name
|
name = 'get_' + descriptor.internalNameFor(attr.identifier.name)
|
||||||
args = [Argument('*mut JSContext', 'cx'),
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
Argument('HandleObject', '_obj'),
|
Argument('HandleObject', '_obj'),
|
||||||
Argument('*const %s' % descriptor.concreteType, 'this'),
|
Argument('*const %s' % descriptor.concreteType, 'this'),
|
||||||
|
@ -2880,7 +2884,10 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, attr):
|
def makeNativeName(descriptor, attr):
|
||||||
name = attr.identifier.name
|
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
|
infallible = ('infallible' in
|
||||||
descriptor.getExtendedAttributes(attr, getter=True))
|
descriptor.getExtendedAttributes(attr, getter=True))
|
||||||
if attr.type.nullable() or not infallible:
|
if attr.type.nullable() or not infallible:
|
||||||
|
@ -2914,7 +2921,7 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, attr):
|
def __init__(self, descriptor, attr):
|
||||||
self.attr = attr
|
self.attr = attr
|
||||||
name = 'set_' + attr.identifier.name
|
name = 'set_' + descriptor.internalNameFor(attr.identifier.name)
|
||||||
args = [Argument('*mut JSContext', 'cx'),
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
Argument('HandleObject', 'obj'),
|
Argument('HandleObject', 'obj'),
|
||||||
Argument('*const %s' % descriptor.concreteType, 'this'),
|
Argument('*const %s' % descriptor.concreteType, 'this'),
|
||||||
|
@ -2931,7 +2938,10 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeNativeName(descriptor, attr):
|
def makeNativeName(descriptor, attr):
|
||||||
name = attr.identifier.name
|
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):
|
class CGStaticSetter(CGAbstractStaticBindingMethod):
|
||||||
|
@ -3045,8 +3055,9 @@ class CGMemberJITInfo(CGThing):
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
if self.member.isAttr():
|
if self.member.isAttr():
|
||||||
getterinfo = ("%s_getterinfo" % self.member.identifier.name)
|
internalMemberName = self.descriptor.internalNameFor(self.member.identifier.name)
|
||||||
getter = ("get_%s" % self.member.identifier.name)
|
getterinfo = ("%s_getterinfo" % internalMemberName)
|
||||||
|
getter = ("get_%s" % internalMemberName)
|
||||||
getterinfal = "infallible" in self.descriptor.getExtendedAttributes(self.member, getter=True)
|
getterinfal = "infallible" in self.descriptor.getExtendedAttributes(self.member, getter=True)
|
||||||
|
|
||||||
movable = self.mayBeMovable() and getterinfal
|
movable = self.mayBeMovable() and getterinfal
|
||||||
|
@ -3070,8 +3081,8 @@ class CGMemberJITInfo(CGThing):
|
||||||
slotIndex,
|
slotIndex,
|
||||||
[self.member.type], None)
|
[self.member.type], None)
|
||||||
if (not self.member.readonly or self.member.getExtendedAttribute("PutForwards")):
|
if (not self.member.readonly or self.member.getExtendedAttribute("PutForwards")):
|
||||||
setterinfo = ("%s_setterinfo" % self.member.identifier.name)
|
setterinfo = ("%s_setterinfo" % internalMemberName)
|
||||||
setter = ("set_%s" % self.member.identifier.name)
|
setter = ("set_%s" % internalMemberName)
|
||||||
# Setters are always fallible, since they have to do a typed unwrap.
|
# Setters are always fallible, since they have to do a typed unwrap.
|
||||||
result += self.defineJitInfo(setterinfo, setter, "Setter",
|
result += self.defineJitInfo(setterinfo, setter, "Setter",
|
||||||
False, False, "AliasEverything",
|
False, False, "AliasEverything",
|
||||||
|
|
|
@ -263,6 +263,8 @@ class Descriptor(DescriptorProvider):
|
||||||
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
||||||
self._binaryNames.setdefault('__stringifier', 'Stringifier')
|
self._binaryNames.setdefault('__stringifier', 'Stringifier')
|
||||||
|
|
||||||
|
self._internalNames = desc.get('internalNames', {})
|
||||||
|
|
||||||
for member in self.interface.members:
|
for member in self.interface.members:
|
||||||
if not member.isAttr() and not member.isMethod():
|
if not member.isAttr() and not member.isMethod():
|
||||||
continue
|
continue
|
||||||
|
@ -272,6 +274,8 @@ class Descriptor(DescriptorProvider):
|
||||||
assert len(binaryName) == 1
|
assert len(binaryName) == 1
|
||||||
self._binaryNames.setdefault(member.identifier.name,
|
self._binaryNames.setdefault(member.identifier.name,
|
||||||
binaryName[0])
|
binaryName[0])
|
||||||
|
self._internalNames.setdefault(member.identifier.name,
|
||||||
|
member.identifier.name.replace('-', '_'))
|
||||||
|
|
||||||
# Build the prototype chain.
|
# Build the prototype chain.
|
||||||
self.prototypeChain = []
|
self.prototypeChain = []
|
||||||
|
@ -285,6 +289,9 @@ class Descriptor(DescriptorProvider):
|
||||||
def binaryNameFor(self, name):
|
def binaryNameFor(self, name):
|
||||||
return self._binaryNames.get(name, 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 getExtendedAttributes(self, member, getter=False, setter=False):
|
||||||
def maybeAppendInfallibleToAttrs(attrs, throws):
|
def maybeAppendInfallibleToAttrs(attrs, throws):
|
||||||
if throws is None:
|
if throws is None:
|
||||||
|
|
|
@ -120,6 +120,10 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn SetBinaryRenamedAttribute(&self, _: DOMString) {}
|
fn SetBinaryRenamedAttribute(&self, _: DOMString) {}
|
||||||
fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) }
|
fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) }
|
||||||
fn BinaryRenamedAttribute(&self) -> DOMString { "".to_owned() }
|
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 GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) }
|
||||||
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
|
|
|
@ -115,6 +115,8 @@ interface TestBinding {
|
||||||
attribute (HTMLElement or long)? unionAttributeNullable;
|
attribute (HTMLElement or long)? unionAttributeNullable;
|
||||||
attribute (Event or DOMString)? union2AttributeNullable;
|
attribute (Event or DOMString)? union2AttributeNullable;
|
||||||
[BinaryName="BinaryRenamedAttribute"] attribute DOMString attrToBinaryRename;
|
[BinaryName="BinaryRenamedAttribute"] attribute DOMString attrToBinaryRename;
|
||||||
|
[BinaryName="BinaryRenamedAttribute2"] attribute DOMString attr-to-binary-rename;
|
||||||
|
attribute DOMString attr-to-automatically-rename;
|
||||||
|
|
||||||
[PutForwards=booleanAttribute]
|
[PutForwards=booleanAttribute]
|
||||||
readonly attribute TestBinding forwardedAttribute;
|
readonly attribute TestBinding forwardedAttribute;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue