Add support for animation of nsStyleCoord and nsStyleSides values to nsStyleAnimation. (Bug 504652) r=dbaron sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Fri, 11 Sep 2009 06:46:36 -0400
changeset 32396 284457eb8f58467479a1bb908f134b00ed953000
parent 32395 a4990b27b9357b268b732e4b96cf57ace8c00442
child 32397 cc19ea010061bc350380c3e03fd50c8cb8680d7d
push idunknown
push userunknown
push dateunknown
reviewersdbaron, bzbarsky
bugs504652
milestone1.9.3a1pre
Add support for animation of nsStyleCoord and nsStyleSides values to nsStyleAnimation. (Bug 504652) r=dbaron sr=bzbarsky
layout/style/nsCSSPropList.h
layout/style/nsCSSProps.h
layout/style/nsStyleAnimation.cpp
layout/style/nsStyleAnimation.h
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -1114,18 +1114,18 @@ CSS_PROP_POSITION(
     bottom,
     bottom,
     Bottom,
     0,
     Position,
     mOffset.mBottom,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mOffset),
+    eStyleAnimType_Sides_Bottom)
 CSS_PROP_BORDER(
     -moz-box-shadow,
     box_shadow,
     MozBoxShadow,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
         CSS_PROPERTY_VALUE_LIST_USES_COMMAS |
         CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED,
     Margin,
@@ -1205,29 +1205,29 @@ CSS_PROP_COLUMN(
     -moz-column-width,
     _moz_column_width,
     MozColumnWidth,
     0,
     Column,
     mColumnWidth,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleColumn, mColumnWidth),
+    eStyleAnimType_Coord)
 CSS_PROP_COLUMN(
     -moz-column-gap,
     _moz_column_gap,
     MozColumnGap,
     0,
     Column,
     mColumnGap,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleColumn, mColumnGap),
+    eStyleAnimType_Coord)
 CSS_PROP_SHORTHAND(
     -moz-column-rule,
     _moz_column_rule,
     MozColumnRule,
     0)
 CSS_PROP_COLUMN(
     -moz-column-rule-color,
     _moz_column_rule_color,
@@ -1489,18 +1489,18 @@ CSS_PROP_POSITION(
     height,
     height,
     Height,
     0,
     Position,
     mHeight,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mHeight),
+    eStyleAnimType_Coord)
 CSS_PROP_LIST(
     -moz-image-region,
     image_region,
     MozImageRegion,
     0,
     List,
     mImageRegion,
     eCSSType_Rect,
@@ -1522,40 +1522,40 @@ CSS_PROP_POSITION(
     left,
     left,
     Left,
     0,
     Position,
     mOffset.mLeft,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mOffset),
+    eStyleAnimType_Sides_Left)
 CSS_PROP_TEXT(
     letter-spacing,
     letter_spacing,
     LetterSpacing,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE,
     Text,
     mLetterSpacing,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleText, mLetterSpacing),
+    eStyleAnimType_Coord)
 CSS_PROP_TEXT(
     line-height,
     line_height,
     LineHeight,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE,
     Text,
     mLineHeight,
     eCSSType_Value,
     kLineHeightKTable,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleText, mLineHeight),
+    eStyleAnimType_Coord)
 CSS_PROP_SHORTHAND(
     list-style,
     list_style,
     ListStyle,
     0)
 CSS_PROP_LIST(
     list-style-image,
     list_style_image,
@@ -1598,18 +1598,18 @@ CSS_PROP_MARGIN(
     margin-bottom,
     margin_bottom,
     MarginBottom,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mMargin.mBottom,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleMargin, mMargin),
+    eStyleAnimType_Sides_Bottom)
 CSS_PROP_SHORTHAND(
     -moz-margin-end,
     margin_end,
     MozMarginEnd,
     0)
 #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
 CSS_PROP_MARGIN(
     margin-end-value,
@@ -1633,18 +1633,18 @@ CSS_PROP_MARGIN(
     margin-left-value,
     margin_left_value,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mMargin.mLeft,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleMargin, mMargin),
+    eStyleAnimType_Sides_Left)
 CSS_PROP_MARGIN(
     margin-left-ltr-source,
     margin_left_ltr_source,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
         CSS_PROPERTY_DIRECTIONAL_SOURCE,
     Margin,
     mMarginLeftLTRSource,
@@ -1675,18 +1675,18 @@ CSS_PROP_MARGIN(
     margin-right-value,
     margin_right_value,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mMargin.mRight,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleMargin, mMargin),
+    eStyleAnimType_Sides_Right)
 CSS_PROP_MARGIN(
     margin-right-ltr-source,
     margin_right_ltr_source,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
         CSS_PROPERTY_DIRECTIONAL_SOURCE,
     Margin,
     mMarginRightLTRSource,
@@ -1729,29 +1729,29 @@ CSS_PROP_MARGIN(
     margin-top,
     margin_top,
     MarginTop,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mMargin.mTop,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleMargin, mMargin),
+    eStyleAnimType_Sides_Top)
 CSS_PROP_CONTENT(
     marker-offset,
     marker_offset,
     MarkerOffset,
     0,
     Content,
     mMarkerOffset,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleContent, mMarkerOffset),
