Bug 1198708 - Part 5: Add method to serialize a ComputedTimingFunction. r=birtles

This commit is contained in:
Cameron McCormack 2015-09-29 12:20:14 +10:00
Родитель e441526821
Коммит 45eb434b3e
2 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -10,6 +10,7 @@
#include "AnimationCommon.h"
#include "nsCSSPropertySet.h"
#include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
#include "nsStyleUtil.h"
namespace mozilla {
@ -53,6 +54,28 @@ ComputedTimingFunction::GetValue(double aPortion) const
return StepEnd(mSteps, aPortion);
}
void
ComputedTimingFunction::AppendToString(nsAString& aResult) const
{
switch (mType) {
case nsTimingFunction::Type::CubicBezier:
nsStyleUtil::AppendCubicBezierTimingFunction(mTimingFunction.X1(),
mTimingFunction.Y1(),
mTimingFunction.X2(),
mTimingFunction.Y2(),
aResult);
break;
case nsTimingFunction::Type::StepStart:
case nsTimingFunction::Type::StepEnd:
nsStyleUtil::AppendStepsTimingFunction(mType, mSteps, mStepSyntax,
aResult);
break;
default:
nsStyleUtil::AppendCubicBezierKeywordTimingFunction(mType, aResult);
break;
}
}
// In the Web Animations model, the iteration progress can be outside the range
// [0.0, 1.0] but it shouldn't be Infinity.
const double ComputedTiming::kNullProgress = PositiveInfinity<double>();

Просмотреть файл

@ -130,6 +130,7 @@ public:
bool operator!=(const ComputedTimingFunction& aOther) const {
return !(*this == aOther);
}
void AppendToString(nsAString& aResult) const;
private:
Type mType;