Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 671282 - Replace nsDebugAutoBoolTrueSetter in docshell and AutoBo…

…olSetter in SMIL with AutoRestore; r=bz
  • Loading branch information...
commit 56cde38b87faf1bf5c73feedbdabf924269ac7d8 1 parent 718cbe3
Ed Morley authored
Showing with 8 additions and 48 deletions.
  1. +5 −28 content/smil/nsSMILInstanceTime.cpp
  2. +3 −20 docshell/base/nsDocShell.cpp
33 content/smil/nsSMILInstanceTime.cpp
View
@@ -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);
}
23 docshell/base/nsDocShell.cpp
View
@@ -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 =
Please sign in to comment.
Something went wrong with that request. Please try again.