Bug 671282 - Replace nsDebugAutoBoolTrueSetter in docshell and AutoBoolSetter in SMIL with AutoRestore; r=bz

This commit is contained in:
Ed Morley 2011-07-19 12:04:55 +02:00
parent d27c027671
commit 1e063d88b5
2 changed files with 8 additions and 48 deletions

View File

@ -38,32 +38,7 @@
#include "nsSMILInstanceTime.h"
#include "nsSMILInterval.h"
#include "nsSMILTimeValueSpec.h"
//----------------------------------------------------------------------
// Helper classes
namespace
{
// Utility class to set a PRPackedBool value to PR_TRUE whilst it is in scope.
// Saves us having to remember to clear the flag at every possible return.
class AutoBoolSetter
{
public:
AutoBoolSetter(PRPackedBool& aValue)
: mValue(aValue)
{
mValue = PR_TRUE;
}
~AutoBoolSetter()
{
mValue = PR_FALSE;
}
private:
PRPackedBool& mValue;
};
}
#include "mozilla/AutoRestore.h"
//----------------------------------------------------------------------
// Implementation
@ -146,7 +121,8 @@ nsSMILInstanceTime::HandleChangedInterval(
PRBool objectChanged = mCreator->DependsOnBegin() ? aBeginObjectChanged :
aEndObjectChanged;
AutoBoolSetter setVisited(mVisited);
mozilla::AutoRestore<PRPackedBool> setVisited(mVisited);
mVisited = PR_TRUE;
nsRefPtr<nsSMILInstanceTime> deathGrip(this);
mCreator->HandleChangedInstanceTime(*GetBaseTime(), aSrcContainer, *this,
@ -224,7 +200,8 @@ nsSMILInstanceTime::IsDependentOn(const nsSMILInstanceTime& aOther) const
return PR_TRUE;
// mVisited is mutable
AutoBoolSetter setVisited(const_cast<nsSMILInstanceTime*>(this)->mVisited);
mozilla::AutoRestore<PRPackedBool> setVisited(const_cast<nsSMILInstanceTime*>(this)->mVisited);
const_cast<nsSMILInstanceTime*>(this)->mVisited = PR_TRUE;
return myBaseTime->IsDependentOn(aOther);
}

View File

@ -110,6 +110,7 @@
#include "mozilla/Services.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "mozilla/AutoRestore.h"
// we want to explore making the document own the load group
// so we can associate the document URI with the load group.
@ -10877,25 +10878,6 @@ nsDocShell::GetRootScrollFrame()
return shell->GetRootScrollFrameAsScrollableExternal();
}
#ifdef DEBUG
class nsDebugAutoBoolTrueSetter
{
public:
nsDebugAutoBoolTrueSetter(PRPackedBool *aBool)
: mBool(aBool)
{
*mBool = PR_TRUE;
}
~nsDebugAutoBoolTrueSetter()
{
*mBool = PR_FALSE;
}
protected:
PRPackedBool *mBool;
};
#endif
NS_IMETHODIMP
nsDocShell::EnsureScriptEnvironment()
{
@ -10915,7 +10897,8 @@ nsDocShell::EnsureScriptEnvironment()
// Yeah, this isn't re-entrant safe, but that's ok since if we
// re-enter this method, we'll infinitely loop...
nsDebugAutoBoolTrueSetter boolSetter(&mInEnsureScriptEnv);
AutoRestore<PRPackedBool> boolSetter(mInEnsureScriptEnv);
mInEnsureScriptEnv = PR_TRUE;
#endif
nsCOMPtr<nsIDOMScriptObjectFactory> factory =