OSDN Git Service

Support to the animate element
authordhrname <dhrname@users.sourceforge.jp>
Thu, 11 Jun 2015 14:29:56 +0000 (23:29 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Thu, 11 Jun 2015 14:29:56 +0000 (23:29 +0900)
org/w3c/dom/smil.js
tool/Spec/spec/SvgDomSpec.js

index 58282f8..cd953d1 100644 (file)
@@ -1015,6 +1015,7 @@ base("$calcMode").up("$attribute").mix( {
            return rgbColor;\r
         };\r
   }\r
+  ele && (this.mode = ele.getAttributeNS(null, "calcMode") || "linear")\r
   if (to) {\r
     this._funcs = to.map( function(x) {\r
       x.to.string = toRGB(x.to.string);\r
@@ -1032,8 +1033,25 @@ base("$calcMode").up("$attribute").mix( {
 \r
 function getDocument() \r
 {\r
-  var svg = document.getElementsByTagName("object").item(0),\r
-      svgDoc = svg && svg.getSVGDocument();\r
+  var svg = document.getElementsByTagName("object"),\r
+      svgns = "http://www.w3.org/2000/svg";\r
+  for (var i=0;i<svg.length;++i) {\r
+    if (svg) {\r
+      var svgDoc = svg[i].getSVGDocument(),\r
+          setElements = svgDoc.getElementsByTagNameNS(svgns, "set"),\r
+          animateElements = svgDoc.getElementsByTagNameNS(svgns, "animate");\r
+      init(base("$calcMode").$attribute.$setElement, setElements);\r
+      init(base("$calcMode").$attribute.$setElement.$animateElement, animateElements);\r
+    }\r
+  }\r
+  \r
+  function init (obj, eles) {\r
+    console.log(obj)\r
+    for (var i=0;i<eles.length;++i) {\r
+      obj.up().init(eles.item(i));\r
+    }\r
+  };\r
+  base("$frame").setFrame(300)\r
 }\r
 window.addEventListener && window.addEventListener("load", getDocument);\r
 //#endif // _SMIL_IDL_\r
index 0501220..c4bc844 100644 (file)
@@ -3150,7 +3150,7 @@ describe("SMIL Animation Spec", function() {
       \r
       /*discrete mode*/\r
       calc.mode = "discrete";\r
-      expect(calc.call()(0)).toBe("1");\r
+      expect(calc.call()(0)).toBe("0");\r
       expect(calc.call()(1)).toBe("1");\r
     } );\r
     /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
@@ -3748,12 +3748,20 @@ describe("SMIL Animation Spec", function() {
           f(24, "M20.0 0.0 L20.0 30.0");\r
           f(36, "M20.0 10.0 L15.0 30.0");\r
           f(48, "");\r
-          \r
+                    \r
           ele.setAttributeNS(null, "fill", "freeze");\r
           $animate.init(ele);\r
           f(24, "M20.0 0.0 L20.0 30.0");\r
           f(36, "M20.0 10.0 L15.0 30.0");\r
           f(48, "M20.0 20.0 L10.0 30.0");\r
+          \r
+          frame.timelines.length = 0;\r
+          ele.setAttributeNS(null, "calcMode", "discrete");\r
+          $animate.init(ele);\r
+          expect($animate.mode).toBe("discrete");\r
+          f(24, "M20 0 L20 30");\r
+          f(36, "M20 20 L20 30");\r
+          f(48, "M20 20 L10 30");\r
         } );\r
         /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
         it("should be this for the value (the valid partion )", function() {\r