Bug 1273706 - Part 10: Expose StyleAnimationValue::StyleCoordToValue and StyleCoordToCSSValue.
Currently these are used by StyleAnimationValue internally in
ExtractComputedValue only. A later patch in this series will use them for
converting nsStyleCoords to StyleAnimationValues and for converting
nsStyleCoords to strings (by way of nsCSSValue::AppendToString).
Also add support for eStyleUnit_Integer to StyleCoordToCSSValue, because we use
nsStyleCoords to store <integer>s too.
MozReview-Commit-ID: L1zTPOxq88Z
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -3274,17 +3274,19 @@ ExtractBorderColor(nsStyleContext* aStyl
GetBorderColor(aSide, color, foreground);
if (foreground) {
// FIXME: should add test for this
color = aStyleContext->StyleColor()->mColor;
}
aComputedValue.SetColorValue(color);
}
-static bool
+namespace mozilla {
+
+bool
StyleCoordToValue(const nsStyleCoord& aCoord, StyleAnimationValue& aValue)
{
switch (aCoord.GetUnit()) {
case eStyleUnit_Normal:
aValue.SetNormalValue();
break;
case eStyleUnit_Auto:
aValue.SetAutoValue();
@@ -3317,17 +3319,17 @@ StyleCoordToValue(const nsStyleCoord& aC
break;
}
default:
return false;
}
return true;
}
-static bool
+bool
StyleCoordToCSSValue(const nsStyleCoord& aCoord, nsCSSValue& aCSSValue)
{
switch (aCoord.GetUnit()) {
case eStyleUnit_Coord:
nscoordToCSSValue(aCoord.GetCoordValue(), aCSSValue);
break;
case eStyleUnit_Factor:
aCSSValue.SetFloatValue(aCoord.GetFactorValue(), eCSSUnit_Number);
@@ -3345,23 +3347,28 @@ StyleCoordToCSSValue(const nsStyleCoord&
aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Grad);
break;
case eStyleUnit_Radian:
aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Radian);
break;
case eStyleUnit_Turn:
aCSSValue.SetFloatValue(aCoord.GetAngleValue(), eCSSUnit_Turn);
break;
+ case eStyleUnit_Integer:
+ aCSSValue.SetIntValue(aCoord.GetIntValue(), eCSSUnit_Integer);
+ break;
default:
MOZ_ASSERT(false, "unexpected unit");
return false;
}
return true;
}
+} // namespace mozilla
+
static void
SetPositionValue(const nsStyleImageLayers::Position& aPos, nsCSSValue& aCSSValue)
{
RefPtr<nsCSSValue::Array> posArray = nsCSSValue::Array::Create(4);
aCSSValue.SetArrayValue(posArray.get(), eCSSUnit_Array);
// NOTE: Array entries #0 and #2 here are intentionally left untouched, with
// eCSSUnit_Null. The purpose of these entries in our specified-style
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -15,30 +15,36 @@
#include "nsCoord.h"
#include "nsColor.h"
#include "nsCSSProps.h"
#include "nsCSSValue.h"
#include "nsTArray.h"
class nsIFrame;
class nsStyleContext;
+class nsStyleCoord;
class gfx3DMatrix;
namespace mozilla {
namespace css {
class StyleRule;
} // namespace css
namespace dom {
class Element;
} // namespace dom
enum class CSSPseudoElementType : uint8_t;
struct PropertyStyleAnimationValuePair;
+class StyleAnimationValue;
+
+bool StyleCoordToValue(const nsStyleCoord& aCoord,
+ StyleAnimationValue& aValue);
+bool StyleCoordToCSSValue(const nsStyleCoord& aCoord, nsCSSValue& aValue);
/**
* Utility class to handle animated style values
*/
class StyleAnimationValue {
public:
// Mathematical methods
// --------------------