diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 056109be1831..fccef4ebedf1 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -2514,20 +2514,20 @@ static bool ComputeAnimationValue(nsCSSProperty aProperty, Element* aElement, const nsAString& aInput, - nsStyleAnimation::Value& aOutput) + StyleAnimationValue& aOutput) { - if (!nsStyleAnimation::ComputeValue(aProperty, aElement, aInput, - false, aOutput)) { + if (!StyleAnimationValue::ComputeValue(aProperty, aElement, aInput, + false, aOutput)) { return false; } // This matches TransExtractComputedValue in nsTransitionManager.cpp. if (aProperty == eCSSProperty_visibility) { - NS_ABORT_IF_FALSE(aOutput.GetUnit() == nsStyleAnimation::eUnit_Enumerated, - "unexpected unit"); + MOZ_ASSERT(aOutput.GetUnit() == StyleAnimationValue::eUnit_Enumerated, + "unexpected unit"); aOutput.SetIntValue(aOutput.GetIntValue(), - nsStyleAnimation::eUnit_Visibility); + StyleAnimationValue::eUnit_Visibility); } return true; @@ -2660,14 +2660,14 @@ nsDOMWindowUtils::ComputeAnimationDistance(nsIDOMElement* aElement, !nsCSSProps::IsShorthand(property), "should not have shorthand"); - nsStyleAnimation::Value v1, v2; + StyleAnimationValue v1, v2; if (property == eCSSProperty_UNKNOWN || !ComputeAnimationValue(property, content->AsElement(), aValue1, v1) || !ComputeAnimationValue(property, content->AsElement(), aValue2, v2)) { return NS_ERROR_ILLEGAL_VALUE; } - if (!nsStyleAnimation::ComputeDistance(property, v1, v2, *aResult)) { + if (!StyleAnimationValue::ComputeDistance(property, v1, v2, *aResult)) { return NS_ERROR_FAILURE; } diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 8f4650923080..3a121ab6a5f2 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -1385,10 +1385,10 @@ interface nsIDOMWindowUtils : nsISupports { 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 - * nsStyleAnimation::ComputeDistance for the given element and + * StyleAnimationValue::ComputeDistance for the given element and * property. */ double computeAnimationDistance(in nsIDOMElement element, diff --git a/dom/smil/nsSMILCSSValueType.cpp b/dom/smil/nsSMILCSSValueType.cpp index 7a0636faf7d4..b269326d6ca9 100644 --- a/dom/smil/nsSMILCSSValueType.cpp +++ b/dom/smil/nsSMILCSSValueType.cpp @@ -19,41 +19,42 @@ #include "nsIDocument.h" using namespace mozilla::dom; +using mozilla::StyleAnimationValue; /*static*/ nsSMILCSSValueType nsSMILCSSValueType::sSingleton; struct ValueWrapper { - ValueWrapper(nsCSSProperty aPropID, const nsStyleAnimation::Value& aValue) : + ValueWrapper(nsCSSProperty aPropID, const StyleAnimationValue& aValue) : mPropID(aPropID), mCSSValue(aValue) {} nsCSSProperty mPropID; - nsStyleAnimation::Value mCSSValue; + StyleAnimationValue mCSSValue; }; // Helper Methods // -------------- -static const nsStyleAnimation::Value* -GetZeroValueForUnit(nsStyleAnimation::Unit aUnit) +static const StyleAnimationValue* +GetZeroValueForUnit(StyleAnimationValue::Unit aUnit) { - static const nsStyleAnimation::Value - sZeroCoord(0, nsStyleAnimation::Value::CoordConstructor); - static const nsStyleAnimation::Value - sZeroPercent(0.0f, nsStyleAnimation::Value::PercentConstructor); - static const nsStyleAnimation::Value - sZeroFloat(0.0f, nsStyleAnimation::Value::FloatConstructor); - static const nsStyleAnimation::Value - sZeroColor(NS_RGB(0,0,0), nsStyleAnimation::Value::ColorConstructor); + static const StyleAnimationValue + sZeroCoord(0, StyleAnimationValue::CoordConstructor); + static const StyleAnimationValue + sZeroPercent(0.0f, StyleAnimationValue::PercentConstructor); + static const StyleAnimationValue + sZeroFloat(0.0f, StyleAnimationValue::FloatConstructor); + static const StyleAnimationValue + 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"); switch (aUnit) { - case nsStyleAnimation::eUnit_Coord: + case StyleAnimationValue::eUnit_Coord: return &sZeroCoord; - case nsStyleAnimation::eUnit_Percent: + case StyleAnimationValue::eUnit_Percent: return &sZeroPercent; - case nsStyleAnimation::eUnit_Float: + case StyleAnimationValue::eUnit_Float: return &sZeroFloat; - case nsStyleAnimation::eUnit_Color: + case StyleAnimationValue::eUnit_Color: return &sZeroColor; default: return nullptr; @@ -71,8 +72,8 @@ GetZeroValueForUnit(nsStyleAnimation::Unit aUnit) // // Returns true on success, or false. static const bool -FinalizeStyleAnimationValues(const nsStyleAnimation::Value*& aValue1, - const nsStyleAnimation::Value*& aValue2) +FinalizeStyleAnimationValues(const StyleAnimationValue*& aValue1, + const StyleAnimationValue*& aValue2) { NS_ABORT_IF_FALSE(aValue1 || aValue2, "expecting at least one non-null value"); @@ -90,32 +91,32 @@ FinalizeStyleAnimationValues(const nsStyleAnimation::Value*& aValue1, // Ok, both values were specified. // Need to handle a special-case, though: unitless nonzero length (parsed as // 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. - const nsStyleAnimation::Value& zeroCoord = - *GetZeroValueForUnit(nsStyleAnimation::eUnit_Coord); + const StyleAnimationValue& zeroCoord = + *GetZeroValueForUnit(StyleAnimationValue::eUnit_Coord); if (*aValue1 == zeroCoord && - aValue2->GetUnit() == nsStyleAnimation::eUnit_Float) { - aValue1 = GetZeroValueForUnit(nsStyleAnimation::eUnit_Float); + aValue2->GetUnit() == StyleAnimationValue::eUnit_Float) { + aValue1 = GetZeroValueForUnit(StyleAnimationValue::eUnit_Float); } else if (*aValue2 == zeroCoord && - aValue1->GetUnit() == nsStyleAnimation::eUnit_Float) { - aValue2 = GetZeroValueForUnit(nsStyleAnimation::eUnit_Float); + aValue1->GetUnit() == StyleAnimationValue::eUnit_Float) { + aValue2 = GetZeroValueForUnit(StyleAnimationValue::eUnit_Float); } return true; } static void -InvertSign(nsStyleAnimation::Value& aValue) +InvertSign(StyleAnimationValue& aValue) { switch (aValue.GetUnit()) { - case nsStyleAnimation::eUnit_Coord: + case StyleAnimationValue::eUnit_Coord: aValue.SetCoordValue(-aValue.GetCoordValue()); break; - case nsStyleAnimation::eUnit_Percent: + case StyleAnimationValue::eUnit_Percent: aValue.SetPercentValue(-aValue.GetPercentValue()); break; - case nsStyleAnimation::eUnit_Float: + case StyleAnimationValue::eUnit_Float: aValue.SetFloatValue(-aValue.GetFloatValue()); break; default: @@ -224,15 +225,15 @@ nsSMILCSSValueType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, nsCSSProperty property = (valueToAddWrapper ? valueToAddWrapper->mPropID : destWrapper->mPropID); // 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 || property == eCSSProperty_stroke_dasharray) { return NS_ERROR_FAILURE; } - const nsStyleAnimation::Value* valueToAdd = valueToAddWrapper ? + const StyleAnimationValue* valueToAdd = valueToAddWrapper ? &valueToAddWrapper->mCSSValue : nullptr; - const nsStyleAnimation::Value* destValue = destWrapper ? + const StyleAnimationValue* destValue = destWrapper ? &destWrapper->mCSSValue : nullptr; if (!FinalizeStyleAnimationValues(valueToAdd, destValue)) { return NS_ERROR_FAILURE; @@ -249,8 +250,8 @@ nsSMILCSSValueType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd, new ValueWrapper(property, *destValue); } - return nsStyleAnimation::Add(property, - destWrapper->mCSSValue, *valueToAdd, aCount) ? + return StyleAnimationValue::Add(property, + destWrapper->mCSSValue, *valueToAdd, aCount) ? NS_OK : NS_ERROR_FAILURE; } @@ -267,16 +268,16 @@ nsSMILCSSValueType::ComputeDistance(const nsSMILValue& aFrom, const ValueWrapper* toWrapper = ExtractValueWrapper(aTo); NS_ABORT_IF_FALSE(toWrapper, "expecting non-null endpoint"); - const nsStyleAnimation::Value* fromCSSValue = fromWrapper ? + const StyleAnimationValue* fromCSSValue = fromWrapper ? &fromWrapper->mCSSValue : nullptr; - const nsStyleAnimation::Value* toCSSValue = &toWrapper->mCSSValue; + const StyleAnimationValue* toCSSValue = &toWrapper->mCSSValue; if (!FinalizeStyleAnimationValues(fromCSSValue, toCSSValue)) { return NS_ERROR_FAILURE; } - return nsStyleAnimation::ComputeDistance(toWrapper->mPropID, - *fromCSSValue, *toCSSValue, - aDistance) ? + return StyleAnimationValue::ComputeDistance(toWrapper->mPropID, + *fromCSSValue, *toCSSValue, + aDistance) ? NS_OK : NS_ERROR_FAILURE; } @@ -299,17 +300,17 @@ nsSMILCSSValueType::Interpolate(const nsSMILValue& aStartVal, const ValueWrapper* endWrapper = ExtractValueWrapper(aEndVal); NS_ABORT_IF_FALSE(endWrapper, "expecting non-null endpoint"); - const nsStyleAnimation::Value* startCSSValue = startWrapper ? + const StyleAnimationValue* startCSSValue = startWrapper ? &startWrapper->mCSSValue : nullptr; - const nsStyleAnimation::Value* endCSSValue = &endWrapper->mCSSValue; + const StyleAnimationValue* endCSSValue = &endWrapper->mCSSValue; if (!FinalizeStyleAnimationValues(startCSSValue, endCSSValue)) { return NS_ERROR_FAILURE; } - nsStyleAnimation::Value resultValue; - if (nsStyleAnimation::Interpolate(endWrapper->mPropID, - *startCSSValue, *endCSSValue, - aUnitDistance, resultValue)) { + StyleAnimationValue resultValue; + if (StyleAnimationValue::Interpolate(endWrapper->mPropID, + *startCSSValue, *endCSSValue, + aUnitDistance, resultValue)) { aResult.mU.mPtr = new ValueWrapper(endWrapper->mPropID, resultValue); return NS_OK; } @@ -331,13 +332,13 @@ GetPresContextForElement(Element* aElem) 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 ValueFromStringHelper(nsCSSProperty aPropID, Element* aTargetElement, nsPresContext* aPresContext, const nsAString& aString, - nsStyleAnimation::Value& aStyleAnimValue, + StyleAnimationValue& aStyleAnimValue, bool* aIsContextSensitive) { // If value is negative, we'll strip off the "-" so the CSS parser won't @@ -358,19 +359,19 @@ ValueFromStringHelper(nsCSSProperty aPropID, } } nsDependentSubstring subString(aString, subStringBegin); - if (!nsStyleAnimation::ComputeValue(aPropID, aTargetElement, subString, - true, aStyleAnimValue, - aIsContextSensitive)) { + if (!StyleAnimationValue::ComputeValue(aPropID, aTargetElement, subString, + true, aStyleAnimValue, + aIsContextSensitive)) { return false; } if (isNegative) { InvertSign(aStyleAnimValue); } - + if (aPropID == eCSSProperty_font_size) { // Divide out text-zoom, since SVG is supposed to ignore it NS_ABORT_IF_FALSE(aStyleAnimValue.GetUnit() == - nsStyleAnimation::eUnit_Coord, + StyleAnimationValue::eUnit_Coord, "'font-size' value with unexpected style unit"); aStyleAnimValue.SetCoordValue(aStyleAnimValue.GetCoordValue() / aPresContext->TextZoom()); @@ -401,7 +402,7 @@ nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID, return; } - nsStyleAnimation::Value parsedValue; + StyleAnimationValue parsedValue; if (ValueFromStringHelper(aPropID, aTargetElement, presContext, aString, parsedValue, aIsContextSensitive)) { sSingleton.Init(aValue); @@ -418,6 +419,6 @@ nsSMILCSSValueType::ValueToString(const nsSMILValue& aValue, "Unexpected SMIL value type"); const ValueWrapper* wrapper = ExtractValueWrapper(aValue); return !wrapper || - nsStyleAnimation::UncomputeValue(wrapper->mPropID, - wrapper->mCSSValue, aString); + StyleAnimationValue::UncomputeValue(wrapper->mPropID, + wrapper->mCSSValue, aString); } diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 714842a1efbd..97c8805c9c81 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -247,28 +247,32 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) case TransformFunction::TRotationX: { 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); break; } case TransformFunction::TRotationY: { 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); break; } case TransformFunction::TRotationZ: { 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); break; } case TransformFunction::TRotation: { 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); break; } @@ -278,7 +282,9 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) float y = aFunctions[i].get_Rotation3D().y(); float z = aFunctions[i].get_Rotation3D().z(); 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(2).SetFloatValue(y, eCSSUnit_Number); arr->Item(3).SetFloatValue(z, eCSSUnit_Number); @@ -287,7 +293,9 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) } 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(2).SetFloatValue(aFunctions[i].get_Scale().y(), eCSSUnit_Number); arr->Item(3).SetFloatValue(aFunctions[i].get_Scale().z(), eCSSUnit_Number); @@ -295,7 +303,9 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) } 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(2).SetFloatValue(aFunctions[i].get_Translation().y(), eCSSUnit_Pixel); arr->Item(3).SetFloatValue(aFunctions[i].get_Translation().z(), eCSSUnit_Pixel); @@ -304,27 +314,32 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) case TransformFunction::TSkewX: { 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); break; } case TransformFunction::TSkewY: { 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); break; } 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(2).SetFloatValue(aFunctions[i].get_Skew().y(), eCSSUnit_Radian); break; } case TransformFunction::TTransformMatrix: { - arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_matrix3d, resultTail); + arr = + StyleAnimationValue::AppendTransformFunction(eCSSKeyword_matrix3d, + resultTail); const gfx::Matrix4x4& matrix = aFunctions[i].get_TransformMatrix().value(); arr->Item(1).SetFloatValue(matrix._11, eCSSUnit_Number); arr->Item(2).SetFloatValue(matrix._12, eCSSUnit_Number); @@ -347,7 +362,9 @@ CreateCSSValueList(const InfallibleTArray& aFunctions) case TransformFunction::TPerspective: { 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); break; } @@ -396,14 +413,14 @@ Layer::SetAnimations(const AnimationArray& aAnimations) 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. - InfallibleTArray& startValues = data->mStartValues; - InfallibleTArray& endValues = data->mEndValues; + InfallibleTArray& startValues = data->mStartValues; + InfallibleTArray& endValues = data->mEndValues; for (uint32_t j = 0; j < mAnimations[i].segments().Length(); j++) { const AnimationSegment& segment = mAnimations[i].segments()[j]; - nsStyleAnimation::Value* startValue = startValues.AppendElement(); - nsStyleAnimation::Value* endValue = endValues.AppendElement(); + StyleAnimationValue* startValue = startValues.AppendElement(); + StyleAnimationValue* endValue = endValues.AppendElement(); if (segment.endState().type() == Animatable::TArrayOfTransformFunction) { const InfallibleTArray& startFunctions = segment.startState().get_ArrayOfTransformFunction(); diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index d16f3d106b8e..8e5e05dc1f52 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -54,6 +54,7 @@ extern uint8_t gLayerManagerLayerBuilder; namespace mozilla { class FrameLayerBuilder; +class StyleAnimationValue; class WebGLContext; namespace gl { @@ -686,8 +687,8 @@ private: typedef InfallibleTArray AnimationArray; struct AnimData { - InfallibleTArray mStartValues; - InfallibleTArray mEndValues; + InfallibleTArray mStartValues; + InfallibleTArray mEndValues; InfallibleTArray > mFunctions; }; diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index c79dc8b356da..a6798f798a6f 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -30,7 +30,7 @@ #include "nsPoint.h" // for nsPoint #include "nsRect.h" // for nsIntRect #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 "nsTArrayForwardDeclare.h" // for InfallibleTArray #if defined(MOZ_WIDGET_ANDROID) @@ -354,14 +354,15 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, } static void -SampleValue(float aPortion, Animation& aAnimation, nsStyleAnimation::Value& aStart, - nsStyleAnimation::Value& aEnd, Animatable* aValue) +SampleValue(float aPortion, Animation& aAnimation, StyleAnimationValue& aStart, + StyleAnimationValue& aEnd, Animatable* aValue) { - nsStyleAnimation::Value interpolatedValue; + StyleAnimationValue interpolatedValue; NS_ASSERTION(aStart.GetUnit() == aEnd.GetUnit() || - aStart.GetUnit() == nsStyleAnimation::eUnit_None || - aEnd.GetUnit() == nsStyleAnimation::eUnit_None, "Must have same unit"); - nsStyleAnimation::Interpolate(aAnimation.property(), aStart, aEnd, + aStart.GetUnit() == StyleAnimationValue::eUnit_None || + aEnd.GetUnit() == StyleAnimationValue::eUnit_None, + "Must have same unit"); + StyleAnimationValue::Interpolate(aAnimation.property(), aStart, aEnd, aPortion, interpolatedValue); if (aAnimation.property() == eCSSProperty_opacity) { *aValue = interpolatedValue.GetFloatValue(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 8783718826c9..cb6a12346b2e 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -335,14 +335,13 @@ nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent, } static gfxSize -GetScaleForValue(const nsStyleAnimation::Value& aValue, - nsIFrame* aFrame) +GetScaleForValue(const StyleAnimationValue& aValue, nsIFrame* aFrame) { if (!aFrame) { NS_WARNING("No frame."); return gfxSize(); } - if (aValue.GetUnit() != nsStyleAnimation::eUnit_Transform) { + if (aValue.GetUnit() != StyleAnimationValue::eUnit_Transform) { NS_WARNING("Expected a transform."); return gfxSize(); } diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 769c93265204..0cacbb076ae0 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -166,17 +166,17 @@ CommonAnimationManager::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) CommonAnimationManager::ExtractComputedValueForTransition( nsCSSProperty aProperty, nsStyleContext* aStyleContext, - nsStyleAnimation::Value& aComputedValue) + StyleAnimationValue& aComputedValue) { - bool result = - nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext, - aComputedValue); + bool result = StyleAnimationValue::ExtractComputedValue(aProperty, + aStyleContext, + aComputedValue); if (aProperty == eCSSProperty_visibility) { NS_ABORT_IF_FALSE(aComputedValue.GetUnit() == - nsStyleAnimation::eUnit_Enumerated, + StyleAnimationValue::eUnit_Enumerated, "unexpected unit"); aComputedValue.SetIntValue(aComputedValue.GetIntValue(), - nsStyleAnimation::eUnit_Visibility); + StyleAnimationValue::eUnit_Visibility); } return result; } @@ -331,7 +331,7 @@ AnimValuesStyleRule::MapRuleInfoInto(nsRuleData* aRuleData) #ifdef DEBUG bool ok = #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"); } } @@ -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) { const PropertyValuePair &pair = mPropertyValuePairs[i]; 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(), NS_ConvertUTF16toUTF8(value).get()); } @@ -889,15 +889,16 @@ CommonElementAnimationData::EnsureStyleRuleFor(TimeStamp aRefreshTime, double valuePosition = segment->mTimingFunction.GetValue(positionInSegment); - nsStyleAnimation::Value *val = + StyleAnimationValue *val = mStyleRule->AddEmptyValue(prop.mProperty); #ifdef DEBUG bool result = #endif - nsStyleAnimation::Interpolate(prop.mProperty, - segment->mFromValue, segment->mToValue, - valuePosition, *val); + StyleAnimationValue::Interpolate(prop.mProperty, + segment->mFromValue, + segment->mToValue, + valuePosition, *val); NS_ABORT_IF_FALSE(result, "interpolate must succeed now"); } } diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index 3db1369e4e40..562c80b3a442 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -27,6 +27,9 @@ struct ElementPropertyTransition; namespace mozilla { + +class StyleAnimationValue; + namespace css { bool IsGeometricProperty(nsCSSProperty aProperty); @@ -66,7 +69,7 @@ public: static bool ExtractComputedValueForTransition( nsCSSProperty aProperty, nsStyleContext* aStyleContext, - nsStyleAnimation::Value& aComputedValue); + mozilla::StyleAnimationValue& aComputedValue); protected: 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 { @@ -174,14 +177,15 @@ public: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; #endif - void AddValue(nsCSSProperty aProperty, nsStyleAnimation::Value &aStartValue) + void AddValue(nsCSSProperty aProperty, + mozilla::StyleAnimationValue &aStartValue) { PropertyValuePair v = { aProperty, aStartValue }; mPropertyValuePairs.AppendElement(v); } // Caller must fill in returned value. - nsStyleAnimation::Value* AddEmptyValue(nsCSSProperty aProperty) + mozilla::StyleAnimationValue* AddEmptyValue(nsCSSProperty aProperty) { PropertyValuePair *p = mPropertyValuePairs.AppendElement(); p->mProperty = aProperty; @@ -190,7 +194,7 @@ public: struct PropertyValuePair { nsCSSProperty mProperty; - nsStyleAnimation::Value mValue; + mozilla::StyleAnimationValue mValue; }; private: @@ -221,7 +225,7 @@ private: struct AnimationPropertySegment { float mFromKey, mToKey; - nsStyleAnimation::Value mFromValue, mToValue; + mozilla::StyleAnimationValue mFromValue, mToValue; mozilla::css::ComputedTimingFunction mTimingFunction; }; diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index d09c0203289e..e08bdd66d206 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -392,7 +392,7 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext, // whether they are resolved relative to other animations: I assume // 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 - // nsStyleAnimation::Value values in AnimationPropertySegment). + // StyleAnimationValue values in AnimationPropertySegment). nsStyleContext *result = mCache.GetWeak(aKeyframe); if (!result) { nsCOMArray rules; @@ -602,14 +602,14 @@ nsAnimationManager::BuildSegment(InfallibleTArray& mozilla::css::Declaration* aFromDeclaration, float aToKey, nsStyleContext* aToContext) { - nsStyleAnimation::Value fromValue, toValue, dummyValue; + StyleAnimationValue fromValue, toValue, dummyValue; if (!ExtractComputedValueForTransition(aProperty, aFromContext, fromValue) || !ExtractComputedValueForTransition(aProperty, aToContext, toValue) || // Check that we can interpolate between these values // (If this is ever a performance problem, we could add a // CanInterpolate method, but it seems fine for now.) - !nsStyleAnimation::Interpolate(aProperty, fromValue, toValue, - 0.5, dummyValue)) { + !StyleAnimationValue::Interpolate(aProperty, fromValue, toValue, + 0.5, dummyValue)) { return false; } diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 7b4d0401f35e..c37005ebad17 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -218,7 +218,7 @@ static_assert((CSS_PROPERTY_PARSE_PROPERTY_MASK & */ enum nsStyleAnimType { // requires a custom implementation in - // nsStyleAnimation::ExtractComputedValue + // StyleAnimationValue::ExtractComputedValue eStyleAnimType_Custom, // nsStyleCoord with animatable values diff --git a/layout/style/nsStyleAnimation.cpp b/layout/style/nsStyleAnimation.cpp index 9eef1c8fecd4..4f8c2728f4b5 100644 --- a/layout/style/nsStyleAnimation.cpp +++ b/layout/style/nsStyleAnimation.cpp @@ -45,23 +45,23 @@ using namespace mozilla; * eUnit_Null if that's not possible. */ static -nsStyleAnimation::Unit +StyleAnimationValue::Unit GetCommonUnit(nsCSSProperty aProperty, - nsStyleAnimation::Unit aFirstUnit, - nsStyleAnimation::Unit aSecondUnit) + StyleAnimationValue::Unit aFirstUnit, + StyleAnimationValue::Unit aSecondUnit) { if (aFirstUnit != aSecondUnit) { if (nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_STORES_CALC) && - (aFirstUnit == nsStyleAnimation::eUnit_Coord || - aFirstUnit == nsStyleAnimation::eUnit_Percent || - aFirstUnit == nsStyleAnimation::eUnit_Calc) && - (aSecondUnit == nsStyleAnimation::eUnit_Coord || - aSecondUnit == nsStyleAnimation::eUnit_Percent || - aSecondUnit == nsStyleAnimation::eUnit_Calc)) { + (aFirstUnit == StyleAnimationValue::eUnit_Coord || + aFirstUnit == StyleAnimationValue::eUnit_Percent || + aFirstUnit == StyleAnimationValue::eUnit_Calc) && + (aSecondUnit == StyleAnimationValue::eUnit_Coord || + aSecondUnit == StyleAnimationValue::eUnit_Percent || + aSecondUnit == StyleAnimationValue::eUnit_Calc)) { // 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; } @@ -316,23 +316,23 @@ ExtractCalcValueInternal(const nsCSSValue& aValue) // Requires a canonical calc() value that we generated. static PixelCalcValue -ExtractCalcValue(const nsStyleAnimation::Value& aValue) +ExtractCalcValue(const StyleAnimationValue& aValue) { PixelCalcValue result; - if (aValue.GetUnit() == nsStyleAnimation::eUnit_Coord) { + if (aValue.GetUnit() == StyleAnimationValue::eUnit_Coord) { result.mLength = nsPresContext::AppUnitsToFloatCSSPixels(aValue.GetCoordValue()); result.mPercent = 0.0f; result.mHasPercent = false; return result; } - if (aValue.GetUnit() == nsStyleAnimation::eUnit_Percent) { + if (aValue.GetUnit() == StyleAnimationValue::eUnit_Percent) { result.mLength = 0.0f; result.mPercent = aValue.GetPercentValue(); result.mHasPercent = true; return result; } - NS_ABORT_IF_FALSE(aValue.GetUnit() == nsStyleAnimation::eUnit_Calc, + NS_ABORT_IF_FALSE(aValue.GetUnit() == StyleAnimationValue::eUnit_Calc, "unexpected unit"); nsCSSValue *val = aValue.GetCSSValueValue(); return ExtractCalcValueInternal(*val); @@ -403,10 +403,10 @@ GetURIAsUtf16StringBuffer(nsIURI* aUri) // ------------- bool -nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, - const Value& aStartValue, - const Value& aEndValue, - double& aDistance) +StyleAnimationValue::ComputeDistance(nsCSSProperty aProperty, + const StyleAnimationValue& aStartValue, + const StyleAnimationValue& aEndValue, + double& aDistance) { Unit commonUnit = GetCommonUnit(aProperty, aStartValue.GetUnit(), aEndValue.GetUnit()); @@ -664,7 +664,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, // particularly useful for paced animation. // 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, normValue1) || !AddWeighted(aProperty, 0.0, aStartValue, 1.0, aEndValue, @@ -707,7 +707,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, } case eUnit_Shadow: { // 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, normValue1) || !AddWeighted(aProperty, 0.0, aStartValue, 1.0, aEndValue, @@ -752,18 +752,18 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, #endif if (color1.GetUnit() != eCSSUnit_Null) { - nsStyleAnimation::Value color1Value - (color1.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); - nsStyleAnimation::Value color2Value - (color2.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); + StyleAnimationValue color1Value + (color1.GetColorValue(), StyleAnimationValue::ColorConstructor); + StyleAnimationValue color2Value + (color2.GetColorValue(), StyleAnimationValue::ColorConstructor); double colorDistance; #ifdef DEBUG bool ok = #endif - nsStyleAnimation::ComputeDistance(eCSSProperty_color, - color1Value, color2Value, - colorDistance); + StyleAnimationValue::ComputeDistance(eCSSProperty_color, + color1Value, color2Value, + colorDistance); NS_ABORT_IF_FALSE(ok, "should not fail"); squareDistance += colorDistance * colorDistance; } @@ -1121,16 +1121,18 @@ AddShadowItems(double aCoeff1, const nsCSSValue &aValue1, } if (color1.GetUnit() != eCSSUnit_Null) { - nsStyleAnimation::Value color1Value - (color1.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); - nsStyleAnimation::Value color2Value - (color2.GetColorValue(), nsStyleAnimation::Value::ColorConstructor); - nsStyleAnimation::Value resultColorValue; + StyleAnimationValue color1Value + (color1.GetColorValue(), StyleAnimationValue::ColorConstructor); + StyleAnimationValue color2Value + (color2.GetColorValue(), StyleAnimationValue::ColorConstructor); + StyleAnimationValue resultColorValue; #ifdef DEBUG bool ok = #endif - nsStyleAnimation::AddWeighted(eCSSProperty_color, aCoeff1, color1Value, - aCoeff2, color2Value, resultColorValue); + StyleAnimationValue::AddWeighted(eCSSProperty_color, + aCoeff1, color1Value, + aCoeff2, color2Value, + resultColorValue); NS_ABORT_IF_FALSE(ok, "should not fail"); resultArray->Item(4).SetColorValue(resultColorValue.GetColorValue()); } @@ -1193,8 +1195,8 @@ AddTransformScale(double aCoeff1, const nsCSSValue &aValue1, } /* static */ already_AddRefed -nsStyleAnimation::AppendTransformFunction(nsCSSKeyword aTransformFunction, - nsCSSValueList**& aListTail) +StyleAnimationValue::AppendTransformFunction(nsCSSKeyword aTransformFunction, + nsCSSValueList**& aListTail) { nsRefPtr arr = AppendFunction(aTransformFunction); nsCSSValueList *item = new nsCSSValueList; @@ -1498,9 +1500,9 @@ T InterpolateNumerically(const T& aOne, const T& aTwo, double aCoeff) /* static */ gfx3DMatrix -nsStyleAnimation::InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1, - const gfx3DMatrix &aMatrix2, - double aProgress) +StyleAnimationValue::InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1, + const gfx3DMatrix &aMatrix2, + double aProgress) { // Decompose both matrices @@ -1580,7 +1582,9 @@ AddDifferentTransformLists(double aCoeff1, const nsCSSValueList* aList1, nsCSSValueList **resultTail = getter_Transfers(result); nsRefPtr arr; - arr = nsStyleAnimation::AppendTransformFunction(eCSSKeyword_interpolatematrix, resultTail); + arr = + StyleAnimationValue::AppendTransformFunction(eCSSKeyword_interpolatematrix, + resultTail); // FIXME: We should change the other transform code to also only // 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_rotate3d && tfunc != eCSSKeyword_perspective) { - arr = nsStyleAnimation::AppendTransformFunction(tfunc, resultTail); + arr = StyleAnimationValue::AppendTransformFunction(tfunc, resultTail); } switch (tfunc) { @@ -1852,10 +1856,12 @@ AddTransformLists(double aCoeff1, const nsCSSValueList* aList1, } bool -nsStyleAnimation::AddWeighted(nsCSSProperty aProperty, - double aCoeff1, const Value& aValue1, - double aCoeff2, const Value& aValue2, - Value& aResultValue) +StyleAnimationValue::AddWeighted(nsCSSProperty aProperty, + double aCoeff1, + const StyleAnimationValue& aValue1, + double aCoeff2, + const StyleAnimationValue& aValue2, + StyleAnimationValue& aResultValue) { Unit commonUnit = GetCommonUnit(aProperty, aValue1.GetUnit(), aValue2.GetUnit()); @@ -2473,12 +2479,12 @@ LookupStyleContext(dom::Element* aElement) } bool -nsStyleAnimation::ComputeValue(nsCSSProperty aProperty, - dom::Element* aTargetElement, - const nsAString& aSpecifiedValue, - bool aUseSVGMode, - Value& aComputedValue, - bool* aIsContextSensitive) +StyleAnimationValue::ComputeValue(nsCSSProperty aProperty, + dom::Element* aTargetElement, + const nsAString& aSpecifiedValue, + bool aUseSVGMode, + StyleAnimationValue& aComputedValue, + bool* aIsContextSensitive) { NS_ABORT_IF_FALSE(aTargetElement, "null target element"); NS_ABORT_IF_FALSE(aTargetElement->GetCurrentDoc(), @@ -2560,9 +2566,9 @@ nsStyleAnimation::ComputeValue(nsCSSProperty aProperty, } bool -nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, - const Value& aComputedValue, - nsCSSValue& aSpecifiedValue) +StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty, + const StyleAnimationValue& aComputedValue, + nsCSSValue& aSpecifiedValue) { switch (aComputedValue.GetUnit()) { case eUnit_Normal: @@ -2653,9 +2659,9 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, } bool -nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, - const Value& aComputedValue, - nsAString& aSpecifiedValue) +StyleAnimationValue::UncomputeValue(nsCSSProperty aProperty, + const StyleAnimationValue& aComputedValue, + nsAString& aSpecifiedValue) { aSpecifiedValue.Truncate(); // Clear outparam, if it's not already empty @@ -2664,7 +2670,7 @@ nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty, return true; } nsCSSValue val; - if (!nsStyleAnimation::UncomputeValue(aProperty, aComputedValue, val)) { + if (!StyleAnimationValue::UncomputeValue(aProperty, aComputedValue, val)) { return false; } @@ -2686,7 +2692,8 @@ StyleDataAtOffset(void* aStyleStruct, ptrdiff_t aOffset) static void ExtractBorderColor(nsStyleContext* aStyleContext, const void* aStyleBorder, - mozilla::css::Side aSide, nsStyleAnimation::Value& aComputedValue) + mozilla::css::Side aSide, + StyleAnimationValue& aComputedValue) { nscolor color; bool foreground; @@ -2700,7 +2707,7 @@ ExtractBorderColor(nsStyleContext* aStyleContext, const void* aStyleBorder, } static bool -StyleCoordToValue(const nsStyleCoord& aCoord, nsStyleAnimation::Value& aValue) +StyleCoordToValue(const nsStyleCoord& aCoord, StyleAnimationValue& aValue) { switch (aCoord.GetUnit()) { case eStyleUnit_Normal: @@ -2723,17 +2730,17 @@ StyleCoordToValue(const nsStyleCoord& aCoord, nsStyleAnimation::Value& aValue) break; case eStyleUnit_Enumerated: aValue.SetIntValue(aCoord.GetIntValue(), - nsStyleAnimation::eUnit_Enumerated); + StyleAnimationValue::eUnit_Enumerated); break; case eStyleUnit_Integer: aValue.SetIntValue(aCoord.GetIntValue(), - nsStyleAnimation::eUnit_Integer); + StyleAnimationValue::eUnit_Integer); break; case eStyleUnit_Calc: { nsAutoPtr val(new nsCSSValue); SetCalcValue(aCoord.GetCalcValue(), *val); aValue.SetAndAdoptCSSValueValue(val.forget(), - nsStyleAnimation::eUnit_Calc); + StyleAnimationValue::eUnit_Calc); break; } default: @@ -2820,9 +2827,9 @@ SubstitutePixelValues(nsStyleContext* aStyleContext, } bool -nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty, - nsStyleContext* aStyleContext, - Value& aComputedValue) +StyleAnimationValue::ExtractComputedValue(nsCSSProperty aProperty, + nsStyleContext* aStyleContext, + StyleAnimationValue& aComputedValue) { NS_ABORT_IF_FALSE(0 <= aProperty && aProperty < eCSSProperty_COUNT_no_shorthands, @@ -3461,42 +3468,43 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty, return false; } -nsStyleAnimation::Value::Value(int32_t aInt, Unit aUnit, - IntegerConstructorType) +StyleAnimationValue::StyleAnimationValue(int32_t aInt, Unit aUnit, + IntegerConstructorType) { NS_ASSERTION(IsIntUnit(aUnit), "unit must be of integer type"); mUnit = aUnit; mValue.mInt = aInt; } -nsStyleAnimation::Value::Value(nscoord aLength, CoordConstructorType) +StyleAnimationValue::StyleAnimationValue(nscoord aLength, CoordConstructorType) { mUnit = eUnit_Coord; mValue.mCoord = aLength; } -nsStyleAnimation::Value::Value(float aPercent, PercentConstructorType) +StyleAnimationValue::StyleAnimationValue(float aPercent, + PercentConstructorType) { mUnit = eUnit_Percent; mValue.mFloat = aPercent; MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); } -nsStyleAnimation::Value::Value(float aFloat, FloatConstructorType) +StyleAnimationValue::StyleAnimationValue(float aFloat, FloatConstructorType) { mUnit = eUnit_Float; mValue.mFloat = aFloat; MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); } -nsStyleAnimation::Value::Value(nscolor aColor, ColorConstructorType) +StyleAnimationValue::StyleAnimationValue(nscolor aColor, ColorConstructorType) { mUnit = eUnit_Color; mValue.mColor = aColor; } -nsStyleAnimation::Value& -nsStyleAnimation::Value::operator=(const Value& aOther) +StyleAnimationValue& +StyleAnimationValue::operator=(const StyleAnimationValue& aOther) { FreeValue(); @@ -3592,28 +3600,28 @@ nsStyleAnimation::Value::operator=(const Value& aOther) } void -nsStyleAnimation::Value::SetNormalValue() +StyleAnimationValue::SetNormalValue() { FreeValue(); mUnit = eUnit_Normal; } void -nsStyleAnimation::Value::SetAutoValue() +StyleAnimationValue::SetAutoValue() { FreeValue(); mUnit = eUnit_Auto; } void -nsStyleAnimation::Value::SetNoneValue() +StyleAnimationValue::SetNoneValue() { FreeValue(); mUnit = eUnit_None; } 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"); FreeValue(); @@ -3622,7 +3630,7 @@ nsStyleAnimation::Value::SetIntValue(int32_t aInt, Unit aUnit) } void -nsStyleAnimation::Value::SetCoordValue(nscoord aLength) +StyleAnimationValue::SetCoordValue(nscoord aLength) { FreeValue(); mUnit = eUnit_Coord; @@ -3630,7 +3638,7 @@ nsStyleAnimation::Value::SetCoordValue(nscoord aLength) } void -nsStyleAnimation::Value::SetPercentValue(float aPercent) +StyleAnimationValue::SetPercentValue(float aPercent) { FreeValue(); mUnit = eUnit_Percent; @@ -3639,7 +3647,7 @@ nsStyleAnimation::Value::SetPercentValue(float aPercent) } void -nsStyleAnimation::Value::SetFloatValue(float aFloat) +StyleAnimationValue::SetFloatValue(float aFloat) { FreeValue(); mUnit = eUnit_Float; @@ -3648,7 +3656,7 @@ nsStyleAnimation::Value::SetFloatValue(float aFloat) } void -nsStyleAnimation::Value::SetColorValue(nscolor aColor) +StyleAnimationValue::SetColorValue(nscolor aColor) { FreeValue(); mUnit = eUnit_Color; @@ -3656,7 +3664,7 @@ nsStyleAnimation::Value::SetColorValue(nscolor aColor) } void -nsStyleAnimation::Value::SetUnparsedStringValue(const nsString& aString) +StyleAnimationValue::SetUnparsedStringValue(const nsString& aString) { FreeValue(); mUnit = eUnit_UnparsedString; @@ -3664,8 +3672,8 @@ nsStyleAnimation::Value::SetUnparsedStringValue(const nsString& aString) } void -nsStyleAnimation::Value::SetAndAdoptCSSValueValue(nsCSSValue *aValue, - Unit aUnit) +StyleAnimationValue::SetAndAdoptCSSValueValue(nsCSSValue *aValue, + Unit aUnit) { FreeValue(); NS_ABORT_IF_FALSE(IsCSSValueUnit(aUnit), "bad unit"); @@ -3675,8 +3683,8 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueValue(nsCSSValue *aValue, } void -nsStyleAnimation::Value::SetAndAdoptCSSValuePairValue( - nsCSSValuePair *aValuePair, Unit aUnit) +StyleAnimationValue::SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValuePair, + Unit aUnit) { FreeValue(); NS_ABORT_IF_FALSE(IsCSSValuePairUnit(aUnit), "bad unit"); @@ -3686,8 +3694,8 @@ nsStyleAnimation::Value::SetAndAdoptCSSValuePairValue( } void -nsStyleAnimation::Value::SetAndAdoptCSSValueTripletValue( - nsCSSValueTriplet *aValueTriplet, Unit aUnit) +StyleAnimationValue::SetAndAdoptCSSValueTripletValue( + nsCSSValueTriplet *aValueTriplet, Unit aUnit) { FreeValue(); NS_ABORT_IF_FALSE(IsCSSValueTripletUnit(aUnit), "bad unit"); @@ -3697,7 +3705,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueTripletValue( } void -nsStyleAnimation::Value::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit) +StyleAnimationValue::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit) { FreeValue(); NS_ABORT_IF_FALSE(IsCSSRectUnit(aUnit), "bad unit"); @@ -3707,8 +3715,8 @@ nsStyleAnimation::Value::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit) } void -nsStyleAnimation::Value::SetAndAdoptCSSValueListValue( - nsCSSValueList *aValueList, Unit aUnit) +StyleAnimationValue::SetAndAdoptCSSValueListValue(nsCSSValueList *aValueList, + Unit aUnit) { FreeValue(); NS_ABORT_IF_FALSE(IsCSSValueListUnit(aUnit), "bad unit"); @@ -3720,7 +3728,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValueListValue( } void -nsStyleAnimation::Value::SetTransformValue(nsCSSValueSharedList* aList) +StyleAnimationValue::SetTransformValue(nsCSSValueSharedList* aList) { FreeValue(); mUnit = eUnit_Transform; @@ -3729,8 +3737,8 @@ nsStyleAnimation::Value::SetTransformValue(nsCSSValueSharedList* aList) } void -nsStyleAnimation::Value::SetAndAdoptCSSValuePairListValue( - nsCSSValuePairList *aValuePairList) +StyleAnimationValue::SetAndAdoptCSSValuePairListValue( + nsCSSValuePairList *aValuePairList) { FreeValue(); NS_ABORT_IF_FALSE(aValuePairList, "may not be null"); @@ -3739,7 +3747,7 @@ nsStyleAnimation::Value::SetAndAdoptCSSValuePairListValue( } void -nsStyleAnimation::Value::FreeValue() +StyleAnimationValue::FreeValue() { if (IsCSSValueUnit(mUnit)) { delete mValue.mCSSValue; @@ -3762,7 +3770,7 @@ nsStyleAnimation::Value::FreeValue() } bool -nsStyleAnimation::Value::operator==(const Value& aOther) const +StyleAnimationValue::operator==(const StyleAnimationValue& aOther) const { if (mUnit != aOther.mUnit) { return false; diff --git a/layout/style/nsStyleAnimation.h b/layout/style/nsStyleAnimation.h index 3c0ca2c0199b..1b8be4da392d 100644 --- a/layout/style/nsStyleAnimation.h +++ b/layout/style/nsStyleAnimation.h @@ -19,18 +19,16 @@ class nsStyleContext; class gfx3DMatrix; namespace mozilla { + namespace dom { class Element; } // namespace dom -} // namespace mozilla /** * Utility class to handle animated style values */ -class nsStyleAnimation { +class StyleAnimationValue { public: - class Value; - // Mathematical methods // -------------------- /** @@ -45,8 +43,8 @@ public: * @param aCount The number of times to add aValueToAdd. * @return true on success, false on failure. */ - static bool Add(nsCSSProperty aProperty, Value& aDest, - const Value& aValueToAdd, uint32_t aCount) { + static bool Add(nsCSSProperty aProperty, StyleAnimationValue& aDest, + const StyleAnimationValue& aValueToAdd, uint32_t aCount) { return AddWeighted(aProperty, 1.0, aDest, aCount, aValueToAdd, aDest); } @@ -55,8 +53,8 @@ public: * * This measure of Distance is guaranteed to be proportional to * portions passed to Interpolate, Add, or AddWeighted. However, for - * some types of Value it may not produce sensible results for paced - * animation. + * some types of StyleAnimationValue it may not produce sensible results + * for paced animation. * * If this method succeeds, the returned distance value is guaranteed to be * non-negative. @@ -69,9 +67,9 @@ public: * @return true on success, false on failure. */ static bool ComputeDistance(nsCSSProperty aProperty, - const Value& aStartValue, - const Value& aEndValue, - double& aDistance); + const StyleAnimationValue& aStartValue, + const StyleAnimationValue& aEndValue, + double& aDistance); /** * Calculates an interpolated value that is the specified |aPortion| between @@ -90,10 +88,10 @@ public: * @return true on success, false on failure. */ static bool Interpolate(nsCSSProperty aProperty, - const Value& aStartValue, - const Value& aEndValue, - double aPortion, - Value& aResultValue) { + const StyleAnimationValue& aStartValue, + const StyleAnimationValue& aEndValue, + double aPortion, + StyleAnimationValue& aResultValue) { return AddWeighted(aProperty, 1.0 - aPortion, aStartValue, aPortion, aEndValue, aResultValue); } @@ -113,9 +111,9 @@ public: * positive. */ static bool AddWeighted(nsCSSProperty aProperty, - double aCoeff1, const Value& aValue1, - double aCoeff2, const Value& aValue2, - Value& aResultValue); + double aCoeff1, const StyleAnimationValue& aValue1, + double aCoeff2, const StyleAnimationValue& aValue2, + StyleAnimationValue& aResultValue); // Type-conversion methods // ----------------------- @@ -147,7 +145,7 @@ public: mozilla::dom::Element* aTargetElement, const nsAString& aSpecifiedValue, bool aUseSVGMode, - Value& aComputedValue, + StyleAnimationValue& aComputedValue, bool* aIsContextSensitive = nullptr); /** @@ -164,10 +162,10 @@ public: * @return true on success, false on failure. */ static bool UncomputeValue(nsCSSProperty aProperty, - const Value& aComputedValue, + const StyleAnimationValue& aComputedValue, nsCSSValue& aSpecifiedValue); static bool UncomputeValue(nsCSSProperty aProperty, - const Value& aComputedValue, + const StyleAnimationValue& aComputedValue, nsAString& aSpecifiedValue); /** @@ -180,23 +178,23 @@ public: * @return true on success, false on failure. */ static bool ExtractComputedValue(nsCSSProperty aProperty, - nsStyleContext* aStyleContext, - Value& aComputedValue); + nsStyleContext* aStyleContext, + StyleAnimationValue& aComputedValue); - /** - * Interpolates between 2 matrices by decomposing them. - * - * @param aMatrix1 First matrix, using CSS pixel units. - * @param aMatrix2 Second matrix, using CSS pixel units. - * @param aProgress Interpolation value in the range [0.0, 1.0] - */ - static gfx3DMatrix InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1, - const gfx3DMatrix &aMatrix2, - double aProgress); + /** + * Interpolates between 2 matrices by decomposing them. + * + * @param aMatrix1 First matrix, using CSS pixel units. + * @param aMatrix2 Second matrix, using CSS pixel units. + * @param aProgress Interpolation value in the range [0.0, 1.0] + */ + static gfx3DMatrix InterpolateTransformMatrix(const gfx3DMatrix &aMatrix1, + const gfx3DMatrix &aMatrix2, + double aProgress); - static already_AddRefed - AppendTransformFunction(nsCSSKeyword aTransformFunction, - nsCSSValueList**& aListTail); + static already_AddRefed + AppendTransformFunction(nsCSSKeyword aTransformFunction, + nsCSSValueList**& aListTail); /** * The types and values for the values that we extract and animate. @@ -228,179 +226,181 @@ public: eUnit_UnparsedString // nsStringBuffer* (never null) }; - class Value { - private: - Unit mUnit; - union { - int32_t mInt; - nscoord mCoord; - float mFloat; - nscolor mColor; - nsCSSValue* mCSSValue; - nsCSSValuePair* mCSSValuePair; - nsCSSValueTriplet* mCSSValueTriplet; - nsCSSRect* mCSSRect; - nsCSSValueList* mCSSValueList; - nsCSSValueSharedList* mCSSValueSharedList; - nsCSSValuePairList* mCSSValuePairList; - nsStringBuffer* mString; - } mValue; - public: - Unit GetUnit() const { - NS_ASSERTION(mUnit != eUnit_Null, "uninitialized"); - return mUnit; - } +private: + Unit mUnit; + union { + int32_t mInt; + nscoord mCoord; + float mFloat; + nscolor mColor; + nsCSSValue* mCSSValue; + nsCSSValuePair* mCSSValuePair; + nsCSSValueTriplet* mCSSValueTriplet; + nsCSSRect* mCSSRect; + nsCSSValueList* mCSSValueList; + nsCSSValueSharedList* mCSSValueSharedList; + nsCSSValuePairList* mCSSValuePairList; + nsStringBuffer* mString; + } mValue; - // Accessor to let us verify assumptions about presence of null unit, - // without tripping the assertion in GetUnit(). - bool IsNull() const { - return mUnit == eUnit_Null; - } +public: + Unit GetUnit() const { + NS_ASSERTION(mUnit != eUnit_Null, "uninitialized"); + return mUnit; + } - int32_t GetIntValue() const { - NS_ASSERTION(IsIntUnit(mUnit), "unit mismatch"); - return mValue.mInt; - } - nscoord GetCoordValue() const { - NS_ASSERTION(mUnit == eUnit_Coord, "unit mismatch"); - return mValue.mCoord; - } - float GetPercentValue() const { - NS_ASSERTION(mUnit == eUnit_Percent, "unit mismatch"); - return mValue.mFloat; - } - float GetFloatValue() const { - NS_ASSERTION(mUnit == eUnit_Float, "unit mismatch"); - return mValue.mFloat; - } - nscolor GetColorValue() const { - NS_ASSERTION(mUnit == eUnit_Color, "unit mismatch"); - return mValue.mColor; - } - nsCSSValue* GetCSSValueValue() const { - NS_ASSERTION(IsCSSValueUnit(mUnit), "unit mismatch"); - return mValue.mCSSValue; - } - nsCSSValuePair* GetCSSValuePairValue() const { - NS_ASSERTION(IsCSSValuePairUnit(mUnit), "unit mismatch"); - return mValue.mCSSValuePair; - } - nsCSSValueTriplet* GetCSSValueTripletValue() const { - NS_ASSERTION(IsCSSValueTripletUnit(mUnit), "unit mismatch"); - return mValue.mCSSValueTriplet; - } - nsCSSRect* GetCSSRectValue() const { - NS_ASSERTION(IsCSSRectUnit(mUnit), "unit mismatch"); - return mValue.mCSSRect; - } - nsCSSValueList* GetCSSValueListValue() const { - NS_ASSERTION(IsCSSValueListUnit(mUnit), "unit mismatch"); - return mValue.mCSSValueList; - } - nsCSSValueSharedList* GetCSSValueSharedListValue() const { - NS_ASSERTION(IsCSSValueSharedListValue(mUnit), "unit mismatch"); - return mValue.mCSSValueSharedList; - } - nsCSSValuePairList* GetCSSValuePairListValue() const { - NS_ASSERTION(IsCSSValuePairListUnit(mUnit), "unit mismatch"); - return mValue.mCSSValuePairList; - } - const char16_t* GetStringBufferValue() const { - NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch"); - return GetBufferValue(mValue.mString); - } + // Accessor to let us verify assumptions about presence of null unit, + // without tripping the assertion in GetUnit(). + bool IsNull() const { + return mUnit == eUnit_Null; + } - void GetStringValue(nsAString& aBuffer) const { - NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch"); - aBuffer.Truncate(); - uint32_t len = NS_strlen(GetBufferValue(mValue.mString)); - mValue.mString->ToString(len, aBuffer); - } + int32_t GetIntValue() const { + NS_ASSERTION(IsIntUnit(mUnit), "unit mismatch"); + return mValue.mInt; + } + nscoord GetCoordValue() const { + NS_ASSERTION(mUnit == eUnit_Coord, "unit mismatch"); + return mValue.mCoord; + } + float GetPercentValue() const { + NS_ASSERTION(mUnit == eUnit_Percent, "unit mismatch"); + return mValue.mFloat; + } + float GetFloatValue() const { + NS_ASSERTION(mUnit == eUnit_Float, "unit mismatch"); + return mValue.mFloat; + } + nscolor GetColorValue() const { + NS_ASSERTION(mUnit == eUnit_Color, "unit mismatch"); + return mValue.mColor; + } + nsCSSValue* GetCSSValueValue() const { + NS_ASSERTION(IsCSSValueUnit(mUnit), "unit mismatch"); + return mValue.mCSSValue; + } + nsCSSValuePair* GetCSSValuePairValue() const { + NS_ASSERTION(IsCSSValuePairUnit(mUnit), "unit mismatch"); + return mValue.mCSSValuePair; + } + nsCSSValueTriplet* GetCSSValueTripletValue() const { + NS_ASSERTION(IsCSSValueTripletUnit(mUnit), "unit mismatch"); + return mValue.mCSSValueTriplet; + } + nsCSSRect* GetCSSRectValue() const { + NS_ASSERTION(IsCSSRectUnit(mUnit), "unit mismatch"); + return mValue.mCSSRect; + } + nsCSSValueList* GetCSSValueListValue() const { + NS_ASSERTION(IsCSSValueListUnit(mUnit), "unit mismatch"); + return mValue.mCSSValueList; + } + nsCSSValueSharedList* GetCSSValueSharedListValue() const { + NS_ASSERTION(IsCSSValueSharedListValue(mUnit), "unit mismatch"); + return mValue.mCSSValueSharedList; + } + nsCSSValuePairList* GetCSSValuePairListValue() const { + NS_ASSERTION(IsCSSValuePairListUnit(mUnit), "unit mismatch"); + return mValue.mCSSValuePairList; + } + const char16_t* GetStringBufferValue() const { + NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch"); + return GetBufferValue(mValue.mString); + } - explicit Value(Unit aUnit = eUnit_Null) : mUnit(aUnit) { - NS_ASSERTION(aUnit == eUnit_Null || aUnit == eUnit_Normal || - aUnit == eUnit_Auto || aUnit == eUnit_None, - "must be valueless unit"); - } - Value(const Value& aOther) : mUnit(eUnit_Null) { *this = aOther; } - enum IntegerConstructorType { IntegerConstructor }; - Value(int32_t aInt, Unit aUnit, IntegerConstructorType); - enum CoordConstructorType { CoordConstructor }; - Value(nscoord aLength, CoordConstructorType); - enum PercentConstructorType { PercentConstructor }; - Value(float aPercent, PercentConstructorType); - enum FloatConstructorType { FloatConstructor }; - Value(float aFloat, FloatConstructorType); - enum ColorConstructorType { ColorConstructor }; - Value(nscolor aColor, ColorConstructorType); + void GetStringValue(nsAString& aBuffer) const { + NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch"); + aBuffer.Truncate(); + uint32_t len = NS_strlen(GetBufferValue(mValue.mString)); + mValue.mString->ToString(len, aBuffer); + } - ~Value() { FreeValue(); } + explicit StyleAnimationValue(Unit aUnit = eUnit_Null) : mUnit(aUnit) { + NS_ASSERTION(aUnit == eUnit_Null || aUnit == eUnit_Normal || + aUnit == eUnit_Auto || aUnit == eUnit_None, + "must be valueless unit"); + } + StyleAnimationValue(const StyleAnimationValue& aOther) + : mUnit(eUnit_Null) { *this = aOther; } + enum IntegerConstructorType { IntegerConstructor }; + StyleAnimationValue(int32_t aInt, Unit aUnit, IntegerConstructorType); + enum CoordConstructorType { CoordConstructor }; + StyleAnimationValue(nscoord aLength, CoordConstructorType); + enum PercentConstructorType { PercentConstructor }; + StyleAnimationValue(float aPercent, PercentConstructorType); + enum FloatConstructorType { FloatConstructor }; + StyleAnimationValue(float aFloat, FloatConstructorType); + enum ColorConstructorType { ColorConstructor }; + StyleAnimationValue(nscolor aColor, ColorConstructorType); - void SetNormalValue(); - void SetAutoValue(); - void SetNoneValue(); - void SetIntValue(int32_t aInt, Unit aUnit); - void SetCoordValue(nscoord aCoord); - void SetPercentValue(float aPercent); - void SetFloatValue(float aFloat); - void SetColorValue(nscolor aColor); - void SetUnparsedStringValue(const nsString& aString); + ~StyleAnimationValue() { FreeValue(); } - // These setters take ownership of |aValue|, and are therefore named - // "SetAndAdopt*". - void SetAndAdoptCSSValueValue(nsCSSValue *aValue, Unit aUnit); - void SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValue, Unit aUnit); - void SetAndAdoptCSSValueTripletValue(nsCSSValueTriplet *aValue, Unit aUnit); - void SetAndAdoptCSSRectValue(nsCSSRect *aValue, Unit aUnit); - void SetAndAdoptCSSValueListValue(nsCSSValueList *aValue, Unit aUnit); - void SetAndAdoptCSSValuePairListValue(nsCSSValuePairList *aValue); + void SetNormalValue(); + void SetAutoValue(); + void SetNoneValue(); + void SetIntValue(int32_t aInt, Unit aUnit); + void SetCoordValue(nscoord aCoord); + void SetPercentValue(float aPercent); + void SetFloatValue(float aFloat); + void SetColorValue(nscolor aColor); + void SetUnparsedStringValue(const nsString& aString); - void SetTransformValue(nsCSSValueSharedList* aList); + // These setters take ownership of |aValue|, and are therefore named + // "SetAndAdopt*". + void SetAndAdoptCSSValueValue(nsCSSValue *aValue, Unit aUnit); + void SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValue, Unit aUnit); + void SetAndAdoptCSSValueTripletValue(nsCSSValueTriplet *aValue, Unit aUnit); + void SetAndAdoptCSSRectValue(nsCSSRect *aValue, Unit aUnit); + void SetAndAdoptCSSValueListValue(nsCSSValueList *aValue, Unit aUnit); + void SetAndAdoptCSSValuePairListValue(nsCSSValuePairList *aValue); - Value& operator=(const Value& aOther); + void SetTransformValue(nsCSSValueSharedList* aList); - bool operator==(const Value& aOther) const; - bool operator!=(const Value& aOther) const - { return !(*this == aOther); } + StyleAnimationValue& operator=(const StyleAnimationValue& aOther); - private: - void FreeValue(); + bool operator==(const StyleAnimationValue& aOther) const; + bool operator!=(const StyleAnimationValue& aOther) const + { return !(*this == aOther); } - static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) { - return static_cast(aBuffer->Data()); - } +private: + void FreeValue(); - static bool IsIntUnit(Unit aUnit) { - return aUnit == eUnit_Enumerated || aUnit == eUnit_Visibility || - aUnit == eUnit_Integer; - } - static bool IsCSSValueUnit(Unit aUnit) { - return aUnit == eUnit_Calc; - } - static bool IsCSSValuePairUnit(Unit aUnit) { - return aUnit == eUnit_CSSValuePair; - } - static bool IsCSSValueTripletUnit(Unit aUnit) { - return aUnit == eUnit_CSSValueTriplet; - } - static bool IsCSSRectUnit(Unit aUnit) { - return aUnit == eUnit_CSSRect; - } - static bool IsCSSValueListUnit(Unit aUnit) { - return aUnit == eUnit_Dasharray || aUnit == eUnit_Filter || - aUnit == eUnit_Shadow || - aUnit == eUnit_BackgroundPosition; - } - static bool IsCSSValueSharedListValue(Unit aUnit) { - return aUnit == eUnit_Transform; - } - static bool IsCSSValuePairListUnit(Unit aUnit) { - return aUnit == eUnit_CSSValuePairList; - } - static bool IsStringUnit(Unit aUnit) { - return aUnit == eUnit_UnparsedString; - } - }; + static const char16_t* GetBufferValue(nsStringBuffer* aBuffer) { + return static_cast(aBuffer->Data()); + } + + static bool IsIntUnit(Unit aUnit) { + return aUnit == eUnit_Enumerated || aUnit == eUnit_Visibility || + aUnit == eUnit_Integer; + } + static bool IsCSSValueUnit(Unit aUnit) { + return aUnit == eUnit_Calc; + } + static bool IsCSSValuePairUnit(Unit aUnit) { + return aUnit == eUnit_CSSValuePair; + } + static bool IsCSSValueTripletUnit(Unit aUnit) { + return aUnit == eUnit_CSSValueTriplet; + } + static bool IsCSSRectUnit(Unit aUnit) { + return aUnit == eUnit_CSSRect; + } + static bool IsCSSValueListUnit(Unit aUnit) { + return aUnit == eUnit_Dasharray || aUnit == eUnit_Filter || + aUnit == eUnit_Shadow || + aUnit == eUnit_BackgroundPosition; + } + static bool IsCSSValueSharedListValue(Unit aUnit) { + return aUnit == eUnit_Transform; + } + static bool IsCSSValuePairListUnit(Unit aUnit) { + return aUnit == eUnit_CSSValuePairList; + } + static bool IsStringUnit(Unit aUnit) { + return aUnit == eUnit_UnparsedString; + } }; +} // namespace mozilla + #endif diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index 84b0426071dd..0b3a93ed4ea5 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -746,19 +746,20 @@ NS_NewStyleContext(nsStyleContext* aParentContext, static inline void ExtractAnimationValue(nsCSSProperty aProperty, nsStyleContext* aStyleContext, - nsStyleAnimation::Value& aResult) + StyleAnimationValue& aResult) { DebugOnly success = - nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext, aResult); + StyleAnimationValue::ExtractComputedValue(aProperty, aStyleContext, + aResult); NS_ABORT_IF_FALSE(success, - "aProperty must be extractable by nsStyleAnimation"); + "aProperty must be extractable by StyleAnimationValue"); } static nscolor ExtractColor(nsCSSProperty aProperty, nsStyleContext *aStyleContext) { - nsStyleAnimation::Value val; + StyleAnimationValue val; ExtractAnimationValue(aProperty, aStyleContext, val); return val.GetColorValue(); } @@ -767,9 +768,9 @@ static nscolor ExtractColorLenient(nsCSSProperty aProperty, nsStyleContext *aStyleContext) { - nsStyleAnimation::Value val; + StyleAnimationValue val; ExtractAnimationValue(aProperty, aStyleContext, val); - if (val.GetUnit() == nsStyleAnimation::eUnit_Color) { + if (val.GetUnit() == StyleAnimationValue::eUnit_Color) { return val.GetColorValue(); } return NS_RGBA(0, 0, 0, 0); diff --git a/layout/style/nsStyleContext.h b/layout/style/nsStyleContext.h index edf1ae4a8f62..c8b4f567ee9e 100644 --- a/layout/style/nsStyleContext.h +++ b/layout/style/nsStyleContext.h @@ -293,7 +293,7 @@ public: * Get a color that depends on link-visitedness using this and * 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 * do change handling for in nsStyleContext::CalcDifference. * diff --git a/layout/style/nsStyleTransformMatrix.cpp b/layout/style/nsStyleTransformMatrix.cpp index 7627bd8a0334..1c6c30bbe09c 100644 --- a/layout/style/nsStyleTransformMatrix.cpp +++ b/layout/style/nsStyleTransformMatrix.cpp @@ -53,7 +53,7 @@ ProcessTranslatePart(const nsCSSValue& aValue, // Handle this here (even though nsRuleNode::CalcLength handles it // fine) so that callers are allowed to pass a null style context // 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. // // Raw numbers are treated as being pixels. @@ -180,12 +180,14 @@ ProcessInterpolateMatrix(gfx3DMatrix& aMatrix, } 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. */ static void -ProcessTranslateX(gfx3DMatrix& aMatrix, +ProcessTranslateX(gfx3DMatrix& aMatrix, const nsCSSValue::Array* aData, nsStyleContext* aContext, nsPresContext* aPresContext, @@ -502,7 +504,7 @@ MatrixForTransformFunction(gfx3DMatrix& aMatrix, 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 // knows that all length units have been converted to pixels (as - // nsStyleAnimation does). + // StyleAnimationValue does). /* Get the keyword for the transform. */ diff --git a/layout/style/nsStyleTransformMatrix.h b/layout/style/nsStyleTransformMatrix.h index e35496c10475..e1ea9c70dbca 100644 --- a/layout/style/nsStyleTransformMatrix.h +++ b/layout/style/nsStyleTransformMatrix.h @@ -56,7 +56,7 @@ namespace nsStyleTransformMatrix { * * aContext and aPresContext may be null if all of the (non-percent) * 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, nsStyleContext* aContext, diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index f5326df2957c..30e3a708a179 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -302,7 +302,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement, ElementAnimationPtrArray& animations = et->mAnimations; uint32_t i = animations.Length(); NS_ABORT_IF_FALSE(i != 0, "empty transitions list?"); - nsStyleAnimation::Value currentValue; + StyleAnimationValue currentValue; do { --i; ElementAnimation* animation = animations[i]; @@ -405,7 +405,7 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty, nsRefPtr pt = new ElementPropertyTransition(); - nsStyleAnimation::Value startValue, endValue, dummyValue; + StyleAnimationValue startValue, endValue, dummyValue; bool haveValues = ExtractComputedValueForTransition(aProperty, aOldStyleContext, startValue) && @@ -420,8 +420,8 @@ nsTransitionManager::ConsiderStartingTransition(nsCSSProperty aProperty, // Check that we can interpolate between these values // (If this is ever a performance problem, we could add a // CanInterpolate method, but it seems fine for now.) - nsStyleAnimation::Interpolate(aProperty, startValue, endValue, - 0.5, dummyValue); + StyleAnimationValue::Interpolate(aProperty, startValue, endValue, + 0.5, dummyValue); bool haveCurrentTransition = false; size_t currentIndex = nsTArray::NoIndex; diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index fa97940d70bf..f0a03db94dc8 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -33,7 +33,7 @@ struct ElementPropertyTransition : public mozilla::ElementAnimation // mProperties[0].mSegments[0].mFromValue, except when this transition // started as the reversal of another in-progress transition. // 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 // transition that we're actually covering. For example, if a :hover // effect has a transition that moves the element 10px to the right