mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Fire assertions when guard objects are used as temporaries. (Bug 531460) r=jst
This commit is contained in:
parent
e4e7561b67
commit
50a17ea3e3
@ -67,6 +67,7 @@
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
@ -1700,26 +1701,32 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
class nsAutoGCRoot {
|
||||
class NS_STACK_CLASS nsAutoGCRoot {
|
||||
public:
|
||||
// aPtr should be the pointer to the jsval we want to protect
|
||||
nsAutoGCRoot(jsval* aPtr, nsresult* aResult) :
|
||||
nsAutoGCRoot(jsval* aPtr, nsresult* aResult
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
mPtr(aPtr)
|
||||
{
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
mResult = *aResult = AddJSGCRoot(aPtr, "nsAutoGCRoot");
|
||||
}
|
||||
|
||||
// aPtr should be the pointer to the JSObject* we want to protect
|
||||
nsAutoGCRoot(JSObject** aPtr, nsresult* aResult) :
|
||||
nsAutoGCRoot(JSObject** aPtr, nsresult* aResult
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
mPtr(aPtr)
|
||||
{
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
mResult = *aResult = AddJSGCRoot(aPtr, "nsAutoGCRoot");
|
||||
}
|
||||
|
||||
// aPtr should be the pointer to the thing we want to protect
|
||||
nsAutoGCRoot(void* aPtr, nsresult* aResult) :
|
||||
nsAutoGCRoot(void* aPtr, nsresult* aResult
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM) :
|
||||
mPtr(aPtr)
|
||||
{
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
mResult = *aResult = AddJSGCRoot(aPtr, "nsAutoGCRoot");
|
||||
}
|
||||
|
||||
@ -1740,28 +1747,34 @@ private:
|
||||
|
||||
void* mPtr;
|
||||
nsresult mResult;
|
||||
MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class nsAutoScriptBlocker {
|
||||
class NS_STACK_CLASS nsAutoScriptBlocker {
|
||||
public:
|
||||
nsAutoScriptBlocker() {
|
||||
nsAutoScriptBlocker(MOZILLA_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) {
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
nsContentUtils::AddScriptBlocker();
|
||||
}
|
||||
~nsAutoScriptBlocker() {
|
||||
nsContentUtils::RemoveScriptBlocker();
|
||||
}
|
||||
private:
|
||||
MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class mozAutoRemovableBlockerRemover
|
||||
class NS_STACK_CLASS mozAutoRemovableBlockerRemover
|
||||
{
|
||||
public:
|
||||
mozAutoRemovableBlockerRemover(nsIDocument* aDocument);
|
||||
mozAutoRemovableBlockerRemover(nsIDocument* aDocument
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
~mozAutoRemovableBlockerRemover();
|
||||
|
||||
private:
|
||||
PRUint32 mNestingLevel;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIDocumentObserver> mObserver;
|
||||
MOZILLA_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
#define NS_AUTO_GCROOT_PASTE2(tok,line) tok##line
|
||||
|
@ -5903,8 +5903,9 @@ nsContentUtils::CheckCCWrapperTraversal(nsISupports* aScriptObjectHolder,
|
||||
}
|
||||
#endif
|
||||
|
||||
mozAutoRemovableBlockerRemover::mozAutoRemovableBlockerRemover(nsIDocument* aDocument)
|
||||
mozAutoRemovableBlockerRemover::mozAutoRemovableBlockerRemover(nsIDocument* aDocument MOZILLA_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
||||
{
|
||||
MOZILLA_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
mNestingLevel = nsContentUtils::GetRemovableScriptBlockerLevel();
|
||||
mDocument = aDocument;
|
||||
nsISupports* sink = aDocument ? aDocument->GetCurrentContentSink() : nsnull;
|
||||
|
Loading…
Reference in New Issue
Block a user