+    eStyleAnimType_Coord)
 CSS_PROP_BACKENDONLY(
     marks,
     marks,
     Marks,
     0,
     Page,
     mMarks,
     eCSSType_Value,
@@ -1760,51 +1760,51 @@ CSS_PROP_POSITION(
     max-height,
     max_height,
     MaxHeight,
     0,
     Position,
     mMaxHeight,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mMaxHeight),
+    eStyleAnimType_Coord)
 CSS_PROP_POSITION(
     max-width,
     max_width,
     MaxWidth,
     0,
     Position,
     mMaxWidth,
     eCSSType_Value,
     kWidthKTable,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mMaxWidth),
+    eStyleAnimType_Coord)
 CSS_PROP_POSITION(
     min-height,
     min_height,
     MinHeight,
     0,
     Position,
     mMinHeight,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mMinHeight),
+    eStyleAnimType_Coord)
 CSS_PROP_POSITION(
     min-width,
     min_width,
     MinWidth,
     0,
     Position,
     mMinWidth,
     eCSSType_Value,
     kWidthKTable,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mMinWidth),
+    eStyleAnimType_Coord)
 CSS_PROP_DISPLAY(
     opacity,
     opacity,
     Opacity,
     0,
     Display,
     mOpacity,
     eCSSType_Value,
@@ -1851,18 +1851,18 @@ CSS_PROP_OUTLINE(
     outline-width,
     outline_width,
     OutlineWidth,
     0,
     Margin,
     mOutlineWidth,
     eCSSType_Value,
     kBorderWidthKTable,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleOutline, mOutlineWidth),
+    eStyleAnimType_Coord)
 CSS_PROP_OUTLINE(
     outline-offset,
     outline_offset,
     OutlineOffset,
     0,
     Margin,
     mOutlineOffset,
     eCSSType_Value,
@@ -1905,18 +1905,18 @@ CSS_PROP_PADDING(
     padding-bottom,
     padding_bottom,
     PaddingBottom,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mPadding.mBottom,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePadding, mPadding),
+    eStyleAnimType_Sides_Bottom)
 CSS_PROP_SHORTHAND(
     -moz-padding-end,
     padding_end,
     MozPaddingEnd,
     0)
 #ifndef CSS_PROP_LIST_EXCLUDE_INTERNAL
 CSS_PROP_PADDING(
     padding-end-value,
@@ -1940,18 +1940,18 @@ CSS_PROP_PADDING(
     padding-left-value,
     padding_left_value,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mPadding.mLeft,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePadding, mPadding),
+    eStyleAnimType_Sides_Left)
 CSS_PROP_PADDING(
     padding-left-ltr-source,
     padding_left_ltr_source,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
         CSS_PROPERTY_DIRECTIONAL_SOURCE,
     Margin,
     mPaddingLeftLTRSource,
@@ -1982,18 +1982,18 @@ CSS_PROP_PADDING(
     padding-right-value,
     padding_right_value,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mPadding.mRight,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePadding, mPadding),
+    eStyleAnimType_Sides_Right)
 CSS_PROP_PADDING(
     padding-right-ltr-source,
     padding_right_ltr_source,
     X,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
         CSS_PROPERTY_DIRECTIONAL_SOURCE,
     Margin,
     mPaddingRightLTRSource,
@@ -2036,18 +2036,18 @@ CSS_PROP_PADDING(
     padding-top,
     padding_top,
     PaddingTop,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER,
     Margin,
     mPadding.mTop,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePadding, mPadding),
+    eStyleAnimType_Sides_Top)
 CSS_PROP_BACKENDONLY(
     page,
     page,
     Page,
     0,
     Breaks,
     mPage,
     eCSSType_Value,
@@ -2170,18 +2170,18 @@ CSS_PROP_POSITION(
     right,
     right,
     Right,
     0,
     Position,
     mOffset.mRight,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mOffset),
+    eStyleAnimType_Sides_Right)
 CSS_PROP_BACKENDONLY(
     size,
     size,
     Size,
     0,
     Page,
     mSize,
     eCSSType_ValuePair,
@@ -2277,18 +2277,18 @@ CSS_PROP_TEXT(
     text-indent,
     text_indent,
     TextIndent,
     0,
     Text,
     mTextIndent,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleText, mTextIndent),
+    eStyleAnimType_Coord)
 CSS_PROP_TEXT(
     text-shadow,
     text_shadow,
     TextShadow,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
         CSS_PROPERTY_VALUE_LIST_USES_COMMAS |
         CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED,
     Text,
@@ -2334,18 +2334,18 @@ CSS_PROP_POSITION(
     top,
     top,
     Top,
     0,
     Position,
     mOffset.mTop,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mOffset),
+    eStyleAnimType_Sides_Top)
 CSS_PROP_SHORTHAND(
     -moz-transition,
     transition,
     MozTransition,
     0)
 CSS_PROP_DISPLAY(
     -moz-transition-delay,
     transition_delay,
@@ -2452,18 +2452,18 @@ CSS_PROP_TEXTRESET(
     vertical-align,
     vertical_align,
     VerticalAlign,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE,
     Text,
     mVerticalAlign,
     eCSSType_Value,
     kVerticalAlignKTable,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleTextReset, mVerticalAlign),
+    eStyleAnimType_Coord)
 CSS_PROP_VISIBILITY(
     visibility,
     visibility,
     Visibility,
     0,
     Display,
     mVisibility,
     eCSSType_Value,
@@ -2512,18 +2512,18 @@ CSS_PROP_POSITION(
     width,
     width,
     Width,
     0,
     Position,
     mWidth,
     eCSSType_Value,
     kWidthKTable,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStylePosition, mWidth),
+    eStyleAnimType_Coord)
 CSS_PROP_UIRESET(
     -moz-window-shadow,
     _moz_window_shadow,
     MozWindowShadow,
     0,
     UserInterface,
     mWindowShadow,
     eCSSType_Value,
@@ -2935,18 +2935,18 @@ CSS_PROP_SVG(
     stroke-dashoffset,
     stroke_dashoffset,
     StrokeDashoffset,
     0,
     SVG,
     mStrokeDashoffset,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleSVG, mStrokeDashoffset),
+    eStyleAnimType_Coord)
 CSS_PROP_SVG(
     stroke-linecap,
     stroke_linecap,
     StrokeLinecap,
     0,
     SVG,
     mStrokeLinecap,
     eCSSType_Value,
@@ -2990,18 +2990,18 @@ CSS_PROP_SVG(
     stroke-width,
     stroke_width,
     StrokeWidth,
     0,
     SVG,
     mStrokeWidth,
     eCSSType_Value,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleSVG, mStrokeWidth),
+    eStyleAnimType_Coord)
 CSS_PROP_SVG(
     text-anchor,
     text_anchor,
     TextAnchor,
     0,
     SVG,
     mTextAnchor,
     eCSSType_Value,
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -64,17 +64,28 @@
 // Note that 'background-color' is ignored differently from the other
 // properties that have this set, but that's just special-cased.
 #define CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED (1<<4)
 
 /**
  * Types of animatable values.
  */
 enum nsStyleAnimType {
-  eStyleAnimType_None /* property not animatable */
+  // nsStyleCoord with animatable values
+  eStyleAnimType_Coord,
+
+  // same as Coord, except for one side of an nsStyleSides
+  // listed in the same order as the NS_STYLE_* constants
+  eStyleAnimType_Sides_Top,
+  eStyleAnimType_Sides_Right,
+  eStyleAnimType_Sides_Bottom,
+  eStyleAnimType_Sides_Left,
+
+  // property not animatable
+  eStyleAnimType_None
 };
 
 class nsCSSProps {
 public:
   static void AddRefTable(void);
   static void ReleaseTable(void);
 
   // Given a property string, return the enum value
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -16,16 +16,17 @@
  *
  * The Initial Developer of the Original Code is
  * The Mozilla Corporation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Daniel Holbert <dholbert@mozilla.com>, Mozilla Corporation
+ *   L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -46,16 +47,17 @@
 #include "nsStyleCoord.h"
 #include "nsStyleContext.h"
 #include "nsStyleSet.h"
 #include "nsComputedDOMStyle.h"
 #include "nsICSSParser.h"
 #include "nsICSSLoader.h"
 #include "nsCSSDataBlock.h"
 #include "nsCSSDeclaration.h"
+#include "prlog.h"
 
 // HELPER METHODS
 // --------------
 /*
  * Given two units, this method returns a common unit that they can both be
  * converted into, if possible.  This is intended to facilitate
  * interpolation, distance-computation, and addition between "similar" units.
  *
@@ -288,32 +290,103 @@ nsStyleAnimation::ComputeValue(nsCSSProp
     styleSet->ResolveStyleForRules(styleContext->GetParent(),
                                    styleContext->GetPseudoType(),
                                    styleContext->GetRuleNode(), ruleArray);
 
   // Extract computed value of our property from the temporary style rule
   return ExtractComputedValue(aProperty, tmpStyleContext, aComputedValue);
 }
 
+inline const void*
+StyleDataAtOffset(const void* aStyleStruct, ptrdiff_t aOffset)
+{
+  return reinterpret_cast<const char*>(aStyleStruct) + aOffset;
+}
+
+inline void*
+StyleDataAtOffset(void* aStyleStruct, ptrdiff_t aOffset)
+{
+  return reinterpret_cast<char*>(aStyleStruct) + aOffset;
+}
+
 PRBool
 nsStyleAnimation::ExtractComputedValue(nsCSSProperty aProperty,
                                        nsStyleContext* aStyleContext,
                                        nsStyleCoord& aComputedValue)
 {
-  // XXXdholbert This is a simple implementation that only supports "font-size"
-  // and "stroke-width for now, so that we can test the rest of the
-  // functionality. A full implementation will require modifications to
-  // nsCSSPropList.h, as described in bug 504652 comment 0.
-  switch(aProperty) {
-    case eCSSProperty_font_size: {
-      const nsStyleFont* styleFont = aStyleContext->GetStyleFont();
-      aComputedValue.SetCoordValue(styleFont->mFont.size);
+  NS_ABORT_IF_FALSE(0 <= aProperty &&
+                    aProperty < eCSSProperty_COUNT_no_shorthands,
+                    "bad property");
+  const void* styleStruct =
+    aStyleContext->GetStyleData(nsCSSProps::kSIDTable[aProperty]);
+  ptrdiff_t ssOffset = nsCSSProps::kStyleStructOffsetTable[aProperty];
+  NS_ABORT_IF_FALSE(0 <= ssOffset, "must be dealing with animatable property");
+  nsStyleAnimType animType = nsCSSProps::kAnimTypeTable[aProperty];
+  switch (animType) {
+    case eStyleAnimType_Coord:
+      aComputedValue = *static_cast<const nsStyleCoord*>(
+        StyleDataAtOffset(styleStruct, ssOffset));
+      return PR_TRUE;
+    case eStyleAnimType_Sides_Top:
+    case eStyleAnimType_Sides_Right:
+    case eStyleAnimType_Sides_Bottom:
+    case eStyleAnimType_Sides_Left:
+      PR_STATIC_ASSERT(0 == NS_SIDE_TOP);
+      PR_STATIC_ASSERT(eStyleAnimType_Sides_Right - eStyleAnimType_Sides_Top
+                         == NS_SIDE_RIGHT);
+      PR_STATIC_ASSERT(eStyleAnimType_Sides_Bottom - eStyleAnimType_Sides_Top
+                         == NS_SIDE_BOTTOM);
+      PR_STATIC_ASSERT(eStyleAnimType_Sides_Left - eStyleAnimType_Sides_Top
+                         == NS_SIDE_LEFT);
+      aComputedValue = static_cast<const nsStyleSides*>(
+        StyleDataAtOffset(styleStruct, ssOffset))->
+          Get(animType - eStyleAnimType_Sides_Top);
+      return PR_TRUE;
+    case eStyleAnimType_None:
+      NS_NOTREACHED("shouldn't use on non-animatable properties");
+  }
+  return PR_FALSE;
+}
+
+PRBool
+nsStyleAnimation::StoreComputedValue(nsCSSProperty aProperty,
+                                     nsPresContext* aPresContext,
+                                     void* aStyleStruct,
+                                     const nsStyleCoord& aComputedValue)
+{
+  NS_ABORT_IF_FALSE(0 <= aProperty &&
+                    aProperty < eCSSProperty_COUNT_no_shorthands,
+                    "bad property");
+  ptrdiff_t ssOffset = nsCSSProps::kStyleStructOffsetTable[aProperty];
+  NS_ABORT_IF_FALSE(0 <= ssOffset, "must be dealing with animatable property");
+  nsStyleAnimType animType = nsCSSProps::kAnimTypeTable[aProperty];
+  switch (animType) {
+    case eStyleAnimType_Coord:
+      *static_cast<nsStyleCoord*>(StyleDataAtOffset(aStyleStruct, ssOffset)) =
+        aComputedValue;
+      return PR_TRUE;
+    case eStyleAnimType_Sides_Top:
+    case eStyleAnimType_Sides_Right:
+    case eStyleAnimType_Sides_Bottom:
+    case eStyleAnimType_Sides_Left: {
+      PR_STATIC_ASSERT(0 == NS_SIDE_TOP);
+      PR_STATIC_ASSERT(eStyleAnimType_Sides_Right - eStyleAnimType_Sides_Top
+                         == NS_SIDE_RIGHT);
+      PR_STATIC_ASSERT(eStyleAnimType_Sides_Bottom - eStyleAnimType_Sides_Top
+                         == NS_SIDE_BOTTOM);
+      PR_STATIC_ASSERT(eStyleAnimType_Sides_Left - eStyleAnimType_Sides_Top
+                         == NS_SIDE_LEFT);
+      static_cast<nsStyleSides*>(StyleDataAtOffset(aStyleStruct, ssOffset))->
+          Set(animType - eStyleAnimType_Sides_Top, aComputedValue);
+
+       nsStyleStructID sid = nsCSSProps::kSIDTable[aProperty];
+       if (sid == eStyleStruct_Margin) {
+         static_cast<nsStyleMargin*>(aStyleStruct)->RecalcData();
+       } else if (sid == eStyleStruct_Padding) {
+         static_cast<nsStylePadding*>(aStyleStruct)->RecalcData();
+       }
       return PR_TRUE;
     }
-    case eCSSProperty_stroke_width: {
-      const nsStyleSVG* styleSVG = aStyleContext->GetStyleSVG();
-      aComputedValue = styleSVG->mStrokeWidth;
-      return PR_TRUE;
-    }
-    default:
-      return PR_FALSE;
+    case eStyleAnimType_None:
+      NS_NOTREACHED("shouldn't use on non-animatable properties");
   }
+  return PR_FALSE;
 }
--- a/layout/style/nsStyleAnimation.h
+++ b/layout/style/nsStyleAnimation.h
@@ -16,16 +16,17 @@
  *
  * The Initial Developer of the Original Code is
  * The Mozilla Corporation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Daniel Holbert <dholbert@mozilla.com>, Mozilla Corporation
+ *   L. David Baron <dbaron@dbaron.org>, Mozilla Corporation
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -42,16 +43,17 @@
 #define nsStyleAnimation_h_
 
 #include "prtypes.h"
 #include "nsAString.h"
 #include "nsCSSProperty.h"
 
 class nsCSSDeclaration;
 class nsIContent;
+class nsPresContext;
 class nsStyleCoord;
 class nsStyleContext;
 
 /**
  * Utility class to handle animated style values
  */
 class nsStyleAnimation {
 public:
@@ -145,11 +147,26 @@ public:
    * @param aProperty     The property whose value we're looking up.
    * @param aStyleContext The style context to check for the computed value.
    * @param [out] aComputedValue The resulting computed value.
    * @return PR_TRUE on success, PR_FALSE on failure.
    */
   static PRBool ExtractComputedValue(nsCSSProperty aProperty,
                                      nsStyleContext* aStyleContext,
                                      nsStyleCoord& aComputedValue);
+
+  /**
+   * Sets the computed value for the given property in the given style
+   * struct.
+   *
+   * @param aProperty      The property whose value we're setting.
+   * @param aPresContext   The pres context associated with aStyleStruct.
+   * @param aStyleStruct   The style struct in which to set the value.
+   * @param aComputedValue The computed value.
+   * @return  PR_TRUE on success, PR_FALSE on failure.
+   */
+  static PRBool StoreComputedValue(nsCSSProperty aProperty,
+                                   nsPresContext* aPresContext,
+                                   void* aStyleStruct,
+                                   const nsStyleCoord& aComputedValue);
 };
 
 #endif