mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Implement getters and setters for img width and height properties
This commit is contained in:
parent
7fb96c1574
commit
42c6a53148
9 changed files with 174 additions and 25 deletions
|
@ -547,12 +547,13 @@ def addExternalIface(iface, nativeType=None, headerFile=None, pointerType=None):
|
|||
domInterface['pointerType'] = pointerType
|
||||
DOMInterfaces[iface] = domInterface
|
||||
|
||||
def addHTMLElement(element, concrete=None):
|
||||
def addHTMLElement(element, concrete=None, needsAbstract=[]):
|
||||
DOMInterfaces[element] = {
|
||||
'nativeType': 'AbstractNode<ScriptView>',
|
||||
'pointerType': '',
|
||||
'concreteType': concrete if concrete else element,
|
||||
'customTrace': 'trace'
|
||||
'customTrace': 'trace',
|
||||
'needsAbstract': needsAbstract
|
||||
}
|
||||
|
||||
addHTMLElement('Comment')
|
||||
|
@ -585,7 +586,7 @@ addHTMLElement('HTMLHeadingElement')
|
|||
addHTMLElement('HTMLHtmlElement')
|
||||
addHTMLElement('HTMLHRElement')
|
||||
addHTMLElement('HTMLIFrameElement')
|
||||
addHTMLElement('HTMLImageElement')
|
||||
addHTMLElement('HTMLImageElement', needsAbstract=['width', 'height'])
|
||||
addHTMLElement('HTMLInputElement')
|
||||
addHTMLElement('HTMLLabelElement')
|
||||
addHTMLElement('HTMLLegendElement')
|
||||
|
|
|
@ -3115,8 +3115,8 @@ class CGGetterCall(CGPerSignatureCall):
|
|||
A class to generate a native object getter call for a particular IDL
|
||||
getter.
|
||||
"""
|
||||
def __init__(self, returnType, nativeMethodName, descriptor, attr):
|
||||
CGPerSignatureCall.__init__(self, returnType, [], [],
|
||||
def __init__(self, argsPre, returnType, nativeMethodName, descriptor, attr):
|
||||
CGPerSignatureCall.__init__(self, returnType, argsPre, [],
|
||||
nativeMethodName, False, descriptor,
|
||||
attr, getter=True)
|
||||
|
||||
|
@ -3290,6 +3290,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
|||
def definition_body(self):
|
||||
name = self.attr.identifier.name
|
||||
nativeName = MakeNativeName(self.descriptor.binaryNames.get(name, name))
|
||||
extraPre = ''
|
||||
argsPre = []
|
||||
# resultOutParam does not depend on whether resultAlreadyAddRefed is set
|
||||
(_, resultOutParam) = getRetvalDeclarationForType(self.attr.type,
|
||||
self.descriptor,
|
||||
|
@ -3297,11 +3299,16 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
|||
infallible = ('infallible' in
|
||||
self.descriptor.getExtendedAttributes(self.attr,
|
||||
getter=True))
|
||||
if name in self.descriptor.needsAbstract:
|
||||
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
|
||||
extraPre = ' let abstract_this = %s::from_box(this);\n' % abstractName
|
||||
argsPre = ['abstract_this']
|
||||
if resultOutParam or self.attr.type.nullable() or not infallible:
|
||||
nativeName = "Get" + nativeName
|
||||
return CGWrapper(CGIndenter(CGGetterCall(self.attr.type, nativeName,
|
||||
return CGWrapper(CGIndenter(CGGetterCall(argsPre, self.attr.type, nativeName,
|
||||
self.descriptor, self.attr)),
|
||||
pre=" let obj = (*obj.unnamed);\n" +
|
||||
pre=extraPre +
|
||||
" let obj = (*obj.unnamed);\n" +
|
||||
" let this = &mut (*this).payload;\n").define()
|
||||
|
||||
class CGGenericSetter(CGAbstractBindingMethod):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue