[Sie-announce] SIEコード [1818] SVGURIReferenceとSVGAElementオブジェクトの実装と修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 5月 11日 (火) 23:36:17 JST


Revision: 1818
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1818
Author:   dhrname
Date:     2010-05-11 23:36:17 +0900 (Tue, 11 May 2010)

Log Message:
-----------
SVGURIReferenceとSVGAElementオブジェクトの実装と修正

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

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-05-11 10:27:43 UTC (rev 1817)
+++ branches/ufltima/dom/svg.js	2010-05-11 14:36:17 UTC (rev 1818)
@@ -764,46 +764,48 @@
 function SVGURIReference() {
   /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
   this.addEventListener("DOMAttrModified", function(evt){
-    this.href.baseVal = evt.newValue;
+    if (evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink" && evt.attrName === "xlink:href") {
+      evt.target.href.baseVal = evt.newValue;
+    }
+    evt = null;
   }, 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;
+    tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
+      var tar = evt.target;
+      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;
+            ep = ep.parentNode;
           }
-          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;
+          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;
         }
-      } else{
-      base = egbase;
+        if (href.indexOf(":") === -1) {
+          tar.xmlbase = base;
+        }  else{
+          tar.xmlbase = "";
+        }
+        tar.href.baseVal = href;
       }
-      if (href.indexOf(":") === -1) {
-        tar.xmlbase = base;
-      }  else{
-        tar.xmlbase = "";
-      }
-      tar.href.baseVal = href;
-    }
-    tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
     }, false);
+    tar = evt = null;
   }, false);
   return this;
 };
@@ -1225,7 +1227,7 @@
     var obje = document.getElementsByTagName("object");
     for (var i=0, objli=1;i<objli;++i) {
       var objei = {style:{}};//obje[i];
-      xmlhttp.open("GET", "../svggen/text-text-01-b.svg", true);//objei.getAttribute("data"), true);
+      xmlhttp.open("GET", "../svggen/linking-a-01-b.svg", true);//objei.getAttribute("data"), true);
       xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
       xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
@@ -2116,7 +2118,9 @@
     if (evt.eventPhase === Event.BUBBLING_PHASE) {
       return; //強制終了させる
     }
-    tar.parentNode._tar.appendChild(tar._tar);
+    if (tar.parentNode._tar) {
+      tar.parentNode._tar.appendChild(tar._tar);
+    }
     tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
       /*以下の処理は、normalizedpathSegListとCTMに基づいて、
        *SVGのd属性をVMLに変換していく処理である。
@@ -3392,8 +3396,30 @@
 
 function SVGAElement() {
   SVGElement.apply(this, arguments);
+  this._tar = document.createElement("a");
   /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
   SVGURIReference.apply(this, arguments);
+  this.addEventListener("DOMAttrModified", function(evt){
+    if (evt.attrName === "target") {
+      evt.target.target.baseVal = evt.newValue;
+    }
+  }, false);
+  this.addEventListener("DOMNodeInserted", function(evt){
+    if (evt.eventPhase === Event.BUBBLING_PHASE) {
+      return; //強制終了させる
+    }
+    var tar = evt.target;
+    if (tar.parentNode._tar) {
+      tar.parentNode._tar.appendChild(tar._tar);
+    }
+    var t = tar.target.baseVal;
+    var st = "replace";
+    if (t === "_blank") {
+      st = "new";
+    }
+    tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st)
+    tar = evt = null;
+  }, false);
   return this;
 };
 SVGAElement.constructor = SVGElement;




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