mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 1516175 - Move nsSMILFloatType into the mozilla namespace r=birtles
--HG-- rename : dom/smil/nsSMILFloatType.cpp => dom/smil/SMILFloatType.cpp rename : dom/smil/nsSMILFloatType.h => dom/smil/SMILFloatType.h
This commit is contained in:
parent
aff4f71c95
commit
0d9759945e
@ -4,51 +4,52 @@
|
||||
* 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 "SMILFloatType.h"
|
||||
#include "nsSMILValue.h"
|
||||
#include "nsDebug.h"
|
||||
#include <math.h>
|
||||
|
||||
void nsSMILFloatType::Init(nsSMILValue& aValue) const {
|
||||
namespace mozilla {
|
||||
|
||||
void SMILFloatType::Init(nsSMILValue& aValue) const {
|
||||
MOZ_ASSERT(aValue.IsNull(), "Unexpected value type");
|
||||
aValue.mU.mDouble = 0.0;
|
||||
aValue.mType = this;
|
||||
}
|
||||
|
||||
void nsSMILFloatType::Destroy(nsSMILValue& aValue) const {
|
||||
void SMILFloatType::Destroy(nsSMILValue& aValue) const {
|
||||
MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value");
|
||||
aValue.mU.mDouble = 0.0;
|
||||
aValue.mType = nsSMILNullType::Singleton();
|
||||
}
|
||||
|
||||
nsresult nsSMILFloatType::Assign(nsSMILValue& aDest,
|
||||
const nsSMILValue& aSrc) const {
|
||||
nsresult SMILFloatType::Assign(nsSMILValue& aDest,
|
||||
const nsSMILValue& aSrc) const {
|
||||
MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
|
||||
MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value");
|
||||
aDest.mU.mDouble = aSrc.mU.mDouble;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsSMILFloatType::IsEqual(const nsSMILValue& aLeft,
|
||||
const nsSMILValue& aRight) const {
|
||||
bool SMILFloatType::IsEqual(const nsSMILValue& aLeft,
|
||||
const nsSMILValue& aRight) const {
|
||||
MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types");
|
||||
MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value");
|
||||
|
||||
return aLeft.mU.mDouble == aRight.mU.mDouble;
|
||||
}
|
||||
|
||||
nsresult nsSMILFloatType::Add(nsSMILValue& aDest,
|
||||
const nsSMILValue& aValueToAdd,
|
||||
uint32_t aCount) const {
|
||||
nsresult SMILFloatType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
|
||||
uint32_t aCount) const {
|
||||
MOZ_ASSERT(aValueToAdd.mType == aDest.mType, "Trying to add invalid types");
|
||||
MOZ_ASSERT(aValueToAdd.mType == this, "Unexpected source type");
|
||||
aDest.mU.mDouble += aValueToAdd.mU.mDouble * aCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsSMILFloatType::ComputeDistance(const nsSMILValue& aFrom,
|
||||
const nsSMILValue& aTo,
|
||||
double& aDistance) const {
|
||||
nsresult SMILFloatType::ComputeDistance(const nsSMILValue& aFrom,
|
||||
const nsSMILValue& aTo,
|
||||
double& aDistance) const {
|
||||
MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types");
|
||||
MOZ_ASSERT(aFrom.mType == this, "Unexpected source type");
|
||||
|
||||
@ -60,10 +61,10 @@ nsresult nsSMILFloatType::ComputeDistance(const nsSMILValue& aFrom,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsSMILFloatType::Interpolate(const nsSMILValue& aStartVal,
|
||||
const nsSMILValue& aEndVal,
|
||||
double aUnitDistance,
|
||||
nsSMILValue& aResult) const {
|
||||
nsresult SMILFloatType::Interpolate(const nsSMILValue& aStartVal,
|
||||
const nsSMILValue& aEndVal,
|
||||
double aUnitDistance,
|
||||
nsSMILValue& aResult) const {
|
||||
MOZ_ASSERT(aStartVal.mType == aEndVal.mType,
|
||||
"Trying to interpolate different types");
|
||||
MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation");
|
||||
@ -76,3 +77,5 @@ nsresult nsSMILFloatType::Interpolate(const nsSMILValue& aStartVal,
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
@ -10,11 +10,13 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsISMILType.h"
|
||||
|
||||
class nsSMILFloatType : public nsISMILType {
|
||||
namespace mozilla {
|
||||
|
||||
class SMILFloatType : public nsISMILType {
|
||||
public:
|
||||
// Singleton for nsSMILValue objects to hold onto.
|
||||
static nsSMILFloatType* Singleton() {
|
||||
static nsSMILFloatType sSingleton;
|
||||
static SMILFloatType* Singleton() {
|
||||
static SMILFloatType sSingleton;
|
||||
return &sSingleton;
|
||||
}
|
||||
|
||||
@ -38,7 +40,9 @@ class nsSMILFloatType : public nsISMILType {
|
||||
|
||||
private:
|
||||
// Private constructor: prevent instances beyond my singleton.
|
||||
constexpr nsSMILFloatType() {}
|
||||
constexpr SMILFloatType() {}
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // NS_SMILFLOATTYPE_H_
|
@ -44,7 +44,6 @@ UNIFIED_SOURCES += [
|
||||
'nsSMILCompositor.cpp',
|
||||
'nsSMILCSSProperty.cpp',
|
||||
'nsSMILCSSValueType.cpp',
|
||||
'nsSMILFloatType.cpp',
|
||||
'nsSMILInstanceTime.cpp',
|
||||
'nsSMILInterval.cpp',
|
||||
'nsSMILKeySpline.cpp',
|
||||
@ -59,6 +58,7 @@ UNIFIED_SOURCES += [
|
||||
'nsSMILValue.cpp',
|
||||
'SMILBoolType.cpp',
|
||||
'SMILEnumType.cpp',
|
||||
'SMILFloatType.cpp',
|
||||
'SMILIntegerType.cpp',
|
||||
'SMILStringType.cpp',
|
||||
'TimeEvent.cpp',
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mozilla/dom/SVGViewportElement.h"
|
||||
#include "nsContentUtils.h" // NS_ENSURE_FINITE
|
||||
#include "nsIFrame.h"
|
||||
#include "nsSMILFloatType.h"
|
||||
#include "SMILFloatType.h"
|
||||
#include "nsSMILValue.h"
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include "nsSVGIntegrationUtils.h"
|
||||
@ -436,7 +436,7 @@ nsresult nsSVGLength2::SMILLength::ValueFromString(
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
nsSMILValue val(SMILFloatType::Singleton());
|
||||
val.mU.mDouble = value * mVal->GetPixelsPerUnit(mSVGElement, unitType);
|
||||
aValue = val;
|
||||
aPreventCachingOfSandwich =
|
||||
@ -448,7 +448,7 @@ nsresult nsSVGLength2::SMILLength::ValueFromString(
|
||||
}
|
||||
|
||||
nsSMILValue nsSVGLength2::SMILLength::GetBaseValue() const {
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
nsSMILValue val(SMILFloatType::Singleton());
|
||||
val.mU.mDouble = mVal->GetBaseValue(mSVGElement);
|
||||
return val;
|
||||
}
|
||||
@ -462,9 +462,9 @@ void nsSVGLength2::SMILLength::ClearAnimValue() {
|
||||
}
|
||||
|
||||
nsresult nsSVGLength2::SMILLength::SetAnimValue(const nsSMILValue& aValue) {
|
||||
NS_ASSERTION(aValue.mType == nsSMILFloatType::Singleton(),
|
||||
NS_ASSERTION(aValue.mType == SMILFloatType::Singleton(),
|
||||
"Unexpected type to assign animated value");
|
||||
if (aValue.mType == nsSMILFloatType::Singleton()) {
|
||||
if (aValue.mType == SMILFloatType::Singleton()) {
|
||||
return mVal->SetAnimValue(float(aValue.mU.mDouble), mSVGElement);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "nsSVGNumber2.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsContentUtils.h" // NS_ENSURE_FINITE
|
||||
#include "nsSMILFloatType.h"
|
||||
#include "SMILFloatType.h"
|
||||
#include "nsSMILValue.h"
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include "SVGContentUtils.h"
|
||||
@ -126,7 +126,7 @@ nsresult nsSVGNumber2::SMILNumber::ValueFromString(
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
nsSMILValue val(SMILFloatType::Singleton());
|
||||
val.mU.mDouble = value;
|
||||
aValue = val;
|
||||
aPreventCachingOfSandwich = false;
|
||||
@ -135,7 +135,7 @@ nsresult nsSVGNumber2::SMILNumber::ValueFromString(
|
||||
}
|
||||
|
||||
nsSMILValue nsSVGNumber2::SMILNumber::GetBaseValue() const {
|
||||
nsSMILValue val(nsSMILFloatType::Singleton());
|
||||
nsSMILValue val(SMILFloatType::Singleton());
|
||||
val.mU.mDouble = mVal->mBaseVal;
|
||||
return val;
|
||||
}
|
||||
@ -149,9 +149,9 @@ void nsSVGNumber2::SMILNumber::ClearAnimValue() {
|
||||
}
|
||||
|
||||
nsresult nsSVGNumber2::SMILNumber::SetAnimValue(const nsSMILValue& aValue) {
|
||||
NS_ASSERTION(aValue.mType == nsSMILFloatType::Singleton(),
|
||||
NS_ASSERTION(aValue.mType == SMILFloatType::Singleton(),
|
||||
"Unexpected type to assign animated value");
|
||||
if (aValue.mType == nsSMILFloatType::Singleton()) {
|
||||
if (aValue.mType == SMILFloatType::Singleton()) {
|
||||
mVal->SetAnimValue(float(aValue.mU.mDouble), mSVGElement);
|
||||
}
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user