[Sie-announce] SIEコード [1815] SVGURIReferenceオブジェクトの実装に着手

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 5月 10日 (月) 23:42:41 JST


Revision: 1815
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1815
Author:   dhrname
Date:     2010-05-10 23:42:40 +0900 (Mon, 10 May 2010)

Log Message:
-----------
SVGURIReferenceオブジェクトの実装に着手

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

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-05-07 13:25:00 UTC (rev 1814)
+++ branches/ufltima/dom/svg.js	2010-05-10 14:42:40 UTC (rev 1815)
@@ -763,6 +763,48 @@
  */
 function SVGURIReference() {
   /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
+  this.addEventListener("DOMAttrModified", function(evt){
+    this.href.baseVal = evt.newValue;
+  }, false);
+  this.addEventListener("DOMNodeInserted", function(evt){
+    var tar = evt.target;
+    if (evt.eventPhase === Event.BUBBLING_PHASE) {
+      return; //強制終了させる
+    }
+    if (tar.href.baseVal !== "") { //xlink:href属性が指定されたとき
+      var base, href = tar.href.baseVal;
+      var egbase = tar.xmlbase;
+      if (!egbase) {
+        var ep = tar.parentNode, b = null;
+        while(!b && ep) {
+          b = ep.xmlbase;
+          if (b) {
+            break;
+          }
+          ep = ep.parentNode;
+        }
+        base = b;
+        if (!b) { //xml:baseの指定がなければ
+          if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
+            var lh = location.href;
+            base = lh.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
+          } else{
+            base = location.href;
+          }
+        }
+      } else{
+      base = egbase;
+      }
+      if (href.indexOf(":") === -1) {
+        tar.xmlbase = base;
+      }  else{
+        tar.xmlbase = "";
+      }
+      tar.href.baseVal = href;
+    }
+    tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
+    }, false);
+  }, false);
   return this;
 };
 function SVGCSSRule() { 
@@ -1097,7 +1139,6 @@
   /*readonly SVGAnimatedLength*/   this.height = new SVGAnimatedLength();
   /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
   /*readonly SVGElementInstance*/ this.animatedInstanceRoot = this.instanceRoot;//アニメの最中のインスタンス。静止中は通常
-  this._xlink = new SVGURIReference(this);                                      //XLink言語のURI参照
   return this;
 };
 SVGUseElement.constructor = SVGElement;
@@ -1116,12 +1157,10 @@
   /*readonly SVGElementInstance*/ this.lastChild;
   /*readonly SVGElementInstance*/ this.previousSibling;
   /*readonly SVGElementInstance*/ this.nextSibling;
-  this._xlink = new SVGURIReference(this);                 //XLink言語のURI参照
   return this;
 };
 SVGElementInstance.prototype = new Node();
 /*SVGElementInstanceList
- *以下はArrayで代用するので、使わない
  */
 function SVGElementInstanceList() { 
   /*readonly unsigned long*/ this.length = 0;
@@ -2700,7 +2739,7 @@
               if (kern.indexOf(tdc) > -1) {
                 alm = fontSize * 0.7;
               } else if ((tdc === "r") || (tdc === "s")){
-                alm = fontSize * 0.65;
+                alm = fontSize * 0.6;
               } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G")){
                 alm = fontSize * 0.2;
               } else if (akern.indexOf(tdc) > -1){
@@ -2921,7 +2960,7 @@
 
 function SVGTRefElement() {
   SVGTextPositioningElement.apply(this, arguments);
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGTRefElement.constructor = SVGTextPositioningElement;
@@ -2932,7 +2971,7 @@
   /*readonly SVGAnimatedLength*/      this.startOffset;
   /*readonly SVGAnimatedEnumeration*/ this.method;
   /*readonly SVGAnimatedEnumeration*/ this.spacing;
-  this._xlink = new SVGURIReference(this);  
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGTextPathElement.constructor = SVGTextContentElement;
@@ -2951,7 +2990,7 @@
   SVGTextPositioningElement.apply(this, arguments);
   /*DOMString*/ this.glyphRef;
   /*DOMString*/ this.format;
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
@@ -2979,7 +3018,7 @@
   /*float*/    this.y;
   /*float*/    this.dx;
   /*float*/    this.dy;
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGGlyphRefElement.constructor = SVGElement;
@@ -3061,7 +3100,7 @@
                        // prefix will be removed upon processing)
   /*DOMString*/      this.name;
   /*unsigned short*/ this.renderingIntent;
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGColorProfileElement.constructor = SVGElement;
@@ -3249,7 +3288,7 @@
   /*readonly SVGAnimatedLength*/        this.y = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/        this.width = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/        this.height = new SVGAnimatedLength();
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
     //SVGFitToViewBoxのインターフェースを用いる
   /*readonly SVGAnimatedRect*/   this.viewBox = new SVGAnimatedRect();
   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
@@ -3290,8 +3329,8 @@
   /*readonly SVGAnimatedLength*/      this.height = new SVGAnimatedLength();
   /*readonly SVGAnimatedInteger*/     this.filterResX = new SVGAnimatedInteger();
   /*readonly SVGAnimatedInteger*/     this.filterResY = new SVGAnimatedInteger();
-  this._xlink = new SVGURIReference(this);
-    void setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
+  SVGURIReference.apply(this, arguments);
+  //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
   return this;
 };
 SVGFilterElement.constructor = SVGElement;
@@ -3345,7 +3384,7 @@
   SVGElement.apply(this, arguments);
   /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGCursorElement.constructor = SVGElement;
@@ -3354,7 +3393,7 @@
 function SVGAElement() {
   SVGElement.apply(this, arguments);
   /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGAElement.constructor = SVGElement;
@@ -3375,7 +3414,7 @@
 function SVGScriptElement() { 
   SVGElement.apply(this, arguments);
   /*DOMString*/ this.type;
-  this._xlink = new SVGURIReference(this);
+  SVGURIReference.apply(this, arguments);
   return this;
 };
 SVGScriptElement.constructor = SVGElement;




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