mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 884268 - Part b: Move nsContentUtils::PreserveWrapper to nsWrapperCache; r=smaug
This commit is contained in:
parent
84041fd5c0
commit
ff63d2149b
@ -1263,32 +1263,6 @@ public:
|
|||||||
static bool AreJSObjectsHeld(void* aScriptObjectHolder);
|
static bool AreJSObjectsHeld(void* aScriptObjectHolder);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void PreserveWrapper(nsISupports* aScriptObjectHolder,
|
|
||||||
nsWrapperCache* aCache)
|
|
||||||
{
|
|
||||||
if (!aCache->PreservingWrapper()) {
|
|
||||||
nsISupports *ccISupports;
|
|
||||||
aScriptObjectHolder->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
|
|
||||||
reinterpret_cast<void**>(&ccISupports));
|
|
||||||
MOZ_ASSERT(ccISupports);
|
|
||||||
nsXPCOMCycleCollectionParticipant* participant;
|
|
||||||
CallQueryInterface(ccISupports, &participant);
|
|
||||||
PreserveWrapper(ccISupports, aCache, participant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void PreserveWrapper(void* aScriptObjectHolder,
|
|
||||||
nsWrapperCache* aCache,
|
|
||||||
nsScriptObjectTracer* aTracer)
|
|
||||||
{
|
|
||||||
if (!aCache->PreservingWrapper()) {
|
|
||||||
HoldJSObjects(aScriptObjectHolder, aTracer);
|
|
||||||
aCache->SetPreservingWrapper(true);
|
|
||||||
#ifdef DEBUG
|
|
||||||
// Make sure the cycle collector will be able to traverse to the wrapper.
|
|
||||||
aCache->CheckCCWrapperTraversal(aScriptObjectHolder, aTracer);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void ReleaseWrapper(void* aScriptObjectHolder,
|
static void ReleaseWrapper(void* aScriptObjectHolder,
|
||||||
nsWrapperCache* aCache);
|
nsWrapperCache* aCache);
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsContentUtils::PreserveWrapper(aBoundElement, aBoundElement);
|
aBoundElement->PreserveWrapper(aBoundElement);
|
||||||
|
|
||||||
wrapper.swap(*aScriptObjectHolder);
|
wrapper.swap(*aScriptObjectHolder);
|
||||||
|
|
||||||
|
@ -5086,8 +5086,7 @@ nsNodeSH::GetFlags(uint32_t *aFlags)
|
|||||||
void
|
void
|
||||||
nsNodeSH::PreserveWrapper(nsISupports *aNative)
|
nsNodeSH::PreserveWrapper(nsISupports *aNative)
|
||||||
{
|
{
|
||||||
nsINode *node = static_cast<nsINode*>(aNative);
|
static_cast<nsINode*>(aNative)->PreserveWrapper(aNative);
|
||||||
nsContentUtils::PreserveWrapper(aNative, node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventTarget helper
|
// EventTarget helper
|
||||||
@ -5122,7 +5121,7 @@ nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
|
|||||||
{
|
{
|
||||||
nsDOMEventTargetHelper *target =
|
nsDOMEventTargetHelper *target =
|
||||||
nsDOMEventTargetHelper::FromSupports(aNative);
|
nsDOMEventTargetHelper::FromSupports(aNative);
|
||||||
nsContentUtils::PreserveWrapper(aNative, target);
|
target->PreserveWrapper(aNative);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDBEventTarget helper
|
// IDBEventTarget helper
|
||||||
|
@ -7,6 +7,17 @@
|
|||||||
#include "nsWrapperCacheInlines.h"
|
#include "nsWrapperCacheInlines.h"
|
||||||
|
|
||||||
#include "nsCycleCollectionTraversalCallback.h"
|
#include "nsCycleCollectionTraversalCallback.h"
|
||||||
|
#include "nsCycleCollector.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
/* static */ void
|
||||||
|
nsWrapperCache::HoldJSObjects(void* aScriptObjectHolder,
|
||||||
|
nsScriptObjectTracer* aTracer)
|
||||||
|
{
|
||||||
|
cyclecollector::AddJSHolder(aScriptObjectHolder, aTracer);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
@ -214,10 +214,35 @@ public:
|
|||||||
mFlags &= ~aFlagsToUnset;
|
mFlags &= ~aFlagsToUnset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreserveWrapper(nsISupports* aScriptObjectHolder)
|
||||||
|
{
|
||||||
|
if (PreservingWrapper()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsISupports* ccISupports;
|
||||||
|
aScriptObjectHolder->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
|
||||||
|
reinterpret_cast<void**>(&ccISupports));
|
||||||
|
MOZ_ASSERT(ccISupports);
|
||||||
|
|
||||||
|
nsXPCOMCycleCollectionParticipant* participant;
|
||||||
|
CallQueryInterface(ccISupports, &participant);
|
||||||
|
PreserveWrapper(ccISupports, participant);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreserveWrapper(void* aScriptObjectHolder, nsScriptObjectTracer* aTracer)
|
||||||
|
{
|
||||||
|
if (PreservingWrapper()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HoldJSObjects(aScriptObjectHolder, aTracer);
|
||||||
|
SetPreservingWrapper(true);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void CheckCCWrapperTraversal(void* aScriptObjectHolder,
|
// Make sure the cycle collector will be able to traverse to the wrapper.
|
||||||
nsScriptObjectTracer* aTracer);
|
CheckCCWrapperTraversal(aScriptObjectHolder, aTracer);
|
||||||
#endif // DEBUG
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JSObject *GetWrapperJSObject() const
|
JSObject *GetWrapperJSObject() const
|
||||||
@ -256,6 +281,14 @@ private:
|
|||||||
mFlags &= ~aFlagsToUnset;
|
mFlags &= ~aFlagsToUnset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void HoldJSObjects(void* aScriptObjectHolder,
|
||||||
|
nsScriptObjectTracer* aTracer);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
void CheckCCWrapperTraversal(void* aScriptObjectHolder,
|
||||||
|
nsScriptObjectTracer* aTracer);
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this bit is set then we're preserving the wrapper, which in effect ties
|
* If this bit is set then we're preserving the wrapper, which in effect ties
|
||||||
* the lifetime of the JS object stored in the cache to the lifetime of the
|
* the lifetime of the JS object stored in the cache to the lifetime of the
|
||||||
|
@ -640,7 +640,7 @@ TryPreserveWrapper(JSObject* obj)
|
|||||||
nsWrapperCache* cache = nullptr;
|
nsWrapperCache* cache = nullptr;
|
||||||
CallQueryInterface(native, &cache);
|
CallQueryInterface(native, &cache);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
nsContentUtils::PreserveWrapper(native, cache);
|
cache->PreserveWrapper(native);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -938,12 +938,12 @@ class CGAddPropertyHook(CGAbstractClassHook):
|
|||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
assert not self.descriptor.workers and self.descriptor.wrapperCache
|
assert not self.descriptor.workers and self.descriptor.wrapperCache
|
||||||
if self.descriptor.nativeOwnership == 'nsisupports':
|
if self.descriptor.nativeOwnership == 'nsisupports':
|
||||||
preserveArgs = "reinterpret_cast<nsISupports*>(self), self"
|
preserveArgs = "reinterpret_cast<nsISupports*>(self)"
|
||||||
else:
|
else:
|
||||||
preserveArgs = "self, self, NS_CYCLE_COLLECTION_PARTICIPANT(%s)" % self.descriptor.nativeType
|
preserveArgs = "self, NS_CYCLE_COLLECTION_PARTICIPANT(%s)" % self.descriptor.nativeType
|
||||||
return (" // We don't want to preserve if we don't have a wrapper.\n"
|
return (" // We don't want to preserve if we don't have a wrapper.\n"
|
||||||
" if (self->GetWrapperPreserveColor()) {\n"
|
" if (self->GetWrapperPreserveColor()) {\n"
|
||||||
" nsContentUtils::PreserveWrapper(%s);\n"
|
" self->PreserveWrapper(%s);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" return true;" % preserveArgs)
|
" return true;" % preserveArgs)
|
||||||
|
|
||||||
@ -8362,11 +8362,7 @@ class CGBindingRoot(CGThing):
|
|||||||
return any(m.getExtendedAttribute("Pref") for m in iface.members + [iface]);
|
return any(m.getExtendedAttribute("Pref") for m in iface.members + [iface]);
|
||||||
requiresPreferences = any(descriptorRequiresPreferences(d) for d in descriptors)
|
requiresPreferences = any(descriptorRequiresPreferences(d) for d in descriptors)
|
||||||
hasOwnedDescriptors = any(d.nativeOwnership == 'owned' for d in descriptors)
|
hasOwnedDescriptors = any(d.nativeOwnership == 'owned' for d in descriptors)
|
||||||
def descriptorRequiresContentUtils(desc):
|
requiresContentUtils = any(d.interface.hasInterfaceObject() for d in descriptors)
|
||||||
return ((desc.concrete and not desc.proxy and
|
|
||||||
not desc.workers and desc.wrapperCache) or
|
|
||||||
desc.interface.hasInterfaceObject())
|
|
||||||
requiresContentUtils = any(descriptorRequiresContentUtils(d) for d in descriptors)
|
|
||||||
def descriptorHasChromeOnlyMembers(desc):
|
def descriptorHasChromeOnlyMembers(desc):
|
||||||
return any(isChromeOnly(a) for a in desc.interface.members)
|
return any(isChromeOnly(a) for a in desc.interface.members)
|
||||||
hasChromeOnlyMembers = any(descriptorHasChromeOnlyMembers(d) for d in descriptors)
|
hasChromeOnlyMembers = any(descriptorHasChromeOnlyMembers(d) for d in descriptors)
|
||||||
|
@ -132,7 +132,7 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JS::Handle<JSObject*> obj)
|
|||||||
nsWrapperCache* cache;
|
nsWrapperCache* cache;
|
||||||
CallQueryInterface(native, &cache);
|
CallQueryInterface(native, &cache);
|
||||||
if (expandoAndGeneration) {
|
if (expandoAndGeneration) {
|
||||||
nsContentUtils::PreserveWrapper(native, cache);
|
cache->PreserveWrapper(native);
|
||||||
expandoAndGeneration->expando.setObject(*expando);
|
expandoAndGeneration->expando.setObject(*expando);
|
||||||
|
|
||||||
return expando;
|
return expando;
|
||||||
|
@ -2532,7 +2532,7 @@ PreserveWrapper(JSContext *cx, JSObject *objArg)
|
|||||||
|
|
||||||
// For pre-Paris DOM bindings objects, we only support Node.
|
// For pre-Paris DOM bindings objects, we only support Node.
|
||||||
if (nsCOMPtr<nsINode> node = do_QueryInterface(supports)) {
|
if (nsCOMPtr<nsINode> node = do_QueryInterface(supports)) {
|
||||||
nsContentUtils::PreserveWrapper(supports, node);
|
node->PreserveWrapper(supports);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1282,7 +1282,7 @@ DOMXrayTraits::preserveWrapper(JSObject *target)
|
|||||||
nsWrapperCache* cache = nullptr;
|
nsWrapperCache* cache = nullptr;
|
||||||
CallQueryInterface(identity, &cache);
|
CallQueryInterface(identity, &cache);
|
||||||
if (cache)
|
if (cache)
|
||||||
nsContentUtils::PreserveWrapper(identity, cache);
|
cache->PreserveWrapper(identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
|
Loading…
Reference in New Issue
Block a user