зеркало из https://github.com/mozilla/pjs.git
Bug 608021, [@ nsFrameMessageManager::ReceiveMessage], r=jst
--HG-- extra : rebase_source : bda56f1dbe7fc469178cacda30ee303a05b45e66
This commit is contained in:
Родитель
ca177b7ae6
Коммит
b4ae86a870
|
@ -1904,9 +1904,10 @@ public:
|
|||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
if (tabChild && tabChild->GetInnerManager()) {
|
||||
tabChild->GetInnerManager()->
|
||||
ReceiveMessage(static_cast<nsPIDOMEventTarget*>(tabChild), mMessage,
|
||||
PR_FALSE, mJSON, nsnull, nsnull);
|
||||
nsFrameScriptCx cx(static_cast<nsPIDOMEventTarget*>(tabChild), tabChild);
|
||||
nsRefPtr<nsFrameMessageManager> mm = tabChild->GetInnerManager();
|
||||
mm->ReceiveMessage(static_cast<nsPIDOMEventTarget*>(tabChild), mMessage,
|
||||
PR_FALSE, mJSON, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -462,6 +462,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
}
|
||||
}
|
||||
}
|
||||
nsRefPtr<nsFrameMessageManager> kungfuDeathGrip = mParentManager;
|
||||
return mParentManager ? mParentManager->ReceiveMessage(aTarget, aMessage,
|
||||
aSync, aJSON, aObjectsArray,
|
||||
aJSONRetVal, mContext) : NS_OK;
|
||||
|
@ -601,11 +602,18 @@ nsFrameScriptExecutor::DidCreateCx()
|
|||
void
|
||||
nsFrameScriptExecutor::DestroyCx()
|
||||
{
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
xpc->ReleaseJSContext(mCx, PR_TRUE);
|
||||
} else {
|
||||
JS_DestroyContext(mCx);
|
||||
if (mCxStackRefCnt) {
|
||||
mDelayedCxDestroy = PR_TRUE;
|
||||
return;
|
||||
}
|
||||
mDelayedCxDestroy = PR_FALSE;
|
||||
if (mCx) {
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
xpc->ReleaseJSContext(mCx, PR_TRUE);
|
||||
} else {
|
||||
JS_DestroyContext(mCx);
|
||||
}
|
||||
}
|
||||
mCx = nsnull;
|
||||
mGlobal = nsnull;
|
||||
|
|
|
@ -201,7 +201,9 @@ class nsFrameScriptExecutor
|
|||
public:
|
||||
static void Shutdown();
|
||||
protected:
|
||||
nsFrameScriptExecutor() : mCx(nsnull)
|
||||
friend class nsFrameScriptCx;
|
||||
nsFrameScriptExecutor() : mCx(nsnull), mCxStackRefCnt(0),
|
||||
mDelayedCxDestroy(PR_FALSE)
|
||||
{ MOZ_COUNT_CTOR(nsFrameScriptExecutor); }
|
||||
~nsFrameScriptExecutor()
|
||||
{ MOZ_COUNT_DTOR(nsFrameScriptExecutor); }
|
||||
|
@ -213,11 +215,32 @@ protected:
|
|||
nsCycleCollectionTraversalCallback &cb);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobal;
|
||||
JSContext* mCx;
|
||||
PRUint32 mCxStackRefCnt;
|
||||
PRPackedBool mDelayedCxDestroy;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
static nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>* sCachedScripts;
|
||||
static nsRefPtr<nsScriptCacheCleaner> sScriptCacheCleaner;
|
||||
};
|
||||
|
||||
class nsFrameScriptCx
|
||||
{
|
||||
public:
|
||||
nsFrameScriptCx(nsISupports* aOwner, nsFrameScriptExecutor* aExec)
|
||||
: mOwner(aOwner), mExec(aExec)
|
||||
{
|
||||
++(mExec->mCxStackRefCnt);
|
||||
}
|
||||
~nsFrameScriptCx()
|
||||
{
|
||||
if (--(mExec->mCxStackRefCnt) == 0 &&
|
||||
mExec->mDelayedCxDestroy) {
|
||||
mExec->DestroyCx();
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsFrameScriptExecutor* mExec;
|
||||
};
|
||||
|
||||
class nsScriptCacheCleaner : public nsIObserver
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
|
|
@ -68,8 +68,8 @@ bool SendSyncMessageToParent(void* aCallbackData,
|
|||
async->Run();
|
||||
}
|
||||
if (tabChild->mChromeMessageManager) {
|
||||
tabChild->mChromeMessageManager->ReceiveMessage(owner, aMessage, PR_TRUE,
|
||||
aJSON, nsnull, aJSONRetVal);
|
||||
nsRefPtr<nsFrameMessageManager> mm = tabChild->mChromeMessageManager;
|
||||
mm->ReceiveMessage(owner, aMessage, PR_TRUE, aJSON, nsnull, aJSONRetVal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -85,9 +85,9 @@ public:
|
|||
{
|
||||
mTabChild->mASyncMessages.RemoveElement(this);
|
||||
if (mTabChild->mChromeMessageManager) {
|
||||
mTabChild->mChromeMessageManager->ReceiveMessage(mTabChild->mOwner, mMessage,
|
||||
PR_FALSE,
|
||||
mJSON, nsnull, nsnull);
|
||||
nsRefPtr<nsFrameMessageManager> mm = mTabChild->mChromeMessageManager;
|
||||
mm->ReceiveMessage(mTabChild->mOwner, mMessage, PR_FALSE,
|
||||
mJSON, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ TabChild::Init()
|
|||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(TabChild)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
||||
|
@ -754,9 +755,11 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
|
|||
const nsString& aJSON)
|
||||
{
|
||||
if (mTabChildGlobal) {
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get())->
|
||||
ReceiveMessage(static_cast<nsPIDOMEventTarget*>(mTabChildGlobal),
|
||||
aMessage, PR_FALSE, aJSON, nsnull, nsnull);
|
||||
nsFrameScriptCx cx(static_cast<nsIWebBrowserChrome*>(this), this);
|
||||
nsRefPtr<nsFrameMessageManager> mm =
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
||||
mm->ReceiveMessage(static_cast<nsPIDOMEventTarget*>(mTabChildGlobal),
|
||||
aMessage, PR_FALSE, aJSON, nsnull, nsnull);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -587,7 +587,8 @@ TabParent::ReceiveMessage(const nsString& aMessage,
|
|||
{
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader && frameLoader->GetFrameMessageManager()) {
|
||||
nsFrameMessageManager* manager = frameLoader->GetFrameMessageManager();
|
||||
nsRefPtr<nsFrameMessageManager> manager =
|
||||
frameLoader->GetFrameMessageManager();
|
||||
JSContext* ctx = manager->GetJSContext();
|
||||
JSAutoRequest ar(ctx);
|
||||
PRUint32 len = 0; //TODO: obtain a real value in bug 572685
|
||||
|
|
Загрузка…
Ссылка в новой задаче