OSDN Git Service

NAIBU.stop関数の修正をして、フレーム処理から時間処理に再び変更
[sie/sie.git] / org / w3c / dom / svg.js
index 871fa91..7dc35d7 100644 (file)
@@ -231,7 +231,7 @@ function SVGElement() {
        *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
        */
       eval("document._s = (function(evt){" +evt.newValue+ "})");
-      var v = name.slice(-2);
+      var v = name.slice(2);
       if (v === "load") {
         v = "SVGLoad";
       } else if (v === "unload") {
@@ -262,14 +262,12 @@ function SVGElement() {
           tvw = tod.viewport.width,
           tvh = tod.viewport.height,
           s,
-          n = evt.newValue.match(tar._NaNReg),
+          n = evt.newValue.slice(-2),
+          m = n.charAt(1),
           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
           _parseFloat = parseFloat;
-      if (!!n) {
-        n = n[0];
-      }
-      if (!n) { //軽量化のためにチェックを設ける
-      } else if (n === "%") {
+      if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
+      } else if (m === "%") {
         if (tar._x1width[name]) {
           tea.baseVal._percent = tvw * 0.01;
         } else if (tar._y1height[name]) {
@@ -315,7 +313,6 @@ SVGElement.prototype = new Element();
   this._syouReg = /^[^a-z\-]+/;
   this._conReg = /\:\s+/g;
   this._bouReg = /\s*;[^a-z\-]*/g;
-  this._NaNReg = /\D+$/;
   /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
    *getCTMメソッドで使う
    */
@@ -1033,7 +1030,7 @@ function SVGURIReference() {
           xmlhttp = NAIBU.xmlhttp;
           ui = uri.indexOf("#");
           if (ui > -1) {
-            id = uri.substring(ui+1, uri.length);
+            id = uri.slice(ui+1);
             uri = uri.replace(/#.+$/, "");
           } else {
             id = null;
@@ -1715,6 +1712,7 @@ function _ca_() {
     /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
      *ここでは、responseTextを用いる
      */
+    var dsd = new Date();
     var ifr = this._tar.previousSibling,
         ifcw = ifr.contentWindow,
         _doc;
@@ -1920,6 +1918,7 @@ function _ca_() {
     trstyle = tpstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
     /*IEのメモリリーク対策として、空関数を入力*/
     this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
+    alert(+(new Date()) - dsd);
     if (this._next) {
       ifcw && (ifr.contentWindow.screen.updateInterval = 0);
       ifr = ifcw = s = void 0;
@@ -1933,7 +1932,7 @@ function _ca_() {
         NAIBU._buff = setInterval(function(){
           var n = NAIBU._buff_num,
               dbuf = DOMImplementation._buffer_,
-              dbufli = dbuf.length,
+              dbufli = dbuf ? dbuf.length : 0, //極端な負荷がかかると、dbufはnullになる可能性あり
               s, evt;
           if (dbufli === 0) {
             clearInterval(NAIBU._buff);              
@@ -2073,13 +2072,9 @@ function SVGPoint() {
 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
   /*整数にしているのは、VMLの設計上、小数点を扱えないときがあるため*/
-  var x = parseInt(matrix.a * this.x + matrix.c * this.y + matrix.e);
-  var y = parseInt(matrix.b * this.x + matrix.d * this.y + matrix.f);
-  if ((-1 < x) && (x < 1)) {x=1;}
-  if ((-1 < y) && (y < 1)) {y=1;}
   var s = new SVGPoint();
-  s.x = x;
-  s.y = y;
+  s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
+  s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
   return s;
 };
 
@@ -2540,10 +2535,10 @@ for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を
 };
 
 /*documentは引数の変数として登録しておく*/
-(function(_doc, _pInt, _math) {
+(function(_doc, _math) {
 //freeArg関数はunloadで使う解放処理
 NAIBU.freeArg = function() {
-  SVGPathElement = _doc = _pInt = _math = void 0;
+  SVGPathElement = _doc = _math = void 0;
 };
 //仮のfill属性とstroke属性の処理
 NAIBU._setPaint = function(tar, matrix) {
@@ -2658,13 +2653,11 @@ NAIBU._setPaint = function(tar, matrix) {
   }
   cursor = style.getPropertyCSSValue("cursor");
   if (cursor && !cursor._isDefault) { //初期値でないならば
-    var tc = cursor.cssText;
-    el.style.cursor = tc.split(":")[1];
-    tc = void 0;
+    el.style.cursor = cursor.cssText.split(":")[1];
   }
   vis = style.getPropertyCSSValue("visibility");
   if (vis && !vis._isDefault) {
-    el.style.visibility = vis.cssText.substring(vis.cssText.indexOf(":")+1, vis.cssText.length);
+    el.style.visibility = vis.cssText.split(":")[1];
   }
   disp = style.getPropertyCSSValue("display");
   if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
@@ -3029,11 +3022,11 @@ _sproto._nodeInsertInto = function(evt){
   var tar = evt.target,
       matrix = tar.getScreenCTM(),
       tlist = tar.normalizedPathSegList,
-      _parseInt = _pInt,
       dat = [],
       ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
       cname = tar._com._nameCom,
-      isZ = tar._com._isZ, isC = tar._com._isC;
+      isZ = tar._com._isZ, isC = tar._com._isC,
+      mr = _math.round;
   for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
     var ti = tlist[i],
         tx = ti.x,
@@ -3046,14 +3039,14 @@ _sproto._nodeInsertInto = function(evt){
        *[mb md mf] * [y]
        *[0  0  1 ]   [1]
        */
-      t += [_parseInt(ma*ti.x1 + mc*ti.y1 + me, 10),
-             _parseInt(mb*ti.x1 + md*ti.y1 + mf, 10),
-             _parseInt(ma*ti.x2 + mc*ti.y2 + me, 10),
-             _parseInt(mb*ti.x2 + md*ti.y2 + mf, 10),
-             _parseInt(ma*tx + mc*ty + me, 10),
-             _parseInt(mb*tx + md*ty + mf, 10)].join(" ");
+      t += [mr(ma*ti.x1 + mc*ti.y1 + me),
+             mr(mb*ti.x1 + md*ti.y1 + mf),
+             mr(ma*ti.x2 + mc*ti.y2 + me),
+             mr(mb*ti.x2 + md*ti.y2 + mf),
+             mr(ma*tx + mc*ty + me),
+             mr(mb*tx + md*ty + mf)].join(" ");
     } else if (!isZ[tps]) {
-      t += _parseInt(ma*tx + mc*ty + me, 10)+ " " +_parseInt(mb*tx + md*ty + mf, 10);
+      t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
     }
     dat[i] = t;
   }
@@ -3064,7 +3057,7 @@ _sproto._nodeInsertInto = function(evt){
   tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
   NAIBU._setPaint(tar, matrix);
   delete tar._cacheMatrix;
-  evt = tar = dat = t = tx = ty = matrix = tlist = x = y = _parseInt = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
+  evt = tar = dat = t = tx = ty = matrix = tlist = x = y = mr = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
 };
 _sproto._com = {
   _nameCom : {
@@ -3345,7 +3338,7 @@ _sproto._com = {
   };
 })(SVGPathElement.prototype)
   NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
-})(document, parseInt, Math);
+})(document, Math);
 
 function SVGRectElement(_doc) {
   SVGElement.apply(this);
@@ -3436,7 +3429,8 @@ function SVGRectElement(_doc) {
           ele = tar._tar,
           vi = tar.ownerDocument.documentElement,
           w = vi.width.baseVal.value,
-          h = vi.height.baseVal.value;
+          h = vi.height.baseVal.value,
+          mr = Math.round;
       for (var i=0, lili=list.length;i<lili;) {
         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
           ++i;
@@ -3446,9 +3440,9 @@ function SVGRectElement(_doc) {
         p.x = list[i];
         p.y = list[i+1];
         pmt = p.matrixTransform(ctm);
-        list[i] = pmt.x;
+        list[i] = mr(pmt.x);
         ++i;
-        list[i] = pmt.y;
+        list[i] = mr(pmt.y);
         ++i;
         p = pmt = void 0;
       }
@@ -3458,7 +3452,7 @@ function SVGRectElement(_doc) {
       ele.coordsize = w + " " + h;
       NAIBU._setPaint(tar, ctm);
       delete tar._cacheMatrix;
-      evt = tar = style = list = dat = ele = vi = fontSize = void 0;
+      evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
     }, false);
     evt = tar = void 0;
   }, false);
@@ -3514,7 +3508,9 @@ function SVGCircleElement(_doc) {
         var rrx = rx * 0.55228, rry = ry * 0.55228;
         var list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
         //以下は、配列listそのものをCTMで座標変換していく処理
-        var par = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM();
+        var par = tar.ownerDocument.documentElement,
+            ctm = tar.getScreenCTM(),
+            mr = Math.round;
         for (var i=0, lili=list.length;i<lili;) {
           if (isNaN(list[i])) { //コマンド文字は読み飛ばす
             ++i;
@@ -3524,9 +3520,9 @@ function SVGCircleElement(_doc) {
           p.x = list[i];
           p.y = list[i+1];
           var pmt = p.matrixTransform(ctm);
-          list[i] = pmt.x;
+          list[i] = mr(pmt.x);
           ++i;
-          list[i] = pmt.y;
+          list[i] = mr(pmt.y);
           ++i;
           p = pmt = void 0;
         }
@@ -3538,7 +3534,7 @@ function SVGCircleElement(_doc) {
         ele.coordsize = w + " " + h;
         NAIBU._setPaint(tar, ctm);
         delete tar._cacheMatrix;
-        evt = tar = list = style = fontSize = dat = ele = void 0;
+        evt = tar = list = mr = style = fontSize = dat = ele = void 0;
     }, false);
     evt = tar = void 0;
   }, false);
@@ -3596,7 +3592,9 @@ function SVGEllipseElement(_doc) {
       var rrx = rx * 0.55228, rry = ry * 0.55228;
       var list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
       //以下は、配列listそのものをCTMで座標変換していく処理
-      var par = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM();
+      var par = tar.ownerDocument.documentElement,
+          ctm = tar.getScreenCTM(),
+          mr = Math.round;
       for (var i=0, lili=list.length;i<lili;) {
         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
           ++i;
@@ -3606,9 +3604,9 @@ function SVGEllipseElement(_doc) {
         p.x = list[i];
         p.y = list[i+1];
         var pmt = p.matrixTransform(ctm);
-        list[i] = pmt.x;
+        list[i] = mr(pmt.x);
         ++i;
-        list[i] = pmt.y;
+        list[i] = mr(pmt.y);
         ++i;
         p = pmt = void 0;
       }
@@ -3620,7 +3618,7 @@ function SVGEllipseElement(_doc) {
       ele.coordsize = w + " " + h;
       NAIBU._setPaint(tar, ctm);
       delete tar._cacheMatrix;
-      evt = ele = tar = style = fontSize = dat = list = ctm = w = h = void 0;
+      evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
     }, false);
     evt = tar = void 0;
   }, false);
@@ -3674,17 +3672,19 @@ function SVGLineElement(_doc) {
       tar.x2.baseVal._emToUnit(fontSize);
       tar.y2.baseVal._emToUnit(fontSize);
       //以下は、配列listそのものをCTMで座標変換していく処理
-      var vi = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM();
-      var dat = "m ";
-      var p = vi.createSVGPoint();
+      var vi = tar.ownerDocument.documentElement,
+          ctm = tar.getScreenCTM(),
+          dat = "m ",
+          mr = Math.round,
+          p = vi.createSVGPoint();
       p.x = tar.x1.baseVal.value;
       p.y = tar.y1.baseVal.value;
       var pmt = p.matrixTransform(ctm);
-      dat += pmt.x+ " " +pmt.y+ " l ";
+      dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
       p.x = tar.x2.baseVal.value;
       p.y = tar.y2.baseVal.value;
       pmt = p.matrixTransform(ctm);
-      dat += pmt.x+ " " +pmt.y;
+      dat += mr(pmt.x)+ " " +mr(pmt.y);
       p = pmt = void 0;
       //VMLに結び付けていく
       var ele = tar._tar, w = vi.width.baseVal.value, h = vi.height.baseVal.value;
@@ -3692,7 +3692,7 @@ function SVGLineElement(_doc) {
       ele.coordsize = w + " " + h;
       NAIBU._setPaint(tar, ctm);
       delete tar._cacheMatrix;
-      evt = ele = tar = style = fontSize = dat = list = ctm = vi = w = h = void 0;
+      evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
     }, false);
     evt = tar = void 0;
   }, false);
@@ -3760,13 +3760,14 @@ NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
       var tar = evt.target,
           tp = tar.points,
-          ctm = tar.getScreenCTM();
+          ctm = tar.getScreenCTM(),
+          mr = Math.round;
       //以下は、配列listそのものをCTMで座標変換していく処理
       for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
         var p = tp.getItem(i),
             pmt = p.matrixTransform(ctm);
-        list[2*i] = pmt.x;
-        list[2*i + 1] = pmt.y;
+        list[2*i] = mr(pmt.x);
+        list[2*i + 1] = mr(pmt.y);
         p = pmt = void 0;
       }
       list.splice(2, 0, "l");
@@ -3780,7 +3781,7 @@ NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
       ele.coordsize = w + " " + h;
       NAIBU._setPaint(tar, ctm);
       delete tar._cacheMatrix;
-      evt = ele = tar = dat = list = ctm = w = h = vi = void 0;
+      evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
     }, false);
     evt = tar = void 0;
   }, false);
@@ -3852,7 +3853,7 @@ t.prototype = new SVGElement();
   t.prototype._list = null;         //文字の位置を格納しておくリストのキャッシュ
   t.prototype._length = 0;          //全文字数
   t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
-  t.prototype._chars = 0;           //tspan要素が全体の何文字目から始まっているか
+  t.prototype._chars = 0;           //tspan (tref)要素が全体の何文字目から始まっているか
   t.prototype._isYokogaki = true;          //横書きかどうか
 /*long*/     t.prototype.getNumberOfChars = function() {
   return (this._length);
@@ -3924,7 +3925,7 @@ t.prototype = new SVGElement();
       while (ti) {
         if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
           tt = ti._tars;
-          /*tspan要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
+          /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
            *使う。また、属性が指定されていないときも同様に祖先や親を使う。
            *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
            *この処理はdx属性やdy、y属性でも同様とする
@@ -4006,8 +4007,9 @@ t.prototype = new SVGElement();
             ti = ti.parentNode;
           }
           ti = ti.nextSibling;
-        } else if ((ti.localName === "tspan") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
-          /*現在のテキスト位置(x,y)の分だけ、tspan要素をずらしておく。
+        } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
+            && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
+          /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
            *さらに、現在のテキスト位置を更新する
            */
           ti._stx = x;
@@ -4082,20 +4084,21 @@ function SVGTextPositioningElement(_doc) {
   /*readonly SVGAnimatedLengthList*/ this.y = new sl();
   /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
   /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
-  _doc = sl = void 0;
+  sl = void 0;
   /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
   this.addEventListener("DOMAttrModified", function(evt){
-    var tar = evt.target, name = evt.attrName, tod = tar.ownerDocument.documentElement;
-    var _parseFloat = parseFloat;
+    var tar = evt.target,
+        name = evt.attrName,
+        tod = tar.ownerDocument.documentElement,
+        _parseFloat = parseFloat;
     if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
-      var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/), teas = tar[name].baseVal;
+      var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
+          teas = tar[name].baseVal;
       for (var i=0, tli=enr.length;i<tli;++i) {
-        var tea = tod.createSVGLength();
-        var n = enr[i].match(/\D+$/), type = 0;
-        if (!!n) {
-          n = n[0];
-        }
-        if (!n) {
+        var tea = tod.createSVGLength(),
+            n = enr[i].slice(-1),
+            type = 0;
+        if (n >= "0" && n <= "9") {
           type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
         } else if (n === "%") {
           if ((name === "x") || (name === "dx")) {
@@ -4104,25 +4107,28 @@ function SVGTextPositioningElement(_doc) {
             tea._percent *= tod.viewport.height;
           }
           type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
-        } else if (n === "em") {
-          var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
-          tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
-          style = void 0;
-          type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
-        } else if (n === "ex") {
-          type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
-        } else if (n === "px") {
-          type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
-        } else if (n === "cm") {
-          type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
-        } else if (n === "mm") {
-          type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
-        } else if (n === "in") {
-          type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
-        } else if (n === "pt") {
-          type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
-        } else if (n === "pc") {
-          type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
+        } else {
+          n = enr[i].slice(-2);
+          if (n === "em") {
+            var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
+            tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
+            style = void 0;
+            type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
+          } else if (n === "ex") {
+            type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
+          } else if (n === "px") {
+            type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
+          } else if (n === "cm") {
+            type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
+          } else if (n === "mm") {
+            type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
+          } else if (n === "in") {
+            type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
+          } else if (n === "pt") {
+            type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
+          } else if (n === "pc") {
+            type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
+          }
         }
         var s = _parseFloat(enr[i]);
         s = isNaN(s) ? 0 : s;
@@ -4143,14 +4149,10 @@ function SVGTextPositioningElement(_doc) {
       evt = tar = void 0;
     }
   }, false);
-  return this;
-};
-SVGTextPositioningElement.constructor = SVGTextContentElement;
-SVGTextPositioningElement.prototype = new SVGTextContentElement();
-
-function SVGTextElement(_doc) {
-  SVGTextPositioningElement.apply(this, arguments);
-  this._tar = _doc.createElement("v:group");
+  if (_doc) {
+    this._tar = _doc.createElement("v:group");
+    this._doc = _doc; //_docプロパティは_texto関数内で使われる
+  }
   this.addEventListener("DOMNodeInserted", function(evt){
     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
       return; //強制終了させる
@@ -4179,157 +4181,167 @@ function SVGTextElement(_doc) {
       tpart.appendChild(tar._tar);      
     }
     tnext = tpart = isLast = void 0;
-    tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
-      var tar = evt.target,
-          ti = tar.firstChild,
-          ttp = tar._tar,
-          style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
-          n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
-          tod = tar.ownerDocument.documentElement,
-          ttpc = ttp, //ttpcはttpのキャッシュ
-          tlen = tar.getComputedTextLength(),
-          anchor = style.getPropertyValue("text-anchor"),
-          tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
-          ttps = ttp.style,
-          ae = [];
-      ttps.fontSize = n + "px";
-      ttps.fontFamily = style.getPropertyValue("font-family");
-      ttps.fontStyle = style.getPropertyValue("font-style");
-      ttps.fontWeight = style.getPropertyValue("font-weight");
-      /*ここでの変数jは前回ノードまでの総文字数*/
-      for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
-        if (ti) {
-          if (!!ti._tars && (ti._tars.length !== 0)) {
-            var ij = (i > j) ? i - j : j - i
-            var sty = ti._tars[ij].style,
-                p = tar.getStartPositionOfChar(i);
-            sty.position = "absolute";
-            if (tar._isYokogaki) {
-              if (anchor === "middle") {
-                p.x -= tlen / 2;
-              } else if (anchor === "end") {
-                p.x -= tlen;
-              }
-            } else {
-              if (anchor === "middle") {
-                p.y -= tlen / 2;
-              } else if (anchor === "end") {
-                p.y -= tlen;
-              }
-            }
-            sty.left = p.x + "px";
-            sty.top = p.y + "px";
-            sty.width = "0px";
-            sty.height = "0px";
-            sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
-            sty.lineHeight = n+10+ "px";
-            sty.textDecoration = tedeco;
-            sty.display = "none"
-            ttp.appendChild(ti._tars[ij]);
-            sty = p = void 0;
+    tar.addEventListener("DOMNodeInsertedIntoDocument", tar._texto, false);
+    evt = tar = void 0;
+  },false);
+  return this;
+};
+SVGTextPositioningElement.constructor = SVGTextContentElement;
+SVGTextPositioningElement.prototype = new SVGTextContentElement();
+SVGTextPositioningElement.prototype._texto = function(evt) {
+  var tar = evt.target,
+      ti = tar.firstChild,
+      ttp = tar._tar,
+      style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
+      n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
+      tod = tar.ownerDocument.documentElement,
+      ttpc = ttp, //ttpcはttpのキャッシュ
+      tlen = tar.getComputedTextLength(),
+      anchor = style.getPropertyValue("text-anchor"),
+      tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
+      ttps = ttp.style,
+      ae = [];
+  ttps.fontSize = n + "px";
+  ttps.fontFamily = style.getPropertyValue("font-family");
+  ttps.fontStyle = style.getPropertyValue("font-style");
+  ttps.fontWeight = style.getPropertyValue("font-weight");
+  /*ここでの変数jは前回ノードまでの総文字数*/
+  for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
+    if (ti) {
+      if (!!ti._tars && (ti._tars.length !== 0)) {
+        var ij = (i > j) ? i - j : j - i
+        var sty = ti._tars[ij].style,
+            p = tar.getStartPositionOfChar(i);
+        sty.position = "absolute";
+        if (tar._isYokogaki) {
+          if (anchor === "middle") {
+            p.x -= tlen / 2;
+          } else if (anchor === "end") {
+            p.x -= tlen;
           }
-          if (ti.nodeName === "#text") {
-            if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
-              j = j + ti.data.length;
-              if (ti.parentNode.localName === "a") {
-                ti =  ti.parentNode;
-                ttp = ttpc;
-              }
-              ti = ti.nextSibling;
-            }
-          } else if (!!ti.getNumberOfChars) {
-              if ((ti.getNumberOfChars()+j) <= i+1) {
-                j = j + ti.getNumberOfChars();
-                ti = ti.nextSibling;
-              }
-          } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
-            ttp = ti._tar;
-            ti = ti.firstChild;
-            ae[ae.length] = ti;
-            i-=2;
+        } else {
+          if (anchor === "middle") {
+            p.y -= tlen / 2;
+          } else if (anchor === "end") {
+            p.y -= tlen;
           }
         }
+        sty.left = p.x + "px";
+        sty.top = p.y + "px";
+        sty.width = "0px";
+        sty.height = "0px";
+        sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
+        sty.lineHeight = n+10+ "px";
+        sty.textDecoration = tedeco;
+        sty.display = "none"
+        ttp.appendChild(ti._tars[ij]);
+        sty = p = void 0;
       }
-      var color = style.getPropertyValue("fill"),
-          cursor = style.getPropertyCSSValue("cursor"),
-          vis = style.getPropertyCSSValue("visibility"),
-          disp = style.getPropertyCSSValue("display"),
-          tts = tar._tar.style,
-          tft = tar.firstChild._tars,
-          ttt = tft[0].innerText.charAt(0), //あらかじめ初期化しておく
-          tfti;
-      if (color === "none"){
-        tts.color = "transparent";
-      } else if (color.indexOf("url") === -1) {
-        tts.color = color;
-      } else {
-        tts.color = "black";
-      }
-      if (cursor && !cursor._isDefault) { //初期値でないならば
-        var tc = cursor.cssText;
-        tts.cursor = tc.substring(tc.indexOf(":")+1, tc.length);
-        tc = void 0;
-      }
-      if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
-          && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
-        /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
-         *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
-         */
-        for (var i=1, tli=tft.length;i<tli;++i) {
-          tfti = tft[i];
-          ttt += tfti.innerText;
-          tfti.parentNode.removeChild(tfti);
-        }
-        //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
-        tft[0].replaceChild(_doc.createTextNode(ttt), tft[0].firstChild);
-        ttt = void 0;
-      }
-      var isRect = true,
-          di = "block";
-      if (ttp.lastChild) {
-        if (ttp.lastChild.nodeName !== "rect") {
-          isRect = false;
-        }
-      } else {
-        isRect = false;
-      }
-      if (!isRect) {
-        var backr = _doc.createElement("v:rect"),
-            backrs = backr.style; //ずれを修正するためのもの
-        backrs.width = backrs.height = "1px";
-        backrs.left = backrs.top = "0px";
-        backr.stroked = backr.filled = "false";
-        ttp.appendChild(backr);
-      }
-      if (vis && !vis._isDefault) {
-        tts.visibility = vis.cssText.substring(vis.cssText.indexOf(":")+1, vis.cssText.length);
-      }
-      /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
-       *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
-       */
-      if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
-        di = "none";
-            } else if (disp && !disp._isDefault) {
-        di = "block";
-      }
-      var jt = tar._tar.firstChild,
-          j = 0;
-      while (jt) {
-        jt.style.display = di;
-        jt = jt.nextSibling;
-      }
-      while (ae[j]) { //要素内部にあるa要素の処理
-        for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
-          ae[j]._tars[l].style.display = di;
+      if (ti.nodeName === "#text") {
+        if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
+          j = j + ti.data.length;
+          if (ti.parentNode.localName === "a") {
+            ti =  ti.parentNode;
+            ttp = ttpc;
+          }
+          ti = ti.nextSibling;
         }
-        l = void 0;
-      ++j;
+      } else if (!!ti.getNumberOfChars) {
+          if ((ti.getNumberOfChars()+j) <= i+1) {
+            j = j + ti.getNumberOfChars();
+            ti = ti.nextSibling;
+          }
+      } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
+        ttp = ti._tar;
+        ti = ti.firstChild;
+        ae[ae.length] = ti;
+        i-=2;
       }
-      delete tar._cacheMatrix;
-      ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
-    }, false);
-    evt = tar = void 0;
-  },false);
+    }
+  }
+  var color = style.getPropertyValue("fill"),
+      cursor = style.getPropertyCSSValue("cursor"),
+      vis = style.getPropertyCSSValue("visibility"),
+      disp = style.getPropertyCSSValue("display"),
+      tts = tar._tar.style,
+      tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
+      ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
+      tfti;
+  if (color === "none"){
+    tts.color = "transparent";
+  } else if (color.indexOf("url") === -1) {
+    tts.color = color;
+  } else {
+    tts.color = "black";
+  }
+  if (cursor && !cursor._isDefault) { //初期値でないならば
+    var tc = cursor.cssText;
+    tts.cursor = tc.split(":")[1];
+    tc = void 0;
+  }
+  if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
+      && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
+    /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
+     *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
+     */
+    for (var i=1, tli=tft.length;i<tli;++i) {
+      tfti = tft[i];
+      ttt += tfti.innerText;
+      tfti.parentNode.removeChild(tfti);
+    }
+    //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
+    if (tft[0] && tft[0].replaceChild) {
+      tft[0].replaceChild(tar._doc.createTextNode(ttt), tft[0].firstChild);
+    }
+    ttt = void 0;
+  }
+  var isRect = true,
+      di = "block";
+  if (ttp.lastChild) {
+    if (ttp.lastChild.nodeName !== "rect") {
+      isRect = false;
+    }
+  } else {
+    isRect = false;
+  }
+  if (!isRect) {
+    var backr = tar._doc.createElement("v:rect"),
+        backrs = backr.style; //ずれを修正するためのもの
+    backrs.width = backrs.height = "1px";
+    backrs.left = backrs.top = "0px";
+    backr.stroked = backr.filled = "false";
+    ttp.appendChild(backr);
+  }
+  if (vis && !vis._isDefault) {
+    tts.visibility = vis.cssText.split(":")[1];
+  }
+  /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
+   *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
+   */
+  if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
+    di = "none";
+        } else if (disp && !disp._isDefault) {
+    di = "block";
+  }
+  var jt = tar._tar.firstChild,
+      j = 0;
+  while (jt) {
+    jt.style.display = di;
+    jt = jt.nextSibling;
+  }
+  while (ae[j]) { //要素内部にあるa要素の処理
+    for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
+      ae[j]._tars[l].style.display = di;
+    }
+    l = void 0;
+    ++j;
+  }
+  delete tar._cacheMatrix;
+  ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
+};
+
+function SVGTextElement(_doc) {
+  SVGTextPositioningElement.apply(this, arguments);
   return this;
 };
 SVGTextElement.constructor = SVGTextPositioningElement;
@@ -4342,8 +4354,26 @@ function SVGTSpanElement() {
 SVGTSpanElement.constructor = SVGTextPositioningElement;
 SVGTSpanElement.prototype = new SVGTextPositioningElement();
 
-function SVGTRefElement() {
+function SVGTRefElement(_doc) {
   SVGTextPositioningElement.apply(this, arguments);
+  this.addEventListener("DOMNodeInserted", function(evt){
+    if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
+      return; //強制終了させる
+    }
+    evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
+  }, false);
+  this.addEventListener("S_Load", function(evt){
+    var tar = evt.target,
+        tic = tar._instance.firstChild;
+    /*textノードのデータだけを処理*/
+    while (tic && (tic.nodeName !== "#text")) {
+      tic = tic.nextSibling;
+    }
+    tic && tar.parentNode.insertBefore(tar.ownerDocument.importNode(tic, false), tar);
+    evt.target = tar.parentNode;
+    tar.parentNode._texto(evt);
+    tar = tic = evtt = void 0;
+  }, false);
   SVGURIReference.apply(this, arguments);
   return this;
 };
@@ -4618,7 +4648,9 @@ function SVGRadialGradientElement(_doc) {
   sl = void 0;
   this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
-    var grad = evt.target, ele = evt._tar, tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
+    var grad = evt.target,
+        ele = evt._tar,
+        tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
     if (!!!ele) { //まだ、path要素などが設定されていない場合
       return;
     }
@@ -4629,32 +4661,50 @@ function SVGRadialGradientElement(_doc) {
       /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
        *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
        */
-      var style = grad.ownerDocument.defaultView.getComputedStyle(tar, "");
-      var fontSize = parseFloat(style.getPropertyValue("font-size"));
+      var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
+          fontSize = parseFloat(style.getPropertyValue("font-size"));
       grad.cx.baseVal._emToUnit(fontSize);
       grad.cy.baseVal._emToUnit(fontSize);
       grad.r.baseVal._emToUnit(fontSize);
       grad.fx.baseVal._emToUnit(fontSize);
       grad.fy.baseVal._emToUnit(fontSize);
-      var cx = grad.cx.baseVal.value, cy = grad.cy.baseVal.value;
-      var r = grad.r.baseVal.value, rx, ry;
+      var cx = grad.cx.baseVal.value,
+          cy = grad.cy.baseVal.value,
+          r = grad.r.baseVal.value,
+          mr = Math.round,
+          rx, ry;
       rx = ry = r;
-      var tarrect = tar.getBBox();
-      var vi = tar.ownerDocument.documentElement.viewport;
-      var el = vi.width | 0, et = vi.height | 0, er = 0, eb = 0;
-      var units = grad.getAttributeNS(null, "gradientUnits");
+      var tarrect = tar.getBBox(),
+          vi = tar.ownerDocument.documentElement.viewport,
+          el = mr(vi.width),
+          et = mr(vi.height),
+          er = 0,
+          eb = 0,
+          units = grad.getAttributeNS(null, "gradientUnits");
       if (!units || units === "objectBoundingBox") {
         //%の場合は小数点に変換(10% -> 0.1)
-        cx = cx > 1 ? cx/100 : cx; cy = cy > 1 ? cy/100 : cy; r = r > 1 ? r/100 : r;
+        cx = cx > 1 ? cx/100 : cx;
+        cy = cy > 1 ? cy/100 : cy;
+        r = r > 1 ? r/100 : r;
         //要素の境界領域を求める(四隅の座標を求める)
-        var nx = tarrect.x, ny = tarrect.y, wid = tarrect.width, hei = tarrect.height;
-        cx = cx*wid + nx; cy = cy*hei + ny; rx = r*wid; ry = r*hei;
+        var nx = tarrect.x,
+            ny = tarrect.y,
+            wid = tarrect.width,
+            hei = tarrect.height;
+        cx = cx*wid + nx;
+        cy = cy*hei + ny;
+        rx = r*wid;
+        ry = r*hei;
         nx = ny = wid = hei = void 0;
       }
       var matrix = tar.getScreenCTM().multiply(grad.getCTM());
-      el = cx - rx; et = cy - ry; er = cx + rx; eb = cy + ry;
-      var rrx = rx * 0.55228, rry = ry * 0.55228;
-      var list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"];
+      el = cx - rx;
+      et = cy - ry;
+      er = cx + rx;
+      eb = cy + ry;
+      var rrx = rx * 0.55228,
+          rry = ry * 0.55228,
+          list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"];
       for (var i = 0, lili = list.length; i < lili;) {
         if (isNaN(list[i])) { //コマンド文字は読み飛ばす
           ++i;
@@ -4664,31 +4714,37 @@ function SVGRadialGradientElement(_doc) {
         p.x = parseFloat(list[i]);
         p.y = parseFloat(list[i+1]);
         var pmt = p.matrixTransform(matrix);
-        list[i] = pmt.x;
+        list[i] = mr(pmt.x);
         i++;
-        list[i] = pmt.y;
+        list[i] = mr(pmt.y);
         i++;
         p = pmt = void 0;
       }
-      var ellipse = list.join(" ");
-      var outline = _doc.getElementById("_NAIBU_outline");
-      var background = _doc.createElement("div"), bstyle = background.style;
+      var ellipse = list.join(" "),
+          outline = _doc.getElementById("_NAIBU_outline"),
+          background = _doc.createElement("div"),
+          bstyle = background.style;
       bstyle.position = "absolute";
       bstyle.display = "inline-block";
-      var w = vi.width, h = vi.height;
-      bstyle.textAlign = "left"; bstyle.top = "0px"; bstyle.left = "0px"; bstyle.width = w+ "px"; bstyle.height = h+ "px";
+      var w = vi.width,
+          h = vi.height;
+      bstyle.textAlign = "left";
+      bstyle.top = "0px";
+      bstyle.left = "0px";
+      bstyle.width = w+ "px";
+      bstyle.height = h+ "px";
       outline.appendChild(background);
       bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
       background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
-      var circle = '<v:shape style="display:inline-block; position:relative; antialias:false; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>';
-      var data = tar._tar.path.value;
+      var circle = '<v:shape style="display:inline-block; position:relative; antialias:false; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>',
+          data = tar._tar.path.value;
       background.innerHTML = '<v:shape style="display:inline-block; position:relative; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +data+ '" stroked="f" fillcolor="' +grad._color[grad._color.length-1]+ '" ></v:shape>';
       background.filters[0].apply();
       background.innerHTML = circle;
       background.filters[0].play();
       tar._tar.parentNode.insertBefore(background, tar._tar);
       tar._tar.filled = "false";
-      ellipse = outline = background = style = fontSize = bstyle = circle = data = list = gt = cx = cy = r = w = h = matrix = void 0;
+      ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
     } else if (!ele.parentNode){
       tar._tar.appendChild(ele);
     }
@@ -5026,76 +5082,117 @@ function SVGAnimationElement(es) {
   this.style.setProperty = function(){};
   this._tar = null;
   /*readonly SVGElement*/ this.targetElement;
-  this._beginValue = "0ms";
-  this._endValue = null;
+  /*それぞれのプロパティは、_を除いた属性に対応している*/
+  this._begin = this._end = this._repeatCount = this._repeatDur = null;
+  this._dur = "indefinite";
   this._currentFrame = 0;
-  this._currentCount = 0;
   /*_maxCountはrepeatCount属性で指定された数値
    *_maxDurはrepeatDur属性で指定された数値
    */
   this._maxCount = 0;
   this._maxDur = 0;
+  /*_isRepeatと_numRepeatは繰り返し再生のときに使う。なお、後者は現在のリピート回数*/
   this._isRepeat = false;
-  /*_simpleDurationプロパティは
-   *dur属性の数値を収納しておく。属性がなければnullのまま
-   */
-  this._simpleDuration = null;
-  /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
-   *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
+  this._numRepeat = 0;
+  /*_startと_finishプロパティはミリ秒数を収納する。
+   *_startはアニメ開始時の秒数。_finishはアニメ終了時の秒数。
    *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
    */
-  this._begin = null;
-  this._end = null;
+  this._start = this._finish = null;
   this._from = this._to = this._values = this._by = null;
   this._keyTimes = null;
   this.addEventListener("beginEvent", function(evt) {
-    var tar = evt.target;
-    if (!tar.isRepeat) {
-      tar.endElementAt(tar.getSimpleDuration());
-    } else {
-      tar.beginElementAt(tar.getSimpleDuration());
-      if (tar.getCurrentTime() !== 0) {
-        var ttd = tar.ownerDocument, evt = ttd.createEvent("TimeEvents");
-        tar._currentCount++;
-        evt.initTimeEvent("repeatEvent", ttd.defaultView, tar._currentCount);
-        tar.dispatchEvent(evt);
+    try {
+      var tar = evt.target,
+      be = tar._start,
+      dur = tar.getSimpleDuration(),
+      durv = tar._dur,
+      end = tar._finish,
+      endv= tar._end,
+      td = tar._repeatDur,
+      tc = tar._repeatCount,
+      ac = 0;
+      /*Activate Duration (活性持続時間と呼ぶことにする)を計算
+       *計算方法は以下を参照のこと
+       *http://www.w3.org/TR/smil-animation/#ComputingActiveDur
+       *3.3.4. Computing the active duration
+       */
+      if ((td === "indefinte") || (tc === "indefinte")) {
+        if (endv) {
+          ac = end - begin;
+        } else {
+          /*活性持続時間が不定(indefinte)なので、強制的にアニメを終了させる*/
+        }
+      } else if (durv === "indefinte") {
+        if (!tc && !endv) {
+          /*活性持続時間が不定(indefinte)なので、強制的にアニメを終了させる*/   
+        } else if (tc && !endv) {
+          ac = tar._getOffset(td);
+        } else if (!tc && endv) {
+          ac = end - begin;
+        } else {
+          ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
+        }
+      } else if (durv && !td && !tc && !endv) {
+        ac = dur;
+      } else if (durv && !td && tc && !endv) {
+        ac = dur * (+tc);
+      } else if (durv && td && !tc && !endv) {
+        ac = tar._getOffset(td);
+      } else if (durv && !td && !tc && endv) {
+        ac = (dur > (end - begin)) ? dur : (end - begin);
+      } else if (durv && td && tc && !endv) {
+        ac = (+tc*dur > tar._getOffset(td)) ? +tc*dur : tar._getOffset(td);
+      } else if (durv && td && tc && endv) {
+        ac = (+tc*dur > Math.min(+td, (end-begin))) ? +tc*dur : Math.min(tar._getOffset(td), (end - begin));
+      } else if (durv && td && !tc && endv) {
+        ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
+      } else if (durv && !td && tc && endv) {
+        ac = (+tc*dur > (end - begin)) ? +tc*dur : (end - begin)
       }
+    } catch (e) {
+      throw new DOMException(DOMException.INVALID_STATE_ERR);
     }
+    tar.endElementAt(active);
   }, false);
   this.addEventListener("DOMAttrModified", function(evt){
     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
       return;
     }
-    var tar = evt.target, name = evt.attrName;
+    var tar = evt.target,
+        name = evt.attrName,
+        evtv = evt.newValue;
     if (name === "begin") {
-      tar._beginValue = evt.newValue;
+      tar._begin = evtv;
     } else if (name === "end") {
-      tar._endValue = evt.newValue;
+      tar._end = evtv;
     } else if (name === "dur") {
-      tar._simpleDuration = tar._getOffset(evt.newValue);
+      tar._dur = evtv;
     } else if (name === "repeatCount") {
-      tar._maxCount = parseFloat(evt.newValue);
+      tar._maxCount = parseFloat(evtv);
+      tar._repeatCount = evtv;
       tar._isRepeat = true;
     } else if (name === "repeatDur") {
-      tar._maxDur = parseFloat(evt.newValue);
+      tar._maxDur = parseFloat(evtv);
+      tar._repeatCount = evtv;
       tar._isRepeat = true;
     } else if (name === "from") {
-      tar._from = evt.newValue;
+      tar._from = evtv;
     } else if (name === "to") {
-      tar._to = evt.newValue;
+      tar._to = evtv;
     } else if (name === "values") {
-      tar._values = evt.newValue.split(";");
+      tar._values = evtv.split(";");
     } else if (name === "by") {
-      tar._by = evt.newValue;
+      tar._by = evtv;
     } else if (name === "keyTimes") {
-      var s = evt.newValue.split(";");
+      var s = evtv.split(";");
       tar._keyTimes = []; //_keyTimesプロパティを初期化
       for (var i=0;i<s.length;++i) {
         tar._keyTimes[i] = parseFloat(s[i]);
       }
       s = void 0;
     }
-    evt = void 0;
+    evt = evtv = void 0;
   }, false);
   this.addEventListener("DOMNodeInserted", function(evt){
     if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
@@ -5127,43 +5224,86 @@ function SVGAnimationElement(es) {
          */
         return this;
       }
+      /*begin属性とend属性を処理する*/
+      var _begin =  tar._begin ? tar._getOffset(tar._begin) : 0,
+          that = tar,
+          timing = function(val, name, offset) {
+        /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
+         *まず、idを検出するためのsearcIdローカル関数を作る
+         */
+        var searchId = function () {
+              var n = val.indexOf(".");
+              if ((n > 0) && (/[a-z]/i).test(val.charAt(n+1))) { //. (dot)の後がアルファベットならば
+                return (val.slice(0, n));
+              }
+              n = nn = void 0;
+              return "";
+            },
+            id;
+        /*
+         *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
+         */
+        if (isFinite(parseFloat(val))) { //1) offset-valueの場合
+          that[name](offset);
+        } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
+          var inte = parseFloat(val.slice(7)),
+              ds = function (evt) {
+                if (inte === evt.target._numRepeat) {
+                  that[name](offset);
+                }
+              };
+              id = searchId();
+              if (id) {
+                that.ownerDocument.getElementById(id).addEventListener("repeatEvent", ds);
+              } else {
+                that.addEventListener("repeatEvent", ds);
+              }
+        } else if ((/\.(begin|end)/).test(val)) { //3) syncbase-valueの場合
+          id = searchId();
+          if (id) {
+            var ds = function (evt) {
+                  that[name](offset);
+                },
+                ev = "";
+            if (RegExp.$1 === "begin") {
+              ev = "beginEvent";
+            } else if (RegExp.$1 === "end") {
+              ev = "endEvent";
+            }
+            that.ownerDocument.getElementById(id).addEventListener(ev, ds);
+          }
+        } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
+          
+        } else if (val === "indefinte") { //5) indefinteの場合
+        } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
+          
+        } else { //7) event-valueの場合
+          id = searchId();
+          var ds = function (evt) {
+               that[name](offset);
+              };
+          if (id && val.match(/\.([a-z]+)/i)) {
+            that.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
+          } else if (val){
+            that.targetElement.addEventListener(val.match(/^[a-z]+/i)[0], ds)
+          }
+        }
+        val = searchId = id = void 0;
+      };
+      timing((tar._begin || "0ms"), "beginElementAt", _begin);
+      if (tar._end) {
+        timing(tar._end, "endElementAt", tar._getOffset(tar._end));
+      }
+      that = void 0;
       if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
         tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").substring(1))
       } else {
         tar.targetElement = tar.parentNode;
       }
-      tar._eventSync(tar._beginValue,
-          (function(te, offse, ta, t) {
-            ta.addEventListener( t.match(te._eventRegExp)[0],
-              function(){
-                if (offse !== 0) {
-                  te.beginElementAt(offse);
-                } else {
-                  te._begin = NAIBU.Time.currentFrame;
-                  te.beginElement();
-                  te._currentFrame++;
-                }
-              }, false);
-           }), "beginElementAt");
-      if (tar._endValue) {
-        tar._eventSync(tar._endValue,
-            (function(te, offse, ta, t) {
-              ta.addEventListener( t.match(te._eventRegExp)[0],
-                  function(){
-                    te.endElementAt(offse);
-                  }, false );
-              }), "endElementAt");
-      }
       evt = tar = void 0;
     }, false);
     evt = tar = void 0;
   }, false);
-  this.addEventListener("repeatEvent", function(evt) {
-    var tar = evt.target;
-    if ((tar._currentCount >= tar._maxCount) || (tar.getCurrentTime() >= (tar._maxDur+tar.getStartTime()))) {
-      tar._isRepeat = false;
-    }
-  }, false);
   return this;
 };
 SVGAnimationElement.constructor = SVGElement;
