[Sie-announce] SIEコード [2584] 1, SVGGradientElementのvar文の整理

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 10日 (日) 21:51:30 JST


Revision: 2584
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2584
Author:   dhrname
Date:     2011-04-10 21:51:30 +0900 (Sun, 10 Apr 2011)

Log Message:
-----------
1, SVGGradientElementのvar文の整理
2, SVGGradientElementについて、必要のないif文を削除

Modified Paths:
--------------
    branches/07x/075/org/w3c/dom/svg.js

Modified: branches/07x/075/org/w3c/dom/svg.js
===================================================================
--- branches/07x/075/org/w3c/dom/svg.js	2011-04-10 12:27:26 UTC (rev 2583)
+++ branches/07x/075/org/w3c/dom/svg.js	2011-04-10 12:51:30 UTC (rev 2584)
@@ -4315,52 +4315,54 @@
 SVGColorProfileRule.prototype = new SVGCSSRule();
 
 function SVGGradientElement() { 
-  SVGElement.apply(this, arguments);
-  SVGURIReference.apply(this, arguments);
+  SVGElement.apply(this);
+  SVGURIReference.apply(this);
   /*readonly SVGAnimatedEnumeration*/   this.gradientUnits = new SVGAnimatedEnumeration();
   /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
   /*readonly SVGAnimatedEnumeration*/   this.spreadMethod = new SVGAnimatedEnumeration();
   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
-    var grad = evt.target, ele = evt._tar, t = evt._style; //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
-    if (!!!ele) { //まだ、path要素などが設定されていない場合
+    var grad = evt.target,
+        ele = evt._tar,
+        t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
+        grad2 = grad,
+        href, stops, length,
+        color = [],
+        colors = [],
+        opacity = [];
+    if (!ele || !grad) { //まだ、path要素などが設定されていない場合
       return;
     }
-    if (grad) {
-      var grad2 = grad;
-      while (grad2 && !grad2.hasChildNodes()) { //stopを子要素に持つgradient要素を探す
-        var href = grad2.getAttributeNS("http://www.w3.org/1999/xlink", "href");
-        if (href) {
-          href.match(/#(.+)/);
-          grad2 = evt.target.ownerDocument.getElementById(RegExp.$1);
-        } else {
-          break;
-        }
+    while (grad2 && !grad2.hasChildNodes()) { //stopを子要素に持つgradient要素を探す
+      href = grad2.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+      if (href) {
+        href.match(/#(.+)/);
+        grad2 = evt.target.ownerDocument.getElementById(RegExp.$1);
+      } else {
+        break;
       }
-      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], sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
-        color[i] = sstyle.getPropertyValue("stop-color");
-        colors[i] = stop.offset.baseVal + " " + color[i];
-        opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * 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]+ "");
-      /*SVGRadialGradientElementインターフェースで利用する*/
-      grad._color = color;
-      grad = ele = stops = lengh = color = colors = opacity = null;        
     }
-    evt = t = null;
+    stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
+    if (!stops) {
+      ele = t = href = grad = grad2 = stops = null;
+      return;
+    }
+    length = stops.length;
+    for (var i = 0; i < length; ++i) {
+      var stop = stops[i], sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
+      color[i] = sstyle.getPropertyValue("stop-color");
+      colors[i] = stop.offset.baseVal + " " + color[i];
+      opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * 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]+ "");
+    /*SVGRadialGradientElementインターフェースで利用する*/
+    grad._color = color;
+    grad = ele = stops = lengh = color = colors = opacity = evt = t = null;
   }, false);
   return this;
 };




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