Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a safe, mostly-sound rooting rooting strategy. #2101

Merged
merged 16 commits into from May 3, 2014
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Remove abstract_self.

  • Loading branch information
jdm committed May 3, 2014
commit 7daa97c7e5de3dac14b4d1c8a923448b025e3c09
@@ -9,8 +9,6 @@
# The configuration table maps each interface name to a |descriptor|.
#
# Valid fields for all descriptors:
# * needsAbstract: a list of members that require a JS<>-wrapped version of
# self to be passed to the native code.
# * createGlobal: True for global objects.
# * outerObjectHook: string to use in place of default value for outerObject and thisObject
# JS class hooks
@@ -26,123 +24,46 @@ DOMInterfaces = {
'ClientRect': {},
'ClientRectList': {},
'Console': {},
'Document': {
'needsAbstract': [
'adoptNode',
'anchors',
'applets',
'body',
'children',
'createComment',
'createDocumentFragment',
'createElement',
'createElementNS',
'createProcessingInstruction',
'createTextNode',
'embeds',
'forms',
'getElementsByClassName',
'getElementsByTagName',
'getElementsByTagNameNS',
'images',
'importNode',
'links',
'location',
'plugins',
'scripts',
'title',
],
},
'Document': {},
'DOMException': {},
'DOMImplementation': {},
'DOMParser': {},
'Element': {
'needsAbstract': [
'attributes',
'children',
'className',
'getAttribute',
'getAttributeNS',
'getBoundingClientRect',
'getClientRects',
'getElementsByClassName',
'getElementsByTagName',
'getElementsByTagNameNS',
'hasAttribute',
'hasAttributeNS',
'id',
'innerHTML',
'outerHTML',
'removeAttribute',
'removeAttributeNS',
'setAttribute',
'setAttributeNS',
]
},
'Element': {},
'Event': {},
'EventListener': {
'nativeType': 'EventListenerBinding::EventListener',
},
'EventTarget': {
'needsAbstract': ['dispatchEvent']
},
'EventTarget': {},
'FormData': {},
'HTMLCollection': {},
'Location': {},
'MouseEvent': {},
'Navigator': {},
'Node': {
'needsAbstract': [
'appendChild',
'childNodes',
'cloneNode',
'compareDocumentPosition',
'contains',
'insertBefore',
'isEqualNode',
'namespaceURI',
'nodeName',
'nodeValue',
'normalize',
'removeChild',
'replaceChild',
'textContent',
]
},

'Node': {},
'NodeList': {},

'UIEvent': {},
'ValidityState': {},
'Window': {
'createGlobal': True,
'outerObjectHook': 'Some(bindings::utils::outerize_global)',
'needsAbstract': [
'console',
'location',
'navigator',
'self',
'window',
],
},
'XMLHttpRequest': {},
'XMLHttpRequestEventTarget': {},
'XMLHttpRequestUpload': {},

#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
'TestBinding': {},

}

# FIXME: This should be renamed: https://github.com/mozilla/servo/issues/1625
def addHTMLElement(element, concrete=None, needsAbstract=[]):
def addHTMLElement(element):
DOMInterfaces[element] = {
'nativeType': 'JS<%s>' % element,
'concreteType': concrete if concrete else element,
'needsAbstract': needsAbstract
}

addHTMLElement('Comment')
addHTMLElement('DocumentFragment', concrete='DocumentFragment', needsAbstract=['children'])
addHTMLElement('DocumentFragment')
addHTMLElement('DocumentType')
addHTMLElement('Text')
addHTMLElement('ProcessingInstruction')
@@ -158,12 +79,12 @@ addHTMLElement('HTMLBRElement')
addHTMLElement('HTMLCanvasElement')
addHTMLElement('HTMLDataElement')
addHTMLElement('HTMLDivElement')
addHTMLElement('HTMLDataListElement', needsAbstract=['options'])
addHTMLElement('HTMLDataListElement')
addHTMLElement('HTMLDirectoryElement')
addHTMLElement('HTMLDListElement')
addHTMLElement('HTMLElement')
addHTMLElement('HTMLEmbedElement')
addHTMLElement('HTMLFieldSetElement', needsAbstract=['elements'])
addHTMLElement('HTMLFieldSetElement')
addHTMLElement('HTMLFontElement')
addHTMLElement('HTMLFormElement')
addHTMLElement('HTMLFrameElement')
@@ -172,8 +93,8 @@ addHTMLElement('HTMLHeadElement')
addHTMLElement('HTMLHeadingElement')
addHTMLElement('HTMLHtmlElement')
addHTMLElement('HTMLHRElement')
addHTMLElement('HTMLIFrameElement', needsAbstract=['sandbox'])
addHTMLElement('HTMLImageElement', needsAbstract=['alt', 'src', 'useMap', 'isMap', 'width', 'height', 'name', 'align', 'hspace', 'vspace', 'longDesc', 'border'])
addHTMLElement('HTMLIFrameElement')
addHTMLElement('HTMLImageElement')
addHTMLElement('HTMLInputElement')
addHTMLElement('HTMLLabelElement')
addHTMLElement('HTMLLegendElement')
@@ -195,7 +116,7 @@ addHTMLElement('HTMLParamElement')
addHTMLElement('HTMLPreElement')
addHTMLElement('HTMLProgressElement')
addHTMLElement('HTMLQuoteElement')
addHTMLElement('HTMLScriptElement', needsAbstract=['src'])
addHTMLElement('HTMLScriptElement')
addHTMLElement('HTMLSelectElement')
addHTMLElement('HTMLSourceElement')
addHTMLElement('HTMLSpanElement')
@@ -2494,12 +2494,6 @@ def definition_body(self):
nativeName = MakeNativeName(name)
extraPre = ''
argsPre = []
if name in self.descriptor.needsAbstract:
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
extraPre = """ let mut abstract_this = %s::from_raw(this);
let abstract_this = abstract_this.root(&roots);
""" % abstractName
argsPre = ['&mut abstract_this.root_ref()']
return CGWrapper(CGMethodCall(argsPre, nativeName, self.method.isStatic(),
self.descriptor, self.method),
pre=extraPre +
@@ -2552,12 +2546,6 @@ def definition_body(self):
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 mut abstract_this = %s::from_raw(this);
let abstract_this = abstract_this.root(&roots);
""" % abstractName
argsPre = ['&mut abstract_this.root_ref()']
if self.attr.type.nullable() or not infallible:
nativeName = "Get" + nativeName
return CGWrapper(CGIndenter(CGGetterCall(argsPre, self.attr.type, nativeName,
@@ -2614,12 +2602,6 @@ def definition_body(self):
nativeName = "Set" + MakeNativeName(name)
argsPre = []
extraPre = ''
if name in self.descriptor.needsAbstract:
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
extraPre = """ let mut abstract_this = %s::from_raw(this);
let abstract_this = abstract_this.root(&roots);
""" % abstractName
argsPre = ['&mut abstract_this.root_ref()']
return CGWrapper(CGIndenter(CGSetterCall(argsPre, self.attr.type, nativeName,
self.descriptor, self.attr)),
pre=extraPre +
@@ -136,7 +136,6 @@ def __init__(self, config, interface, desc):
self.returnType = "Unrooted<%s>" % ifaceName
self.nativeType = desc.get('nativeType', nativeTypeDefault)
self.concreteType = desc.get('concreteType', ifaceName)
self.needsAbstract = desc.get('needsAbstract', [])
self.createGlobal = desc.get('createGlobal', False)
self.register = desc.get('register', True)
self.outerObjectHook = desc.get('outerObjectHook', 'None')
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.