Bug 1010067 part 1 - Rename nsStyleAnimation::Value to mozilla::StyleAnimationValue; r=dbaron

This patch also moves the static methods defined on nsStyleAnimation so that
they are part of StyleAnimationValue class.

Renaming nsStyleAnimation.h to StyleAnimationValue.h is performed in a separate
patch to simplify the diff (since some tools may not handle file renames
elegantly).
This commit is contained in:
Brian Birtles 2014-06-24 15:29:54 +09:00
parent c171a38d22
commit 9fe1178360
19 changed files with 464 additions and 429 deletions

View File

@ -2514,20 +2514,20 @@ static bool
ComputeAnimationValue(nsCSSProperty aProperty, ComputeAnimationValue(nsCSSProperty aProperty,
Element* aElement, Element* aElement,
const nsAString& aInput, const nsAString& aInput,
nsStyleAnimation::Value& aOutput) StyleAnimationValue& aOutput)
{ {
if (!nsStyleAnimation::ComputeValue(aProperty, aElement, aInput, if (!StyleAnimationValue::ComputeValue(aProperty, aElement, aInput,
false, aOutput)) { false, aOutput)) {
return false; return false;
} }
// This matches TransExtractComputedValue in nsTransitionManager.cpp. // This matches TransExtractComputedValue in nsTransitionManager.cpp.
if (aProperty == eCSSProperty_visibility) { if (aProperty == eCSSProperty_visibility) {
NS_ABORT_IF_FALSE(aOutput.GetUnit() == nsStyleAnimation::eUnit_Enumerated, MOZ_ASSERT(aOutput.GetUnit() == StyleAnimationValue::eUnit_Enumerated,
"unexpected unit"); "unexpected unit");
aOutput.SetIntValue(aOutput.GetIntValue(), aOutput.SetIntValue(aOutput.GetIntValue(),
nsStyleAnimation::eUnit_Visibility); StyleAnimationValue::eUnit_Visibility);
} }
return true; return true;
@ -2660,14 +2660,14 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement,
!nsCSSProps::IsShorthand(property), !nsCSSProps::IsShorthand(property),
"should not have shorthand"); "should not have shorthand");
nsStyleAnimation::Value v1, v2; StyleAnimationValue v1, v2;
if (property == eCSSProperty_UNKNOWN || if (property == eCSSProperty_UNKNOWN ||
!ComputeAnimationValue(property, content->AsElement(), aValue1, v1) || !ComputeAnimationValue(property, content->AsElement(), aValue1, v1) ||
!ComputeAnimationValue(property, content->AsElement(), aValue2, v2)) { !ComputeAnimationValue(property, content->AsElement(), aValue2, v2)) {
return NS_ERROR_ILLEGAL_VALUE; return NS_ERROR_ILLEGAL_VALUE;
} }
if (!nsStyleAnimation::ComputeDistance(property, v1, v2, *aResult)) { if (!StyleAnimationValue::ComputeDistance(property, v1, v2, *aResult)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@ -1385,10 +1385,10 @@ interface nsIDOMWindowUtils : nsISupports {
void setAsyncScrollOffset(in nsIDOMNode aNode, in int32_t aX, in int32_t aY); void setAsyncScrollOffset(in nsIDOMNode aNode, in int32_t aX, in int32_t aY);
/** /**
* Method for testing nsStyleAnimation::ComputeDistance. * Method for testing StyleAnimationValue::ComputeDistance.
* *
* Returns the distance between the two values as reported by * Returns the distance between the two values as reported by
* nsStyleAnimation::ComputeDistance for the given element and * StyleAnimationValue::ComputeDistance for the given element and
* property. * property.
*/ */
double computeAnimationDistance(in nsIDOMElement element, double computeAnimationDistance(in nsIDOMElement element,

View File

@ -19,41 +19,42 @@
#include "nsIDocument.h" #include "nsIDocument.h"
using namespace mozilla::dom; using namespace mozilla::dom;
using mozilla::StyleAnimationValue;
/*static*/ nsSMILCSSValueType nsSMILCSSValueType::sSingleton; /*static*/ nsSMILCSSValueType nsSMILCSSValueType::sSingleton;
struct ValueWrapper { struct ValueWrapper {
ValueWrapper(nsCSSProperty aPropID, const nsStyleAnimation::Value& aValue) : ValueWrapper(nsCSSProperty aPropID, const StyleAnimationValue& aValue) :
mPropID(aPropID), mCSSValue(aValue) {} mPropID(aPropID), mCSSValue(aValue) {}
nsCSSProperty mPropID; nsCSSProperty mPropID;
nsStyleAnimation::Value mCSSValue; StyleAnimationValue mCSSValue;
}; };
// Helper Methods // Helper Methods
// -------------- // --------------
static const nsStyleAnimation::Value* static const StyleAnimationValue*
GetZeroValueForUnit(nsStyleAnimation::Unit aUnit) GetZeroValueForUnit(StyleAnimationValue::Unit aUnit)
{ {
static const nsStyleAnimation::Value static const StyleAnimationValue
sZeroCoord(0, nsStyleAnimation::Value::CoordConstructor); sZeroCoord(0, StyleAnimationValue::CoordConstructor);
static const nsStyleAnimation::Value static const StyleAnimationValue
sZeroPercent(0.0f, nsStyleAnimation::Value::PercentConstructor); sZeroPercent(0.0f, StyleAnimationValue::PercentConstructor);
static const nsStyleAnimation::Value static const StyleAnimationValue
sZeroFloat(0.0f, nsStyleAnimation::Value::FloatConstructor); sZeroFloat(0.0f, StyleAnimationValue::FloatConstructor);
static const nsStyleAnimation::Value static const StyleAnimationValue
sZeroColor(NS_RGB(0,0,0), nsStyleAnimation::Value::ColorConstructor); sZeroColor(NS_RGB(0,0,0), StyleAnimationValue::ColorConstructor);
NS_ABORT_IF_FALSE(aUnit != nsStyleAnimation::eUnit_Null, NS_ABORT_IF_FALSE(aUnit != StyleAnimationValue::eUnit_Null,
"Need non-null unit for a zero value"); "Need non-null unit for a zero value");
switch (aUnit) { switch (aUnit) {
case nsStyleAnimation::eUnit_Coord: case StyleAnimationValue::eUnit_Coord:
return &sZeroCoord; return &sZeroCoord;
case nsStyleAnimation::eUnit_Percent: case StyleAnimationValue::eUnit_Percent:
return &sZeroPercent; return &sZeroPercent;
case nsStyleAnimation::eUnit_Float: case StyleAnimationValue::eUnit_Float:
return &sZeroFloat; return &sZeroFloat;
case nsStyleAnimation::eUnit_Color: case StyleAnimationValue::eUnit_Color:
return &sZeroColor; return &sZeroColor;
default: default:
return nullptr; return nullptr;
@ -71,8 +72,8 @@ GetZeroValueForUnit(nsStyleAnimation::Unit aUnit)
// //
// Returns true on success, or false. // Returns true on success, or false.
static const bool static const bool
FinalizeStyleAnimationValues(const nsStyleAnimation::Value*& aValue1, FinalizeStyleAnimationValues(const StyleAnimationValue*& aValue1,
const nsStyleAnimation::Value*& aValue2) const StyleAnimationValue*& aValue2)
{ {
NS_ABORT_IF_FALSE(aValue1 || aValue2, NS_ABORT_IF_FALSE(aValue1 || aValue2,
"expecting at least one non-null value"); "expecting at least one non-null value");
@ -90,32 +91,32 @@ FinalizeStyleAnimationValues(const nsStyleAnimation::Value*& aValue1,
// Ok, both values were specified. // Ok, both values were specified.
// Need to handle a special-case, though: unitless nonzero length (parsed as // Need to handle a special-case, though: unitless nonzero length (parsed as
// eUnit_Float) mixed with unitless 0 length (parsed as eUnit_Coord). These // eUnit_Float) mixed with unitless 0 length (parsed as eUnit_Coord). These
// won't interoperate in nsStyleAnimation, since their Units don't match. // won't interoperate in StyleAnimationValue, since their Units don't match.
// In this case, we replace the eUnit_Coord 0 value with eUnit_Float 0 value. // In this case, we replace the eUnit_Coord 0 value with eUnit_Float 0 value.
const nsStyleAnimation::Value& zeroCoord = const StyleAnimationValue& zeroCoord =
*GetZeroValueForUnit(nsStyleAnimation::eUnit_Coord); *GetZeroValueForUnit(StyleAnimationValue::eUnit_Coord);
if (*aValue1 == zeroCoord && if (*aValue1 == zeroCoord &&
aValue2->GetUnit() == nsStyleAnimation::eUnit_Float) { aValue2->GetUnit() == StyleAnimationValue::eUnit_Float) {
aValue1 = GetZeroValueForUnit(nsStyleAnimation::eUnit_Float); aValue1 = GetZeroValueForUnit(StyleAnimationValue::eUnit_Float);
} else if (*aValue2 == zeroCoord && } else if (*aValue2 == zeroCoord &&
aValue1->GetUnit() == nsStyleAnimation::eUnit_Float) { aValue1->GetUnit() == StyleAnimationValue::eUnit_Float) {
aValue2 = GetZeroValueForUnit(nsStyleAnimation::eUnit_Float); aValue2 = GetZeroValueForUnit(StyleAnimationValue::eUnit_Float);
} }
return true; return true;
} }
static void static void
InvertSign(nsStyleAnimation::Value& aValue) InvertSign(StyleAnimationValue& aValue)
{ {
switch (aValue.GetUnit()) { switch (aValue.GetUnit()) {
case nsStyleAnimation::eUnit_Coord: case StyleAnimationValue::eUnit_Coord:
aValue.SetCoordValue(-aValue.GetCoordValue()); aValue.SetCoordValue(-aValue.GetCoordValue());
break; break;
case nsStyleAnimation::eUnit_Percent: case StyleAnimationValue::eUnit_Percent:
aValue.SetPercentValue(-aValue.GetPercentValue()); aValue.SetPercentValue(-aValue.GetPercentValue());
break; break;
case nsStyleAnimation::eUnit_Float: case StyleAnimationValue::eUnit_Float:
aValue.SetFloatValue(-aValue.GetFloatValue()); aValue.SetFloatValue(-aValue.GetFloatValue());
break; break;
default: default:
@ -224,15 +225,15 @@ nsSMILCSSValueType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
nsCSSProperty property = (valueToAddWrapper ? valueToAddWrapper->mPropID : nsCSSProperty property = (valueToAddWrapper ? valueToAddWrapper->mPropID :
destWrapper->mPropID); destWrapper->mPropID);
// Special case: font-size-adjust and stroke-dasharray are explicitly // Special case: font-size-adjust and stroke-dasharray are explicitly
// non-additive (even though nsStyleAnimation *could* support adding them) // non-additive (even though StyleAnimationValue *could* support adding them)
if (property == eCSSProperty_font_size_adjust || if (property == eCSSProperty_font_size_adjust ||
property == eCSSProperty_stroke_dasharray) { property == eCSSProperty_stroke_dasharray) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
const nsStyleAnimation::Value* valueToAdd = valueToAddWrapper ? const StyleAnimationValue* valueToAdd = valueToAddWrapper ?
&valueToAddWrapper->mCSSValue : nullptr; &valueToAddWrapper->mCSSValue : nullptr;
const nsStyleAnimation::Value* destValue = destWrapper ? const StyleAnimationValue* destValue = destWrapper ?
&destWrapper->mCSSValue : nullptr; &destWrapper->mCSSValue : nullptr;
if (!FinalizeStyleAnimationValues(valueToAdd, destValue)) { if (!FinalizeStyleAnimationValues(valueToAdd, destValue)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -249,7 +250,7 @@ nsSMILCSSValueType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
new ValueWrapper(property, *destValue); new ValueWrapper(property, *destValue);
} }
return nsStyleAnimation::Add(property, return StyleAnimationValue::Add(property,
destWrapper->mCSSValue, *valueToAdd, aCount) ? destWrapper->mCSSValue, *valueToAdd, aCount) ?
NS_OK : NS_ERROR_FAILURE; NS_OK : NS_ERROR_FAILURE;
} }
@ -267,14 +268,14 @@ nsSMILCSSValueType::ComputeDistance(const nsSMILValue& aFrom,
const ValueWrapper* toWrapper = ExtractValueWrapper(aTo); const ValueWrapper* toWrapper = ExtractValueWrapper(aTo);
NS_ABORT_IF_FALSE(toWrapper, "expecting non-null endpoint"); NS_ABORT_IF_FALSE(toWrapper, "expecting non-null endpoint");
const nsStyleAnimation::Value* fromCSSValue = fromWrapper ? const StyleAnimationValue* fromCSSValue = fromWrapper ?
&fromWrapper->mCSSValue : nullptr; &fromWrapper->mCSSValue : nullptr;
const nsStyleAnimation::Value* toCSSValue = &toWrapper->mCSSValue; const StyleAnimationValue* toCSSValue = &toWrapper->mCSSValue;
if (!FinalizeStyleAnimationValues(fromCSSValue, toCSSValue)) { if (!FinalizeStyleAnimationValues(fromCSSValue, toCSSValue)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
return nsStyleAnimation::ComputeDistance(toWrapper->mPropID, return StyleAnimationValue::ComputeDistance(toWrapper->mPropID,
*fromCSSValue, *toCSSValue, *fromCSSValue, *toCSSValue,
aDistance) ? aDistance) ?
NS_OK : NS_ERROR_FAILURE; NS_OK : NS_ERROR_FAILURE;
@ -299,15 +300,15 @@ nsSMILCSSValueType::Interpolate(const nsSMILValue& aStartVal,
const ValueWrapper* endWrapper = ExtractValueWrapper(aEndVal); const ValueWrapper* endWrapper = ExtractValueWrapper(aEndVal);
NS_ABORT_IF_FALSE(endWrapper, "expecting non-null endpoint"); NS_ABORT_IF_FALSE(endWrapper, "expecting non-null endpoint");
const nsStyleAnimation::Value* startCSSValue = startWrapper ? const StyleAnimationValue* startCSSValue = startWrapper ?
&startWrapper->mCSSValue : nullptr; &startWrapper->mCSSValue : nullptr;
const nsStyleAnimation::Value* endCSSValue = &endWrapper->mCSSValue; const StyleAnimationValue* endCSSValue = &endWrapper->mCSSValue;
if (!FinalizeStyleAnimationValues(startCSSValue, endCSSValue)) { if (!FinalizeStyleAnimationValues(startCSSValue, endCSSValue)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsStyleAnimation::Value resultValue; StyleAnimationValue resultValue;
if (nsStyleAnimation::Interpolate(endWrapper->mPropID, if (StyleAnimationValue::Interpolate(endWrapper->mPropID,
*startCSSValue, *endCSSValue, *startCSSValue, *endCSSValue,
aUnitDistance, resultValue)) { aUnitDistance, resultValue)) {
aResult.mU.mPtr = new ValueWrapper(endWrapper->mPropID, resultValue); aResult.mU.mPtr = new ValueWrapper(endWrapper->mPropID, resultValue);
@ -331,13 +332,13 @@ GetPresContextForElement(Element* aElem)
return shell ? shell->GetPresContext() : nullptr; return shell ? shell->GetPresContext() : nullptr;
} }
// Helper function to parse a string into a nsStyleAnimation::Value // Helper function to parse a string into a StyleAnimationValue
static bool static bool
ValueFromStringHelper(nsCSSProperty aPropID, ValueFromStringHelper(nsCSSProperty aPropID,
Element* aTargetElement, Element* aTargetElement,
nsPresContext* aPresContext, nsPresContext* aPresContext,
const nsAString& aString, const nsAString& aString,
nsStyleAnimation::Value& aStyleAnimValue, StyleAnimationValue& aStyleAnimValue,
bool* aIsContextSensitive) bool* aIsContextSensitive)
{ {
// If value is negative, we'll strip off the "-" so the CSS parser won't // If value is negative, we'll strip off the "-" so the CSS parser won't
@ -358,7 +359,7 @@ ValueFromStringHelper(nsCSSProperty aPropID,
} }
} }
nsDependentSubstring subString(aString, subStringBegin); nsDependentSubstring subString(aString, subStringBegin);
if (!nsStyleAnimation::ComputeValue(aPropID, aTargetElement, subString, if (!StyleAnimationValue::ComputeValue(aPropID, aTargetElement, subString,
true, aStyleAnimValue, true, aStyleAnimValue,
aIsContextSensitive)) { aIsContextSensitive)) {
return false; return false;
@ -370,7 +371,7 @@ ValueFromStringHelper(nsCSSProperty aPropID,
if (aPropID == eCSSProperty_font_size) { if (aPropID == eCSSProperty_font_size) {
// Divide out text-zoom, since SVG is supposed to ignore it // Divide out text-zoom, since SVG is supposed to ignore it
NS_ABORT_IF_FALSE(aStyleAnimValue.GetUnit() == NS_ABORT_IF_FALSE(aStyleAnimValue.GetUnit() ==
nsStyleAnimation::eUnit_Coord, StyleAnimationValue::eUnit_Coord,
"'font-size' value with unexpected style unit"); "'font-size' value with unexpected style unit");
aStyleAnimValue.SetCoordValue(aStyleAnimValue.GetCoordValue() / aStyleAnimValue.SetCoordValue(aStyleAnimValue.GetCoordValue() /
aPresContext->TextZoom()); aPresContext->TextZoom());
@ -401,7 +402,7 @@ nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID,
return; return;
} }
nsStyleAnimation::Value parsedValue; StyleAnimationValue parsedValue;
if (ValueFromStringHelper(aPropID, aTargetElement, presContext, if (ValueFromStringHelper(aPropID, aTargetElement, presContext,
aString, parsedValue, aIsContextSensitive)) { aString, parsedValue, aIsContextSensitive)) {
sSingleton.Init(aValue); sSingleton.Init(aValue);
@ -418,6 +419,6 @@ nsSMILCSSValueType::ValueToString(const nsSMILValue& aValue,
"Unexpected SMIL value type"); "Unexpected SMIL value type");
const ValueWrapper* wrapper = ExtractValueWrapper(aValue); const ValueWrapper* wrapper = ExtractValueWrapper(aValue);
return !wrapper || return !wrapper ||
nsStyleAnimation::UncomputeValue(wrapper->mPropID, StyleAnimationValue::UncomputeValue(wrapper->mPropID,
wrapper->mCSSValue, aString); wrapper->mCSSValue, aString);
} }

View File

@ -247,28 +247,32 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
case TransformFunction::TRotationX: case TransformFunction::TRotationX:
{ {
float theta = aFunctions[i].get_RotationX().radians(); float theta = aFunctions[i].get_RotationX().radians();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotatex, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatex,
resultTail);
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian); arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
break; break;
} }
case TransformFunction::TRotationY: case TransformFunction::TRotationY:
{ {
float theta = aFunctions[i].get_RotationY().radians(); float theta = aFunctions[i].get_RotationY().radians();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotatey, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatey,
resultTail);
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian); arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
break; break;
} }
case TransformFunction::TRotationZ: case TransformFunction::TRotationZ:
{ {
float theta = aFunctions[i].get_RotationZ().radians(); float theta = aFunctions[i].get_RotationZ().radians();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotatez, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotatez,
resultTail);
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian); arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
break; break;
} }
case TransformFunction::TRotation: case TransformFunction::TRotation:
{ {
float theta = aFunctions[i].get_Rotation().radians(); float theta = aFunctions[i].get_Rotation().radians();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotate, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotate,
resultTail);
arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian); arr->Item(1).SetFloatValue(theta, eCSSUnit_Radian);
break; break;
} }
@ -278,7 +282,9 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
float y = aFunctions[i].get_Rotation3D().y(); float y = aFunctions[i].get_Rotation3D().y();
float z = aFunctions[i].get_Rotation3D().z(); float z = aFunctions[i].get_Rotation3D().z();
float theta = aFunctions[i].get_Rotation3D().radians(); float theta = aFunctions[i].get_Rotation3D().radians();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_rotate3d, resultTail); arr =
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_rotate3d,
resultTail);
arr->Item(1).SetFloatValue(x, eCSSUnit_Number); arr->Item(1).SetFloatValue(x, eCSSUnit_Number);
arr->Item(2).SetFloatValue(y, eCSSUnit_Number); arr->Item(2).SetFloatValue(y, eCSSUnit_Number);
arr->Item(3).SetFloatValue(z, eCSSUnit_Number); arr->Item(3).SetFloatValue(z, eCSSUnit_Number);
@ -287,7 +293,9 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
} }
case TransformFunction::TScale: case TransformFunction::TScale:
{ {
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_scale3d, resultTail); arr =
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_scale3d,
resultTail);
arr->Item(1).SetFloatValue(aFunctions[i].get_Scale().x(), eCSSUnit_Number); arr->Item(1).SetFloatValue(aFunctions[i].get_Scale().x(), eCSSUnit_Number);
arr->Item(2).SetFloatValue(aFunctions[i].get_Scale().y(), eCSSUnit_Number); arr->Item(2).SetFloatValue(aFunctions[i].get_Scale().y(), eCSSUnit_Number);
arr->Item(3).SetFloatValue(aFunctions[i].get_Scale().z(), eCSSUnit_Number); arr->Item(3).SetFloatValue(aFunctions[i].get_Scale().z(), eCSSUnit_Number);
@ -295,7 +303,9 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
} }
case TransformFunction::TTranslation: case TransformFunction::TTranslation:
{ {
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_translate3d, resultTail); arr =
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_translate3d,
resultTail);
arr->Item(1).SetFloatValue(aFunctions[i].get_Translation().x(), eCSSUnit_Pixel); arr->Item(1).SetFloatValue(aFunctions[i].get_Translation().x(), eCSSUnit_Pixel);
arr->Item(2).SetFloatValue(aFunctions[i].get_Translation().y(), eCSSUnit_Pixel); arr->Item(2).SetFloatValue(aFunctions[i].get_Translation().y(), eCSSUnit_Pixel);
arr->Item(3).SetFloatValue(aFunctions[i].get_Translation().z(), eCSSUnit_Pixel); arr->Item(3).SetFloatValue(aFunctions[i].get_Translation().z(), eCSSUnit_Pixel);
@ -304,27 +314,32 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
case TransformFunction::TSkewX: case TransformFunction::TSkewX:
{ {
float x = aFunctions[i].get_SkewX().x(); float x = aFunctions[i].get_SkewX().x();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_skewx, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skewx,
resultTail);
arr->Item(1).SetFloatValue(x, eCSSUnit_Radian); arr->Item(1).SetFloatValue(x, eCSSUnit_Radian);
break; break;
} }
case TransformFunction::TSkewY: case TransformFunction::TSkewY:
{ {
float y = aFunctions[i].get_SkewY().y(); float y = aFunctions[i].get_SkewY().y();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_skewy, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skewy,
resultTail);
arr->Item(1).SetFloatValue(y, eCSSUnit_Radian); arr->Item(1).SetFloatValue(y, eCSSUnit_Radian);
break; break;
} }
case TransformFunction::TSkew: case TransformFunction::TSkew:
{ {
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_skew, resultTail); arr = StyleAnimationValue::AppendTransformFunction(eCSSKeyword_skew,
resultTail);
arr->Item(1).SetFloatValue(aFunctions[i].get_Skew().x(), eCSSUnit_Radian); arr->Item(1).SetFloatValue(aFunctions[i].get_Skew().x(), eCSSUnit_Radian);
arr->Item(2).SetFloatValue(aFunctions[i].get_Skew().y(), eCSSUnit_Radian); arr->Item(2).SetFloatValue(aFunctions[i].get_Skew().y(), eCSSUnit_Radian);
break; break;
} }
case TransformFunction::TTransformMatrix: case TransformFunction::TTransformMatrix:
{ {
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_matrix3d, resultTail); arr =
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_matrix3d,
resultTail);
const gfx::Matrix4x4& matrix = aFunctions[i].get_TransformMatrix().value(); const gfx::Matrix4x4& matrix = aFunctions[i].get_TransformMatrix().value();
arr->Item(1).SetFloatValue(matrix._11, eCSSUnit_Number); arr->Item(1).SetFloatValue(matrix._11, eCSSUnit_Number);
arr->Item(2).SetFloatValue(matrix._12, eCSSUnit_Number); arr->Item(2).SetFloatValue(matrix._12, eCSSUnit_Number);
@ -347,7 +362,9 @@ CreateCSSValueList(const InfallibleTArray<TransformFunction>& aFunctions)
case TransformFunction::TPerspective: case TransformFunction::TPerspective:
{ {
float perspective = aFunctions[i].get_Perspective().value(); float perspective = aFunctions[i].get_Perspective().value();
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_perspective, resultTail); arr =
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_perspective,
resultTail);
arr->Item(1).SetFloatValue(perspective, eCSSUnit_Pixel); arr->Item(1).SetFloatValue(perspective, eCSSUnit_Pixel);
break; break;
} }
@ -396,14 +413,14 @@ Layer::SetAnimations(const AnimationArray& aAnimations)
functions.AppendElement(ctf); functions.AppendElement(ctf);
} }
// Precompute the nsStyleAnimation::Values that we need if this is a transform // Precompute the StyleAnimationValues that we need if this is a transform
// animation. // animation.
InfallibleTArray<nsStyleAnimation::Value>& startValues = data->mStartValues; InfallibleTArray<StyleAnimationValue>& startValues = data->mStartValues;
InfallibleTArray<nsStyleAnimation::Value>& endValues = data->mEndValues; InfallibleTArray<StyleAnimationValue>& endValues = data->mEndValues;
for (uint32_t j = 0; j < mAnimations[i].segments().Length(); j++) { for (uint32_t j = 0; j < mAnimations[i].segments().Length(); j++) {
const AnimationSegment& segment = mAnimations[i].segments()[j]; const AnimationSegment& segment = mAnimations[i].segments()[j];
nsStyleAnimation::Value* startValue = startValues.AppendElement(); StyleAnimationValue* startValue = startValues.AppendElement();
nsStyleAnimation::Value* endValue = endValues.AppendElement(); StyleAnimationValue* endValue = endValues.AppendElement();
if (segment.endState().type() == Animatable::TArrayOfTransformFunction) { if (segment.endState().type() == Animatable::TArrayOfTransformFunction) {
const InfallibleTArray<TransformFunction>& startFunctions = const InfallibleTArray<TransformFunction>& startFunctions =
segment.startState().get_ArrayOfTransformFunction(); segment.startState().get_ArrayOfTransformFunction();

View File

@ -54,6 +54,7 @@ extern uint8_t gLayerManagerLayerBuilder;
namespace mozilla { namespace mozilla {
class FrameLayerBuilder; class FrameLayerBuilder;
class StyleAnimationValue;
class WebGLContext; class WebGLContext;
namespace gl { namespace gl {
@ -686,8 +687,8 @@ private:
typedef InfallibleTArray<Animation> AnimationArray; typedef InfallibleTArray<Animation> AnimationArray;
struct AnimData { struct AnimData {
InfallibleTArray<nsStyleAnimation::Value> mStartValues; InfallibleTArray<mozilla::StyleAnimationValue> mStartValues;
InfallibleTArray<nsStyleAnimation::Value> mEndValues; InfallibleTArray<mozilla::StyleAnimationValue> mEndValues;
InfallibleTArray<nsAutoPtr<mozilla::css::ComputedTimingFunction> > mFunctions; InfallibleTArray<nsAutoPtr<mozilla::css::ComputedTimingFunction> > mFunctions;
}; };

View File

@ -30,7 +30,7 @@
#include "nsPoint.h" // for nsPoint #include "nsPoint.h" // for nsPoint
#include "nsRect.h" // for nsIntRect #include "nsRect.h" // for nsIntRect
#include "nsRegion.h" // for nsIntRegion #include "nsRegion.h" // for nsIntRegion
#include "nsStyleAnimation.h" // for nsStyleAnimation::Value, etc #include "nsStyleAnimation.h" // for StyleAnimationValue, etc
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc #include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray #include "nsTArrayForwardDeclare.h" // for InfallibleTArray
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
@ -354,14 +354,15 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer,
} }
static void static void
SampleValue(float aPortion, Animation& aAnimation, nsStyleAnimation::Value& aStart, SampleValue(float aPortion, Animation& aAnimation, StyleAnimationValue& aStart,
nsStyleAnimation::Value& aEnd, Animatable* aValue) StyleAnimationValue& aEnd, Animatable* aValue)
{ {
nsStyleAnimation::Value interpolatedValue; StyleAnimationValue interpolatedValue;
NS_ASSERTION(aStart.GetUnit() == aEnd.GetUnit() || NS_ASSERTION(aStart.GetUnit() == aEnd.GetUnit() ||
aStart.GetUnit() == nsStyleAnimation::eUnit_None || aStart.GetUnit() == StyleAnimationValue::eUnit_None ||
aEnd.GetUnit() == nsStyleAnimation::eUnit_None, "Must have same unit"); aEnd.GetUnit() == StyleAnimationValue::eUnit_None,
nsStyleAnimation::Interpolate(aAnimation.property(), aStart, aEnd, "Must have same unit");
StyleAnimationValue::Interpolate(aAnimation.property(), aStart, aEnd,
aPortion, interpolatedValue); aPortion, interpolatedValue);
if (aAnimation.property() == eCSSProperty_opacity) { if (aAnimation.property() == eCSSProperty_opacity) {
*aValue = interpolatedValue.GetFloatValue(); *aValue = interpolatedValue.GetFloatValue();

View File

@ -335,14 +335,13 @@ nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent,
} }
static gfxSize static gfxSize
GetScaleForValue(const nsStyleAnimation::Value& aValue, GetScaleForValue(const StyleAnimationValue& aValue, nsIFrame* aFrame)
nsIFrame* aFrame)
{ {
if (!aFrame) { if (!aFrame) {
NS_WARNING("No frame."); NS_WARNING("No frame.");
return gfxSize(); return gfxSize();
} }
if (aValue.GetUnit() != nsStyleAnimation::eUnit_Transform) { if (aValue.GetUnit() != StyleAnimationValue::eUnit_Transform) {
NS_WARNING("Expected a transform."); NS_WARNING("Expected a transform.");
return gfxSize(); return gfxSize();
} }

View File

@ -166,17 +166,17 @@ CommonAnimationManager::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
CommonAnimationManager::ExtractComputedValueForTransition( CommonAnimationManager::ExtractComputedValueForTransition(
nsCSSProperty aProperty, nsCSSProperty aProperty,
nsStyleContext* aStyleContext, nsStyleContext* aStyleContext,
nsStyleAnimation::Value& aComputedValue) StyleAnimationValue& aComputedValue)
{ {
bool result = bool result = StyleAnimationValue::ExtractComputedValue(aProperty,
nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext, aStyleContext,
aComputedValue); aComputedValue);
if (aProperty == eCSSProperty_visibility) { if (aProperty == eCSSProperty_visibility) {
NS_ABORT_IF_FALSE(aComputedValue.GetUnit() == NS_ABORT_IF_FALSE(aComputedValue.GetUnit() ==
nsStyleAnimation::eUnit_Enumerated, StyleAnimationValue::eUnit_Enumerated,
"unexpected unit"); "unexpected unit");
aComputedValue.SetIntValue(aComputedValue.GetIntValue(), aComputedValue.SetIntValue(aComputedValue.GetIntValue(),
nsStyleAnimation::eUnit_Visibility); StyleAnimationValue::eUnit_Visibility);
} }
return result; return result;
} }
@ -331,7 +331,7 @@ AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData)
#ifdef DEBUG #ifdef DEBUG
bool ok = bool ok =
#endif #endif
nsStyleAnimation::UncomputeValue(cv.mProperty, cv.mValue, *prop); StyleAnimationValue::UncomputeValue(cv.mProperty, cv.mValue, *prop);
NS_ABORT_IF_FALSE(ok, "could not store computed value"); NS_ABORT_IF_FALSE(ok, "could not store computed value");
} }
} }
@ -347,7 +347,7 @@ AnimValuesStyleRule::List(FILE* out, int32_t aIndent) const
for (uint32_t i = 0, i_end = mPropertyValuePairs.Length(); i < i_end; ++i) { for (uint32_t i = 0, i_end = mPropertyValuePairs.Length(); i < i_end; ++i) {
const PropertyValuePair &pair = mPropertyValuePairs[i]; const PropertyValuePair &pair = mPropertyValuePairs[i];
nsAutoString value; nsAutoString value;
nsStyleAnimation::UncomputeValue(pair.mProperty, pair.mValue, value); StyleAnimationValue::UncomputeValue(pair.mProperty, pair.mValue, value);
fprintf(out, "%s: %s; ", nsCSSProps::GetStringValue(pair.mProperty).get(), fprintf(out, "%s: %s; ", nsCSSProps::GetStringValue(pair.mProperty).get(),
NS_ConvertUTF16toUTF8(value).get()); NS_ConvertUTF16toUTF8(value).get());
} }
@ -889,14 +889,15 @@ CommonElementAnimationData::EnsureStyleRuleFor(TimeStamp aRefreshTime,
double valuePosition = double valuePosition =
segment->mTimingFunction.GetValue(positionInSegment); segment->mTimingFunction.GetValue(positionInSegment);
nsStyleAnimation::Value *val = StyleAnimationValue *val =
mStyleRule->AddEmptyValue(prop.mProperty); mStyleRule->AddEmptyValue(prop.mProperty);
#ifdef DEBUG #ifdef DEBUG
bool result = bool result =
#endif #endif
nsStyleAnimation::Interpolate(prop.mProperty, StyleAnimationValue::Interpolate(prop.mProperty,
segment->mFromValue, segment->mToValue, segment->mFromValue,
segment->mToValue,
valuePosition, *val); valuePosition, *val);
NS_ABORT_IF_FALSE(result, "interpolate must succeed now"); NS_ABORT_IF_FALSE(result, "interpolate must succeed now");
} }

View File

@ -27,6 +27,9 @@ struct ElementPropertyTransition;
namespace mozilla { namespace mozilla {
class StyleAnimationValue;
namespace css { namespace css {
bool IsGeometricProperty(nsCSSProperty aProperty); bool IsGeometricProperty(nsCSSProperty aProperty);
@ -66,7 +69,7 @@ public:
static bool ExtractComputedValueForTransition( static bool ExtractComputedValueForTransition(
nsCSSProperty aProperty, nsCSSProperty aProperty,
nsStyleContext* aStyleContext, nsStyleContext* aStyleContext,
nsStyleAnimation::Value& aComputedValue); mozilla::StyleAnimationValue& aComputedValue);
protected: protected:
virtual ~CommonAnimationManager(); virtual ~CommonAnimationManager();
@ -160,7 +163,7 @@ class_::UpdateAllThrottledStylesInternal() \
} }
/** /**
* A style rule that maps property-nsStyleAnimation::Value pairs. * A style rule that maps property-StyleAnimationValue pairs.
*/ */
class AnimValuesStyleRule MOZ_FINAL : public nsIStyleRule class AnimValuesStyleRule MOZ_FINAL : public nsIStyleRule
{ {
@ -174,14 +177,15 @@ public:
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
#endif #endif
void AddValue(nsCSSProperty aProperty, nsStyleAnimation::Value &aStartValue) void AddValue(nsCSSProperty aProperty,
mozilla::StyleAnimationValue &aStartValue)
{ {
PropertyValuePair v = { aProperty, aStartValue }; PropertyValuePair v = { aProperty, aStartValue };
mPropertyValuePairs.AppendElement(v); mPropertyValuePairs.AppendElement(v);
} }
// Caller must fill in returned value. // Caller must fill in returned value.
nsStyleAnimation::Value* AddEmptyValue(nsCSSProperty aProperty) mozilla::StyleAnimationValue* AddEmptyValue(nsCSSProperty aProperty)
{ {
PropertyValuePair *p = mPropertyValuePairs.AppendElement(); PropertyValuePair *p = mPropertyValuePairs.AppendElement();
p->mProperty = aProperty; p->mProperty = aProperty;
@ -190,7 +194,7 @@ public:
struct PropertyValuePair { struct PropertyValuePair {
nsCSSProperty mProperty; nsCSSProperty mProperty;
nsStyleAnimation::Value mValue; mozilla::StyleAnimationValue mValue;
}; };
private: private:
@ -221,7 +225,7 @@ private:
struct AnimationPropertySegment struct AnimationPropertySegment
{ {
float mFromKey, mToKey; float mFromKey, mToKey;
nsStyleAnimation::Value mFromValue, mToValue; mozilla::StyleAnimationValue mFromValue, mToValue;
mozilla::css::ComputedTimingFunction mTimingFunction; mozilla::css::ComputedTimingFunction mTimingFunction;
}; };

View File

@ -392,7 +392,7 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext,
// whether they are resolved relative to other animations: I assume // whether they are resolved relative to other animations: I assume
// that they're not, since that would prevent us from caching a lot of // that they're not, since that would prevent us from caching a lot of
// data that we'd really like to cache (in particular, the // data that we'd really like to cache (in particular, the
// nsStyleAnimation::Value values in AnimationPropertySegment). // StyleAnimationValue values in AnimationPropertySegment).
nsStyleContext *result = mCache.GetWeak(aKeyframe); nsStyleContext *result = mCache.GetWeak(aKeyframe);
if (!result) { if (!result) {
nsCOMArray<nsIStyleRule> rules; nsCOMArray<nsIStyleRule> rules;
@ -602,13 +602,13 @@ nsAnimationManager::BuildSegment(InfallibleTArray<AnimationPropertySegment>&
mozilla::css::Declaration* aFromDeclaration, mozilla::css::Declaration* aFromDeclaration,
float aToKey, nsStyleContext* aToContext) float aToKey, nsStyleContext* aToContext)
{ {
nsStyleAnimation::Value fromValue, toValue, dummyValue; StyleAnimationValue fromValue, toValue, dummyValue;
if (!ExtractComputedValueForTransition(aProperty, aFromContext, fromValue) || if (!ExtractComputedValueForTransition(aProperty, aFromContext, fromValue) ||
!ExtractComputedValueForTransition(aProperty, aToContext, toValue) || !ExtractComputedValueForTransition(aProperty, aToContext, toValue) ||
// Check that we can interpolate between these values // Check that we can interpolate between these values
// (If this is ever a performance problem, we could add a // (If this is ever a performance problem, we could add a
// CanInterpolate method, but it seems fine for now.) // CanInterpolate method, but it seems fine for now.)
!nsStyleAnimation::Interpolate(aProperty, fromValue, toValue, !StyleAnimationValue::Interpolate(aProperty, fromValue, toValue,
0.5, dummyValue)) { 0.5, dummyValue)) {
return false; return false;
} }

View File

@ -218,7 +218,7 @@ static_assert((CSS_PROPERTY_PARSE_PROPERTY_MASK &
*/ */
enum nsStyleAnimType { enum nsStyleAnimType {
// requires a custom implementation in // requires a custom implementation in
// nsStyleAnimation::ExtractComputedValue // StyleAnimationValue::ExtractComputedValue
eStyleAnimType_Custom, eStyleAnimType_Custom,
// nsStyleCoord with animatable values // nsStyleCoord with animatable values

View File

@ -45,23 +45,23 @@ using namespace mozilla;
* eUnit_Null if that's not possible. * eUnit_Null if that's not possible.
*/ */
static static
nsStyleAnimation::Unit StyleAnimationValue::Unit
GetCommonUnit(nsCSSProperty aProperty, GetCommonUnit(nsCSSProperty aProperty,
nsStyleAnimation::Unit aFirstUnit, StyleAnimationValue::Unit aFirstUnit,
nsStyleAnimation::Unit aSecondUnit) StyleAnimationValue::Unit aSecondUnit)
{ {
if (aFirstUnit != aSecondUnit) { if (aFirstUnit != aSecondUnit) {
if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_STORES_CALC) && if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_STORES_CALC) &&
(aFirstUnit == nsStyleAnimation::eUnit_Coord || (aFirstUnit == StyleAnimationValue::eUnit_Coord ||
aFirstUnit == nsStyleAnimation::eUnit_Percent || aFirstUnit == StyleAnimationValue::eUnit_Percent ||
aFirstUnit == nsStyleAnimation::eUnit_Calc) && aFirstUnit == StyleAnimationValue::eUnit_Calc) &&
(aSecondUnit == nsStyleAnimation::eUnit_Coord || (aSecondUnit == StyleAnimationValue::eUnit_Coord ||
aSecondUnit == nsStyleAnimation::eUnit_Percent || aSecondUnit == StyleAnimationValue::eUnit_Percent ||
aSecondUnit == nsStyleAnimation::eUnit_Calc)) { aSecondUnit == StyleAnimationValue::eUnit_Calc)) {
// We can use calc() as the common unit. // We can use calc() as the common unit.
return nsStyleAnimation::eUnit_Calc; return StyleAnimationValue::eUnit_Calc;
} }
return nsStyleAnimation::eUnit_Null; return StyleAnimationValue::eUnit_Null;
} }
return aFirstUnit; return aFirstUnit;
} }
@ -316,23 +316,23 @@ ExtractCalcValueInternal(const nsCSSValue& aValue)
// Requires a canonical calc() value that we generated. // Requires a canonical calc() value that we generated.
static PixelCalcValue static PixelCalcValue
ExtractCalcValue(const nsStyleAnimation::Value& aValue) ExtractCalcValue(const StyleAnimationValue& aValue)
{ {
PixelCalcValue result; PixelCalcValue result;
if (aValue.GetUnit() == nsStyleAnimation::eUnit_Coord) { if (aValue.GetUnit() == StyleAnimationValue::eUnit_Coord) {
result.mLength = result.mLength =
nsPresContext::AppUnitsToFloatCSSPixels(aValue.GetCoordValue()); nsPresContext::AppUnitsToFloatCSSPixels(aValue.GetCoordValue());
result.mPercent = 0.0f; result.mPercent = 0.0f;
result.mHasPercent = false; result.mHasPercent = false;
return result; return result;
} }
if (aValue.GetUnit() == nsStyleAnimation::eUnit_Percent) { if (aValue.GetUnit() == StyleAnimationValue::eUnit_Percent) {
result.mLength = 0.0f; result.mLength = 0.0f;
result.mPercent = aValue.GetPercentValue(); result.mPercent = aValue.GetPercentValue();
result.mHasPercent = true; result.mHasPercent = true;
return result; return result;
} }
NS_ABORT_IF_FALSE(aValue.GetUnit() == nsStyleAnimation::eUnit_Calc, NS_ABORT_IF_FALSE(aValue.GetUnit() == StyleAnimationValue::eUnit_Calc,
"unexpected unit"); "unexpected unit");
nsCSSValue *val = aValue.GetCSSValueValue(); nsCSSValue *val = aValue.GetCSSValueValue();
return ExtractCalcValueInternal(*val); return ExtractCalcValueInternal(*val);
@ -403,9 +403,9 @@ GetURIAsUtf16StringBuffer(nsIURI* aUri)
// ------------- // -------------
bool bool
nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, StyleAnimationValue::ComputeDistance(nsCSSProperty aProperty,
const Value& aStartValue, const StyleAnimationValue& aStartValue,
const Value& aEndValue, const StyleAnimationValue& aEndValue,
double& aDistance) double& aDistance)
{ {
Unit commonUnit = Unit commonUnit =
@ -664,7 +664,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
// particularly useful for paced animation. // particularly useful for paced animation.
// Call AddWeighted to make us lists of the same length. // Call AddWeighted to make us lists of the same length.
Value normValue1, normValue2; StyleAnimationValue normValue1, normValue2;
if (!AddWeighted(aProperty, 1.0, aStartValue, 0.0, aEndValue, if (!AddWeighted(aProperty, 1.0, aStartValue, 0.0, aEndValue,
normValue1) || normValue1) ||
!AddWeighted(aProperty, 0.0, aStartValue, 1.0, aEndValue, !AddWeighted(aProperty, 0.0, aStartValue, 1.0, aEndValue,
@ -707,7 +707,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
} }
case eUnit_Shadow: { case eUnit_Shadow: {
// Call AddWeighted to make us lists of the same length. // Call AddWeighted to make us lists of the same length.
Value normValue1, normValue2; StyleAnimationValue normValue1, normValue2;
if (!AddWeighted(aProperty, 1.0, aStartValue, 0.0, aEndValue, if (!AddWeighted(aProperty, 1.0, aStartValue, 0.0, aEndValue,
normValue1) || normValue1) ||
!AddWeighted(aProperty, 0.0, aStartValue, 1.0, aEndValue, !AddWeighted(aProperty, 0.0, aStartValue, 1.0, aEndValue,
@ -752,16 +752,16 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
#endif #endif
if (color1.GetUnit() != eCSSUnit_Null) { if (color1.GetUnit() != eCSSUnit_Null) {
nsStyleAnimation::Value color1Value StyleAnimationValue color1Value
(color1.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); (color1.GetColorValue(), StyleAnimationValue::ColorConstructor);
nsStyleAnimation::Value color2Value StyleAnimationValue color2Value
(color2.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); (color2.GetColorValue(), StyleAnimationValue::ColorConstructor);
double colorDistance; double colorDistance;
#ifdef DEBUG #ifdef DEBUG
bool ok = bool ok =
#endif #endif
nsStyleAnimation::ComputeDistance(eCSSProperty_color, StyleAnimationValue::ComputeDistance(eCSSProperty_color,
color1Value, color2Value, color1Value, color2Value,
colorDistance); colorDistance);
NS_ABORT_IF_FALSE(ok, "should not fail"); NS_ABORT_IF_FALSE(ok, "should not fail");
@ -1121,16 +1121,18 @@ AddShadowItems(double aCoeff1, const nsCSSValue &aValue1,
} }
if (color1.GetUnit() != eCSSUnit_Null) { if (color1.GetUnit() != eCSSUnit_Null) {
nsStyleAnimation::Value color1Value StyleAnimationValue color1Value
(color1.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); (color1.GetColorValue(), StyleAnimationValue::ColorConstructor);
nsStyleAnimation::Value color2Value StyleAnimationValue color2Value
(color2.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); (color2.GetColorValue(), StyleAnimationValue::ColorConstructor);
nsStyleAnimation::Value resultColorValue; StyleAnimationValue resultColorValue;
#ifdef DEBUG #ifdef DEBUG
bool ok = bool ok =
#endif #endif
nsStyleAnimation::AddWeighted(eCSSProperty_color, aCoeff1, color1Value, StyleAnimationValue::AddWeighted(eCSSProperty_color,
aCoeff2, color2Value, resultColorValue); aCoeff1, color1Value,
aCoeff2, color2Value,
resultColorValue);
NS_ABORT_IF_FALSE(ok, "should not fail"); NS_ABORT_IF_FALSE(ok, "should not fail");
resultArray->Item(4).SetColorValue(resultColorValue.GetColorValue()); resultArray->Item(4).SetColorValue(resultColorValue.GetColorValue());
} }
@ -1193,7 +1195,7 @@ AddTransformScale(double aCoeff1, const nsCSSValue &aValue1,
} }
/* static */ already_AddRefed<nsCSSValue::Array> /* static */ already_AddRefed<nsCSSValue::Array>
nsStyleAnimation::AppendTransformFunction(nsCSSKeyword aTransformFunction, StyleAnimationValue::AppendTransformFunction(nsCSSKeyword aTransformFunction,
nsCSSValueList**& aListTail) nsCSSValueList**& aListTail)
{ {
nsRefPtr<nsCSSValue::Array> arr = AppendFunction(aTransformFunction); nsRefPtr<nsCSSValue::Array> arr = AppendFunction(aTransformFunction);
@ -1498,7 +1500,7 @@ T InterpolateNumerically(const T& aOne, const T& aTwo, double aCoeff)
/* static */ gfx3DMatrix /* static */ gfx3DMatrix
nsStyleAnimation::InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1, StyleAnimationValue::InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1,
const gfx3DMatrix &aMatrix2, const gfx3DMatrix &aMatrix2,
double aProgress) double aProgress)
{ {
@ -1580,7 +1582,9 @@ AddDifferentTransformLists(double aCoeff1, const nsCSSValueList* aList1,
nsCSSValueList **resultTail = getter_Transfers(result); nsCSSValueList **resultTail = getter_Transfers(result);
nsRefPtr<nsCSSValue::Array> arr; nsRefPtr<nsCSSValue::Array> arr;
arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_interpolatematrix, resultTail); arr =
StyleAnimationValue::AppendTransformFunction(eCSSKeyword_interpolatematrix,
resultTail);
// FIXME: We should change the other transform code to also only // FIXME: We should change the other transform code to also only
// take a single progress value, as having values that don't // take a single progress value, as having values that don't
@ -1741,7 +1745,7 @@ AddTransformLists(double aCoeff1, const nsCSSValueList* aList1,
tfunc != eCSSKeyword_interpolatematrix && tfunc != eCSSKeyword_interpolatematrix &&
tfunc != eCSSKeyword_rotate3d && tfunc != eCSSKeyword_rotate3d &&
tfunc != eCSSKeyword_perspective) { tfunc != eCSSKeyword_perspective) {
arr = nsStyleAnimation::AppendTransformFunction(tfunc, resultTail); arr = StyleAnimationValue::AppendTransformFunction(tfunc, resultTail);
} }
switch (tfunc) { switch (tfunc) {
@ -1852,10 +1856,12 @@ AddTransformLists(double aCoeff1, const nsCSSValueList* aList1,
} }
bool bool
nsStyleAnimation::AddWeighted(nsCSSProperty aProperty, StyleAnimationValue::AddWeighted(nsCSSProperty aProperty,
double aCoeff1, const Value& aValue1, double aCoeff1,
double aCoeff2, const Value& aValue2, const StyleAnimationValue& aValue1,
Value& aResultValue) double aCoeff2,
const StyleAnimationValue& aValue2,
StyleAnimationValue& aResultValue)
{ {
Unit commonUnit = Unit commonUnit =
GetCommonUnit(aProperty, aValue1.GetUnit(), aValue2.GetUnit()); GetCommonUnit(aProperty, aValue1.GetUnit(), aValue2.GetUnit());
@ -2473,11 +2479,11 @@ LookupStyleContext(dom::Element* aElement)
} }
bool bool
nsStyleAnimation::ComputeValue(nsCSSProperty aProperty, StyleAnimationValue::ComputeValue(nsCSSProperty aProperty,
dom::Element* aTargetElement, dom::Element* aTargetElement,
const nsAString& aSpecifiedValue, const nsAString& aSpecifiedValue,
bool aUseSVGMode, bool aUseSVGMode,
Value& aComputedValue, StyleAnimationValue& aComputedValue,
bool* aIsContextSensitive) bool* aIsContextSensitive)
{ {
NS_ABORT_IF_FALSE(aTargetElement, "null target element"); NS_ABORT_IF_FALSE(aTargetElement, "null target element");
@ -2560,8 +2566,8 @@ nsStyleAnimation::ComputeValue(nsCSSProperty aProperty,
} }
bool bool
nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty,
const Value& aComputedValue, const StyleAnimationValue& aComputedValue,
nsCSSValue& aSpecifiedValue) nsCSSValue& aSpecifiedValue)
{ {
switch (aComputedValue.GetUnit()) { switch (aComputedValue.GetUnit()) {
@ -2653,8 +2659,8 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
} }
bool bool
nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty,
const Value& aComputedValue, const StyleAnimationValue& aComputedValue,
nsAString& aSpecifiedValue) nsAString& aSpecifiedValue)
{ {
aSpecifiedValue.Truncate(); // Clear outparam, if it's not already empty aSpecifiedValue.Truncate(); // Clear outparam, if it's not already empty
@ -2664,7 +2670,7 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
return true; return true;
} }
nsCSSValue val; nsCSSValue val;
if (!nsStyleAnimation::UncomputeValue(aProperty, aComputedValue, val)) { if (!StyleAnimationValue::UncomputeValue(aProperty, aComputedValue, val)) {
return false; return false;
} }
@ -2686,7 +2692,8 @@ StyleDataAtOffset(void* aStyleStruct, ptrdiff_t aOffset)
static void static void
ExtractBorderColor(nsStyleContext* aStyleContext, const void* aStyleBorder, ExtractBorderColor(nsStyleContext* aStyleContext, const void* aStyleBorder,
mozilla::css::Side aSide, nsStyleAnimation::Value& aComputedValue) mozilla::css::Side aSide,
StyleAnimationValue& aComputedValue)
{ {
nscolor color; nscolor color;
bool foreground; bool foreground;
@ -2700,7 +2707,7 @@ ExtractBorderColor(nsStyleContext* aStyleContext, const void* aStyleBorder,
} }
static bool static bool
StyleCoordToValue(const nsStyleCoord& aCoord, nsStyleAnimation::Value& aValue) StyleCoordToValue(const nsStyleCoord& aCoord, StyleAnimationValue& aValue)
{ {
switch (aCoord.GetUnit()) { switch (aCoord.GetUnit()) {
case eStyleUnit_Normal: case eStyleUnit_Normal:
@ -2723,17 +2730,17 @@ StyleCoordToValue(const nsStyleCoord& aCoord, nsStyleAnimation::Value& aValue)
break; break;
case eStyleUnit_Enumerated: case eStyleUnit_Enumerated:
aValue.SetIntValue(aCoord.GetIntValue(), aValue.SetIntValue(aCoord.GetIntValue(),
nsStyleAnimation::eUnit_Enumerated); StyleAnimationValue::eUnit_Enumerated);
break; break;
case eStyleUnit_Integer: case eStyleUnit_Integer:
aValue.SetIntValue(aCoord.GetIntValue(), aValue.SetIntValue(aCoord.GetIntValue(),
nsStyleAnimation::eUnit_Integer); StyleAnimationValue::eUnit_Integer);
break; break;
case eStyleUnit_Calc: { case eStyleUnit_Calc: {
nsAutoPtr<nsCSSValue> val(new nsCSSValue); nsAutoPtr<nsCSSValue> val(new nsCSSValue);
SetCalcValue(aCoord.GetCalcValue(), *val); SetCalcValue(aCoord.GetCalcValue(), *val);
aValue.SetAndAdoptCSSValueValue(val.forget(), aValue.SetAndAdoptCSSValueValue(val.forget(),
nsStyleAnimation::eUnit_Calc); StyleAnimationValue::eUnit_Calc);
break; break;
} }
default: default:
@ -2820,9 +2827,9 @@ SubstitutePixelValues(nsStyleContext* aStyleContext,
} }
bool bool
nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty, StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty,
nsStyleContext* aStyleContext, nsStyleContext* aStyleContext,
Value& aComputedValue) StyleAnimationValue& aComputedValue)
{ {
NS_ABORT_IF_FALSE(0 <= aProperty && NS_ABORT_IF_FALSE(0 <= aProperty &&
aProperty < eCSSProperty_COUNT_no_shorthands, aProperty < eCSSProperty_COUNT_no_shorthands,
@ -3461,7 +3468,7 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
return false; return false;
} }
nsStyleAnimation::Value::Value(int32_t aInt, Unit aUnit, StyleAnimationValue::StyleAnimationValue(int32_t aInt, Unit aUnit,
IntegerConstructorType) IntegerConstructorType)
{ {
NS_ASSERTION(IsIntUnit(aUnit), "unit must be of integer type"); NS_ASSERTION(IsIntUnit(aUnit), "unit must be of integer type");
@ -3469,34 +3476,35 @@ nsStyleAnimation::Value::Value(int32_t aInt, Unit aUnit,
mValue.mInt = aInt; mValue.mInt = aInt;
} }
nsStyleAnimation::Value::Value(nscoord aLength, CoordConstructorType) StyleAnimationValue::StyleAnimationValue(nscoord aLength, CoordConstructorType)
{ {
mUnit = eUnit_Coord; mUnit = eUnit_Coord;
mValue.mCoord = aLength; mValue.mCoord = aLength;
} }
nsStyleAnimation::Value::Value(float aPercent, PercentConstructorType) StyleAnimationValue::StyleAnimationValue(float aPercent,
PercentConstructorType)
{ {
mUnit = eUnit_Percent; mUnit = eUnit_Percent;
mValue.mFloat = aPercent; mValue.mFloat = aPercent;
MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
} }
nsStyleAnimation::Value::Value(float aFloat, FloatConstructorType) StyleAnimationValue::StyleAnimationValue(float aFloat, FloatConstructorType)
{ {
mUnit = eUnit_Float; mUnit = eUnit_Float;
mValue.mFloat = aFloat; mValue.mFloat = aFloat;
MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
} }
nsStyleAnimation::Value::Value(nscolor aColor, ColorConstructorType) StyleAnimationValue::StyleAnimationValue(nscolor aColor, ColorConstructorType)
{ {
mUnit = eUnit_Color; mUnit = eUnit_Color;
mValue.mColor = aColor; mValue.mColor = aColor;
} }
nsStyleAnimation::Value& StyleAnimationValue&
nsStyleAnimation::Value::operator=(const Value& aOther) StyleAnimationValue::operator=(const StyleAnimationValue& aOther)
{ {
FreeValue(); FreeValue();
@ -3592,28 +3600,28 @@ nsStyleAnimation::Value::operator=(const Value& aOther)
} }
void void
nsStyleAnimation::Value::SetNormalValue() StyleAnimationValue::SetNormalValue()
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Normal; mUnit = eUnit_Normal;
} }
void void
nsStyleAnimation::Value::SetAutoValue() StyleAnimationValue::SetAutoValue()
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Auto; mUnit = eUnit_Auto;
} }
void void
nsStyleAnimation::Value::SetNoneValue() StyleAnimationValue::SetNoneValue()
{ {
FreeValue(); FreeValue();
mUnit = eUnit_None; mUnit = eUnit_None;
} }
void void
nsStyleAnimation::Value::SetIntValue(int32_t aInt, Unit aUnit) StyleAnimationValue::SetIntValue(int32_t aInt, Unit aUnit)
{ {
NS_ASSERTION(IsIntUnit(aUnit), "unit must be of integer type"); NS_ASSERTION(IsIntUnit(aUnit), "unit must be of integer type");
FreeValue(); FreeValue();
@ -3622,7 +3630,7 @@ nsStyleAnimation::Value::SetIntValue(int32_t aInt, Unit aUnit)
} }
void void
nsStyleAnimation::Value::SetCoordValue(nscoord aLength) StyleAnimationValue::SetCoordValue(nscoord aLength)
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Coord; mUnit = eUnit_Coord;
@ -3630,7 +3638,7 @@ nsStyleAnimation::Value::SetCoordValue(nscoord aLength)
} }
void void
nsStyleAnimation::Value::SetPercentValue(float aPercent) StyleAnimationValue::SetPercentValue(float aPercent)
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Percent; mUnit = eUnit_Percent;
@ -3639,7 +3647,7 @@ nsStyleAnimation::Value::SetPercentValue(float aPercent)
} }
void void
nsStyleAnimation::Value::SetFloatValue(float aFloat) StyleAnimationValue::SetFloatValue(float aFloat)
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Float; mUnit = eUnit_Float;
@ -3648,7 +3656,7 @@ nsStyleAnimation::Value::SetFloatValue(float aFloat)
} }
void void
nsStyleAnimation::Value::SetColorValue(nscolor aColor) StyleAnimationValue::SetColorValue(nscolor aColor)
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Color; mUnit = eUnit_Color;
@ -3656,7 +3664,7 @@ nsStyleAnimation::Value::SetColorValue(nscolor aColor)
} }
void void
nsStyleAnimation::Value::SetUnparsedStringValue(const nsString& aString) StyleAnimationValue::SetUnparsedStringValue(const nsString& aString)
{ {
FreeValue(); FreeValue();
mUnit = eUnit_UnparsedString; mUnit = eUnit_UnparsedString;
@ -3664,7 +3672,7 @@ nsStyleAnimation::Value::SetUnparsedStringValue(const nsString& aString)
} }
void void
nsStyleAnimation::Value::SetAndAdoptCSSValueValue(nsCSSValue *aValue, StyleAnimationValue::SetAndAdoptCSSValueValue(nsCSSValue *aValue,
Unit aUnit) Unit aUnit)
{ {
FreeValue(); FreeValue();
@ -3675,8 +3683,8 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueValue(nsCSSValue *aValue,
} }
void void
nsStyleAnimation::Value::SetAndAdoptCSSValuePairValue( StyleAnimationValue::SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValuePair,
nsCSSValuePair *aValuePair, Unit aUnit) Unit aUnit)
{ {
FreeValue(); FreeValue();
NS_ABORT_IF_FALSE(IsCSSValuePairUnit(aUnit), "bad unit"); NS_ABORT_IF_FALSE(IsCSSValuePairUnit(aUnit), "bad unit");
@ -3686,7 +3694,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValuePairValue(
} }
void void
nsStyleAnimation::Value::SetAndAdoptCSSValueTripletValue( StyleAnimationValue::SetAndAdoptCSSValueTripletValue(
nsCSSValueTriplet *aValueTriplet, Unit aUnit) nsCSSValueTriplet *aValueTriplet, Unit aUnit)
{ {
FreeValue(); FreeValue();
@ -3697,7 +3705,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueTripletValue(
} }
void void
nsStyleAnimation::Value::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit) StyleAnimationValue::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit)
{ {
FreeValue(); FreeValue();
NS_ABORT_IF_FALSE(IsCSSRectUnit(aUnit), "bad unit"); NS_ABORT_IF_FALSE(IsCSSRectUnit(aUnit), "bad unit");
@ -3707,8 +3715,8 @@ nsStyleAnimation::Value::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit)
} }
void void
nsStyleAnimation::Value::SetAndAdoptCSSValueListValue( StyleAnimationValue::SetAndAdoptCSSValueListValue(nsCSSValueList *aValueList,
nsCSSValueList *aValueList, Unit aUnit) Unit aUnit)
{ {
FreeValue(); FreeValue();
NS_ABORT_IF_FALSE(IsCSSValueListUnit(aUnit), "bad unit"); NS_ABORT_IF_FALSE(IsCSSValueListUnit(aUnit), "bad unit");
@ -3720,7 +3728,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueListValue(
} }
void void
nsStyleAnimation::Value::SetTransformValue(nsCSSValueSharedList* aList) StyleAnimationValue::SetTransformValue(nsCSSValueSharedList* aList)
{ {
FreeValue(); FreeValue();
mUnit = eUnit_Transform; mUnit = eUnit_Transform;
@ -3729,7 +3737,7 @@ nsStyleAnimation::Value::SetTransformValue(nsCSSValueSharedList* aList)
} }
void void
nsStyleAnimation::Value::SetAndAdoptCSSValuePairListValue( StyleAnimationValue::SetAndAdoptCSSValuePairListValue(
nsCSSValuePairList *aValuePairList) nsCSSValuePairList *aValuePairList)
{ {
FreeValue(); FreeValue();
@ -3739,7 +3747,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValuePairListValue(
} }
void void
nsStyleAnimation::Value::FreeValue() StyleAnimationValue::FreeValue()
{ {
if (IsCSSValueUnit(mUnit)) { if (IsCSSValueUnit(mUnit)) {
delete mValue.mCSSValue; delete mValue.mCSSValue;
@ -3762,7 +3770,7 @@ nsStyleAnimation::Value::FreeValue()
} }
bool bool
nsStyleAnimation::Value::operator==(const Value& aOther) const StyleAnimationValue::operator==(const StyleAnimationValue& aOther) const
{ {
if (mUnit != aOther.mUnit) { if (mUnit != aOther.mUnit) {
return false; return false;

View File

@ -19,18 +19,16 @@ class nsStyleContext;
class gfx3DMatrix; class gfx3DMatrix;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class Element; class Element;
} // namespace dom } // namespace dom
} // namespace mozilla
/** /**
* Utility class to handle animated style values * Utility class to handle animated style values
*/ */
class nsStyleAnimation { class StyleAnimationValue {
public: public:
class Value;
// Mathematical methods // Mathematical methods
// -------------------- // --------------------
/** /**
@ -45,8 +43,8 @@ public:
* @param aCount The number of times to add aValueToAdd. * @param aCount The number of times to add aValueToAdd.
* @return true on success, false on failure. * @return true on success, false on failure.
*/ */
static bool Add(nsCSSProperty aProperty, Value& aDest, static bool Add(nsCSSProperty aProperty, StyleAnimationValue& aDest,
const Value& aValueToAdd, uint32_t aCount) { const StyleAnimationValue& aValueToAdd, uint32_t aCount) {
return AddWeighted(aProperty, 1.0, aDest, aCount, aValueToAdd, aDest); return AddWeighted(aProperty, 1.0, aDest, aCount, aValueToAdd, aDest);
} }
@ -55,8 +53,8 @@ public:
* *
* This measure of Distance is guaranteed to be proportional to * This measure of Distance is guaranteed to be proportional to
* portions passed to Interpolate, Add, or AddWeighted. However, for * portions passed to Interpolate, Add, or AddWeighted. However, for
* some types of Value it may not produce sensible results for paced * some types of StyleAnimationValue it may not produce sensible results
* animation. * for paced animation.
* *
* If this method succeeds, the returned distance value is guaranteed to be * If this method succeeds, the returned distance value is guaranteed to be
* non-negative. * non-negative.
@ -69,8 +67,8 @@ public:
* @return true on success, false on failure. * @return true on success, false on failure.
*/ */
static bool ComputeDistance(nsCSSProperty aProperty, static bool ComputeDistance(nsCSSProperty aProperty,
const Value& aStartValue, const StyleAnimationValue& aStartValue,
const Value& aEndValue, const StyleAnimationValue& aEndValue,
double& aDistance); double& aDistance);
/** /**
@ -90,10 +88,10 @@ public:
* @return true on success, false on failure. * @return true on success, false on failure.
*/ */
static bool Interpolate(nsCSSProperty aProperty, static bool Interpolate(nsCSSProperty aProperty,
const Value& aStartValue, const StyleAnimationValue& aStartValue,
const Value& aEndValue, const StyleAnimationValue& aEndValue,
double aPortion, double aPortion,
Value& aResultValue) { StyleAnimationValue& aResultValue) {
return AddWeighted(aProperty, 1.0 - aPortion, aStartValue, return AddWeighted(aProperty, 1.0 - aPortion, aStartValue,
aPortion, aEndValue, aResultValue); aPortion, aEndValue, aResultValue);
} }
@ -113,9 +111,9 @@ public:
* positive. * positive.
*/ */
static bool AddWeighted(nsCSSProperty aProperty, static bool AddWeighted(nsCSSProperty aProperty,
double aCoeff1, const Value& aValue1, double aCoeff1, const StyleAnimationValue& aValue1,
double aCoeff2, const Value& aValue2, double aCoeff2, const StyleAnimationValue& aValue2,
Value& aResultValue); StyleAnimationValue& aResultValue);
// Type-conversion methods // Type-conversion methods
// ----------------------- // -----------------------
@ -147,7 +145,7 @@ public:
mozilla::dom::Element* aTargetElement, mozilla::dom::Element* aTargetElement,
const nsAString& aSpecifiedValue, const nsAString& aSpecifiedValue,
bool aUseSVGMode, bool aUseSVGMode,
Value& aComputedValue, StyleAnimationValue& aComputedValue,
bool* aIsContextSensitive = nullptr); bool* aIsContextSensitive = nullptr);
/** /**
@ -164,10 +162,10 @@ public:
* @return true on success, false on failure. * @return true on success, false on failure.
*/ */
static bool UncomputeValue(nsCSSProperty aProperty, static bool UncomputeValue(nsCSSProperty aProperty,
const Value& aComputedValue, const StyleAnimationValue& aComputedValue,
nsCSSValue& aSpecifiedValue); nsCSSValue& aSpecifiedValue);
static bool UncomputeValue(nsCSSProperty aProperty, static bool UncomputeValue(nsCSSProperty aProperty,
const Value& aComputedValue, const StyleAnimationValue& aComputedValue,
nsAString& aSpecifiedValue); nsAString& aSpecifiedValue);
/** /**
@ -181,7 +179,7 @@ public:
*/ */
static bool ExtractComputedValue(nsCSSProperty aProperty, static bool ExtractComputedValue(nsCSSProperty aProperty,
nsStyleContext* aStyleContext, nsStyleContext* aStyleContext,
Value& aComputedValue); StyleAnimationValue& aComputedValue);
/** /**
* Interpolates between 2 matrices by decomposing them. * Interpolates between 2 matrices by decomposing them.
@ -228,8 +226,7 @@ public:
eUnit_UnparsedString // nsStringBuffer* (never null) eUnit_UnparsedString // nsStringBuffer* (never null)
}; };
class Value { private:
private:
Unit mUnit; Unit mUnit;
union { union {
int32_t mInt; int32_t mInt;
@ -245,7 +242,8 @@ public:
nsCSSValuePairList* mCSSValuePairList; nsCSSValuePairList* mCSSValuePairList;
nsStringBuffer* mString; nsStringBuffer* mString;
} mValue; } mValue;
public:
public:
Unit GetUnit() const { Unit GetUnit() const {
NS_ASSERTION(mUnit != eUnit_Null, "uninitialized"); NS_ASSERTION(mUnit != eUnit_Null, "uninitialized");
return mUnit; return mUnit;
@ -317,24 +315,25 @@ public:
mValue.mString->ToString(len, aBuffer); mValue.mString->ToString(len, aBuffer);
} }
explicit Value(Unit aUnit = eUnit_Null) : mUnit(aUnit) { explicit StyleAnimationValue(Unit aUnit = eUnit_Null) : mUnit(aUnit) {
NS_ASSERTION(aUnit == eUnit_Null || aUnit == eUnit_Normal || NS_ASSERTION(aUnit == eUnit_Null || aUnit == eUnit_Normal ||
aUnit == eUnit_Auto || aUnit == eUnit_None, aUnit == eUnit_Auto || aUnit == eUnit_None,
"must be valueless unit"); "must be valueless unit");
} }
Value(const Value& aOther) : mUnit(eUnit_Null) { *this = aOther; } StyleAnimationValue(const StyleAnimationValue& aOther)
: mUnit(eUnit_Null) { *this = aOther; }
enum IntegerConstructorType { IntegerConstructor }; enum IntegerConstructorType { IntegerConstructor };
Value(int32_t aInt, Unit aUnit, IntegerConstructorType); StyleAnimationValue(int32_t aInt, Unit aUnit, IntegerConstructorType);
enum CoordConstructorType { CoordConstructor }; enum CoordConstructorType { CoordConstructor };
Value(nscoord aLength, CoordConstructorType); StyleAnimationValue(nscoord aLength, CoordConstructorType);
enum PercentConstructorType { PercentConstructor }; enum PercentConstructorType { PercentConstructor };
Value(float aPercent, PercentConstructorType); StyleAnimationValue(float aPercent, PercentConstructorType);
enum FloatConstructorType { FloatConstructor }; enum FloatConstructorType { FloatConstructor };
Value(float aFloat, FloatConstructorType); StyleAnimationValue(float aFloat, FloatConstructorType);
enum ColorConstructorType { ColorConstructor }; enum ColorConstructorType { ColorConstructor };
Value(nscolor aColor, ColorConstructorType); StyleAnimationValue(nscolor aColor, ColorConstructorType);
~Value() { FreeValue(); } ~StyleAnimationValue() { FreeValue(); }
void SetNormalValue(); void SetNormalValue();
void SetAutoValue(); void SetAutoValue();
@ -357,13 +356,13 @@ public:
void SetTransformValue(nsCSSValueSharedList* aList); void SetTransformValue(nsCSSValueSharedList* aList);
Value& operator=(const Value& aOther); StyleAnimationValue& operator=(const StyleAnimationValue& aOther);
bool operator==(const Value& aOther) const; bool operator==(const StyleAnimationValue& aOther) const;
bool operator!=(const Value& aOther) const bool operator!=(const StyleAnimationValue& aOther) const
{ return !(*this == aOther); } { return !(*this == aOther); }
private: private:
void FreeValue(); void FreeValue();
static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) { static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) {
@ -400,7 +399,8 @@ public:
static bool IsStringUnit(Unit aUnit) { static bool IsStringUnit(Unit aUnit) {
return aUnit == eUnit_UnparsedString; return aUnit == eUnit_UnparsedString;
} }
};
}; };
} // namespace mozilla
#endif #endif

View File

@ -746,19 +746,20 @@ NS_NewStyleContext(nsStyleContext* aParentContext,
static inline void static inline void
ExtractAnimationValue(nsCSSProperty aProperty, ExtractAnimationValue(nsCSSProperty aProperty,
nsStyleContext* aStyleContext, nsStyleContext* aStyleContext,
nsStyleAnimation::Value& aResult) StyleAnimationValue& aResult)
{ {
DebugOnly<bool> success = DebugOnly<bool> success =
nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext, aResult); StyleAnimationValue::ExtractComputedValue(aProperty, aStyleContext,
aResult);
NS_ABORT_IF_FALSE(success, NS_ABORT_IF_FALSE(success,
"aProperty must be extractable by nsStyleAnimation"); "aProperty must be extractable by StyleAnimationValue");
} }
static nscolor static nscolor
ExtractColor(nsCSSProperty aProperty, ExtractColor(nsCSSProperty aProperty,
nsStyleContext *aStyleContext) nsStyleContext *aStyleContext)
{ {
nsStyleAnimation::Value val; StyleAnimationValue val;
ExtractAnimationValue(aProperty, aStyleContext, val); ExtractAnimationValue(aProperty, aStyleContext, val);
return val.GetColorValue(); return val.GetColorValue();
} }
@ -767,9 +768,9 @@ static nscolor
ExtractColorLenient(nsCSSProperty aProperty, ExtractColorLenient(nsCSSProperty aProperty,
nsStyleContext *aStyleContext) nsStyleContext *aStyleContext)
{ {
nsStyleAnimation::Value val; StyleAnimationValue val;
ExtractAnimationValue(aProperty, aStyleContext, val); ExtractAnimationValue(aProperty, aStyleContext, val);
if (val.GetUnit() == nsStyleAnimation::eUnit_Color) { if (val.GetUnit() == StyleAnimationValue::eUnit_Color) {
return val.GetColorValue(); return val.GetColorValue();
} }
return NS_RGBA(0, 0, 0, 0); return NS_RGBA(0, 0, 0, 0);

View File

@ -293,7 +293,7 @@ public:
* Get a color that depends on link-visitedness using this and * Get a color that depends on link-visitedness using this and
* this->GetStyleIfVisited(). * this->GetStyleIfVisited().
* *
* aProperty must be a color-valued property that nsStyleAnimation * aProperty must be a color-valued property that StyleAnimationValue
* knows how to extract. It must also be a property that we know to * knows how to extract. It must also be a property that we know to
* do change handling for in nsStyleContext::CalcDifference. * do change handling for in nsStyleContext::CalcDifference.
* *

View File

@ -53,7 +53,7 @@ ProcessTranslatePart(const nsCSSValue& aValue,
// Handle this here (even though nsRuleNode::CalcLength handles it // Handle this here (even though nsRuleNode::CalcLength handles it
// fine) so that callers are allowed to pass a null style context // fine) so that callers are allowed to pass a null style context
// and pres context to SetToTransformFunction if they know (as // and pres context to SetToTransformFunction if they know (as
// nsStyleAnimation does) that all lengths within the transform // StyleAnimationValue does) that all lengths within the transform
// function have already been computed to pixels and percents. // function have already been computed to pixels and percents.
// //
// Raw numbers are treated as being pixels. // Raw numbers are treated as being pixels.
@ -180,7 +180,9 @@ ProcessInterpolateMatrix(gfx3DMatrix& aMatrix,
} }
double progress = aData->Item(3).GetPercentValue(); double progress = aData->Item(3).GetPercentValue();
aMatrix = nsStyleAnimation::InterpolateTransformMatrix(matrix1, matrix2, progress) * aMatrix; aMatrix =
StyleAnimationValue::InterpolateTransformMatrix(matrix1, matrix2, progress)
* aMatrix;
} }
/* Helper function to process a translatex function. */ /* Helper function to process a translatex function. */
@ -502,7 +504,7 @@ MatrixForTransformFunction(gfx3DMatrix& aMatrix,
NS_PRECONDITION(aData, "Why did you want to get data from a null array?"); NS_PRECONDITION(aData, "Why did you want to get data from a null array?");
// It's OK if aContext and aPresContext are null if the caller already // It's OK if aContext and aPresContext are null if the caller already
// knows that all length units have been converted to pixels (as // knows that all length units have been converted to pixels (as
// nsStyleAnimation does). // StyleAnimationValue does).
/* Get the keyword for the transform. */ /* Get the keyword for the transform. */

View File

@ -56,7 +56,7 @@ namespace nsStyleTransformMatrix {
* *
* aContext and aPresContext may be null if all of the (non-percent) * aContext and aPresContext may be null if all of the (non-percent)
* length values in aData are already known to have been converted to * length values in aData are already known to have been converted to
* eCSSUnit_Pixel (as they are in an nsStyleAnimation::Value) * eCSSUnit_Pixel (as they are in an StyleAnimationValue)
*/ */
gfx3DMatrix ReadTransforms(const nsCSSValueList* aList, gfx3DMatrix ReadTransforms(const nsCSSValueList* aList,
nsStyleContext* aContext, nsStyleContext* aContext,

View File

@ -302,7 +302,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
ElementAnimationPtrArray& animations = et->mAnimations; ElementAnimationPtrArray& animations = et->mAnimations;
uint32_t i = animations.Length(); uint32_t i = animations.Length();
NS_ABORT_IF_FALSE(i != 0, "empty transitions list?"); NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
nsStyleAnimation::Value currentValue; StyleAnimationValue currentValue;
do { do {
--i; --i;
ElementAnimation* animation = animations[i]; ElementAnimation* animation = animations[i];
@ -405,7 +405,7 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty,
nsRefPtr<ElementPropertyTransition> pt = new ElementPropertyTransition(); nsRefPtr<ElementPropertyTransition> pt = new ElementPropertyTransition();
nsStyleAnimation::Value startValue, endValue, dummyValue; StyleAnimationValue startValue, endValue, dummyValue;
bool haveValues = bool haveValues =
ExtractComputedValueForTransition(aProperty, aOldStyleContext, ExtractComputedValueForTransition(aProperty, aOldStyleContext,
startValue) && startValue) &&
@ -420,7 +420,7 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty,
// Check that we can interpolate between these values // Check that we can interpolate between these values
// (If this is ever a performance problem, we could add a // (If this is ever a performance problem, we could add a
// CanInterpolate method, but it seems fine for now.) // CanInterpolate method, but it seems fine for now.)
nsStyleAnimation::Interpolate(aProperty, startValue, endValue, StyleAnimationValue::Interpolate(aProperty, startValue, endValue,
0.5, dummyValue); 0.5, dummyValue);
bool haveCurrentTransition = false; bool haveCurrentTransition = false;

View File

@ -33,7 +33,7 @@ struct ElementPropertyTransition : public mozilla::ElementAnimation
// mProperties[0].mSegments[0].mFromValue, except when this transition // mProperties[0].mSegments[0].mFromValue, except when this transition
// started as the reversal of another in-progress transition. // started as the reversal of another in-progress transition.
// Needed so we can handle two reverses in a row. // Needed so we can handle two reverses in a row.
nsStyleAnimation::Value mStartForReversingTest; mozilla::StyleAnimationValue mStartForReversingTest;
// Likewise, the portion (in value space) of the "full" reversed // Likewise, the portion (in value space) of the "full" reversed
// transition that we're actually covering. For example, if a :hover // transition that we're actually covering. For example, if a :hover
// effect has a transition that moves the element 10px to the right // effect has a transition that moves the element 10px to the right