Bug 1121623 part 10. Use a more-accurate default value for 'concrete' in Web IDL bindings. r=peterv

The idea is that we should only generate concreate-binding (wrap methods, etc)
machinery for an interface by default if we have reason to expect that the
interface is used as the primary interface for some objects.  Two clear signals
that would indicate that are the interface being a leaf interface (with no
descendants) and the interface having a constructor.  Other cases would require
a 'concrete' annotation in Bindings.conf.

Differential Revision: https://phabricator.services.mozilla.com/D32208

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-05-24 10:43:37 +00:00
parent 6f302d793c
commit 3d0e0bba72
3 changed files with 75 additions and 87 deletions

View file

@ -49,18 +49,6 @@
DOMInterfaces = {
'AbstractWorker': {
'concrete': False
},
'AnimationEffect': {
'concrete': False
},
'AnimationTimeline': {
'concrete': False
},
'AnonymousContent': {
'wrapperCache': False
},
@ -82,7 +70,6 @@ DOMInterfaces = {
},
'AudioNode' : {
'concrete': False,
'binaryNames': {
'channelCountMode': 'channelCountModeValue',
'channelInterpretation': 'channelInterpretationValue',
@ -110,6 +97,10 @@ DOMInterfaces = {
'headerFile': 'BatteryManager.h'
},
'BrowsingContext': {
'concrete': True,
},
'Cache': {
'implicitJSContext': [ 'add', 'addAll', 'match', 'matchAll', 'put',
'delete', 'keys' ],
@ -138,8 +129,8 @@ DOMInterfaces = {
'nativeType': 'mozilla::extensions::ChannelWrapper',
},
'CharacterData': {
'concrete': False
'Client' : {
'concrete': True,
},
'Clipboard' : {
@ -162,6 +153,10 @@ DOMInterfaces = {
'headerFile': 'nsGeoPosition.h'
},
'Credential' : {
'concrete': True,
},
'Crypto' : {
'headerFile': 'Crypto.h'
},
@ -171,13 +166,11 @@ DOMInterfaces = {
},
'CSSConditionRule': {
'concrete': False,
'nativeType': 'mozilla::css::ConditionRule',
'headerFile': 'mozilla/css/GroupRule.h',
},
'CSSGroupingRule': {
'concrete': False,
'nativeType': 'mozilla::css::GroupRule',
},
@ -186,12 +179,13 @@ DOMInterfaces = {
},
'CSSRule': {
'concrete': False,
'nativeType': 'mozilla::css::Rule'
},
'CSSStyleDeclaration': {
'nativeType': 'nsICSSDeclaration'
'nativeType': 'nsICSSDeclaration',
# Concrete because of the font-face mess.
'concrete': True,
},
'CSSStyleRule': {
@ -252,6 +246,7 @@ DOMInterfaces = {
'DOMRequest': {
'implicitJSContext': [ 'then' ],
'concrete': True,
},
'DOMStringMap': {
@ -268,6 +263,10 @@ DOMInterfaces = {
},
},
'Element': {
'concrete': True,
},
'Event': {
'implicitJSContext': [ 'preventDefault' ],
},
@ -309,6 +308,10 @@ DOMInterfaces = {
'wrapperCache': False,
},
'FileSystemEntry': {
'concrete': True,
},
'FontFaceSet': {
'implicitJSContext': [ 'load' ],
},
@ -349,6 +352,7 @@ DOMInterfaces = {
'nativeType': 'nsIHTMLCollection',
# nsContentList.h pulls in nsIHTMLCollection.h
'headerFile': 'nsContentList.h',
'concrete': True,
},
'HTMLDirectoryElement': {
@ -361,6 +365,7 @@ DOMInterfaces = {
'HTMLDocument': {
'nativeType': 'nsHTMLDocument',
'concrete': True,
},
'HTMLElement': {
@ -375,10 +380,6 @@ DOMInterfaces = {
'nativeType': 'mozilla::dom::HTMLSharedElement'
},
'HTMLMediaElement': {
'concrete': False
},
'HTMLOListElement': {
'nativeType' : 'mozilla::dom::HTMLSharedListElement'
},
@ -405,7 +406,8 @@ DOMInterfaces = {
'implicitJSContext': [ 'delete' ],
'binaryNames': {
'direction': 'getDirection'
}
},
'concrete': True,
},
'IDBCursorWithValue': {
@ -431,6 +433,7 @@ DOMInterfaces = {
'IDBKeyRange': {
'wrapperCache': False,
'concrete': True,
},
'IDBLocaleAwareKeyRange': {
@ -449,6 +452,10 @@ DOMInterfaces = {
'headerFile': 'IDBRequest.h'
},
'IDBRequest': {
'concrete': True,
},
'IDBVersionChangeEvent': {
'headerFile': 'IDBEvents.h',
},
@ -483,10 +490,6 @@ DOMInterfaces = {
'binaryNames': { 'constructor': 'ConstructorJS' },
},
'KeyEvent': {
'concrete': False
},
'LegacyMozTCPSocket': {
'headerFile': 'TCPSocket.h',
'wrapperCache': False,
@ -530,18 +533,6 @@ DOMInterfaces = {
'headerFile': 'MediaRecorder.h',
},
'MessageBroadcaster': {
'concrete': False
},
'MessageListenerManager': {
'concrete': False
},
'MessageSender': {
'concrete': False
},
'MimeType': {
'headerFile' : 'nsMimeTypeArray.h',
'nativeType': 'nsMimeType',
@ -572,6 +563,7 @@ DOMInterfaces = {
'MozSharedMap': {
'nativeType': 'mozilla::dom::ipc::SharedMap',
'concrete': True,
},
'MozWritableSharedMap': {
@ -621,7 +613,6 @@ DOMInterfaces = {
'Node': {
'nativeType': 'nsINode',
'concrete': False,
},
'NodeIterator': {
@ -630,6 +621,7 @@ DOMInterfaces = {
'NodeList': {
'nativeType': 'nsINodeList',
'concrete': True,
},
'NotificationEvent': {
@ -661,6 +653,18 @@ DOMInterfaces = {
'wrapperCache': False
},
'PerformanceResourceTiming' : {
'concrete': True,
},
'PlacesBookmark' : {
'concrete': True,
},
'PlacesEvent' : {
'concrete': True,
},
'TransceiverImpl': {
'nativeType': 'mozilla::TransceiverImpl',
'headerFile': 'TransceiverImpl.h',
@ -830,12 +834,8 @@ DOMInterfaces = {
'headerFile': 'DOMSVGAngle.h'
},
'SVGAnimationElement': {
'concrete': False
},
'SVGComponentTransferFunctionElement': {
'concrete': False,
'SVGElement': {
'concrete': True,
},
'SVGFEFuncAElement': {
@ -854,14 +854,6 @@ DOMInterfaces = {
'headerFile': 'mozilla/dom/SVGComponentTransferFunctionElement.h',
},
'SVGGraphicsElement': {
'concrete': False,
},
'SVGGradientElement': {
'concrete': False,
},
'SVGLength': {
'nativeType': 'mozilla::dom::DOMSVGLength',
'headerFile': 'DOMSVGLength.h'
@ -889,7 +881,6 @@ DOMInterfaces = {
'SVGPathSeg': {
'nativeType': 'mozilla::DOMSVGPathSeg',
'headerFile': 'DOMSVGPathSeg.h',
'concrete': False,
},
'SVGPathSegClosePath': {
@ -1020,14 +1011,6 @@ DOMInterfaces = {
'headerFile': 'DOMSVGStringList.h',
},
'SVGTextContentElement': {
'concrete': False
},
'SVGTextPositioningElement': {
'concrete': False
},
'SVGTransform': {
'nativeType': 'mozilla::dom::DOMSVGTransform',
'headerFile': 'DOMSVGTransform.h',
@ -1042,14 +1025,13 @@ DOMInterfaces = {
},
'SVGUnitTypes' : {
# Maybe should be a namespace.
'concrete': False,
},
'SVGZoomAndPan' : {
'concrete': False,
},
'SyncMessageSender' : {
# Part of a kinda complicated legacy setup for putting some constants on
# both interfaces and this thing, which ideally should be a namespace.
'concrete': False,
},
@ -1552,7 +1534,6 @@ DOMInterfaces = {
'WorkerGlobalScope': {
'headerFile': 'mozilla/dom/WorkerScope.h',
'implicitJSContext': [ 'createImageBitmap', 'importScripts' ],
'concrete': False,
# Rename a few things so we don't have both classes and methods
# with the same name
'binaryNames': {
@ -1560,12 +1541,13 @@ DOMInterfaces = {
},
},
'XMLHttpRequest': {
'implicitJSContext': [ 'send'],
'Worklet': {
# Paint worklets just use the Worklet interface.
'concrete': True,
},
'XMLHttpRequestEventTarget': {
'concrete': False
'XMLHttpRequest': {
'implicitJSContext': [ 'send'],
},
'XMLSerializer': {
@ -1574,7 +1556,8 @@ DOMInterfaces = {
},
'XPathEvaluator': {
'wrapperCache': False
'wrapperCache': False,
'concrete': True,
},
'XPathExpression': {
@ -1694,7 +1677,6 @@ DOMInterfaces = {
'headerFile': 'TestBindingHeader.h',
'register': False,
'castable': False,
'concrete': False
},
'OnlyForUseInConstructor' : {
@ -1704,43 +1686,36 @@ DOMInterfaces = {
'ImplementedInterface' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False,
},
'ImplementedInterfaceParent' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False
},
'DiamondImplements' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False
},
'DiamondBranch1A' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False
},
'DiamondBranch1B' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False
},
'DiamondBranch2A' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False
},
'DiamondBranch2B' : {
'headerFile': 'TestBindingHeader.h',
'concrete': False,
'register': False
},

View file

@ -401,10 +401,21 @@ class Descriptor(DescriptorProvider):
# If we're concrete, we need to crawl our ancestor interfaces and mark
# them as having a concrete descendant.
self.concrete = (not self.interface.isExternal() and
not self.interface.isCallback() and
not self.interface.isNamespace() and
desc.get('concrete', True))
concreteDefault = (not self.interface.isExternal() and
not self.interface.isCallback() and
# Exclude interfaces that are used as the RHS of
# "implements", because those would typically not be
# concrete.
not self.interface.isConsequential() and
not self.interface.isNamespace() and
# We're going to assume that leaf interfaces are
# concrete; otherwise what's the point? Also
# interfaces with constructors had better be
# concrete; otherwise how can you construct them?
(not self.interface.hasChildInterfaces() or
self.interface.ctor() is not None))
self.concrete = desc.get('concrete', concreteDefault)
self.hasUnforgeableMembers = (self.concrete and
any(MemberIsUnforgeable(m, self) for m in
self.interface.members))
@ -730,7 +741,7 @@ class Descriptor(DescriptorProvider):
def isMaybeCrossOriginObject(self):
# If we're isGlobal and have cross-origin members, we're a Window, and
# that's not a cross-origin object. The WindowProxy is.
return self.hasCrossOriginMembers and not self.isGlobal()
return self.concrete and self.hasCrossOriginMembers and not self.isGlobal()
def needsHeaderInclude(self):
"""

View file

@ -129,6 +129,8 @@ nsINode* CSSFontFaceRuleDecl::GetParentObject() {
JSObject* CSSFontFaceRuleDecl::WrapObject(JSContext* cx,
JS::Handle<JSObject*> aGivenProto) {
// If this changes to use a different type, remove the 'concrete'
// annotation from CSSStyleDeclaration.
return CSSStyleDeclaration_Binding::Wrap(cx, this, aGivenProto);
}