[Sie-announce] SIEコード [2030] 1, _setPaintの最適化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 10月 1日 (金) 22:11:44 JST


Revision: 2030
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2030
Author:   dhrname
Date:     2010-10-01 22:11:44 +0900 (Fri, 01 Oct 2010)

Log Message:
-----------
1, _setPaintの最適化
2, DOMNodeInsertedIntoDocumentイベントに対する修正
3, getComputedTextLengthメソッドの修正

Modified Paths:
--------------
    branches/06x/061/org/w3c/dom/svg.js

Modified: branches/06x/061/org/w3c/dom/svg.js
===================================================================
--- branches/06x/061/org/w3c/dom/svg.js	2010-09-30 10:33:58 UTC (rev 2029)
+++ branches/06x/061/org/w3c/dom/svg.js	2010-10-01 13:11:44 UTC (rev 2030)
@@ -1447,7 +1447,7 @@
   objei.style.display = "none";
   xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
   xmlhttp.onreadystatechange = function() {
-    if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
+    if ((xmlhttp.readyState === 4)  &&  (xmlhttp.status === 200)) {
       /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因は不明)、
        *ここでは、responseTextを用いる
        */
@@ -1582,7 +1582,7 @@
       } else {
         /*全要素の読み込みが終了した場合*/
         NAIBU.Time.start();
-        NAIBU.doc = null;
+        delete NAIBU.doc;
       }
     }
   };
@@ -2069,9 +2069,9 @@
   var tod = tar.ownerDocument;
   var style = tod.defaultView.getComputedStyle(tar, "");
   var el = tar._tar, fill = style.getPropertyCSSValue("fill"), stroke = style.getPropertyCSSValue("stroke");
-  if (fill.paintType === SVGPaint.SVG_PAINTTYPE_RGBCOLOR || fill.paintType === SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) {
+  if (fill.paintType === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1 || fill.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
     var fillElement = !!tar._fillElement ? tar._fillElement : document.createElement("v:fill");
-    var fc = fill.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER;
+    var fc = fill.rgbColor, num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
     fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
     var fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
     if (fillOpacity < 1) {
@@ -2102,7 +2102,7 @@
   } else {
     el.filled = "false";
   }
-  if (stroke.paintType === SVGPaint.SVG_PAINTTYPE_RGBCOLOR || stroke.paintType === SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) {
+  if (stroke.paintType === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1 || stroke.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
     var strokeElement = !!tar._strokeElement ? tar._strokeElement : document.createElement("v:stroke");
     var sgsw = style.getPropertyCSSValue("stroke-width"), w = tod.documentElement.viewport.width, h = tod.documentElement.viewport.height;
     sgsw._percent = Math.sqrt((w*w + h*h) / 2);
@@ -2110,7 +2110,7 @@
     strokeElement.setAttribute("weight", swx + "px");
     sgsw = w = h = null;
     if (!stroke.uri) {
-      var fc = stroke.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER;
+      var fc = stroke.rgbColor, num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
       strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
       var strokeOpacity = parseFloat(style.getPropertyValue("stroke-opacity")) * parseFloat(style.getPropertyValue("opacity")); //opacityを掛け合わせる
       if (swx < 1) {
@@ -2172,8 +2172,10 @@
   SVGElement.apply(this);
   this._tar = document.createElement("v:shape");
   //interface SVGAnimatedPathData
-  /*readonly SVGPathSegList*/ this.animatedPathSegList = this.pathSegList = new SVGPathSegList();
-  /*readonly SVGPathSegList*/ this.animatedNormalizedPathSegList = this.normalizedPathSegList = new SVGPathSegList();
+  /*readonly SVGPathSegList*/ this.pathSegList = new SVGPathSegList();
+  this.animatedPathSegList = this.pathSegList;
+  /*readonly SVGPathSegList*/ this.normalizedPathSegList = new SVGPathSegList();
+  this.animatedNormalizedPathSegList = this.normalizedPathSegList;
   /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
   //以下は、d属性に変更があった場合の処理
   var ra = /\-/g, rb = /,/g, rc = /([a-yA-Y])/g, rd = /([zZ])/g, re = /,/, sgs = /\S+/g;
@@ -2508,9 +2510,10 @@
       var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
       dat[dat.length] = " e";
       tar._tar.path = dat.join(" ");
+      dat = null;
       tar._tar.coordsize = w + " " + h;
       NAIBU._setPaint(tar, matrix);
-      evt = tar = w = h = matrix = dat = x = y = null;
+      evt = tar = w = h = matrix  = x = y = _parseInt = null;
     }, false);
     evt = tar = null;
   }, false);
@@ -3254,6 +3257,9 @@
   this._isYokogaki = true;
   this.addEventListener("DOMNodeInserted", function(evt){
     var tar = evt.target, cur = evt.currentTarget;
+    /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
+     *あらかじめ、Capturingフェーズで処理しておく
+     */
     if ((evt.eventPhase === Event.CAPTURING_PHASE) && (tar.nodeType === Node.TEXT_NODE) && !!!tar._tar) {
       /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
       tar._tar = [];
@@ -3269,9 +3275,9 @@
         d.appendChild(document.createTextNode(tar.data.charAt(i)));
         tar._tar[tar._tar.length] = d;
       }
-      this._length += tar._tar.length;
-    } else if ((evt.eventPhase === Event.CAPTURING_PHASE) && (tar.localName === "tspan")) {
-      cur._length += tar.getNumberOfChars();
+      cur._length += tar._tar.length;
+    } else if ((evt.eventPhase === Event.CAPTURING_PHASE) && (tar instanceof SVGTextContentElement) && !!!tar._tar) {
+      cur._length += tar._length;
     }
     evt = tar = null;
   }, true);
@@ -3284,7 +3290,7 @@
   /*unsigned short*/ SVGTextContentElement.LENGTHADJUST_SPACING           = 1;
   /*unsigned short*/ SVGTextContentElement.LENGTHADJUST_SPACINGANDGLYPHS  = 2;
 /*long*/     SVGTextContentElement.prototype.getNumberOfChars = function() {
-  return (this._list.length / 3);
+  return (this._length);
 };
 /*float*/    SVGTextContentElement.prototype.getComputedTextLength = function() {
   var l = this.textLength.baseVal;
@@ -4190,7 +4196,7 @@
   }, false);
   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
     var tar = evt.target;
-    if (tar._tar) {
+    if (!!tar._tar && (tar.nodeType === Node.ELEMENT_NODE)) {
       var txts = tar._tar.style;
       txts.cursor = "hand";
       txts.textDecoration = "none";




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