Backed out changeset be654bd9e20d (bug 1131801)

This commit is contained in:
Wes Kocher 2015-02-13 13:25:38 -08:00
parent 3f404209b5
commit 0453383547
3 changed files with 46 additions and 1 deletions

View File

@ -1664,6 +1664,12 @@ nsHTMLDocument::Open(JSContext* cx,
}
}
}
nsIXPConnect *xpc = nsContentUtils::XPConnect();
rv = xpc->RescueOrphansInScope(cx, oldScope->GetGlobalJSObject());
if (rv.Failed()) {
return nullptr;
}
}
}

View File

@ -267,7 +267,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
%}
[noscript, uuid(6872bfd6-660b-4aa3-b54b-41ce1d2d69e3)]
[noscript, uuid(75975244-2cf0-43b1-b79a-9fd447fac06b)]
interface nsIXPConnect : nsISupports
{
%{ C++
@ -465,6 +465,9 @@ interface nsIXPConnect : nsISupports
setFunctionThisTranslator(in nsIIDRef aIID,
in nsIXPCFunctionThisTranslator aTranslator);
void
rescueOrphansInScope(in JSContextPtr aJSContext, in JSObjectPtr aScope);
nsIXPConnectJSObjectHolder
getWrappedNativePrototype(in JSContextPtr aJSContext,
in JSObjectPtr aScope,

View File

@ -690,6 +690,42 @@ nsXPConnect::GetWrappedNativeOfNativeObject(JSContext * aJSContext,
return NS_OK;
}
static PLDHashOperator
MoveableWrapperFinder(PLDHashTable *table, PLDHashEntryHdr *hdr,
uint32_t number, void *arg)
{
nsTArray<nsRefPtr<XPCWrappedNative> > *array =
static_cast<nsTArray<nsRefPtr<XPCWrappedNative> > *>(arg);
XPCWrappedNative *wn = ((Native2WrappedNativeMap::Entry*)hdr)->value;
// If a wrapper is expired, then there are no references to it from JS, so
// we don't have to move it.
if (!wn->IsWrapperExpired())
array->AppendElement(wn);
return PL_DHASH_NEXT;
}
/* void rescueOrphansInScope(in JSContextPtr aJSContext, in JSObjectPtr aScope); */
NS_IMETHODIMP
nsXPConnect::RescueOrphansInScope(JSContext *aJSContext, JSObject *aScopeArg)
{
RootedObject aScope(aJSContext, aScopeArg);
XPCWrappedNativeScope *scope = ObjectScope(aScope);
if (!scope)
return UnexpectedFailure(NS_ERROR_FAILURE);
// First, look through the old scope and find all of the wrappers that we
// might need to rescue.
nsTArray<nsRefPtr<XPCWrappedNative> > wrappersToMove;
Native2WrappedNativeMap *map = scope->GetWrappedNativeMap();
wrappersToMove.SetCapacity(map->Count());
map->Enumerate(MoveableWrapperFinder, &wrappersToMove);
return NS_OK;
}
/* nsIStackFrame createStackFrameLocation (in uint32_t aLanguage, in string aFilename, in string aFunctionName, in int32_t aLineNumber, in nsIStackFrame aCaller); */
NS_IMETHODIMP
nsXPConnect::CreateStackFrameLocation(uint32_t aLanguage,