зеркало из https://github.com/mozilla/gecko-dev.git
Bug 946906 part 4. Codegen Xray expando JSClasses for DOM objects with [Cached] or [StoreInSlot] members. r=bholley
This commit is contained in:
Родитель
7f2945874f
Коммит
bb0814b5d3
|
@ -353,6 +353,11 @@ class CGNativePropertyHooks(CGThing):
|
|||
parentHooks = (toBindingNamespace(parentProtoName) + "::sNativePropertyHooks"
|
||||
if parentProtoName else 'nullptr')
|
||||
|
||||
if self.descriptor.wantsXrayExpandoClass:
|
||||
expandoClass = "&sXrayExpandoObjectClass"
|
||||
else:
|
||||
expandoClass = "&DefaultXrayExpandoObjectClass"
|
||||
|
||||
return fill(
|
||||
"""
|
||||
const NativePropertyHooks sNativePropertyHooks[] = { {
|
||||
|
@ -361,7 +366,8 @@ class CGNativePropertyHooks(CGThing):
|
|||
{ ${regular}, ${chrome} },
|
||||
${prototypeID},
|
||||
${constructorID},
|
||||
${parentHooks}
|
||||
${parentHooks},
|
||||
${expandoClass}
|
||||
} };
|
||||
""",
|
||||
resolveOwnProperty=resolveOwnProperty,
|
||||
|
@ -370,7 +376,8 @@ class CGNativePropertyHooks(CGThing):
|
|||
chrome=chrome,
|
||||
prototypeID=prototypeID,
|
||||
constructorID=constructorID,
|
||||
parentHooks=parentHooks)
|
||||
parentHooks=parentHooks,
|
||||
expandoClass=expandoClass)
|
||||
|
||||
|
||||
def NativePropertyHooks(descriptor):
|
||||
|
@ -529,6 +536,35 @@ class CGDOMProxyJSClass(CGThing):
|
|||
descriptor=DOMClass(self.descriptor))
|
||||
|
||||
|
||||
class CGXrayExpandoJSClass(CGThing):
|
||||
"""
|
||||
Generate a JSClass for an Xray expando object. This is only
|
||||
needed if we have members in slots (for [Cached] or [StoreInSlot]
|
||||
stuff).
|
||||
"""
|
||||
def __init__(self, descriptor):
|
||||
assert descriptor.interface.totalMembersInSlots != 0
|
||||
assert descriptor.wantsXrays
|
||||
assert descriptor.wantsXrayExpandoClass
|
||||
CGThing.__init__(self)
|
||||
self.descriptor = descriptor;
|
||||
|
||||
def declare(self):
|
||||
return ""
|
||||
|
||||
def define(self):
|
||||
return fill(
|
||||
"""
|
||||
// This may allocate too many slots, because we only really need
|
||||
// slots for our non-interface-typed members that we cache. But
|
||||
// allocating slots only for those would make the slot index
|
||||
// computations much more complicated, so let's do this the simple
|
||||
// way for now.
|
||||
DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, ${memberSlots});
|
||||
""",
|
||||
memberSlots=self.descriptor.interface.totalMembersInSlots)
|
||||
|
||||
|
||||
def PrototypeIDAndDepth(descriptor):
|
||||
prototypeID = "prototypes::id::"
|
||||
if descriptor.interface.hasInterfacePrototypeObject():
|
||||
|
@ -12073,6 +12109,8 @@ class CGDescriptor(CGThing):
|
|||
elif descriptor.needsXrayResolveHooks():
|
||||
cgThings.append(CGResolveOwnPropertyViaResolve(descriptor))
|
||||
cgThings.append(CGEnumerateOwnPropertiesViaGetOwnPropertyNames(descriptor))
|
||||
if descriptor.wantsXrayExpandoClass:
|
||||
cgThings.append(CGXrayExpandoJSClass(descriptor))
|
||||
|
||||
# Now that we have our ResolveOwnProperty/EnumerateOwnProperties stuff
|
||||
# done, set up our NativePropertyHooks.
|
||||
|
@ -13473,6 +13511,10 @@ class CGBindingRoot(CGThing):
|
|||
descriptorRequiresTelemetry(d) for d in descriptors)
|
||||
bindingHeaders["mozilla/dom/SimpleGlobalObject.h"] = any(
|
||||
CGDictionary.dictionarySafeToJSONify(d) for d in dictionaries)
|
||||
bindingHeaders["XrayWrapper.h"] = any(
|
||||
d.wantsXrays and d.wantsXrayExpandoClass for d in descriptors)
|
||||
bindingHeaders["mozilla/dom/XrayExpandoClass.h"] = any(
|
||||
d.wantsXrays for d in descriptors)
|
||||
|
||||
cgthings.extend(traverseMethods)
|
||||
cgthings.extend(unlinkMethods)
|
||||
|
|
|
@ -279,7 +279,18 @@ class Descriptor(DescriptorProvider):
|
|||
self.config = config
|
||||
self.interface = interface
|
||||
|
||||
self.wantsXrays = interface.isExposedInWindow()
|
||||
self.wantsXrays = (not interface.isExternal() and
|
||||
interface.isExposedInWindow())
|
||||
|
||||
if self.wantsXrays:
|
||||
# We could try to restrict self.wantsXrayExpandoClass further. For
|
||||
# example, we could set it to false if all of our slots store
|
||||
# Gecko-interface-typed things, because we don't use Xray expando
|
||||
# slots for those. But note that we would need to check the types
|
||||
# of not only the members of "interface" but also of all its
|
||||
# ancestors, because those can have members living in our slots too.
|
||||
# For now, do the simple thing.
|
||||
self.wantsXrayExpandoClass = (interface.totalMembersInSlots != 0)
|
||||
|
||||
# Read the desc, and fill in the relevant defaults.
|
||||
ifaceName = self.interface.identifier.name
|
||||
|
|
|
@ -293,6 +293,10 @@ struct NativePropertyHooks
|
|||
// The NativePropertyHooks instance for the parent interface (for
|
||||
// ShimInterfaceInfo).
|
||||
const NativePropertyHooks* mProtoHooks;
|
||||
|
||||
// The JSClass to use for expandos on our Xrays. Can be null, in which case
|
||||
// Xrays will use a default class of their choice.
|
||||
const JSClass* mXrayExpandoClass;
|
||||
};
|
||||
|
||||
enum DOMObjectType : uint8_t {
|
||||
|
|
Загрузка…
Ссылка в новой задаче