зеркало из https://github.com/mozilla/gecko-dev.git
Bug 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, cache named properties objects. r=bz.
--HG-- extra : rebase_source : ed4b2cc3c095690b8d91bee3202e8316e4531f60
This commit is contained in:
Родитель
94ec1727fe
Коммит
f0b7d81451
|
@ -291,13 +291,17 @@ IsConvertibleToCallbackInterface(JSContext* cx, JS::Handle<JSObject*> obj)
|
||||||
return IsNotDateOrRegExp(cx, obj);
|
return IsNotDateOrRegExp(cx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The items in the protoAndIfaceCache are indexed by the prototypes::id::ID and
|
// The items in the protoAndIfaceCache are indexed by the prototypes::id::ID,
|
||||||
// constructors::id::ID enums, in that order. The end of the prototype objects
|
// constructors::id::ID and namedpropertiesobjects::id::ID enums, in that order.
|
||||||
// should be the start of the interface objects.
|
// The end of the prototype objects should be the start of the interface
|
||||||
|
// objects, and the end of the interface objects should be the start of the
|
||||||
|
// named properties objects.
|
||||||
static_assert((size_t)constructors::id::_ID_Start ==
|
static_assert((size_t)constructors::id::_ID_Start ==
|
||||||
(size_t)prototypes::id::_ID_Count,
|
(size_t)prototypes::id::_ID_Count &&
|
||||||
|
(size_t)namedpropertiesobjects::id::_ID_Start ==
|
||||||
|
(size_t)constructors::id::_ID_Count,
|
||||||
"Overlapping or discontiguous indexes.");
|
"Overlapping or discontiguous indexes.");
|
||||||
const size_t kProtoAndIfaceCacheCount = constructors::id::_ID_Count;
|
const size_t kProtoAndIfaceCacheCount = namedpropertiesobjects::id::_ID_Count;
|
||||||
|
|
||||||
class ProtoAndIfaceCache
|
class ProtoAndIfaceCache
|
||||||
{
|
{
|
||||||
|
|
|
@ -2581,8 +2581,8 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
parentProtoName = self.descriptor.parentPrototypeName
|
parentProtoName = self.descriptor.parentPrototypeName
|
||||||
if self.descriptor.hasNamedPropertiesObject:
|
if self.descriptor.hasNamedPropertiesObject:
|
||||||
parentProtoType = "Rooted"
|
parentProtoType = "Handle"
|
||||||
getParentProto = "aCx, GetNamedPropertiesObject(aCx, aGlobal)"
|
getParentProto = "GetNamedPropertiesObject(aCx, aGlobal)"
|
||||||
elif parentProtoName is None:
|
elif parentProtoName is None:
|
||||||
parentProtoType = "Rooted"
|
parentProtoType = "Rooted"
|
||||||
if self.descriptor.interface.getExtendedAttribute("ArrayClass"):
|
if self.descriptor.interface.getExtendedAttribute("ArrayClass"):
|
||||||
|
@ -2856,7 +2856,7 @@ class CGGetNamedPropertiesObjectMethod(CGAbstractStaticMethod):
|
||||||
Argument('JS::Handle<JSObject*>', 'aGlobal')]
|
Argument('JS::Handle<JSObject*>', 'aGlobal')]
|
||||||
CGAbstractStaticMethod.__init__(self, descriptor,
|
CGAbstractStaticMethod.__init__(self, descriptor,
|
||||||
'GetNamedPropertiesObject',
|
'GetNamedPropertiesObject',
|
||||||
'JSObject*', args)
|
'JS::Handle<JSObject*>', args)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
parentProtoName = self.descriptor.parentPrototypeName
|
parentProtoName = self.descriptor.parentPrototypeName
|
||||||
|
@ -2868,17 +2868,30 @@ class CGGetNamedPropertiesObjectMethod(CGAbstractStaticMethod):
|
||||||
"""
|
"""
|
||||||
JS::Rooted<JSObject*> parentProto(aCx, ${parent}::GetProtoObject(aCx, aGlobal));
|
JS::Rooted<JSObject*> parentProto(aCx, ${parent}::GetProtoObject(aCx, aGlobal));
|
||||||
if (!parentProto) {
|
if (!parentProto) {
|
||||||
return nullptr;
|
return js::NullPtr();
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
parent=toBindingNamespace(parentProtoName))
|
parent=toBindingNamespace(parentProtoName))
|
||||||
parentProto = "parentProto"
|
parentProto = "parentProto"
|
||||||
return fill(
|
return fill(
|
||||||
"""
|
"""
|
||||||
$*{getParentProto}
|
/* Make sure our global is sane. Hopefully we can remove this sometime */
|
||||||
return ${nativeType}::CreateNamedPropertiesObject(aCx, ${parentProto});
|
if (!(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL)) {
|
||||||
|
return JS::NullPtr();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check to see whether the named properties object has already been created */
|
||||||
|
ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(aGlobal);
|
||||||
|
|
||||||
|
JS::Heap<JSObject*>& namedPropertiesObject = protoAndIfaceCache.EntrySlotOrCreate(namedpropertiesobjects::id::${ifaceName});
|
||||||
|
if (!namedPropertiesObject) {
|
||||||
|
$*{getParentProto}
|
||||||
|
namedPropertiesObject = ${nativeType}::CreateNamedPropertiesObject(aCx, ${parentProto});
|
||||||
|
}
|
||||||
|
return JS::Handle<JSObject*>::fromMarkedLocation(namedPropertiesObject.address());
|
||||||
""",
|
""",
|
||||||
getParentProto=getParentProto,
|
getParentProto=getParentProto,
|
||||||
|
ifaceName=self.descriptor.name,
|
||||||
parentProto=parentProto,
|
parentProto=parentProto,
|
||||||
nativeType=self.descriptor.nativeType)
|
nativeType=self.descriptor.nativeType)
|
||||||
|
|
||||||
|
@ -14209,6 +14222,18 @@ class GlobalGenRoots():
|
||||||
|
|
||||||
curr.append(idEnum)
|
curr.append(idEnum)
|
||||||
|
|
||||||
|
# Named properties object enum.
|
||||||
|
namedPropertiesObjects = [d.name for d in config.getDescriptors(hasNamedPropertiesObject=True)]
|
||||||
|
idEnum = CGNamespacedEnum('id', 'ID', ['_ID_Start'] + namedPropertiesObjects,
|
||||||
|
['constructors::id::_ID_Count', '_ID_Start'])
|
||||||
|
|
||||||
|
# Wrap all of that in our namespaces.
|
||||||
|
idEnum = CGNamespace.build(['mozilla', 'dom', 'namedpropertiesobjects'],
|
||||||
|
CGWrapper(idEnum, pre='\n'))
|
||||||
|
idEnum = CGWrapper(idEnum, post='\n')
|
||||||
|
|
||||||
|
curr.append(idEnum)
|
||||||
|
|
||||||
traitsDecls = [CGGeneric(declare=dedent("""
|
traitsDecls = [CGGeneric(declare=dedent("""
|
||||||
template <prototypes::ID PrototypeID>
|
template <prototypes::ID PrototypeID>
|
||||||
struct PrototypeTraits;
|
struct PrototypeTraits;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче