[Sie-announce] SIEコード [1779]

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 4月 5日 (月) 23:36:07 JST


Revision: 1779
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1779
Author:   dhrname
Date:     2010-04-05 23:36:07 +0900 (Mon, 05 Apr 2010)

Log Message:
-----------


Modified Paths:
--------------
    branches/ufltima/dom/svg.js

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-04-04 15:12:46 UTC (rev 1778)
+++ branches/ufltima/dom/svg.js	2010-04-05 14:36:07 UTC (rev 1779)
@@ -1161,7 +1161,7 @@
     var obje = document.getElementsByTagName("object");
     for (var i=0, objli=1;i<objli;++i) {
       var objei = {style:{}};//obje[i];
-      xmlhttp.open("GET", "tiger.svg", true);//objei.getAttribute("data"), true);
+      xmlhttp.open("GET", "4wd.svg", true);//objei.getAttribute("data"), true);
       xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
       xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
@@ -2029,7 +2029,7 @@
           var evtt = tar.ownerDocument.createEvent("MutationEvents");
           evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
           evtt._tar = !!tar._fillElement ? tar._fillElement : document.createElement("v:fill");
-          evtt._style = style;
+          evtt._style = style, evtt._ttar = tar;
           t.dispatchEvent(evtt);
           if (t.localName !== "radialGradient" && !!!tar._fillElement) {
             el.appendChild(evtt._tar);
@@ -2607,44 +2607,39 @@
   /*readonly SVGAnimatedEnumeration*/   this.gradientUnits = new SVGAnimatedEnumeration();
   /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
   /*readonly SVGAnimatedEnumeration*/   this.spreadMethod = new SVGAnimatedEnumeration();
-  this.addEventListener("DOMNodeInserted", function(evt) {
-    if (evt.eventPhase === Event.BUBBLING_PHASE) {
+  this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
+    var grad = evt.target, ele = evt._tar, t = evt._style; //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
+    if (!!!ele) { //まだ、path要素などが設定されていない場合
       return;
     }
-    evt.target.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
-      var grad = evt.target, ele = evt._tar, t = evt._style; //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
-      if (!!!ele) { //まだ、path要素などが設定されていない場合
+    if (grad) {
+      var grad2 = grad;
+      while (grad2 && !grad2.hasChildNodes()) { //stopを子要素に持つgradient要素を探す
+        grad2.getAttributeNS("http://www.w3.org/1999/xlink", "href").match(/#(.+)/);
+        grad2 = evt.target.ownerDocument.getElementById(RegExp.$1);
+      }
+      var stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
+      if (!stops) {
+        grad = grad2 = stops = null;
         return;
       }
-      if (grad) {
-        var grad2 = grad;
-        while (grad2 && !grad2.hasChildNodes()) { //stopを子要素に持つgradient要素を探す
-          grad2.getAttributeNS("http://www.w3.org/1999/xlink", "href").match(/#(.+)/);
-          grad2 = evt.target.ownerDocument.getElementById(RegExp.$1);
-        }
-        var stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
-        if (!stops) {
-          grad = grad2 = stops = null;
-          return;
-        }
-        var length = stops.length;
-        var color = [], colors = [], opacity = [];
-        for (var i = 0; i < length; ++i) {
-          var stop = stops[i];
-          color[i] = stop.style.getPropertyValue("stop-color");
-          colors[i] = stop.offset.baseVal + " " + color[i];
-          opacity[i] = (parseFloat(stop.style.getPropertyValue("stop-opacity")) || 1) * parseFloat(t.getPropertyValue("fill-opacity")) * parseFloat(t.getPropertyValue("opacity"));
-        }
-        ele.setAttribute("method", "none");
-        ele.setAttribute("color",  color[0]);
-        ele.setAttribute("color2", color[length-1]);
-        ele.setAttribute("colors", colors.join(","));
-        // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
-        ele.setAttribute("opacity", opacity[length-1]+ "");
-        ele.setAttribute("o:opacity2", opacity[0]+ "");
-        grad = ele = stops = lengh = color = colors = opacity = null;        
+      var length = stops.length;
+      var color = [], colors = [], opacity = [];
+      for (var i = 0; i < length; ++i) {
+        var stop = stops[i];
+        color[i] = stop.style.getPropertyValue("stop-color");
+        colors[i] = stop.offset.baseVal + " " + color[i];
+        opacity[i] = (parseFloat(stop.style.getPropertyValue("stop-opacity")) || 1) * parseFloat(t.getPropertyValue("fill-opacity")) * parseFloat(t.getPropertyValue("opacity"));
       }
-    }, false);
+      ele.setAttribute("method", "none");
+      ele.setAttribute("color",  color[0]);
+      ele.setAttribute("color2", color[length-1]);
+      ele.setAttribute("colors", colors.join(","));
+      // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
+      ele.setAttribute("opacity", opacity[length-1]+ "");
+      ele.setAttribute("o:opacity2", opacity[0]+ "");
+      grad = ele = stops = lengh = color = colors = opacity = null;        
+    }
   }, false);
   return this;
 };
@@ -2688,14 +2683,17 @@
   /*readonly SVGAnimatedLength*/ this.fx = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/ this.fy = new SVGAnimatedLength();
   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
-    var grad = evt.target, ele = evt._tar;
+    var grad = evt.target, ele = evt._tar, tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
     if (!!!ele) { //まだ、path要素などが設定されていない場合
       return;
     }
     ele.setAttribute("type", "gradientTitle");
     ele.setAttribute("focus", "100%");
     ele.setAttribute("focusposition", "0.5 0.5");
-    if (ele.localName === "rect") {
+    if (tar.localName === "rect") {
+      /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
+       *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
+       */
       var cx = parseFloat((grad.getAttributeNS(null, "cx") || "0.5"));
       var cy = parseFloat((grad.getAttributeNS(null, "cy") || "0.5"));
       var r = rx = ry = parseFloat((grad.getAttributeNS(null, "r") || "0.5"));
@@ -2741,9 +2739,11 @@
       background.filters[0].apply();
       background.innerHTML = circle;
       background.filters[0].play();
-      ele._tar.parentNode.insertBefore(background, ele.tar);
-      ele._tar.filled = "false";
+      ele.parentNode.insertBefore(background, ele);
+      ele.parentNode.filled = "false";
       ellipse = circle = data = list = pl = plm = gt = cx = cy = r = null;
+    } else if (!ele.parentNode){
+      tar._tar.appendChild(ele);
     }
   }, false);
   return this;




Sie-announce メーリングリストの案内
Back to archive index