@@ -5183,14 +5323,14 @@ SVGAnimationElement.prototype = new SVGElement();
 };
 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
   var ntc = this.ownerDocument.documentElement.getCurrentTime();
-  this._begin = offset + ntc;
+  this._start = offset + ntc;
 };
 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
   var ntc = this.ownerDocument.documentElement.getCurrentTime();
-  this._end = offset + ntc;
+  this._finish = offset + ntc;
 };
 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
-SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/;
+SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?$/;
 SVGAnimationElement.prototype._unit = {
     "h"   : 2880000,
     "min" : 48000,
@@ -5206,43 +5346,20 @@ SVGAnimationElement.prototype._unit = {
  ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
  */
 SVGAnimationElement.prototype._getOffset = function(/*string*/ t) {
-  var n = parseFloat(t.match(this._timeRegExp));
-  if (!isNaN(n) && RegExp.$1) {
+  var n = parseFloat(t.match(this._timeRegExp)),
+      offset = 0;
+  if (isFinite(n) && RegExp.$1) {
     var offset = n * this._unit[RegExp.$1]
-  } else if (!isNaN(n)) {
-    var offset = n;
-  } else {
-    var offset = 0;
+  } else if (isFinite(n)) {
+    offset = n;
   }
   n = t = void 0;
   return offset;
 };
-/*_eventSyncメソッド
- *イベントがある場合とない場合とで、別々の処理に分けるメソッド
- */
-SVGAnimationElement.prototype._eventSync = function(/*string*/ t, /*function*/ f, /*string*/ methodName) {
-  var offset = this._getOffset(t);
-  this._begin = NAIBU.Time.Max;
-  if ( /(mouse|activ|click|begin|end)/.test(t) ) { //イベントがある場合
-    var tar;
-    if ( /([^;]+)\.\D/.test(t) ) {
-      tar = this.ownerDocument.getElementById(RegExp.$1);
-    } else {
-      tar = this.targetElement;
-    }
-    if (!offset && offset !== 0) {
-      offset = NAIBU.Time.Max;
-    }
-    f(this, offset, tar, t);
-  } else if (!offset && (t !== "undefined") && (offset !== 0)) {
-    this._begin = 0;
-  } else {
-    this[methodName](offset);
-  }
-};
+
 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
-  if (!!this._begin || (this._begin === 0)) {
-    return (this._begin);
+  if (this._start || (this._start === 0)) {
+    return (this._start);
   } else {
     throw new DOMException(DOMException.INVALID_STATE_ERR);
   }
@@ -5255,14 +5372,11 @@ SVGAnimationElement.prototype._eventSync = function(/*string*/ t, /*function*/ f
   return (this._currentFrame * 125 * 0.8);
 };
 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
-  if (!!!this._simpleDuration && !!!this._end && (this._simpleDuration !== 0)) {
+  if (!this._dur && !this._finish && (this._dur === "indefinte")) {
     throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
-  } else if (!!this._simpleDuration && !!this._end) {
-    var s = (this._simpleDuration > this._end - this._begin) ? this._end - this._begin : this._simpleDuration;
   } else {
-    var s = !!this._end ? this._end - this._begin : this._simpleDuration;
+    return (this._getOffset(this._dur));
   }
- return s;
 };
                     //raises( DOMException );
 NAIBU.Time = {
@@ -5277,34 +5391,40 @@ NAIBU.Time = {
     }
     NAIBU.stop = setInterval( (function() {
 /*      try{*/
-        var ntc = NAIBU.Time.currentFrame++;
-        var nc = NAIBU.Clip;
-        var s = ntc * 100; //フレーム数ntcをミリ秒数sに変換
+        var ntc = NAIBU.Time.currentFrame,
+            nc = NAIBU.Clip,
+            s = ntc * 100; //フレーム数ntcをミリ秒数sに変換 (100 = 125 * 0.8)
         if (ntc > NAIBU.Time.Max) {
           clearInterval(NAIBU.stop);
         }
+        nc[0] && nc[0].ownerDocument.documentElement.setCurrentTime(s);
         for (var i=0,ncli=nc.length;i<ncli;++i) {
-          var nci = nc[i];
-          nci.ownerDocument.documentElement.setCurrentTime(s);
-          if ("_begin" in nci) {
-            if (nci.getStartTime() <= s) {
-              if (nci.getCurrentTime() === 0) {
-                nci.beginElement();
-              }
-              nci._currentFrame++;
-            }
-            if (nci._end && (nci._end <= s) && (nci.getCurrentTime() !== 0)) {
-              nci.endElement();
-              nci._frame && nci._frame();
-              nci._currentFrame = 0;
-              delete nci._begin;
-              nci._end = null;
-            } else if (!!nci._frame) {
-              nci._frame();
-            }
+          var nci = nc[i]
+              s2 = s + 100,
+              s1 = s - 100;
+          if ((nci._start || (nci._start === 0)) && (nci.getCurrentTime() === 0) && (s1 <= nci._start && nci._start < s2)) {
+            nci.beginElement();
+          }
+          if (nci._isRepeat && (nci.getCurrentTime() !== 0) && ((nci.getSimpleDuration() % s) === 0)) {
+            var ttd = nci.ownerDocument,
+                evt = ttd.createEvent("TimeEvents");
+            ++nci._numRepeat;
+            evt.initTimeEvent("repeatEvent", ttd.defaultView, nci._numRepeat);
+            nci.dispatchEvent(evt);
+            ttd = evt = void 0;
+          }
+          if ((nci._finish || (nci._finish === 0)) && (s1 <= nci._finish && nci._finish < s2) && (nci.getCurrentTime() !== 0)) {
+            nci.endElement();
+            nci._frame && nci._frame();
+            nci._currentFrame = 0;
+          }
+          if (nci._frame) {
+            nci._currentFrame++;
+            nci._frame();
           }
-          nci = void 0;
         }
+        ++NAIBU.Time.currentFrame;
+        nci = s1 = s2 = void 0;
 /*      } catch (e) {
         stlog.add(e, 4157);
       }*/
@@ -6070,9 +6190,9 @@ NAIBU._fontSearchURI = function(evt){
   var doc = evt.target.ownerDocument;
   var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
   for (var i=0;i<tsrc.length;++i) {
-    var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href");
-    var ids = src.substring(src.indexOf("#")+1, src.length);
-    var xmlhttp = NAIBU.xmlhttp;
+    var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
+        ids = src.split(":")[1],
+        xmlhttp = NAIBU.xmlhttp;
     xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
     xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
     xmlhttp.onreadystatechange = function() {
@@ -6114,7 +6234,7 @@ NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/
       dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
       dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
       fontSize = parseFloat(style.getPropertyValue("font-size")),
-      fe = fontSize / em;
+      fe = fontSize / em,
       ds = false, npdlist = ["fill",
   "fill-opacity",
   "stroke",
@@ -6167,7 +6287,12 @@ NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/
             matrix.a = fe;
             matrix.d = -fe;
             for (var j=0;j<npdlist.length;++j){
-              var nj = npdlist[j], tg = ti.getAttributeNS(null, nj);
+              var nj = npdlist[j],
+                  tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
+              if (nj === "stroke-width") {
+                tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
+                tg += "";
+              }
               if (tg) {
                 path.setAttributeNS(null, nj, tg);
               }