зеркало из https://github.com/mozilla/pjs.git
Bug 554687 patch 1: Add Swap() method for nsSMILValue. r=roc
This commit is contained in:
Родитель
7193d8a001
Коммит
496a409aa7
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "nsSMILValue.h"
|
||||
#include "nsDebug.h"
|
||||
#include "prlog.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
@ -84,6 +85,29 @@ nsSMILValue::operator==(const nsSMILValue& aVal) const
|
|||
return mType == aVal.mType && mType->IsEqual(*this, aVal);
|
||||
}
|
||||
|
||||
static inline void
|
||||
CopyMemberData(nsSMILValue& aDest, const nsSMILValue& aSrc)
|
||||
{
|
||||
aDest.mType = aSrc.mType;
|
||||
aDest.mU.mUint = aSrc.mU.mUint;
|
||||
// Make sure the above assignments accounted for all the bits in nsSMILValue
|
||||
PR_STATIC_ASSERT(sizeof(aDest) ==
|
||||
sizeof(aDest.mType) + sizeof(aDest.mU.mUint));
|
||||
}
|
||||
|
||||
void
|
||||
nsSMILValue::Swap(nsSMILValue& aOther)
|
||||
{
|
||||
nsSMILValue tmp;
|
||||
CopyMemberData(tmp, aOther); // tmp = aOther
|
||||
CopyMemberData(aOther, *this); // aOther = this
|
||||
CopyMemberData(*this, tmp); // 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;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSMILValue::Add(const nsSMILValue& aValueToAdd, PRUint32 aCount)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
return (mType == &nsSMILNullType::sSingleton);
|
||||
}
|
||||
|
||||
// Swaps the contents (mU & mType) of two nsSMILValue objects.
|
||||
void Swap(nsSMILValue& aOther);
|
||||
nsresult Add(const nsSMILValue& aValueToAdd, PRUint32 aCount = 1);
|
||||
nsresult SandwichAdd(const nsSMILValue& aValueToAdd);
|
||||
nsresult ComputeDistance(const nsSMILValue& aTo, double& aDistance) const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче