Bug 520486 (patch 2): Enable SVG/SMIL animation of properties with enumerated values. r=roc
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 21 Oct 2009 14:57:57 -0700
changeset 34084 3745dd4c718c1e8569dbf6d9134cf9cd3f8543a3
parent 34083 71af388ef07d0db405f420bb9653a795244a42dc
child 34085 a8dacfc7dfcc7a5ce9e274401fcee1df1aaae03e
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs520486
milestone1.9.3a1pre
Bug 520486 (patch 2): Enable SVG/SMIL animation of properties with enumerated values. r=roc
content/smil/nsSMILCSSProperty.cpp
content/smil/test/db_smilCSSFromTo.js
--- a/content/smil/nsSMILCSSProperty.cpp
+++ b/content/smil/nsSMILCSSProperty.cpp
@@ -227,61 +227,61 @@ nsSMILCSSProperty::IsPropertyAnimatable(
       return PR_FALSE;
 
     // PROPERTIES OF TYPE eCSSType_ValuePair
     case eCSSProperty_fill:
     case eCSSProperty_stroke:
       return PR_TRUE;
 
     // PROPERTIES OF TYPE eCSSType_Value
-    // XXXdholbert: Many properties' types aren't yet supported by
-    // nsStyleAnimation (due to using enumerated values, float values, URI
-    // values).  I'm commenting those properties out here for the time being,
-    // so that we don't try to animate them yet.
-    // case eCSSProperty_clip_rule:
+    // XXXdholbert: Some properties' types aren't yet supported by
+    // nsStyleAnimation (due to using URI values or string values).  I'm
+    // commenting those properties out here for the time being, so that we
+    // don't try to animate them yet.
+    case eCSSProperty_clip_rule:
     // case eCSSProperty_clip_path:
     case eCSSProperty_color:
-    // case eCSSProperty_color_interpolation:
-    // case eCSSProperty_color_interpolation_filters:
-    // case eCSSProperty_display:
-    // case eCSSProperty_dominant_baseline:
+    case eCSSProperty_color_interpolation:
+    case eCSSProperty_color_interpolation_filters:
+    case eCSSProperty_display:
+    case eCSSProperty_dominant_baseline:
     case eCSSProperty_fill_opacity:
-    // case eCSSProperty_fill_rule:
+    case eCSSProperty_fill_rule:
     // case eCSSProperty_filter:
     case eCSSProperty_flood_color:
     case eCSSProperty_flood_opacity:
     // case eCSSProperty_font_family:
     case eCSSProperty_font_size:
     case eCSSProperty_font_size_adjust:
     // case eCSSProperty_font_stretch:
-    // case eCSSProperty_font_style:
-    // case eCSSProperty_font_variant:
+    case eCSSProperty_font_style:
+    case eCSSProperty_font_variant:
     // case eCSSProperty_font_weight:
-    // case eCSSProperty_image_rendering:
+    case eCSSProperty_image_rendering:
     case eCSSProperty_letter_spacing:
     case eCSSProperty_lighting_color:
     // case eCSSProperty_marker_end:
     // case eCSSProperty_marker_mid:
     // case eCSSProperty_marker_start:
     // case eCSSProperty_mask:
     case eCSSProperty_opacity:
-    // case eCSSProperty_pointer_events:
-    // case eCSSProperty_shape_rendering:
+    case eCSSProperty_pointer_events:
+    case eCSSProperty_shape_rendering:
     case eCSSProperty_stop_color:
     case eCSSProperty_stop_opacity:
     case eCSSProperty_stroke_dashoffset:
-    // case eCSSProperty_stroke_linecap:
-    // case eCSSProperty_stroke_linejoin:
+    case eCSSProperty_stroke_linecap:
+    case eCSSProperty_stroke_linejoin:
     case eCSSProperty_stroke_miterlimit:
     case eCSSProperty_stroke_opacity:
     case eCSSProperty_stroke_width:
-    // case eCSSProperty_text_anchor:
-    // case eCSSProperty_text_decoration:
-    // case eCSSProperty_text_rendering:
-    // case eCSSProperty_visibility:
+    case eCSSProperty_text_anchor:
+    case eCSSProperty_text_decoration:
+    case eCSSProperty_text_rendering:
+    case eCSSProperty_visibility:
     case eCSSProperty_word_spacing:
       return PR_TRUE;
 
     // EXPLICITLY NON-ANIMATABLE PROPERTIES:
     // (Some of these aren't supported at all in Gecko -- I've commented those
     // ones out. If/when we add support for them, uncomment their line here)
     // ----------------------------------------------------------------------
     // case eCSSProperty_enable_background:
--- a/content/smil/test/db_smilCSSFromTo.js
+++ b/content/smil/test/db_smilCSSFromTo.js
@@ -158,74 +158,78 @@ var gFromToBundles = [
     new AnimTestcaseFromTo("rect(1px, 2px, 3px, 4px)",
                            "rect(11px, 22px, 33px, 44px)",
                            { midComp: "rect(6px, 12px, 18px, 24px)" }),
   ], "need support for rect() values"),
   new TestcaseBundle(gPropList.clip_path, _fromToTestLists.URIsAndNone),
   new TestcaseBundle(gPropList.clip_rule, [
     new AnimTestcaseFromTo("nonzero", "evenodd"),
     new AnimTestcaseFromTo("evenodd", "inherit", { toComp: "nonzero" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.color,
                      [].concat(_fromToTestLists.color, [
     // Note: inherited value is rgb(50, 50, 50) (set on <svg>)
     new AnimTestcaseFromTo("inherit", "rgb(200, 200, 200)",
                            { fromComp: "rgb(50, 50, 50)",
                              midComp: "rgb(125, 125, 125)" }),
   ])),
   new TestcaseBundle(gPropList.color_interpolation, [
     new AnimTestcaseFromTo("sRGB", "auto", { fromComp: "srgb" }),
     new AnimTestcaseFromTo("inherit", "linearRGB",
                          { fromComp: "srgb", toComp: "linearrgb" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.color_interpolation_filters, [
     new AnimTestcaseFromTo("sRGB", "auto", { fromComp: "srgb" }),
     new AnimTestcaseFromTo("auto", "inherit",
                          { toComp: "linearrgb" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.cursor, [
     new AnimTestcaseFromTo("crosshair", "move"),
     new AnimTestcaseFromTo("url('a.cur'), url('b.cur'), nw-resize", "sw-resize",
                            { fromComp: "url(\"" + _testPath + "/a.cur\"), " +
                                        "url(\"" + _testPath + "/b.cur\"), " +
                                        "nw-resize"})
   ], "need support for CSS value-lists and URI values"),
   new TestcaseBundle(gPropList.direction, [
     new AnimTestcaseFromTo("ltr", "rtl"),
     new AnimTestcaseFromTo("rtl", "inherit"),
   ]),
   new TestcaseBundle(gPropList.display, [
     // I'm not testing the "inherit" value for "display", because part of
     // my test runs with "display: none" on everything, and so the
     // inherited value isn't always the same.  (i.e. the computed value
     // of 'inherit' will be different in different tests)
-    new AnimTestcaseFromTo("block", "table-cell", {}),
-    new AnimTestcaseFromTo("inline", "inline-table", {}),
-    new AnimTestcaseFromTo("table-row", "none", {}),
-  ], "need support for enumerated values"),
+    new AnimTestcaseFromTo("block", "table-cell"),
+    new AnimTestcaseFromTo("inline", "inline-table"),
+    new AnimTestcaseFromTo("table-row", "none"),
+  ]),
   new TestcaseBundle(gPropList.dominant_baseline, [
     new AnimTestcaseFromTo("use-script", "no-change"),
     new AnimTestcaseFromTo("reset-size", "ideographic"),
-    new AnimTestcaseFromTo("text-after-edge", "text-before-edge"),
-  ], "need support for enumerated values"),
+    new AnimTestcaseFromTo("alphabetic", "hanging"),
+    new AnimTestcaseFromTo("mathematical", "central"),
+    new AnimTestcaseFromTo("middle", "text-after-edge"),
+    new AnimTestcaseFromTo("text-before-edge", "auto"),
+    new AnimTestcaseFromTo("use-script", "inherit", { toComp: "auto" } ),
+  ]),
   // NOTE: Mozilla doesn't currently support "enable-background", but I'm
   // testing it here in case we ever add support for it, because it's
   // explicitly not animatable in the SVG spec.
   new TestcaseBundle(gPropList.enable_background, [
     new AnimTestcaseFromTo("new", "accumulate"),
   ]),
   new TestcaseBundle(gPropList.fill,
                      [].concat(_fromToTestLists.color,
                                _fromToTestLists.paintServer,
                                _fromToTestLists.colorFromInheritBlack)),
   new TestcaseBundle(gPropList.fill_opacity, _fromToTestLists.opacity),
   new TestcaseBundle(gPropList.fill_rule, [
     new AnimTestcaseFromTo("nonzero", "evenodd"),
     new AnimTestcaseFromTo("evenodd", "inherit", { toComp: "nonzero" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.filter, _fromToTestLists.URIsAndNone),
   new TestcaseBundle(gPropList.flood_color,
                      [].concat(_fromToTestLists.color,
                                _fromToTestLists.colorFromInheritBlack)),
   new TestcaseBundle(gPropList.flood_opacity, _fromToTestLists.opacity),
   new TestcaseBundle(gPropList.font, [
     // NOTE: 'line-height' is hard-wired at 10px in test_smilCSSFromTo.xhtml
     // because if it's not explicitly set, its value varies across platforms.
@@ -269,22 +273,25 @@ var gFromToBundles = [
     new AnimTestcaseFromTo("normal", "wider"),
     new AnimTestcaseFromTo("narrower", "ultra-condensed"),
     new AnimTestcaseFromTo("extra-condensed", "condensed"),
     new AnimTestcaseFromTo("semi-condensed", "semi-expanded"),
     new AnimTestcaseFromTo("expanded", "extra-expanded"),
     new AnimTestcaseFromTo("ultra-expanded", "inherit", { toComp: "normal" }),
   ], "need support for all properties that get stored in nsFont"),
   new TestcaseBundle(gPropList.font_style, [
+    new AnimTestcaseFromTo("italic", "inherit", { toComp: "normal" }),
     new AnimTestcaseFromTo("normal", "italic"),
     new AnimTestcaseFromTo("italic", "oblique"),
-  ], "need support for all properties that get stored in nsFont"),
+    new AnimTestcaseFromTo("oblique", "normal"),
+  ]),
   new TestcaseBundle(gPropList.font_variant, [
     new AnimTestcaseFromTo("inherit", "small-caps", { fromComp: "normal" }),
-  ], "need support for all properties that get stored in nsFont"),
+    new AnimTestcaseFromTo("small-caps", "normal"),
+  ]),
   new TestcaseBundle(gPropList.font_weight, [
     new AnimTestcaseFromTo("100", "900"),
     new AnimTestcaseFromTo("700", "100",
                            // Note that '700' ends up as "bold" in computed
                            // style (not the other way around)
                            { fromComp: "bold" }),
     new AnimTestcaseFromTo("inherit", "200",
                            { fromComp: "400" }),
@@ -300,17 +307,17 @@ var gFromToBundles = [
   new TestcaseBundle(gPropList.glyph_orientation_vertical,
                      [ new AnimTestcaseFromTo("45deg", "60deg") ]),
   new TestcaseBundle(gPropList.image_rendering, [
     new AnimTestcaseFromTo("auto", "optimizeQuality",
                            { toComp: "optimizequality" }),
     new AnimTestcaseFromTo("optimizeQuality", "optimizeSpeed",
                            { fromComp: "optimizequality",
                              toComp: "optimizespeed" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.letter_spacing,
                      [].concat(_fromToTestLists.lengthPx,
                                _fromToTestLists.lengthPxPctSVG)),
   new TestcaseBundle(gPropList.letter_spacing,
                      _fromToTestLists.lengthPctSVG,
                      "pct->pct animations don't currently work for " +
                      "*-spacing properties"),
   new TestcaseBundle(gPropList.lighting_color,
@@ -326,24 +333,24 @@ var gFromToBundles = [
     new AnimTestcaseFromTo("auto", "visible"),
     new AnimTestcaseFromTo("scroll", "auto"),
   ], "need support for 'overflow' shorthand"),
   new TestcaseBundle(gPropList.pointer_events, [
     new AnimTestcaseFromTo("visibleFill", "stroke",
                            { fromComp: "visiblefill" }),
     new AnimTestcaseFromTo("none", "visibleStroke",
                            { toComp: "visiblestroke" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.shape_rendering, [
     new AnimTestcaseFromTo("auto", "optimizeSpeed",
                            { toComp: "optimizespeed" }),
     new AnimTestcaseFromTo("crispEdges", "geometricPrecision",
                            { fromComp: "crispedges",
                              toComp: "geometricprecision" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.stop_color,
                         [].concat(_fromToTestLists.color,
                                   _fromToTestLists.colorFromInheritBlack)),
   new TestcaseBundle(gPropList.stop_opacity, _fromToTestLists.opacity),
   new TestcaseBundle(gPropList.stroke,
                      [].concat(_fromToTestLists.color,
                                _fromToTestLists.paintServer, [
      // Note: inherited value is "none" (the default for "stroke" property)
@@ -360,59 +367,59 @@ var gFromToBundles = [
   ]), "need support for CSS value-lists"),
   new TestcaseBundle(gPropList.stroke_dashoffset,
                      [].concat(_fromToTestLists.lengthPx,
                                _fromToTestLists.lengthPxPctSVG,
                                _fromToTestLists.lengthPctSVG)),
   new TestcaseBundle(gPropList.stroke_linecap, [
     new AnimTestcaseFromTo("butt", "round"),
     new AnimTestcaseFromTo("round", "square"),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.stroke_linejoin, [
     new AnimTestcaseFromTo("miter", "round"),
     new AnimTestcaseFromTo("round", "bevel"),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.stroke_miterlimit, [
     new AnimTestcaseFromTo("1", "2", { midComp: "1.5" }),
     new AnimTestcaseFromTo("20.1", "10.1", { midComp: "15.1" }),
   ]),
   new TestcaseBundle(gPropList.stroke_opacity, _fromToTestLists.opacity),
   new TestcaseBundle(gPropList.stroke_width,
                      [].concat(_fromToTestLists.lengthPx,
                                _fromToTestLists.lengthPxPctSVG,
                                _fromToTestLists.lengthPctSVG, [
     new AnimTestcaseFromTo("inherit", "7px",
                            { fromComp: "1px", midComp: "4px"}),
   ])),
   new TestcaseBundle(gPropList.text_anchor, [
     new AnimTestcaseFromTo("start", "middle"),
     new AnimTestcaseFromTo("middle", "end"),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.text_decoration, [
     new AnimTestcaseFromTo("none", "underline"),
     new AnimTestcaseFromTo("overline", "line-through"),
     new AnimTestcaseFromTo("blink", "underline"),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.text_rendering, [
     new AnimTestcaseFromTo("auto", "optimizeSpeed",
                            { toComp: "optimizespeed" }),
     new AnimTestcaseFromTo("optimizeSpeed", "geometricPrecision",
                            { fromComp: "optimizespeed",
                              toComp: "geometricprecision" }),
     new AnimTestcaseFromTo("geometricPrecision", "optimizeLegibility",
                            { fromComp: "geometricprecision",
                              toComp: "optimizelegibility" }),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.unicode_bidi, [
     new AnimTestcaseFromTo("embed", "bidi-override"),
   ]),
   new TestcaseBundle(gPropList.visibility, [
     new AnimTestcaseFromTo("visible", "hidden"),
     new AnimTestcaseFromTo("hidden", "collapse"),
-  ], "need support for enumerated values"),
+  ]),
   new TestcaseBundle(gPropList.word_spacing,
                      [].concat(_fromToTestLists.lengthPx,
                                _fromToTestLists.lengthPxPctSVG)),
   new TestcaseBundle(gPropList.word_spacing,
                      _fromToTestLists.lengthPctSVG,
                      "pct->pct animations don't currently work for " +
                      "*-spacing properties"),
   // NOTE: Mozilla doesn't currently support "writing-mode", but I'm