bug 877886 - get rid of a number of static constructors in content/ and dom/ r=smaug
authorTrevor Saunders <trev.saunders@gmail.com>
Thu, 30 May 2013 18:34:53 -0400
changeset 134153 17aa0fec31dc5bb301c79b98c0d94ec310961203
parent 134152 d96df10fe4f53d3a62d31b9d602de4005b93d295
child 134154 9305b1486c2dfe418d642fef80fc01d78626a774
push id29072
push usertrev.saunders@gmail.com
push dateWed, 05 Jun 2013 21:04:59 +0000
treeherdermozilla-inbound@17aa0fec31dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs877886
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 877886 - get rid of a number of static constructors in content/ and dom/ r=smaug
content/canvas/src/CanvasRenderingContext2D.cpp
content/smil/SMILBoolType.cpp
content/smil/SMILBoolType.h
content/smil/SMILEnumType.cpp
content/smil/SMILEnumType.h
content/smil/SMILIntegerType.cpp
content/smil/SMILIntegerType.h
content/smil/SMILStringType.cpp
content/smil/SMILStringType.h
content/smil/nsSMILCSSValueType.cpp
content/smil/nsSMILFloatType.cpp
content/smil/nsSMILFloatType.h
content/smil/nsSMILNullType.cpp
content/smil/nsSMILNullType.h
content/smil/nsSMILValue.cpp
content/smil/nsSMILValue.h
content/svg/content/src/DOMSVGAnimatedLengthList.cpp
content/svg/content/src/DOMSVGAnimatedNumberList.cpp
content/svg/content/src/DOMSVGPathSegList.cpp
content/svg/content/src/DOMSVGPointList.cpp
content/svg/content/src/DOMSVGStringList.cpp
content/svg/content/src/SVGAnimatedPathSegList.cpp
content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
content/svg/content/src/SVGIntegerPairSMILType.cpp
content/svg/content/src/SVGIntegerPairSMILType.h
content/svg/content/src/SVGLengthListSMILType.cpp
content/svg/content/src/SVGMotionSMILType.cpp
content/svg/content/src/SVGNumberListSMILType.cpp
content/svg/content/src/SVGNumberPairSMILType.cpp
content/svg/content/src/SVGOrientSMILType.cpp
content/svg/content/src/SVGPathSegListSMILType.cpp
content/svg/content/src/SVGPathSegListSMILType.h
content/svg/content/src/SVGPointListSMILType.cpp
content/svg/content/src/SVGTransform.cpp
content/svg/content/src/SVGTransformListSMILType.cpp
content/svg/content/src/SVGTransformListSMILType.h
content/svg/content/src/SVGViewBoxSMILType.cpp
content/svg/content/src/nsSVGAnimatedTransformList.cpp
content/svg/content/src/nsSVGBoolean.cpp
content/svg/content/src/nsSVGClass.cpp
content/svg/content/src/nsSVGEnum.cpp
content/svg/content/src/nsSVGInteger.cpp
content/svg/content/src/nsSVGIntegerPair.cpp
content/svg/content/src/nsSVGLength2.cpp
content/svg/content/src/nsSVGNumber2.cpp
content/svg/content/src/nsSVGString.cpp
dom/base/nsDOMException.cpp
dom/indexedDB/IDBTransaction.cpp
dom/src/geolocation/nsGeolocation.cpp
dom/src/geolocation/nsGeolocation.h
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -117,20 +117,16 @@ using namespace mozilla::gfx;
 using namespace mozilla::ipc;
 using namespace mozilla::layers;
 
 namespace mgfx = mozilla::gfx;
 
 namespace mozilla {
 namespace dom {
 
-static float kDefaultFontSize = 10.0;
-static NS_NAMED_LITERAL_STRING(kDefaultFontName, "sans-serif");
-static NS_NAMED_LITERAL_STRING(kDefaultFontStyle, "10px sans-serif");
-
 // Cap sigma to avoid overly large temp surfaces.
 const Float SIGMA_MAX = 100;
 
 /* Memory reporter stuff */
 static int64_t gCanvasAzureMemoryUsed = 0;
 
 static int64_t GetCanvasAzureMemoryUsed() {
   return gCanvasAzureMemoryUsed;
@@ -2703,22 +2699,24 @@ CanvasRenderingContext2D::DrawOrMeasureT
   return NS_OK;
 }
 
 gfxFontGroup *CanvasRenderingContext2D::GetCurrentFontStyle()
 {
   // use lazy initilization for the font group since it's rather expensive
   if (!CurrentState().fontGroup) {
     ErrorResult err;
+    NS_NAMED_LITERAL_STRING(kDefaultFontStyle, "10px sans-serif");
+    static float kDefaultFontSize = 10.0;
     SetFont(kDefaultFontStyle, err);
     if (err.Failed()) {
       gfxFontStyle style;
       style.size = kDefaultFontSize;
       CurrentState().fontGroup =
-        gfxPlatform::GetPlatform()->CreateFontGroup(kDefaultFontName,
+        gfxPlatform::GetPlatform()->CreateFontGroup(NS_LITERAL_STRING("sans-serif"),
                                                     &style,
                                                     nullptr);
       if (CurrentState().fontGroup) {
         CurrentState().font = kDefaultFontStyle;
       } else {
         NS_ERROR("Default canvas font is invalid");
       }
     }
--- a/content/smil/SMILBoolType.cpp
+++ b/content/smil/SMILBoolType.cpp
@@ -5,32 +5,30 @@
 
 #include "SMILBoolType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include <math.h>
 
 namespace mozilla {
 
-/*static*/ SMILBoolType SMILBoolType::sSingleton;
-
 void
 SMILBoolType::Init(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mBool = false;
   aValue.mType = this;
 }
 
 void
 SMILBoolType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mBool = false;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILBoolType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mBool = aSrc.mU.mBool;
--- a/content/smil/SMILBoolType.h
+++ b/content/smil/SMILBoolType.h
@@ -10,17 +10,21 @@
 #include "nsISMILType.h"
 
 namespace mozilla {
 
 class SMILBoolType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static SMILBoolType sSingleton;
+  static SMILBoolType* Singleton()
+  {
+    static SMILBoolType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual void     Destroy(nsSMILValue&) const;
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
   virtual nsresult Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
--- a/content/smil/SMILEnumType.cpp
+++ b/content/smil/SMILEnumType.cpp
@@ -5,32 +5,30 @@
 
 #include "SMILEnumType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include <math.h>
 
 namespace mozilla {
 
-/*static*/ SMILEnumType SMILEnumType::sSingleton;
-
 void
 SMILEnumType::Init(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mUint = 0;
   aValue.mType = this;
 }
 
 void
 SMILEnumType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mUint = 0;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILEnumType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mUint = aSrc.mU.mUint;
--- a/content/smil/SMILEnumType.h
+++ b/content/smil/SMILEnumType.h
@@ -10,17 +10,22 @@
 #include "nsISMILType.h"
 
 namespace mozilla {
 
 class SMILEnumType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static SMILEnumType sSingleton;
+  static SMILEnumType*
+  Singleton()
+  {
+    static SMILEnumType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual void     Destroy(nsSMILValue&) const;
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
   virtual bool     IsEqual(const nsSMILValue& aLeft,
--- a/content/smil/SMILIntegerType.cpp
+++ b/content/smil/SMILIntegerType.cpp
@@ -5,32 +5,30 @@
 
 #include "SMILIntegerType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include <math.h>
 
 namespace mozilla {
 
-/*static*/ SMILIntegerType SMILIntegerType::sSingleton;
-
 void
 SMILIntegerType::Init(nsSMILValue& aValue) const
 {
   NS_ABORT_IF_FALSE(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mInt = 0;
   aValue.mType = this;
 }
 
 void
 SMILIntegerType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mInt = 0;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILIntegerType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mInt = aSrc.mU.mInt;
--- a/content/smil/SMILIntegerType.h
+++ b/content/smil/SMILIntegerType.h
@@ -24,17 +24,22 @@ public:
   virtual nsresult ComputeDistance(const nsSMILValue& aFrom,
                                    const nsSMILValue& aTo,
                                    double& aDistance) const MOZ_OVERRIDE;
   virtual nsresult Interpolate(const nsSMILValue& aStartVal,
                                const nsSMILValue& aEndVal,
                                double aUnitDistance,
                                nsSMILValue& aResult) const MOZ_OVERRIDE;
 
-  static SMILIntegerType sSingleton;
+  static SMILIntegerType*
+  Singleton()
+  {
+    static SMILIntegerType sSingleton;
+    return &sSingleton;
+  }
 
 private:
   SMILIntegerType() {}
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SMILINTEGERTYPE_H_
--- a/content/smil/SMILStringType.cpp
+++ b/content/smil/SMILStringType.cpp
@@ -5,33 +5,31 @@
 
 #include "SMILStringType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include "nsString.h"
 
 namespace mozilla {
 
-/*static*/ SMILStringType SMILStringType::sSingleton;
-
 void
 SMILStringType::Init(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mPtr = new nsString();
   aValue.mType = this;
 }
 
 void
 SMILStringType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   delete static_cast<nsAString*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SMILStringType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
 
--- a/content/smil/SMILStringType.h
+++ b/content/smil/SMILStringType.h
@@ -10,17 +10,22 @@
 #include "nsISMILType.h"
 
 namespace mozilla {
 
 class SMILStringType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static SMILStringType sSingleton;
+  static SMILStringType*
+  Singleton()
+  {
+    static SMILStringType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual void     Destroy(nsSMILValue&) const;
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
   virtual bool     IsEqual(const nsSMILValue& aLeft,
--- a/content/smil/nsSMILCSSValueType.cpp
+++ b/content/smil/nsSMILCSSValueType.cpp
@@ -146,17 +146,17 @@ nsSMILCSSValueType::Init(nsSMILValue& aV
   aValue.mType = this;
 }
 
 void
 nsSMILCSSValueType::Destroy(nsSMILValue& aValue) const
 {
   NS_ABORT_IF_FALSE(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<ValueWrapper*>(aValue.mU.mPtr);
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 nsSMILCSSValueType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_ABORT_IF_FALSE(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_ABORT_IF_FALSE(aDest.mType == this, "Unexpected SMIL value type");
   const ValueWrapper* srcWrapper = ExtractValueWrapper(aSrc);
--- a/content/smil/nsSMILFloatType.cpp
+++ b/content/smil/nsSMILFloatType.cpp
@@ -3,32 +3,30 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSMILFloatType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include <math.h>
 
-/*static*/ nsSMILFloatType nsSMILFloatType::sSingleton;
-
 void
 nsSMILFloatType::Init(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mDouble = 0.0;
   aValue.mType = this;
 }
 
 void
 nsSMILFloatType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mDouble = 0.0;
-  aValue.mType      = &nsSMILNullType::sSingleton;
+  aValue.mType      = nsSMILNullType::Singleton();
 }
 
 nsresult
 nsSMILFloatType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
   aDest.mU.mDouble = aSrc.mU.mDouble;
--- a/content/smil/nsSMILFloatType.h
+++ b/content/smil/nsSMILFloatType.h
@@ -8,17 +8,22 @@
 
 #include "mozilla/Attributes.h"
 #include "nsISMILType.h"
 
 class nsSMILFloatType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static nsSMILFloatType sSingleton;
+  static nsSMILFloatType*
+  Singleton()
+  {
+    static nsSMILFloatType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual void     Destroy(nsSMILValue&) const;
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
   virtual bool     IsEqual(const nsSMILValue& aLeft,
--- a/content/smil/nsSMILNullType.cpp
+++ b/content/smil/nsSMILNullType.cpp
@@ -2,25 +2,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSMILNullType.h"
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 
-/*static*/ nsSMILNullType nsSMILNullType::sSingleton;
-
 nsresult
 nsSMILNullType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aSrc.mType == this, "Unexpected source type");
   aDest.mU    = aSrc.mU;
-  aDest.mType = &sSingleton;
+  aDest.mType = Singleton();
   return NS_OK;
 }
 
 bool
 nsSMILNullType::IsEqual(const nsSMILValue& aLeft,
                         const nsSMILValue& aRight) const
 {
   NS_PRECONDITION(aLeft.mType == aRight.mType, "Incompatible SMIL types");
--- a/content/smil/nsSMILNullType.h
+++ b/content/smil/nsSMILNullType.h
@@ -8,17 +8,22 @@
 
 #include "mozilla/Attributes.h"
 #include "nsISMILType.h"
 
 class nsSMILNullType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static nsSMILNullType sSingleton;
+  static nsSMILNullType*
+  Singleton()
+  {
+    static nsSMILNullType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void Init(nsSMILValue& aValue) const MOZ_OVERRIDE {}
   virtual void Destroy(nsSMILValue& aValue) const MOZ_OVERRIDE {}
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
 
--- a/content/smil/nsSMILValue.cpp
+++ b/content/smil/nsSMILValue.cpp
@@ -6,28 +6,28 @@
 #include "nsSMILValue.h"
 #include "nsDebug.h"
 #include <string.h>
 
 //----------------------------------------------------------------------
 // Public methods
 
 nsSMILValue::nsSMILValue(const nsISMILType* aType)
-  : mType(&nsSMILNullType::sSingleton)
+  : mType(nsSMILNullType::Singleton())
 {
   if (!aType) {
     NS_ERROR("Trying to construct nsSMILValue with null mType pointer");
     return;
   }
 
   InitAndCheckPostcondition(aType);
 }
 
 nsSMILValue::nsSMILValue(const nsSMILValue& aVal)
-  : mType(&nsSMILNullType::sSingleton)
+  : mType(nsSMILNullType::Singleton())
 {
   InitAndCheckPostcondition(aVal.mType);
   mType->Assign(*this, aVal);
 }
 
 const nsSMILValue&
 nsSMILValue::operator=(const nsSMILValue& aVal)
 {
@@ -57,17 +57,17 @@ nsSMILValue::Swap(nsSMILValue& aOther)
 {
   nsSMILValue tmp;
   memcpy(&tmp,    &aOther, sizeof(nsSMILValue));  // tmp    = aOther
   memcpy(&aOther, this,    sizeof(nsSMILValue));  // aOther = this
   memcpy(this,    &tmp,    sizeof(nsSMILValue));  // this   = tmp
 
   // |tmp| is about to die -- we need to clear its mType, so that its
   // destructor doesn't muck with the data we just transferred out of it.
-  tmp.mType = &nsSMILNullType::sSingleton;
+  tmp.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 nsSMILValue::Add(const nsSMILValue& aValueToAdd, uint32_t aCount)
 {
   if (aValueToAdd.mType != mType) {
     NS_ERROR("Trying to add incompatible types");
     return NS_ERROR_FAILURE;
--- a/content/smil/nsSMILValue.h
+++ b/content/smil/nsSMILValue.h
@@ -16,17 +16,17 @@
  * cached so that the SMIL engine can make certain optimizations during a
  * sample if the base value has not changed since the last sample (potentially
  * avoiding recomposing). These nsSMILValue objects typically live much longer
  * than a single sample.
  */
 class nsSMILValue
 {
 public:
-  nsSMILValue() : mU(), mType(&nsSMILNullType::sSingleton) { }
+  nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
   explicit nsSMILValue(const nsISMILType* aType);
   nsSMILValue(const nsSMILValue& aVal);
 
   ~nsSMILValue()
   {
     mType->Destroy(*this);
   }
 
@@ -36,17 +36,17 @@ public:
   // more than you'd expect) - see comment above nsISMILType::IsEqual.
   bool operator==(const nsSMILValue& aVal) const;
   bool operator!=(const nsSMILValue& aVal) const {
     return !(*this == aVal);
   }
 
   bool IsNull() const
   {
-    return (mType == &nsSMILNullType::sSingleton);
+    return (mType == nsSMILNullType::Singleton());
   }
 
   // Swaps the member data (mU & mPtr) of |this| with |aOther|
   void     Swap(nsSMILValue& aOther);
 
   nsresult Add(const nsSMILValue& aValueToAdd, uint32_t aCount = 1);
   nsresult SandwichAdd(const nsSMILValue& aValueToAdd);
   nsresult ComputeDistance(const nsSMILValue& aTo, double& aDistance) const;
--- a/content/svg/content/src/DOMSVGAnimatedLengthList.cpp
+++ b/content/svg/content/src/DOMSVGAnimatedLengthList.cpp
@@ -11,18 +11,24 @@
 #include "nsSVGAttrTearoffTable.h"
 #include "mozilla/dom/SVGAnimatedLengthListBinding.h"
 #include "nsContentUtils.h"
 
 // See the architecture comment in this file's header.
 
 namespace mozilla {
 
-static nsSVGAttrTearoffTable<SVGAnimatedLengthList, DOMSVGAnimatedLengthList>
-  sSVGAnimatedLengthListTearoffTable;
+static inline
+nsSVGAttrTearoffTable<SVGAnimatedLengthList, DOMSVGAnimatedLengthList>&
+SVGAnimatedLengthListTearoffTable()
+{
+  static nsSVGAttrTearoffTable<SVGAnimatedLengthList, DOMSVGAnimatedLengthList>
+    sSVGAnimatedLengthListTearoffTable;
+  return sSVGAnimatedLengthListTearoffTable;
+}
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedLengthList, mElement)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAnimatedLengthList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedLengthList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedLengthList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@@ -57,35 +63,35 @@ DOMSVGAnimatedLengthList::AnimVal()
 
 /* static */ already_AddRefed<DOMSVGAnimatedLengthList>
 DOMSVGAnimatedLengthList::GetDOMWrapper(SVGAnimatedLengthList *aList,
                                         nsSVGElement *aElement,
                                         uint8_t aAttrEnum,
                                         uint8_t aAxis)
 {
   nsRefPtr<DOMSVGAnimatedLengthList> wrapper =
-    sSVGAnimatedLengthListTearoffTable.GetTearoff(aList);
+    SVGAnimatedLengthListTearoffTable().GetTearoff(aList);
   if (!wrapper) {
     wrapper = new DOMSVGAnimatedLengthList(aElement, aAttrEnum, aAxis);
-    sSVGAnimatedLengthListTearoffTable.AddTearoff(aList, wrapper);
+    SVGAnimatedLengthListTearoffTable().AddTearoff(aList, wrapper);
   }
   return wrapper.forget();
 }
 
 /* static */ DOMSVGAnimatedLengthList*
 DOMSVGAnimatedLengthList::GetDOMWrapperIfExists(SVGAnimatedLengthList *aList)
 {
-  return sSVGAnimatedLengthListTearoffTable.GetTearoff(aList);
+  return SVGAnimatedLengthListTearoffTable().GetTearoff(aList);
 }
 
 DOMSVGAnimatedLengthList::~DOMSVGAnimatedLengthList()
 {
   // Script no longer has any references to us, to our base/animVal objects, or
   // to any of their list items.
-  sSVGAnimatedLengthListTearoffTable.RemoveTearoff(&InternalAList());
+  SVGAnimatedLengthListTearoffTable().RemoveTearoff(&InternalAList());
 }
 
 void
 DOMSVGAnimatedLengthList::InternalBaseValListWillChangeTo(const SVGLengthList& aNewValue)
 {
   // When the number of items in our internal counterpart's baseVal changes,
   // we MUST keep our baseVal in sync. If we don't, script will either see a
   // list that is too short and be unable to access indexes that should be
--- a/content/svg/content/src/DOMSVGAnimatedNumberList.cpp
+++ b/content/svg/content/src/DOMSVGAnimatedNumberList.cpp
@@ -11,18 +11,24 @@
 #include "nsSVGAttrTearoffTable.h"
 #include "mozilla/dom/SVGAnimatedNumberListBinding.h"
 #include "nsContentUtils.h"
 
 // See the architecture comment in this file's header.
 
 namespace mozilla {
 
-static nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>
-  sSVGAnimatedNumberListTearoffTable;
+  static inline
+nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>&
+SVGAnimatedNumberListTearoffTable()
+{
+  static nsSVGAttrTearoffTable<SVGAnimatedNumberList, DOMSVGAnimatedNumberList>
+    sSVGAnimatedNumberListTearoffTable;
+  return sSVGAnimatedNumberListTearoffTable;
+}
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGAnimatedNumberList, mElement)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGAnimatedNumberList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGAnimatedNumberList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGAnimatedNumberList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@@ -56,35 +62,35 @@ DOMSVGAnimatedNumberList::AnimVal()
 }
 
 /* static */ already_AddRefed<DOMSVGAnimatedNumberList>
 DOMSVGAnimatedNumberList::GetDOMWrapper(SVGAnimatedNumberList *aList,
                                         nsSVGElement *aElement,
                                         uint8_t aAttrEnum)
 {
   nsRefPtr<DOMSVGAnimatedNumberList> wrapper =
-    sSVGAnimatedNumberListTearoffTable.GetTearoff(aList);
+    SVGAnimatedNumberListTearoffTable().GetTearoff(aList);
   if (!wrapper) {
     wrapper = new DOMSVGAnimatedNumberList(aElement, aAttrEnum);
-    sSVGAnimatedNumberListTearoffTable.AddTearoff(aList, wrapper);
+    SVGAnimatedNumberListTearoffTable().AddTearoff(aList, wrapper);
   }
   return wrapper.forget();
 }
 
 /* static */ DOMSVGAnimatedNumberList*
 DOMSVGAnimatedNumberList::GetDOMWrapperIfExists(SVGAnimatedNumberList *aList)
 {
-  return sSVGAnimatedNumberListTearoffTable.GetTearoff(aList);
+  return SVGAnimatedNumberListTearoffTable().GetTearoff(aList);
 }
 
 DOMSVGAnimatedNumberList::~DOMSVGAnimatedNumberList()
 {
   // Script no longer has any references to us, to our base/animVal objects, or
   // to any of their list items.
-  sSVGAnimatedNumberListTearoffTable.RemoveTearoff(&InternalAList());
+  SVGAnimatedNumberListTearoffTable().RemoveTearoff(&InternalAList());
 }
 
 void
 DOMSVGAnimatedNumberList::InternalBaseValListWillChangeTo(const SVGNumberList& aNewValue)
 {
   // When the number of items in our internal counterpart's baseVal changes,
   // we MUST keep our baseVal in sync. If we don't, script will either see a
   // list that is too short and be unable to access indexes that should be
--- a/content/svg/content/src/DOMSVGPathSegList.cpp
+++ b/content/svg/content/src/DOMSVGPathSegList.cpp
@@ -13,18 +13,24 @@
 #include "SVGPathSegUtils.h"
 #include "mozilla/dom/SVGPathSegListBinding.h"
 #include "nsContentUtils.h"
 
 // See the comment in this file's header.
 
 namespace mozilla {
 
-static nsSVGAttrTearoffTable<void, DOMSVGPathSegList>
-  sSVGPathSegListTearoffTable;
+  static inline
+nsSVGAttrTearoffTable<void, DOMSVGPathSegList>&
+SVGPathSegListTearoffTable()
+{
+  static nsSVGAttrTearoffTable<void, DOMSVGPathSegList>
+    sSVGPathSegListTearoffTable;
+  return sSVGPathSegListTearoffTable;
+}
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGPathSegList)
   // No unlinking of mElement, we'd need to null out the value pointer (the
   // object it points to is held by the element) and null-check it everywhere.
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGPathSegList)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement)
@@ -44,38 +50,38 @@ NS_INTERFACE_MAP_END
 
 
 /* static */ already_AddRefed<DOMSVGPathSegList>
 DOMSVGPathSegList::GetDOMWrapper(void *aList,
                                  nsSVGElement *aElement,
                                  bool aIsAnimValList)
 {
   nsRefPtr<DOMSVGPathSegList> wrapper =
-    sSVGPathSegListTearoffTable.GetTearoff(aList);
+    SVGPathSegListTearoffTable().GetTearoff(aList);
   if (!wrapper) {
     wrapper = new DOMSVGPathSegList(aElement, aIsAnimValList);
-    sSVGPathSegListTearoffTable.AddTearoff(aList, wrapper);
+    SVGPathSegListTearoffTable().AddTearoff(aList, wrapper);
   }
   return wrapper.forget();
 }
 
 /* static */ DOMSVGPathSegList*
 DOMSVGPathSegList::GetDOMWrapperIfExists(void *aList)
 {
-  return sSVGPathSegListTearoffTable.GetTearoff(aList);
+  return SVGPathSegListTearoffTable().GetTearoff(aList);
 }
 
 DOMSVGPathSegList::~DOMSVGPathSegList()
 {
   // There are now no longer any references to us held by script or list items.
   // Note we must use GetAnimValKey/GetBaseValKey here, NOT InternalList()!
   void *key = mIsAnimValList ?
     InternalAList().GetAnimValKey() :
     InternalAList().GetBaseValKey();
-  sSVGPathSegListTearoffTable.RemoveTearoff(key);
+  SVGPathSegListTearoffTable().RemoveTearoff(key);
 }
 
 JSObject*
 DOMSVGPathSegList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGPathSegListBinding::Wrap(cx, scope, this);
 }
 
--- a/content/svg/content/src/DOMSVGPointList.cpp
+++ b/content/svg/content/src/DOMSVGPointList.cpp
@@ -31,18 +31,24 @@ UpdateListIndicesFromIndex(FallibleTArra
     }
   }
 }
 
 } // namespace
 
 namespace mozilla {
 
-static nsSVGAttrTearoffTable<void, DOMSVGPointList>
-  sSVGPointListTearoffTable;
+  static inline
+nsSVGAttrTearoffTable<void, DOMSVGPointList>&
+SVGPointListTearoffTable()
+{
+  static nsSVGAttrTearoffTable<void, DOMSVGPointList>
+    sSVGPointListTearoffTable;
+  return sSVGPointListTearoffTable;
+}
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGPointList)
   // No unlinking of mElement, we'd need to null out the value pointer (the
   // object it points to is held by the element) and null-check it everywhere.
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGPointList)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement)
@@ -62,38 +68,38 @@ NS_INTERFACE_MAP_END
 
 
 /* static */ already_AddRefed<DOMSVGPointList>
 DOMSVGPointList::GetDOMWrapper(void *aList,
                                nsSVGElement *aElement,
                                bool aIsAnimValList)
 {
   nsRefPtr<DOMSVGPointList> wrapper =
-    sSVGPointListTearoffTable.GetTearoff(aList);
+    SVGPointListTearoffTable().GetTearoff(aList);
   if (!wrapper) {
     wrapper = new DOMSVGPointList(aElement, aIsAnimValList);
-    sSVGPointListTearoffTable.AddTearoff(aList, wrapper);
+    SVGPointListTearoffTable().AddTearoff(aList, wrapper);
   }
   return wrapper.forget();
 }
 
 /* static */ DOMSVGPointList*
 DOMSVGPointList::GetDOMWrapperIfExists(void *aList)
 {
-  return sSVGPointListTearoffTable.GetTearoff(aList);
+  return SVGPointListTearoffTable().GetTearoff(aList);
 }
 
 DOMSVGPointList::~DOMSVGPointList()
 {
   // There are now no longer any references to us held by script or list items.
   // Note we must use GetAnimValKey/GetBaseValKey here, NOT InternalList()!
   void *key = mIsAnimValList ?
     InternalAList().GetAnimValKey() :
     InternalAList().GetBaseValKey();
-  sSVGPointListTearoffTable.RemoveTearoff(key);
+  SVGPointListTearoffTable().RemoveTearoff(key);
 }
 
 JSObject*
 DOMSVGPointList::WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
 {
   return mozilla::dom::SVGPointListBinding::Wrap(cx, scope, this);
 }
 
--- a/content/svg/content/src/DOMSVGStringList.cpp
+++ b/content/svg/content/src/DOMSVGStringList.cpp
@@ -13,18 +13,24 @@
 #include <algorithm>
 
 // See the architecture comment in this file's header.
 
 namespace mozilla {
 
 using namespace dom;
 
-static nsSVGAttrTearoffTable<SVGStringList, DOMSVGStringList>
-  sSVGStringListTearoffTable;
+static inline
+nsSVGAttrTearoffTable<SVGStringList, DOMSVGStringList>&
+SVGStringListTearoffTable()
+{
+  static nsSVGAttrTearoffTable<SVGStringList, DOMSVGStringList>
+    sSVGStringListTearoffTable;
+  return sSVGStringListTearoffTable;
+}
 
 NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(DOMSVGStringList, mElement)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMSVGStringList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMSVGStringList)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGStringList)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@@ -33,30 +39,30 @@ NS_INTERFACE_MAP_END
 
 /* static */ already_AddRefed<DOMSVGStringList>
 DOMSVGStringList::GetDOMWrapper(SVGStringList *aList,
                                 nsSVGElement *aElement,
                                 bool aIsConditionalProcessingAttribute,
                                 uint8_t aAttrEnum)
 {
   nsRefPtr<DOMSVGStringList> wrapper =
-    sSVGStringListTearoffTable.GetTearoff(aList);
+    SVGStringListTearoffTable().GetTearoff(aList);
   if (!wrapper) {
     wrapper = new DOMSVGStringList(aElement, 
                                    aIsConditionalProcessingAttribute,
                                    aAttrEnum);
-    sSVGStringListTearoffTable.AddTearoff(aList, wrapper);
+    SVGStringListTearoffTable().AddTearoff(aList, wrapper);
   }
   return wrapper.forget();
 }
 
 DOMSVGStringList::~DOMSVGStringList()
 {
   // Script no longer has any references to us.
-  sSVGStringListTearoffTable.RemoveTearoff(&InternalList());
+  SVGStringListTearoffTable().RemoveTearoff(&InternalList());
 }
 
 /* virtual */ JSObject*
 DOMSVGStringList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return SVGStringListBinding::Wrap(aCx, aScope, this);
 }
 
--- a/content/svg/content/src/SVGAnimatedPathSegList.cpp
+++ b/content/svg/content/src/SVGAnimatedPathSegList.cpp
@@ -149,17 +149,17 @@ SVGAnimatedPathSegList::ToSMILAttr(nsSVG
 
 nsresult
 SVGAnimatedPathSegList::
   SMILAnimatedPathSegList::ValueFromString(const nsAString& aStr,
                                const dom::SVGAnimationElement* /*aSrcElement*/,
                                nsSMILValue& aValue,
                                bool& aPreventCachingOfSandwich) const
 {
-  nsSMILValue val(&SVGPathSegListSMILType::sSingleton);
+  nsSMILValue val(SVGPathSegListSMILType::Singleton());
   SVGPathDataAndOwner *list = static_cast<SVGPathDataAndOwner*>(val.mU.mPtr);
   nsresult rv = list->SetValueFromString(aStr);
   if (NS_SUCCEEDED(rv)) {
     list->SetElement(mElement);
     aValue.Swap(val);
   }
   aPreventCachingOfSandwich = false;
   return rv;
@@ -168,32 +168,32 @@ SVGAnimatedPathSegList::
 nsSMILValue
 SVGAnimatedPathSegList::SMILAnimatedPathSegList::GetBaseValue() const
 {
   // To benefit from Return Value Optimization and avoid copy constructor calls
   // due to our use of return-by-value, we must return the exact same object
   // from ALL return points. This function must only return THIS variable:
   nsSMILValue val;
 
-  nsSMILValue tmp(&SVGPathSegListSMILType::sSingleton);
+  nsSMILValue tmp(SVGPathSegListSMILType::Singleton());
   SVGPathDataAndOwner *list = static_cast<SVGPathDataAndOwner*>(tmp.mU.mPtr);
   nsresult rv = list->CopyFrom(mVal->mBaseVal);
   if (NS_SUCCEEDED(rv)) {
     list->SetElement(mElement);
     val.Swap(tmp);
   }
   return val;
 }
 
 nsresult
 SVGAnimatedPathSegList::SMILAnimatedPathSegList::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SVGPathSegListSMILType::sSingleton,
+  NS_ASSERTION(aValue.mType == SVGPathSegListSMILType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SVGPathSegListSMILType::sSingleton) {
+  if (aValue.mType == SVGPathSegListSMILType::Singleton()) {
     mVal->SetAnimValue(*static_cast<SVGPathDataAndOwner*>(aValue.mU.mPtr),
                        mElement);
   }
   return NS_OK;
 }
 
 void
 SVGAnimatedPathSegList::SMILAnimatedPathSegList::ClearAnimValue()
--- a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
+++ b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
@@ -316,27 +316,27 @@ SMILPreserveAspectRatio::ValueFromString
                                          const SVGAnimationElement* /*aSrcElement*/,
                                          nsSMILValue& aValue,
                                          bool& aPreventCachingOfSandwich) const
 {
   SVGPreserveAspectRatio par;
   nsresult res = ToPreserveAspectRatio(aStr, &par);
   NS_ENSURE_SUCCESS(res, res);
 
-  nsSMILValue val(&SMILEnumType::sSingleton);
+  nsSMILValue val(SMILEnumType::Singleton());
   val.mU.mUint = PackPreserveAspectRatio(par);
   aValue = val;
   aPreventCachingOfSandwich = false;
   return NS_OK;
 }
 
 nsSMILValue
 SMILPreserveAspectRatio::GetBaseValue() const
 {
-  nsSMILValue val(&SMILEnumType::sSingleton);
+  nsSMILValue val(SMILEnumType::Singleton());
   val.mU.mUint = PackPreserveAspectRatio(mVal->GetBaseValue());
   return val;
 }
 
 void
 SMILPreserveAspectRatio::ClearAnimValue()
 {
   if (mVal->mIsAnimated) {
@@ -344,15 +344,15 @@ SMILPreserveAspectRatio::ClearAnimValue(
     mVal->mAnimVal = mVal->mBaseVal;
     mSVGElement->DidAnimatePreserveAspectRatio();
   }
 }
 
 nsresult
 SMILPreserveAspectRatio::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SMILEnumType::sSingleton,
+  NS_ASSERTION(aValue.mType == SMILEnumType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SMILEnumType::sSingleton) {
+  if (aValue.mType == SMILEnumType::Singleton()) {
     mVal->SetAnimValue(aValue.mU.mUint, mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/SVGIntegerPairSMILType.cpp
+++ b/content/svg/content/src/SVGIntegerPairSMILType.cpp
@@ -5,35 +5,33 @@
 
 #include "SVGIntegerPairSMILType.h"
 #include "nsSMILValue.h"
 #include "nsMathUtils.h"
 #include "nsDebug.h"
 
 namespace mozilla {
 
-/*static*/ SVGIntegerPairSMILType SVGIntegerPairSMILType::sSingleton;
-
 void
 SVGIntegerPairSMILType::Init(nsSMILValue& aValue) const
 {
   NS_ABORT_IF_FALSE(aValue.IsNull(), "Unexpected value type");
 
   aValue.mU.mIntPair[0] = 0;
   aValue.mU.mIntPair[1] = 0;
   aValue.mType = this;
 }
 
 void
 SVGIntegerPairSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mIntPair[0] = 0;
   aValue.mU.mIntPair[1] = 0;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGIntegerPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
 
--- a/content/svg/content/src/SVGIntegerPairSMILType.h
+++ b/content/svg/content/src/SVGIntegerPairSMILType.h
@@ -12,17 +12,22 @@
 class nsSMILValue;
 
 namespace mozilla {
 
 class SVGIntegerPairSMILType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static SVGIntegerPairSMILType sSingleton;
+  static SVGIntegerPairSMILType*
+  Singleton()
+  {
+    static SVGIntegerPairSMILType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual void     Destroy(nsSMILValue&) const;
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
   virtual bool     IsEqual(const nsSMILValue& aLeft,
--- a/content/svg/content/src/SVGLengthListSMILType.cpp
+++ b/content/svg/content/src/SVGLengthListSMILType.cpp
@@ -32,17 +32,17 @@ SVGLengthListSMILType::Init(nsSMILValue 
 }
 
 void
 SVGLengthListSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGLengthListAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGLengthListSMILType::Assign(nsSMILValue& aDest,
                               const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
--- a/content/svg/content/src/SVGMotionSMILType.cpp
+++ b/content/svg/content/src/SVGMotionSMILType.cpp
@@ -174,17 +174,17 @@ void
 SVGMotionSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_ABORT_IF_FALSE(aValue.mType == this, "Unexpected SMIL type");
 
   MotionSegmentArray* arr = static_cast<MotionSegmentArray*>(aValue.mU.mPtr);
   delete arr;
 
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGMotionSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_ABORT_IF_FALSE(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_ABORT_IF_FALSE(aDest.mType == this, "Unexpected SMIL type");
 
--- a/content/svg/content/src/SVGNumberListSMILType.cpp
+++ b/content/svg/content/src/SVGNumberListSMILType.cpp
@@ -45,17 +45,17 @@ SVGNumberListSMILType::Init(nsSMILValue 
 }
 
 void
 SVGNumberListSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGNumberListAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGNumberListSMILType::Assign(nsSMILValue& aDest,
                               const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
--- a/content/svg/content/src/SVGNumberPairSMILType.cpp
+++ b/content/svg/content/src/SVGNumberPairSMILType.cpp
@@ -23,17 +23,17 @@ SVGNumberPairSMILType::Init(nsSMILValue&
 }
 
 void
 SVGNumberPairSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   aValue.mU.mNumberPair[0] = 0;
   aValue.mU.mNumberPair[1] = 0;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGNumberPairSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
 
--- a/content/svg/content/src/SVGOrientSMILType.cpp
+++ b/content/svg/content/src/SVGOrientSMILType.cpp
@@ -25,17 +25,17 @@ SVGOrientSMILType::Init(nsSMILValue& aVa
   aValue.mType = this;
 }
 
 void
 SVGOrientSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value.");
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGOrientSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types.");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value.");
 
--- a/content/svg/content/src/SVGPathSegListSMILType.cpp
+++ b/content/svg/content/src/SVGPathSegListSMILType.cpp
@@ -12,18 +12,16 @@
 
 // Indices of boolean flags within 'arc' segment chunks in path-data arrays
 // (where '0' would correspond to the index of the encoded segment type):
 #define LARGE_ARC_FLAG_IDX 4
 #define SWEEP_FLAG_IDX     5
 
 namespace mozilla {
 
-/*static*/ SVGPathSegListSMILType SVGPathSegListSMILType::sSingleton;
-
 //----------------------------------------------------------------------
 // nsISMILType implementation
 
 void
 SVGPathSegListSMILType::Init(nsSMILValue &aValue) const
 {
   NS_ABORT_IF_FALSE(aValue.IsNull(), "Unexpected value type");
   aValue.mU.mPtr = new SVGPathDataAndOwner();
@@ -31,17 +29,17 @@ SVGPathSegListSMILType::Init(nsSMILValue
 }
 
 void
 SVGPathSegListSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGPathDataAndOwner*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGPathSegListSMILType::Assign(nsSMILValue& aDest,
                                const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
--- a/content/svg/content/src/SVGPathSegListSMILType.h
+++ b/content/svg/content/src/SVGPathSegListSMILType.h
@@ -17,17 +17,21 @@ namespace mozilla {
 // SVGPathSegListSMILType
 //
 // Operations for animating an SVGPathData.
 //
 class SVGPathSegListSMILType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static SVGPathSegListSMILType sSingleton;
+  static SVGPathSegListSMILType* Singleton()
+  {
+    static SVGPathSegListSMILType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
 
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
 
   virtual void     Destroy(nsSMILValue& aValue) const MOZ_OVERRIDE;
--- a/content/svg/content/src/SVGPointListSMILType.cpp
+++ b/content/svg/content/src/SVGPointListSMILType.cpp
@@ -28,17 +28,17 @@ SVGPointListSMILType::Init(nsSMILValue &
 }
 
 void
 SVGPointListSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
   delete static_cast<SVGPointListAndInfo*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGPointListSMILType::Assign(nsSMILValue& aDest,
                               const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
--- a/content/svg/content/src/SVGTransform.cpp
+++ b/content/svg/content/src/SVGTransform.cpp
@@ -11,17 +11,22 @@
 #include "nsAttrValueInlines.h"
 #include "nsSVGAnimatedTransformList.h"
 #include "nsSVGAttrTearoffTable.h"
 #include "mozilla/dom/SVGTransformBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
+static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix>&
+SVGMatrixTearoffTable()
+{
+  static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
+  return sSVGMatrixTearoffTable;
+}
 
 //----------------------------------------------------------------------
 
 // We could use NS_IMPL_CYCLE_COLLECTION_1, except that in Unlink() we need to
 // clear our list's weak ref to us to be safe. (The other option would be to
 // not unlink and rely on the breaking of the other edges in the cycle, as
 // NS_SVG_VAL_IMPL_CYCLE_COLLECTION does.)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SVGTransform)
@@ -31,17 +36,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SV
   }
 NS_IMPL_CYCLE_COLLECTION_UNLINK(mList)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(SVGTransform)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList)
   SVGMatrix* matrix =
-    sSVGMatrixTearoffTable.GetTearoff(tmp);
+    SVGMatrixTearoffTable().GetTearoff(tmp);
   CycleCollectionNoteChild(cb, matrix, "matrix");
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(SVGTransform)
 NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
@@ -99,19 +104,19 @@ SVGTransform::SVGTransform(const nsSVGTr
   , mIsAnimValItem(false)
   , mTransform(new nsSVGTransform(aTransform))
 {
   SetIsDOMBinding();
 }
 
 SVGTransform::~SVGTransform()
 {
-  SVGMatrix* matrix = sSVGMatrixTearoffTable.GetTearoff(this);
+  SVGMatrix* matrix = SVGMatrixTearoffTable().GetTearoff(this);
   if (matrix) {
-    sSVGMatrixTearoffTable.RemoveTearoff(this);
+    SVGMatrixTearoffTable().RemoveTearoff(this);
     NS_RELEASE(matrix);
   }
   // Our mList's weak ref to us must be nulled out when we die. If GC has
   // unlinked us using the cycle collector code, then that has already
   // happened, and mList is null.
   if (mList) {
     mList->mItems[mListIndex] = nullptr;
   }
@@ -122,20 +127,20 @@ SVGTransform::Type() const
 {
   return Transform().Type();
 }
 
 SVGMatrix*
 SVGTransform::Matrix()
 {
   SVGMatrix* wrapper =
-    sSVGMatrixTearoffTable.GetTearoff(this);
+    SVGMatrixTearoffTable().GetTearoff(this);
   if (!wrapper) {
     NS_ADDREF(wrapper = new SVGMatrix(*this));
-    sSVGMatrixTearoffTable.AddTearoff(this, wrapper);
+    SVGMatrixTearoffTable().AddTearoff(this, wrapper);
   }
   return wrapper;
 }
 
 float
 SVGTransform::Angle() const
 {
   return Transform().Angle();
--- a/content/svg/content/src/SVGTransformListSMILType.cpp
+++ b/content/svg/content/src/SVGTransformListSMILType.cpp
@@ -7,18 +7,16 @@
 #include "SVGTransformList.h"
 #include "nsSVGTransform.h"
 #include "nsSMILValue.h"
 #include "nsCRT.h"
 #include <math.h>
 
 using namespace mozilla;
 
-/*static*/ SVGTransformListSMILType SVGTransformListSMILType::sSingleton;
-
 typedef FallibleTArray<SVGTransformSMILData> TransformArray;
 
 //----------------------------------------------------------------------
 // nsISMILType implementation
 
 void
 SVGTransformListSMILType::Init(nsSMILValue &aValue) const
 {
@@ -31,17 +29,17 @@ SVGTransformListSMILType::Init(nsSMILVal
 
 void
 SVGTransformListSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value type");
   TransformArray* params = static_cast<TransformArray*>(aValue.mU.mPtr);
   delete params;
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGTransformListSMILType::Assign(nsSMILValue& aDest,
                                const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
@@ -316,29 +314,29 @@ SVGTransformListSMILType::Interpolate(co
 // Transform array accessors
 
 // static
 nsresult
 SVGTransformListSMILType::AppendTransform(
   const SVGTransformSMILData& aTransform,
   nsSMILValue& aValue)
 {
-  NS_PRECONDITION(aValue.mType == &sSingleton, "Unexpected SMIL value type");
+  NS_PRECONDITION(aValue.mType == &Singleton(), "Unexpected SMIL value type");
 
   TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
   return transforms.AppendElement(aTransform) ?
     NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 // static
 bool
 SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList,
                                            nsSMILValue& aValue)
 {
-  NS_PRECONDITION(aValue.mType == &sSingleton, "Unexpected SMIL value type");
+  NS_PRECONDITION(aValue.mType == &Singleton(), "Unexpected SMIL value type");
 
   TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
 
   if (!transforms.SetCapacity(transforms.Length() + aList.Length()))
     return false;
 
   for (uint32_t i = 0; i < aList.Length(); ++i) {
     // No need to check the return value below since we have already allocated
@@ -348,17 +346,17 @@ SVGTransformListSMILType::AppendTransfor
   return true;
 }
 
 // static
 bool
 SVGTransformListSMILType::GetTransforms(const nsSMILValue& aValue,
                                         FallibleTArray<nsSVGTransform>& aTransforms)
 {
-  NS_PRECONDITION(aValue.mType == &sSingleton, "Unexpected SMIL value type");
+  NS_PRECONDITION(aValue.mType == &Singleton(), "Unexpected SMIL value type");
 
   const TransformArray& smilTransforms =
     *static_cast<const TransformArray*>(aValue.mU.mPtr);
 
   aTransforms.Clear();
   if (!aTransforms.SetCapacity(smilTransforms.Length()))
       return false;
 
--- a/content/svg/content/src/SVGTransformListSMILType.h
+++ b/content/svg/content/src/SVGTransformListSMILType.h
@@ -76,17 +76,22 @@ class SVGTransformSMILData;
 // may have use a start-value the base value of the target attribute (which as
 // we have seen above can contain 0..n elements) whilst the end-value comes from
 // the <animateTransform> and so can only hold 1 transform.
 //
 class SVGTransformListSMILType : public nsISMILType
 {
 public:
   // Singleton for nsSMILValue objects to hold onto.
-  static SVGTransformListSMILType sSingleton;
+  static SVGTransformListSMILType*
+  Singleton()
+  {
+    static SVGTransformListSMILType sSingleton;
+    return &sSingleton;
+  }
 
 protected:
   // nsISMILType Methods
   // -------------------
   virtual void     Init(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual void     Destroy(nsSMILValue& aValue) const MOZ_OVERRIDE;
   virtual nsresult Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const MOZ_OVERRIDE;
   virtual bool     IsEqual(const nsSMILValue& aLeft,
--- a/content/svg/content/src/SVGViewBoxSMILType.cpp
+++ b/content/svg/content/src/SVGViewBoxSMILType.cpp
@@ -23,17 +23,17 @@ SVGViewBoxSMILType::Init(nsSMILValue& aV
 }
 
 void
 SVGViewBoxSMILType::Destroy(nsSMILValue& aValue) const
 {
   NS_PRECONDITION(aValue.mType == this, "Unexpected SMIL value");
   delete static_cast<nsSVGViewBoxRect*>(aValue.mU.mPtr);
   aValue.mU.mPtr = nullptr;
-  aValue.mType = &nsSMILNullType::sSingleton;
+  aValue.mType = nsSMILNullType::Singleton();
 }
 
 nsresult
 SVGViewBoxSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
 {
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
 
--- a/content/svg/content/src/nsSVGAnimatedTransformList.cpp
+++ b/content/svg/content/src/nsSVGAnimatedTransformList.cpp
@@ -220,17 +220,17 @@ nsSVGAnimatedTransformList::SMILAnimated
     // y-angle
     if (numParsed != 1)
       return;
     transformType = SVG_TRANSFORM_SKEWY;
   } else {
     return;
   }
 
-  nsSMILValue val(&SVGTransformListSMILType::sSingleton);
+  nsSMILValue val(SVGTransformListSMILType::Singleton());
   SVGTransformSMILData transform(transformType, params);
   if (NS_FAILED(SVGTransformListSMILType::AppendTransform(transform, val))) {
     return; // OOM
   }
 
   // Success! Populate our outparam with parsed value.
   aResult.Swap(val);
 }
@@ -287,30 +287,30 @@ nsSVGAnimatedTransformList::SMILAnimated
 }
 
 nsSMILValue
 nsSVGAnimatedTransformList::SMILAnimatedTransformList::GetBaseValue() const
 {
   // To benefit from Return Value Optimization and avoid copy constructor calls
   // due to our use of return-by-value, we must return the exact same object
   // from ALL return points. This function must only return THIS variable:
-  nsSMILValue val(&SVGTransformListSMILType::sSingleton);
+  nsSMILValue val(SVGTransformListSMILType::Singleton());
   if (!SVGTransformListSMILType::AppendTransforms(mVal->mBaseVal, val)) {
     val = nsSMILValue();
   }
 
   return val;
 }
 
 nsresult
 nsSVGAnimatedTransformList::SMILAnimatedTransformList::SetAnimValue(
   const nsSMILValue& aNewAnimValue)
 {
   NS_ABORT_IF_FALSE(
-    aNewAnimValue.mType == &SVGTransformListSMILType::sSingleton,
+    aNewAnimValue.mType == SVGTransformListSMILType::Singleton(),
     "Unexpected type to assign animated value");
   SVGTransformList animVal;
   if (!SVGTransformListSMILType::GetTransforms(aNewAnimValue,
                                                animVal.mItems)) {
     return NS_ERROR_FAILURE;
   }
 
   return mVal->SetAnimValue(animVal, mElement);
--- a/content/svg/content/src/nsSVGBoolean.cpp
+++ b/content/svg/content/src/nsSVGBoolean.cpp
@@ -10,18 +10,24 @@
 #include "SMILBoolType.h"
 #include "SVGAnimatedBoolean.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 /* Implementation */
 
-static nsSVGAttrTearoffTable<nsSVGBoolean, SVGAnimatedBoolean>
-  sSVGAnimatedBooleanTearoffTable;
+static inline
+nsSVGAttrTearoffTable<nsSVGBoolean, SVGAnimatedBoolean>&
+SVGAnimatedBooleanTearoffTable()
+{
+  static nsSVGAttrTearoffTable<nsSVGBoolean, SVGAnimatedBoolean>
+    sSVGAnimatedBooleanTearoffTable;
+  return sSVGAnimatedBooleanTearoffTable;
+}
 
 static nsresult
 GetValueFromString(const nsAString &aValueAsString,
                    bool *aValue)
 {
   if (aValueAsString.EqualsLiteral("true")) {
     *aValue = true;
     return NS_OK;
@@ -103,28 +109,28 @@ nsSVGBoolean::SetAnimValue(bool aValue, 
   mIsAnimated = true;
   aSVGElement->DidAnimateBoolean(mAttrEnum);
 }
 
 already_AddRefed<SVGAnimatedBoolean>
 nsSVGBoolean::ToDOMAnimatedBoolean(nsSVGElement* aSVGElement)
 {
   nsRefPtr<SVGAnimatedBoolean> domAnimatedBoolean =
-    sSVGAnimatedBooleanTearoffTable.GetTearoff(this);
+    SVGAnimatedBooleanTearoffTable().GetTearoff(this);
   if (!domAnimatedBoolean) {
     domAnimatedBoolean = new SVGAnimatedBoolean(this, aSVGElement);
-    sSVGAnimatedBooleanTearoffTable.AddTearoff(this, domAnimatedBoolean);
+    SVGAnimatedBooleanTearoffTable().AddTearoff(this, domAnimatedBoolean);
   }
 
   return domAnimatedBoolean.forget();
 }
 
 SVGAnimatedBoolean::~SVGAnimatedBoolean()
 {
-  sSVGAnimatedBooleanTearoffTable.RemoveTearoff(mVal);
+  SVGAnimatedBooleanTearoffTable().RemoveTearoff(mVal);
 }
 
 nsISMILAttr*
 nsSVGBoolean::ToSMILAttr(nsSVGElement *aSVGElement)
 {
   return new SMILBool(this, aSVGElement);
 }
 
@@ -135,28 +141,28 @@ nsSVGBoolean::SMILBool::ValueFromString(
                                         bool& aPreventCachingOfSandwich) const
 {
   bool value;
   nsresult rv = GetValueFromString(aStr, &value);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsSMILValue val(&SMILBoolType::sSingleton);
+  nsSMILValue val(SMILBoolType::Singleton());
   val.mU.mBool = value;
   aValue = val;
   aPreventCachingOfSandwich = false;
 
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGBoolean::SMILBool::GetBaseValue() const
 {
-  nsSMILValue val(&SMILBoolType::sSingleton);
+  nsSMILValue val(SMILBoolType::Singleton());
   val.mU.mBool = mVal->mBaseVal;
   return val;
 }
 
 void
 nsSVGBoolean::SMILBool::ClearAnimValue()
 {
   if (mVal->mIsAnimated) {
@@ -164,15 +170,15 @@ nsSVGBoolean::SMILBool::ClearAnimValue()
     mVal->mAnimVal = mVal->mBaseVal;
     mSVGElement->DidAnimateBoolean(mVal->mAttrEnum);
   }
 }
 
 nsresult
 nsSVGBoolean::SMILBool::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SMILBoolType::sSingleton,
+  NS_ASSERTION(aValue.mType == SMILBoolType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SMILBoolType::sSingleton) {
+  if (aValue.mType == SMILBoolType::Singleton()) {
     mVal->SetAnimValue(uint16_t(aValue.mU.mBool), mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGClass.cpp
+++ b/content/svg/content/src/nsSVGClass.cpp
@@ -87,28 +87,28 @@ nsSVGClass::ToSMILAttr(nsSVGElement *aSV
 }
 
 nsresult
 nsSVGClass::SMILString::ValueFromString(const nsAString& aStr,
                                         const dom::SVGAnimationElement* /*aSrcElement*/,
                                         nsSMILValue& aValue,
                                         bool& aPreventCachingOfSandwich) const
 {
-  nsSMILValue val(&SMILStringType::sSingleton);
+  nsSMILValue val(SMILStringType::Singleton());
 
   *static_cast<nsAString*>(val.mU.mPtr) = aStr;
   aValue.Swap(val);
   aPreventCachingOfSandwich = false;
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGClass::SMILString::GetBaseValue() const
 {
-  nsSMILValue val(&SMILStringType::sSingleton);
+  nsSMILValue val(SMILStringType::Singleton());
   mSVGElement->GetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                        *static_cast<nsAString*>(val.mU.mPtr));
   return val;
 }
 
 void
 nsSVGClass::SMILString::ClearAnimValue()
 {
@@ -116,15 +116,15 @@ nsSVGClass::SMILString::ClearAnimValue()
     mVal->mAnimVal = nullptr;
     mSVGElement->DidAnimateClass();
   }
 }
 
 nsresult
 nsSVGClass::SMILString::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SMILStringType::sSingleton,
+  NS_ASSERTION(aValue.mType == SMILStringType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SMILStringType::sSingleton) {
+  if (aValue.mType == SMILStringType::Singleton()) {
     mVal->SetAnimValue(*static_cast<nsAString*>(aValue.mU.mPtr), mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGEnum.cpp
+++ b/content/svg/content/src/nsSVGEnum.cpp
@@ -161,17 +161,17 @@ nsSVGEnum::SMILEnum::ValueFromString(con
                                      bool& aPreventCachingOfSandwich) const
 {
   nsIAtom *valAtom = NS_GetStaticAtom(aStr);
   if (valAtom) {
     nsSVGEnumMapping *mapping = mVal->GetMapping(mSVGElement);
 
     while (mapping && mapping->mKey) {
       if (valAtom == *(mapping->mKey)) {
-        nsSMILValue val(&SMILEnumType::sSingleton);
+        nsSMILValue val(SMILEnumType::Singleton());
         val.mU.mUint = mapping->mVal;
         aValue = val;
         aPreventCachingOfSandwich = false;
         return NS_OK;
       }
       mapping++;
     }
   }
@@ -179,17 +179,17 @@ nsSVGEnum::SMILEnum::ValueFromString(con
   // only a warning since authors may mistype attribute values
   NS_WARNING("unknown enumeration key");
   return NS_ERROR_FAILURE;
 }
 
 nsSMILValue
 nsSVGEnum::SMILEnum::GetBaseValue() const
 {
-  nsSMILValue val(&SMILEnumType::sSingleton);
+  nsSMILValue val(SMILEnumType::Singleton());
   val.mU.mUint = mVal->mBaseVal;
   return val;
 }
 
 void
 nsSVGEnum::SMILEnum::ClearAnimValue()
 {
   if (mVal->mIsAnimated) {
@@ -197,17 +197,17 @@ nsSVGEnum::SMILEnum::ClearAnimValue()
     mVal->mAnimVal = mVal->mBaseVal;
     mSVGElement->DidAnimateEnum(mVal->mAttrEnum);
   }
 }
 
 nsresult
 nsSVGEnum::SMILEnum::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SMILEnumType::sSingleton,
+  NS_ASSERTION(aValue.mType == SMILEnumType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SMILEnumType::sSingleton) {
+  if (aValue.mType == SMILEnumType::Singleton()) {
     NS_ABORT_IF_FALSE(aValue.mU.mUint <= USHRT_MAX,
                       "Very large enumerated value - too big for uint16_t");
     mVal->SetAnimValue(uint16_t(aValue.mU.mUint), mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGInteger.cpp
+++ b/content/svg/content/src/nsSVGInteger.cpp
@@ -152,27 +152,27 @@ nsSVGInteger::SMILInteger::ValueFromStri
 {
   int32_t val;
 
   nsresult rv = GetValueFromString(aStr, &val);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsSMILValue smilVal(&SMILIntegerType::sSingleton);
+  nsSMILValue smilVal(SMILIntegerType::Singleton());
   smilVal.mU.mInt = val;
   aValue = smilVal;
   aPreventCachingOfSandwich = false;
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGInteger::SMILInteger::GetBaseValue() const
 {
-  nsSMILValue val(&SMILIntegerType::sSingleton);
+  nsSMILValue val(SMILIntegerType::Singleton());
   val.mU.mInt = mVal->mBaseVal;
   return val;
 }
 
 void
 nsSVGInteger::SMILInteger::ClearAnimValue()
 {
   if (mVal->mIsAnimated) {
@@ -180,15 +180,15 @@ nsSVGInteger::SMILInteger::ClearAnimValu
     mVal->mAnimVal = mVal->mBaseVal;
     mSVGElement->DidAnimateInteger(mVal->mAttrEnum);
   }
 }
 
 nsresult
 nsSVGInteger::SMILInteger::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SMILIntegerType::sSingleton,
+  NS_ASSERTION(aValue.mType == SMILIntegerType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SMILIntegerType::sSingleton) {
+  if (aValue.mType == SMILIntegerType::Singleton()) {
     mVal->SetAnimValue(int(aValue.mU.mInt), mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGIntegerPair.cpp
+++ b/content/svg/content/src/nsSVGIntegerPair.cpp
@@ -219,29 +219,29 @@ nsSVGIntegerPair::SMILIntegerPair::Value
 {
   int32_t values[2];
 
   nsresult rv = ParseIntegerOptionalInteger(aStr, values);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsSMILValue val(&SVGIntegerPairSMILType::sSingleton);
+  nsSMILValue val(SVGIntegerPairSMILType::Singleton());
   val.mU.mIntPair[0] = values[0];
   val.mU.mIntPair[1] = values[1];
   aValue = val;
   aPreventCachingOfSandwich = false;
 
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGIntegerPair::SMILIntegerPair::GetBaseValue() const
 {
-  nsSMILValue val(&SVGIntegerPairSMILType::sSingleton);
+  nsSMILValue val(SVGIntegerPairSMILType::Singleton());
   val.mU.mIntPair[0] = mVal->mBaseVal[0];
   val.mU.mIntPair[1] = mVal->mBaseVal[1];
   return val;
 }
 
 void
 nsSVGIntegerPair::SMILIntegerPair::ClearAnimValue()
 {
@@ -251,15 +251,15 @@ nsSVGIntegerPair::SMILIntegerPair::Clear
     mVal->mAnimVal[1] = mVal->mBaseVal[1];
     mSVGElement->DidAnimateIntegerPair(mVal->mAttrEnum);
   }
 }
 
 nsresult
 nsSVGIntegerPair::SMILIntegerPair::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SVGIntegerPairSMILType::sSingleton,
+  NS_ASSERTION(aValue.mType == SVGIntegerPairSMILType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SVGIntegerPairSMILType::sSingleton) {
+  if (aValue.mType == SVGIntegerPairSMILType::Singleton()) {
     mVal->SetAnimValue(aValue.mU.mIntPair, mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGLength2.cpp
+++ b/content/svg/content/src/nsSVGLength2.cpp
@@ -512,31 +512,31 @@ nsSVGLength2::SMILLength::ValueFromStrin
   float value;
   uint16_t unitType;
   
   nsresult rv = GetValueFromString(aStr, &value, &unitType);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsSMILValue val(&nsSMILFloatType::sSingleton);
+  nsSMILValue val(nsSMILFloatType::Singleton());
   val.mU.mDouble = value / mVal->GetUnitScaleFactor(mSVGElement, unitType);
   aValue = val;
   aPreventCachingOfSandwich =
               (unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
                unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_EMS ||
                unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_EXS);
 
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGLength2::SMILLength::GetBaseValue() const
 {
-  nsSMILValue val(&nsSMILFloatType::sSingleton);
+  nsSMILValue val(nsSMILFloatType::Singleton());
   val.mU.mDouble = mVal->GetBaseValue(mSVGElement);
   return val;
 }
 
 void
 nsSVGLength2::SMILLength::ClearAnimValue()
 {
   if (mVal->mIsAnimated) {
@@ -544,15 +544,15 @@ nsSVGLength2::SMILLength::ClearAnimValue
     mVal->mAnimVal = mVal->mBaseVal;
     mSVGElement->DidAnimateLength(mVal->mAttrEnum);
   }  
 }
 
 nsresult
 nsSVGLength2::SMILLength::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &nsSMILFloatType::sSingleton,
+  NS_ASSERTION(aValue.mType == nsSMILFloatType::Singleton(),
     "Unexpected type to assign animated value");
-  if (aValue.mType == &nsSMILFloatType::sSingleton) {
+  if (aValue.mType == nsSMILFloatType::Singleton()) {
     mVal->SetAnimValue(float(aValue.mU.mDouble), mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGNumber2.cpp
+++ b/content/svg/content/src/nsSVGNumber2.cpp
@@ -192,28 +192,28 @@ nsSVGNumber2::SMILNumber::ValueFromStrin
 
   nsresult rv = GetValueFromString(
     aStr, mSVGElement->NumberAttrAllowsPercentage(mVal->mAttrEnum), &value);
 
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsSMILValue val(&nsSMILFloatType::sSingleton);
+  nsSMILValue val(nsSMILFloatType::Singleton());
   val.mU.mDouble = value;
   aValue = val;
   aPreventCachingOfSandwich = false;
 
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGNumber2::SMILNumber::GetBaseValue() const
 {
-  nsSMILValue val(&nsSMILFloatType::sSingleton);
+  nsSMILValue val(nsSMILFloatType::Singleton());
   val.mU.mDouble = mVal->mBaseVal;
   return val;
 }
 
 void
 nsSVGNumber2::SMILNumber::ClearAnimValue()
 {
   if (mVal->mIsAnimated) {
@@ -221,15 +221,15 @@ nsSVGNumber2::SMILNumber::ClearAnimValue
     mVal->mAnimVal = mVal->mBaseVal;
     mSVGElement->DidAnimateNumber(mVal->mAttrEnum);
   }
 }
 
 nsresult
 nsSVGNumber2::SMILNumber::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &nsSMILFloatType::sSingleton,
+  NS_ASSERTION(aValue.mType == nsSMILFloatType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &nsSMILFloatType::sSingleton) {
+  if (aValue.mType == nsSMILFloatType::Singleton()) {
     mVal->SetAnimValue(float(aValue.mU.mDouble), mSVGElement);
   }
   return NS_OK;
 }
--- a/content/svg/content/src/nsSVGString.cpp
+++ b/content/svg/content/src/nsSVGString.cpp
@@ -18,18 +18,24 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGSt
 DOMCI_DATA(SVGAnimatedString, nsSVGString::DOMAnimatedString)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGString::DOMAnimatedString)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedString)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGAnimatedString)
 NS_INTERFACE_MAP_END
 
-static nsSVGAttrTearoffTable<nsSVGString, nsSVGString::DOMAnimatedString>
-  sSVGAnimatedStringTearoffTable;
+static inline
+nsSVGAttrTearoffTable<nsSVGString, nsSVGString::DOMAnimatedString>&
+SVGAnimatedStringTearoffTable()
+{
+  static nsSVGAttrTearoffTable<nsSVGString, nsSVGString::DOMAnimatedString>
+    sSVGAnimatedStringTearoffTable;
+  return sSVGAnimatedStringTearoffTable;
+}
 
 /* Implementation */
 
 void
 nsSVGString::SetBaseValue(const nsAString& aValue,
                           nsSVGElement *aSVGElement,
                           bool aDoSetAttr)
 {
@@ -79,69 +85,69 @@ nsSVGString::ToDOMAnimatedString(nsIDOMS
   *aResult = ToDOMAnimatedString(aSVGElement).get();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMSVGAnimatedString>
 nsSVGString::ToDOMAnimatedString(nsSVGElement* aSVGElement)
 {
   nsRefPtr<DOMAnimatedString> domAnimatedString =
-    sSVGAnimatedStringTearoffTable.GetTearoff(this);
+    SVGAnimatedStringTearoffTable().GetTearoff(this);
   if (!domAnimatedString) {
     domAnimatedString = new DOMAnimatedString(this, aSVGElement);
-    sSVGAnimatedStringTearoffTable.AddTearoff(this, domAnimatedString);
+    SVGAnimatedStringTearoffTable().AddTearoff(this, domAnimatedString);
   }
 
   return domAnimatedString.forget();
 }
 
 nsSVGString::DOMAnimatedString::~DOMAnimatedString()
 {
-  sSVGAnimatedStringTearoffTable.RemoveTearoff(mVal);
+  SVGAnimatedStringTearoffTable().RemoveTearoff(mVal);
 }
 
 nsISMILAttr*
 nsSVGString::ToSMILAttr(nsSVGElement *aSVGElement)
 {
   return new SMILString(this, aSVGElement);
 }
 
 nsresult
 nsSVGString::SMILString::ValueFromString(const nsAString& aStr,
                                          const dom::SVGAnimationElement* /*aSrcElement*/,
                                          nsSMILValue& aValue,
                                          bool& aPreventCachingOfSandwich) const
 {
-  nsSMILValue val(&SMILStringType::sSingleton);
+  nsSMILValue val(SMILStringType::Singleton());
 
   *static_cast<nsAString*>(val.mU.mPtr) = aStr;
   aValue.Swap(val);
   aPreventCachingOfSandwich = false;
   return NS_OK;
 }
 
 nsSMILValue
 nsSVGString::SMILString::GetBaseValue() const
 {
-  nsSMILValue val(&SMILStringType::sSingleton);
+  nsSMILValue val(SMILStringType::Singleton());
   mSVGElement->GetStringBaseValue(mVal->mAttrEnum, *static_cast<nsAString*>(val.mU.mPtr));
   return val;
 }
 
 void
 nsSVGString::SMILString::ClearAnimValue()
 {
   if (mVal->mAnimVal) {
     mVal->mAnimVal = nullptr;
     mSVGElement->DidAnimateString(mVal->mAttrEnum);
   }
 }
 
 nsresult
 nsSVGString::SMILString::SetAnimValue(const nsSMILValue& aValue)
 {
-  NS_ASSERTION(aValue.mType == &SMILStringType::sSingleton,
+  NS_ASSERTION(aValue.mType == SMILStringType::Singleton(),
                "Unexpected type to assign animated value");
-  if (aValue.mType == &SMILStringType::sSingleton) {
+  if (aValue.mType == SMILStringType::Singleton()) {
     mVal->SetAnimValue(*static_cast<nsAString*>(aValue.mU.mPtr), mSVGElement);
   }
   return NS_OK;
 }
--- a/dom/base/nsDOMException.cpp
+++ b/dom/base/nsDOMException.cpp
@@ -9,16 +9,18 @@
 #include "nsDOMClassInfoID.h"
 #include "nsError.h"
 #include "nsDOMException.h"
 #include "nsIDOMDOMException.h"
 #include "nsIDocument.h"
 #include "nsString.h"
 #include "prprf.h"
 
+using namespace mozilla;
+
 enum DOM4ErrorTypeCodeMap {
   /* DOM4 errors from http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#domexception */
   IndexSizeError             = nsIDOMDOMException::INDEX_SIZE_ERR,
   HierarchyRequestError      = nsIDOMDOMException::HIERARCHY_REQUEST_ERR,
   WrongDocumentError         = nsIDOMDOMException::WRONG_DOCUMENT_ERR,
   InvalidCharacterError      = nsIDOMDOMException::INVALID_CHARACTER_ERR,
   NoModificationAllowedError = nsIDOMDOMException::NO_MODIFICATION_ALLOWED_ERR,
   NotFoundError              = nsIDOMDOMException::NOT_FOUND_ERR,
@@ -55,53 +57,49 @@ enum DOM4ErrorTypeCodeMap {
 
   /* File API errors http://dev.w3.org/2006/webapi/FileAPI/#ErrorAndException */
   NotReadableError         = 0,
 
   /* FileHandle API errors */
   LockedFileInactiveError = 0,
 };
 
-#define DOM4_MSG_DEF(name, message, nsresult) {(nsresult), name, #name, message},
-#define DOM_MSG_DEF(val, message) {(val), NS_ERROR_GET_CODE(val), #val, message},
-
-static struct ResultStruct
-{
-  nsresult mNSResult;
-  uint16_t mCode;
-  const char* mName;
-  const char* mMessage;
-} gDOMErrorMsgMap[] = {
-#include "domerr.msg"
-  {NS_OK, 0, nullptr, nullptr}   // sentinel to mark end of array
-};
-
-#undef DOM4_MSG_DEF
-#undef DOM_MSG_DEF
-
 static void
 NSResultToNameAndMessage(nsresult aNSResult,
                          const char** aName,
                          const char** aMessage,
                          uint16_t* aCode)
 {
   *aName = nullptr;
   *aMessage = nullptr;
   *aCode = 0;
-  ResultStruct* result_struct = gDOMErrorMsgMap;
+
+#define DOM4_MSG_DEF(name, message, nsresult) {(nsresult), name, #name, message},
+#define DOM_MSG_DEF(val, message) {(val), NS_ERROR_GET_CODE(val), #val, message},
 
-  while (result_struct->mName) {
-    if (aNSResult == result_struct->mNSResult) {
-      *aName = result_struct->mName;
-      *aMessage = result_struct->mMessage;
-      *aCode = result_struct->mCode;
+  static const struct ResultStruct
+  {
+    nsresult mNSResult;
+    uint16_t mCode;
+    const char* mName;
+    const char* mMessage;
+  } sDOMErrorMsgMap[] = {
+#include "domerr.msg"
+  };
+
+#undef DOM4_MSG_DEF
+#undef DOM_MSG_DEF
+
+  for (uint32_t idx = 0; idx < ArrayLength(sDOMErrorMsgMap); idx++) {
+    if (aNSResult == sDOMErrorMsgMap[idx].mNSResult) {
+      *aName = sDOMErrorMsgMap[idx].mName;
+      *aMessage = sDOMErrorMsgMap[idx].mMessage;
+      *aCode = sDOMErrorMsgMap[idx].mCode;
       return;
     }
-
-    ++result_struct;
   }
 
   NS_WARNING("Huh, someone is throwing non-DOM errors using the DOM module!");
 
   return;
 }
 
 nsresult
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -80,18 +80,16 @@ NS_IMETHODIMP_(nsrefcnt) StartTransactio
 
 NS_IMETHODIMP_(nsrefcnt) StartTransactionRunnable::Release()
 {
   return 1;
 }
 
 NS_IMPL_QUERY_INTERFACE1(StartTransactionRunnable, nsIRunnable)
 
-StartTransactionRunnable gStartTransactionRunnable;
-
 } // anonymous namespace
 
 
 // static
 already_AddRefed<IDBTransaction>
 IDBTransaction::CreateInternal(IDBDatabase* aDatabase,
                                nsTArray<nsString>& aObjectStoreNames,
                                Mode aMode,
@@ -123,17 +121,18 @@ IDBTransaction::CreateInternal(IDBDataba
 
   if (IndexedDatabaseManager::IsMainProcess()) {
     transaction->mCachedStatements.Init();
 
     if (aMode != IDBTransaction::VERSION_CHANGE) {
       TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
       NS_ENSURE_TRUE(pool, nullptr);
 
-      pool->Dispatch(transaction, &gStartTransactionRunnable, false, nullptr);
+      static StartTransactionRunnable sStartTransactionRunnable;
+      pool->Dispatch(transaction, &sStartTransactionRunnable, false, nullptr);
     }
   }
   else if (!aIsVersionChangeTransactionChild) {
     IndexedDBDatabaseChild* dbActor = aDatabase->GetActorChild();
     NS_ASSERTION(dbActor, "Must have an actor here!");
 
     ipc::NormalTransactionParams params;
     params.names().AppendElements(aObjectStoreNames);
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -933,17 +933,17 @@ nsGeolocationService::StopDevice()
   mHigherAccuracy = false;
 
   mProvider->Shutdown();
   obs->NotifyObservers(mProvider,
                        "geolocation-device-events",
                        NS_LITERAL_STRING("shutdown").get());
 }
 
-nsRefPtr<nsGeolocationService> nsGeolocationService::sService;
+StaticRefPtr<nsGeolocationService> nsGeolocationService::sService;
 
 already_AddRefed<nsGeolocationService>
 nsGeolocationService::GetGeolocationService()
 {
   nsRefPtr<nsGeolocationService> result;
   if (nsGeolocationService::sService) {
     result = nsGeolocationService::sService;
     return result.forget();
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -4,16 +4,17 @@
 
 #ifndef nsGeoLocation_h
 #define nsGeoLocation_h
 
 #include "mozilla/dom/PContentPermissionRequestChild.h"
 // Microsoft's API Name hackery sucks
 #undef CreateEvent
 
+#include "mozilla/StaticPtr.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsITimer.h"
 #include "nsIObserver.h"
 #include "nsIURI.h"
 #include "nsWrapperCache.h"
@@ -107,17 +108,17 @@ class nsGeolocationRequest
 /**
  * Singleton that manages the geolocation provider
  */
 class nsGeolocationService MOZ_FINAL : public nsIGeolocationUpdate, public nsIObserver
 {
 public:
 
   static already_AddRefed<nsGeolocationService> GetGeolocationService();
-  static nsRefPtr<nsGeolocationService> sService;
+  static mozilla::StaticRefPtr<nsGeolocationService> sService;
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIGEOLOCATIONUPDATE
   NS_DECL_NSIOBSERVER
 
   nsGeolocationService() {
       mHigherAccuracy = false;
   }