Add support for animation of nsStyleSVGPaint values to nsStyleAnimation. (Bug 504652) r=dholbert sr=bzbarsky

This commit is contained in:
L. David Baron 2009-09-11 06:46:36 -04:00
parent 2088a9b2f5
commit 9f0d0e127d
3 changed files with 28 additions and 4 deletions

View File

@ -2760,8 +2760,8 @@ CSS_PROP_SVG(
mFill,
eCSSType_ValuePair,
nsnull,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
offsetof(nsStyleSVG, mFill),
eStyleAnimType_PaintServer)
CSS_PROP_SVG(
fill-opacity,
fill_opacity,
@ -2930,8 +2930,8 @@ CSS_PROP_SVG(
mStroke,
eCSSType_ValuePair,
nsnull,
CSS_PROP_NO_OFFSET,
eStyleAnimType_None)
offsetof(nsStyleSVG, mStroke),
eStyleAnimType_PaintServer)
CSS_PROP_SVG(
stroke-dasharray,
stroke_dasharray,

View File

@ -85,6 +85,9 @@ enum nsStyleAnimType {
// nscolor values
eStyleAnimType_Color,
// nsStyleSVGPaint values
eStyleAnimType_PaintServer,
// property not animatable
eStyleAnimType_None
};

View File

@ -458,6 +458,20 @@ nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
aComputedValue.SetColorValue(*static_cast<const nscolor*>(
StyleDataAtOffset(styleStruct, ssOffset)));
return PR_TRUE;
case eStyleAnimType_PaintServer: {
const nsStyleSVGPaint &paint = *static_cast<const nsStyleSVGPaint*>(
StyleDataAtOffset(styleStruct, ssOffset));
// We *could* animate 'none' by treating it as rgba(0, 0, 0, 0),
// but since SVG doesn't have (or really get along with) rgba()
// colors, I think we're not supposed to.
// FIXME: However, at some point in the future, we should animate
// gradients.
if (paint.mType == eStyleSVGPaintType_Color) {
aComputedValue.SetColorValue(paint.mPaint.mColor);
return PR_TRUE;
}
return PR_FALSE;
}
case eStyleAnimType_None:
NS_NOTREACHED("shouldn't use on non-animatable properties");
}
@ -521,6 +535,13 @@ nsStyleAnimation::StoreComputedValue(nsCSSProperty aProperty,
*static_cast<nscolor*>(StyleDataAtOffset(aStyleStruct, ssOffset)) =
aComputedValue.GetColorValue();
return PR_TRUE;
case eStyleAnimType_PaintServer: {
nsStyleSVGPaint &paint = *static_cast<nsStyleSVGPaint*>(
StyleDataAtOffset(aStyleStruct, ssOffset));
paint.mType = eStyleSVGPaintType_Color;
paint.mPaint.mColor = aComputedValue.GetColorValue();
return PR_TRUE;
}
case eStyleAnimType_None:
NS_NOTREACHED("shouldn't use on non-animatable properties");
}