зеркало из https://github.com/mozilla/gecko-dev.git
bug 877886 - get rid of a number of static constructors in content/ and dom/ r=smaug
This commit is contained in:
Родитель
0dc1f9fb7f
Коммит
2721f313e5
|
@ -122,10 +122,6 @@ 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;
|
||||
|
||||
|
@ -2708,12 +2704,14 @@ 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) {
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/*static*/ SMILBoolType SMILBoolType::sSingleton;
|
||||
|
||||
void
|
||||
SMILBoolType::Init(nsSMILValue& aValue) const
|
||||
{
|
||||
|
@ -25,7 +23,7 @@ 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
|
||||
|
|
|
@ -15,7 +15,11 @@ 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
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/*static*/ SMILEnumType SMILEnumType::sSingleton;
|
||||
|
||||
void
|
||||
SMILEnumType::Init(nsSMILValue& aValue) const
|
||||
{
|
||||
|
@ -25,7 +23,7 @@ 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
|
||||
|
|
|
@ -15,7 +15,12 @@ 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
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/*static*/ SMILIntegerType SMILIntegerType::sSingleton;
|
||||
|
||||
void
|
||||
SMILIntegerType::Init(nsSMILValue& aValue) const
|
||||
{
|
||||
|
@ -25,7 +23,7 @@ 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
|
||||
|
|
|
@ -29,7 +29,12 @@ public:
|
|||
double aUnitDistance,
|
||||
nsSMILValue& aResult) const MOZ_OVERRIDE;
|
||||
|
||||
static SMILIntegerType sSingleton;
|
||||
static SMILIntegerType*
|
||||
Singleton()
|
||||
{
|
||||
static SMILIntegerType sSingleton;
|
||||
return &sSingleton;
|
||||
}
|
||||
|
||||
private:
|
||||
SMILIntegerType() {}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/*static*/ SMILStringType SMILStringType::sSingleton;
|
||||
|
||||
void
|
||||
SMILStringType::Init(nsSMILValue& aValue) const
|
||||
{
|
||||
|
@ -26,7 +24,7 @@ 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
|
||||
|
|
|
@ -15,7 +15,12 @@ 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
|
||||
|
|
|
@ -151,7 +151,7 @@ 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
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include "nsDebug.h"
|
||||
#include <math.h>
|
||||
|
||||
/*static*/ nsSMILFloatType nsSMILFloatType::sSingleton;
|
||||
|
||||
void
|
||||
nsSMILFloatType::Init(nsSMILValue& aValue) const
|
||||
{
|
||||
|
@ -23,7 +21,7 @@ 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
|
||||
|
|
|
@ -13,7 +13,12 @@ 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
|
||||
|
|
|
@ -7,15 +7,13 @@
|
|||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,12 @@ 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
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// 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");
|
||||
|
@ -22,7 +22,7 @@ nsSMILValue::nsSMILValue(const nsISMILType* aType)
|
|||
}
|
||||
|
||||
nsSMILValue::nsSMILValue(const nsSMILValue& aVal)
|
||||
: mType(&nsSMILNullType::sSingleton)
|
||||
: mType(nsSMILNullType::Singleton())
|
||||
{
|
||||
InitAndCheckPostcondition(aVal.mType);
|
||||
mType->Assign(*this, aVal);
|
||||
|
@ -62,7 +62,7 @@ nsSMILValue::Swap(nsSMILValue& aOther)
|
|||
|
||||
// |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
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
class nsSMILValue
|
||||
{
|
||||
public:
|
||||
nsSMILValue() : mU(), mType(&nsSMILNullType::sSingleton) { }
|
||||
nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
|
||||
explicit nsSMILValue(const nsISMILType* aType);
|
||||
nsSMILValue(const nsSMILValue& aVal);
|
||||
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
bool IsNull() const
|
||||
{
|
||||
return (mType == &nsSMILNullType::sSingleton);
|
||||
return (mType == nsSMILNullType::Singleton());
|
||||
}
|
||||
|
||||
// Swaps the member data (mU & mPtr) of |this| with |aOther|
|
||||
|
|
|
@ -16,8 +16,14 @@
|
|||
|
||||
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)
|
||||
|
||||
|
@ -62,10 +68,10 @@ DOMSVGAnimatedLengthList::GetDOMWrapper(SVGAnimatedLengthList *aList,
|
|||
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();
|
||||
}
|
||||
|
@ -73,14 +79,14 @@ DOMSVGAnimatedLengthList::GetDOMWrapper(SVGAnimatedLengthList *aList,
|
|||
/* 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
|
||||
|
|
|
@ -16,8 +16,14 @@
|
|||
|
||||
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)
|
||||
|
||||
|
@ -61,10 +67,10 @@ DOMSVGAnimatedNumberList::GetDOMWrapper(SVGAnimatedNumberList *aList,
|
|||
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();
|
||||
}
|
||||
|
@ -72,14 +78,14 @@ DOMSVGAnimatedNumberList::GetDOMWrapper(SVGAnimatedNumberList *aList,
|
|||
/* 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
|
||||
|
|
|
@ -18,8 +18,14 @@
|
|||
|
||||
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
|
||||
|
@ -49,10 +55,10 @@ DOMSVGPathSegList::GetDOMWrapper(void *aList,
|
|||
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();
|
||||
}
|
||||
|
@ -60,7 +66,7 @@ DOMSVGPathSegList::GetDOMWrapper(void *aList,
|
|||
/* static */ DOMSVGPathSegList*
|
||||
DOMSVGPathSegList::GetDOMWrapperIfExists(void *aList)
|
||||
{
|
||||
return sSVGPathSegListTearoffTable.GetTearoff(aList);
|
||||
return SVGPathSegListTearoffTable().GetTearoff(aList);
|
||||
}
|
||||
|
||||
DOMSVGPathSegList::~DOMSVGPathSegList()
|
||||
|
@ -70,7 +76,7 @@ DOMSVGPathSegList::~DOMSVGPathSegList()
|
|||
void *key = mIsAnimValList ?
|
||||
InternalAList().GetAnimValKey() :
|
||||
InternalAList().GetBaseValKey();
|
||||
sSVGPathSegListTearoffTable.RemoveTearoff(key);
|
||||
SVGPathSegListTearoffTable().RemoveTearoff(key);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
@ -36,8 +36,14 @@ UpdateListIndicesFromIndex(FallibleTArray<mozilla::nsISVGPoint*>& aItemsArray,
|
|||
|
||||
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
|
||||
|
@ -67,10 +73,10 @@ DOMSVGPointList::GetDOMWrapper(void *aList,
|
|||
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();
|
||||
}
|
||||
|
@ -78,7 +84,7 @@ DOMSVGPointList::GetDOMWrapper(void *aList,
|
|||
/* static */ DOMSVGPointList*
|
||||
DOMSVGPointList::GetDOMWrapperIfExists(void *aList)
|
||||
{
|
||||
return sSVGPointListTearoffTable.GetTearoff(aList);
|
||||
return SVGPointListTearoffTable().GetTearoff(aList);
|
||||
}
|
||||
|
||||
DOMSVGPointList::~DOMSVGPointList()
|
||||
|
@ -88,7 +94,7 @@ DOMSVGPointList::~DOMSVGPointList()
|
|||
void *key = mIsAnimValList ?
|
||||
InternalAList().GetAnimValKey() :
|
||||
InternalAList().GetBaseValKey();
|
||||
sSVGPointListTearoffTable.RemoveTearoff(key);
|
||||
SVGPointListTearoffTable().RemoveTearoff(key);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
@ -18,8 +18,14 @@ 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)
|
||||
|
||||
|
@ -38,12 +44,12 @@ DOMSVGStringList::GetDOMWrapper(SVGStringList *aList,
|
|||
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();
|
||||
}
|
||||
|
@ -51,7 +57,7 @@ DOMSVGStringList::GetDOMWrapper(SVGStringList *aList,
|
|||
DOMSVGStringList::~DOMSVGStringList()
|
||||
{
|
||||
// Script no longer has any references to us.
|
||||
sSVGStringListTearoffTable.RemoveTearoff(&InternalList());
|
||||
SVGStringListTearoffTable().RemoveTearoff(&InternalList());
|
||||
}
|
||||
|
||||
/* virtual */ JSObject*
|
||||
|
|
|
@ -154,7 +154,7 @@ SVGAnimatedPathSegList::
|
|||
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)) {
|
||||
|
@ -173,7 +173,7 @@ SVGAnimatedPathSegList::SMILAnimatedPathSegList::GetBaseValue() const
|
|||
// 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)) {
|
||||
|
@ -186,9 +186,9 @@ SVGAnimatedPathSegList::SMILAnimatedPathSegList::GetBaseValue() const
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ SMILPreserveAspectRatio::ValueFromString(const nsAString& aStr,
|
|||
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;
|
||||
|
@ -331,7 +331,7 @@ SMILPreserveAspectRatio::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue
|
||||
SMILPreserveAspectRatio::GetBaseValue() const
|
||||
{
|
||||
nsSMILValue val(&SMILEnumType::sSingleton);
|
||||
nsSMILValue val(SMILEnumType::Singleton());
|
||||
val.mU.mUint = PackPreserveAspectRatio(mVal->GetBaseValue());
|
||||
return val;
|
||||
}
|
||||
|
@ -349,9 +349,9 @@ SMILPreserveAspectRatio::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/*static*/ SVGIntegerPairSMILType SVGIntegerPairSMILType::sSingleton;
|
||||
|
||||
void
|
||||
SVGIntegerPairSMILType::Init(nsSMILValue& aValue) const
|
||||
{
|
||||
|
@ -28,7 +26,7 @@ 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
|
||||
|
|
|
@ -17,7 +17,12 @@ 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
|
||||
|
|
|
@ -37,7 +37,7 @@ 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
|
||||
|
|
|
@ -179,7 +179,7 @@ SVGMotionSMILType::Destroy(nsSMILValue& aValue) const
|
|||
delete arr;
|
||||
|
||||
aValue.mU.mPtr = nullptr;
|
||||
aValue.mType = &nsSMILNullType::sSingleton;
|
||||
aValue.mType = nsSMILNullType::Singleton();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -50,7 +50,7 @@ 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
|
||||
|
|
|
@ -28,7 +28,7 @@ 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
|
||||
|
|
|
@ -30,7 +30,7 @@ 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
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/*static*/ SVGPathSegListSMILType SVGPathSegListSMILType::sSingleton;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISMILType implementation
|
||||
|
||||
|
@ -36,7 +34,7 @@ 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
|
||||
|
|
|
@ -22,7 +22,11 @@ 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
|
||||
|
|
|
@ -33,7 +33,7 @@ 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
|
||||
|
|
|
@ -16,7 +16,12 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
|
||||
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix>&
|
||||
SVGMatrixTearoffTable()
|
||||
{
|
||||
static nsSVGAttrTearoffTable<SVGTransform, SVGMatrix> sSVGMatrixTearoffTable;
|
||||
return sSVGMatrixTearoffTable;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@ -36,7 +41,7 @@ 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
|
||||
|
@ -104,9 +109,9 @@ SVGTransform::SVGTransform(const nsSVGTransform &aTransform)
|
|||
|
||||
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
|
||||
|
@ -127,10 +132,10 @@ 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;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
/*static*/ SVGTransformListSMILType SVGTransformListSMILType::sSingleton;
|
||||
|
||||
typedef FallibleTArray<SVGTransformSMILData> TransformArray;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -36,7 +34,7 @@ SVGTransformListSMILType::Destroy(nsSMILValue& aValue) const
|
|||
TransformArray* params = static_cast<TransformArray*>(aValue.mU.mPtr);
|
||||
delete params;
|
||||
aValue.mU.mPtr = nullptr;
|
||||
aValue.mType = &nsSMILNullType::sSingleton;
|
||||
aValue.mType = nsSMILNullType::Singleton();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -321,7 +319,7 @@ 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) ?
|
||||
|
@ -333,7 +331,7 @@ 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);
|
||||
|
||||
|
@ -353,7 +351,7 @@ 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);
|
||||
|
|
|
@ -81,7 +81,12 @@ 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
|
||||
|
|
|
@ -28,7 +28,7 @@ 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
|
||||
|
|
|
@ -225,7 +225,7 @@ nsSVGAnimatedTransformList::SMILAnimatedTransformList::ParseValue(
|
|||
return;
|
||||
}
|
||||
|
||||
nsSMILValue val(&SVGTransformListSMILType::sSingleton);
|
||||
nsSMILValue val(SVGTransformListSMILType::Singleton());
|
||||
SVGTransformSMILData transform(transformType, params);
|
||||
if (NS_FAILED(SVGTransformListSMILType::AppendTransform(transform, val))) {
|
||||
return; // OOM
|
||||
|
@ -292,7 +292,7 @@ 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();
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ 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,
|
||||
|
|
|
@ -15,8 +15,14 @@ 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,
|
||||
|
@ -108,10 +114,10 @@ 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();
|
||||
|
@ -119,7 +125,7 @@ nsSVGBoolean::ToDOMAnimatedBoolean(nsSVGElement* aSVGElement)
|
|||
|
||||
SVGAnimatedBoolean::~SVGAnimatedBoolean()
|
||||
{
|
||||
sSVGAnimatedBooleanTearoffTable.RemoveTearoff(mVal);
|
||||
SVGAnimatedBooleanTearoffTable().RemoveTearoff(mVal);
|
||||
}
|
||||
|
||||
nsISMILAttr*
|
||||
|
@ -140,7 +146,7 @@ nsSVGBoolean::SMILBool::ValueFromString(const nsAString& aStr,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsSMILValue val(&SMILBoolType::sSingleton);
|
||||
nsSMILValue val(SMILBoolType::Singleton());
|
||||
val.mU.mBool = value;
|
||||
aValue = val;
|
||||
aPreventCachingOfSandwich = false;
|
||||
|
@ -151,7 +157,7 @@ nsSVGBoolean::SMILBool::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue
|
||||
nsSVGBoolean::SMILBool::GetBaseValue() const
|
||||
{
|
||||
nsSMILValue val(&SMILBoolType::sSingleton);
|
||||
nsSMILValue val(SMILBoolType::Singleton());
|
||||
val.mU.mBool = mVal->mBaseVal;
|
||||
return val;
|
||||
}
|
||||
|
@ -169,9 +175,9 @@ nsSVGBoolean::SMILBool::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -92,7 +92,7 @@ nsSVGClass::SMILString::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue& aValue,
|
||||
bool& aPreventCachingOfSandwich) const
|
||||
{
|
||||
nsSMILValue val(&SMILStringType::sSingleton);
|
||||
nsSMILValue val(SMILStringType::Singleton());
|
||||
|
||||
*static_cast<nsAString*>(val.mU.mPtr) = aStr;
|
||||
aValue.Swap(val);
|
||||
|
@ -103,7 +103,7 @@ nsSVGClass::SMILString::ValueFromString(const nsAString& aStr,
|
|||
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;
|
||||
|
@ -121,9 +121,9 @@ nsSVGClass::SMILString::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -166,7 +166,7 @@ nsSVGEnum::SMILEnum::ValueFromString(const nsAString& aStr,
|
|||
|
||||
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;
|
||||
|
@ -184,7 +184,7 @@ nsSVGEnum::SMILEnum::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue
|
||||
nsSVGEnum::SMILEnum::GetBaseValue() const
|
||||
{
|
||||
nsSMILValue val(&SMILEnumType::sSingleton);
|
||||
nsSMILValue val(SMILEnumType::Singleton());
|
||||
val.mU.mUint = mVal->mBaseVal;
|
||||
return val;
|
||||
}
|
||||
|
@ -202,9 +202,9 @@ nsSVGEnum::SMILEnum::ClearAnimValue()
|
|||
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);
|
||||
|
|
|
@ -157,7 +157,7 @@ nsSVGInteger::SMILInteger::ValueFromString(const nsAString& aStr,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsSMILValue smilVal(&SMILIntegerType::sSingleton);
|
||||
nsSMILValue smilVal(SMILIntegerType::Singleton());
|
||||
smilVal.mU.mInt = val;
|
||||
aValue = smilVal;
|
||||
aPreventCachingOfSandwich = false;
|
||||
|
@ -167,7 +167,7 @@ nsSVGInteger::SMILInteger::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue
|
||||
nsSVGInteger::SMILInteger::GetBaseValue() const
|
||||
{
|
||||
nsSMILValue val(&SMILIntegerType::sSingleton);
|
||||
nsSMILValue val(SMILIntegerType::Singleton());
|
||||
val.mU.mInt = mVal->mBaseVal;
|
||||
return val;
|
||||
}
|
||||
|
@ -185,9 +185,9 @@ nsSVGInteger::SMILInteger::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -224,7 +224,7 @@ nsSVGIntegerPair::SMILIntegerPair::ValueFromString(const nsAString& aStr,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsSMILValue val(&SVGIntegerPairSMILType::sSingleton);
|
||||
nsSMILValue val(SVGIntegerPairSMILType::Singleton());
|
||||
val.mU.mIntPair[0] = values[0];
|
||||
val.mU.mIntPair[1] = values[1];
|
||||
aValue = val;
|
||||
|
@ -236,7 +236,7 @@ nsSVGIntegerPair::SMILIntegerPair::ValueFromString(const nsAString& aStr,
|
|||
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;
|
||||
|
@ -256,9 +256,9 @@ nsSVGIntegerPair::SMILIntegerPair::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -517,7 +517,7 @@ nsSVGLength2::SMILLength::ValueFromString(const nsAString& aStr,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsSMILValue val(&nsSMILFloatType::sSingleton);
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
val.mU.mDouble = value / mVal->GetUnitScaleFactor(mSVGElement, unitType);
|
||||
aValue = val;
|
||||
aPreventCachingOfSandwich =
|
||||
|
@ -531,7 +531,7 @@ nsSVGLength2::SMILLength::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue
|
||||
nsSVGLength2::SMILLength::GetBaseValue() const
|
||||
{
|
||||
nsSMILValue val(&nsSMILFloatType::sSingleton);
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
val.mU.mDouble = mVal->GetBaseValue(mSVGElement);
|
||||
return val;
|
||||
}
|
||||
|
@ -549,9 +549,9 @@ nsSVGLength2::SMILLength::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -197,7 +197,7 @@ nsSVGNumber2::SMILNumber::ValueFromString(const nsAString& aStr,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsSMILValue val(&nsSMILFloatType::sSingleton);
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
val.mU.mDouble = value;
|
||||
aValue = val;
|
||||
aPreventCachingOfSandwich = false;
|
||||
|
@ -208,7 +208,7 @@ nsSVGNumber2::SMILNumber::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue
|
||||
nsSVGNumber2::SMILNumber::GetBaseValue() const
|
||||
{
|
||||
nsSMILValue val(&nsSMILFloatType::sSingleton);
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
val.mU.mDouble = mVal->mBaseVal;
|
||||
return val;
|
||||
}
|
||||
|
@ -226,9 +226,9 @@ nsSVGNumber2::SMILNumber::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -23,8 +23,14 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGString::DOMAnimatedString)
|
|||
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 */
|
||||
|
||||
|
@ -84,10 +90,10 @@ 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();
|
||||
|
@ -95,7 +101,7 @@ nsSVGString::ToDOMAnimatedString(nsSVGElement* aSVGElement)
|
|||
|
||||
nsSVGString::DOMAnimatedString::~DOMAnimatedString()
|
||||
{
|
||||
sSVGAnimatedStringTearoffTable.RemoveTearoff(mVal);
|
||||
SVGAnimatedStringTearoffTable().RemoveTearoff(mVal);
|
||||
}
|
||||
|
||||
nsISMILAttr*
|
||||
|
@ -110,7 +116,7 @@ nsSVGString::SMILString::ValueFromString(const nsAString& aStr,
|
|||
nsSMILValue& aValue,
|
||||
bool& aPreventCachingOfSandwich) const
|
||||
{
|
||||
nsSMILValue val(&SMILStringType::sSingleton);
|
||||
nsSMILValue val(SMILStringType::Singleton());
|
||||
|
||||
*static_cast<nsAString*>(val.mU.mPtr) = aStr;
|
||||
aValue.Swap(val);
|
||||
|
@ -121,7 +127,7 @@ nsSVGString::SMILString::ValueFromString(const nsAString& aStr,
|
|||
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;
|
||||
}
|
||||
|
@ -138,9 +144,9 @@ nsSVGString::SMILString::ClearAnimValue()
|
|||
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;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#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,
|
||||
|
@ -60,23 +62,6 @@ enum DOM4ErrorTypeCodeMap {
|
|||
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,
|
||||
|
@ -86,17 +71,30 @@ NSResultToNameAndMessage(nsresult aNSResult,
|
|||
*aName = nullptr;
|
||||
*aMessage = nullptr;
|
||||
*aCode = 0;
|
||||
ResultStruct* result_struct = gDOMErrorMsgMap;
|
||||
|
||||
while (result_struct->mName) {
|
||||
if (aNSResult == result_struct->mNSResult) {
|
||||
*aName = result_struct->mName;
|
||||
*aMessage = result_struct->mMessage;
|
||||
*aCode = result_struct->mCode;
|
||||
#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 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!");
|
||||
|
|
|
@ -85,8 +85,6 @@ NS_IMETHODIMP_(nsrefcnt) StartTransactionRunnable::Release()
|
|||
|
||||
NS_IMPL_QUERY_INTERFACE1(StartTransactionRunnable, nsIRunnable)
|
||||
|
||||
StartTransactionRunnable gStartTransactionRunnable;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
|
@ -128,7 +126,8 @@ IDBTransaction::CreateInternal(IDBDatabase* aDatabase,
|
|||
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) {
|
||||
|
|
|
@ -938,7 +938,7 @@ nsGeolocationService::StopDevice()
|
|||
NS_LITERAL_STRING("shutdown").get());
|
||||
}
|
||||
|
||||
nsRefPtr<nsGeolocationService> nsGeolocationService::sService;
|
||||
StaticRefPtr<nsGeolocationService> nsGeolocationService::sService;
|
||||
|
||||
already_AddRefed<nsGeolocationService>
|
||||
nsGeolocationService::GetGeolocationService()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// Microsoft's API Name hackery sucks
|
||||
#undef CreateEvent
|
||||
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
@ -112,7 +113,7 @@ class nsGeolocationService MOZ_FINAL : public nsIGeolocationUpdate, public nsIOb
|
|||
public:
|
||||
|
||||
static already_AddRefed<nsGeolocationService> GetGeolocationService();
|
||||
static nsRefPtr<nsGeolocationService> sService;
|
||||
static mozilla::StaticRefPtr<nsGeolocationService> sService;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGEOLOCATIONUPDATE
|
||||
|
|
Загрузка…
Ссылка в новой задаче