[Sie-announce] SIEコード [1265] SVGURIReferenceオブジェクトの設定

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 9月 17日 (木) 22:48:27 JST


Revision: 1265
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1265
Author:   dhrname
Date:     2009-09-17 22:48:27 +0900 (Thu, 17 Sep 2009)

Log Message:
-----------
SVGURIReferenceオブジェクトの設定

Modified Paths:
--------------
    branches/DOM/org/w3c/dom/svg.js

Modified: branches/DOM/org/w3c/dom/svg.js
===================================================================
--- branches/DOM/org/w3c/dom/svg.js	2009-09-17 13:36:13 UTC (rev 1264)
+++ branches/DOM/org/w3c/dom/svg.js	2009-09-17 13:48:27 UTC (rev 1265)
@@ -1437,63 +1437,6 @@
   }
 }
 
-//XLink言語を処理
-NAIBU.XLink = function( /*element*/ ele) {
-  this.tar = ele;
-  var href = ele.getAttribute("xlink:href");
-  this.href = href ? href  :  null;
-  this.show = ele.getAttribute("xlink:show");
-  var base;
-  var egbase = ele.getAttribute("xml:base");
-  if (!egbase) {
-    var ep = ele.parentNode, b = null;
-    while(!b  &&  ep.tagName == "group") {
-      b = ep.getAttribute("xml:base");
-      ep = ep.parentNode;
-    }
-    base = b || location.href;
-  }  else{
-    base = egbase;
-  }
-  if (href.indexOf(":") == -1) {
-    this.base = base;
-  }  else{
-    this.base  ="";
-  }
-  return this;
-}
-NAIBU.XLink.prototype.set = function() {
-  if (this.href) {
-    var tbth = this.base + this.href;
-    if (this.href.indexOf(".") == 0) {
-      tbth = this.href;
-    }
-    var uri = tbth;
-    var attr = "href";
-    switch (this.show) {
-      case "embed":
-        if (this.tar.tagName == "image") {
-          attr = "src";
-        }  else{
-          uri.match(/#(.+)$/);
-          this.resource = document.getElementById(RegExp.$1);
-          var dc = this.resource.cloneNode(false);
-          this.tar.previousSibling.appendChild(dc);
-          var doc = new SVGtoVML();
-          doc.read(obc);
-          return doc;
-        }
-      break;
-      case "new":
-        this.tar.setAttribute("target","_blank");
-      break;
-      default:
-      break;
-    }
-    this.tar.setAttribute(attr,uri);
-  }
-}
-
 function utf16( /*string*/ s)  {
   return unescape(s);
 }
@@ -1967,10 +1910,71 @@
 };
 
 
-  interface SVGURIReference { 
-    readonly attribute SVGAnimatedString href;
-  };
-  interface SVGCSSRule : css::CSSRule { 
+function SVGURIReference( /*element*/ ele) {
+  this.tar = ele;
+  var href = ele.getAttribute("xlink:href");
+  if (href) { //xlink:href属性が指定されたとき
+    this.show = ele.getAttribute("xlink:show");
+    var base;
+    var egbase = ele.getAttribute("xml:base");
+    if (!egbase) {
+      var ep = ele.parentNode, b = null;
+      while(!b  &&  ep.tagName === "group") {
+        b = ep.getAttribute("xml:base");
+        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) {
+      this.base = base;
+    }  else{
+      this.base  ="";
+    }
+    /*readonly SVGAnimatedString*/ this.href = href;
+  } else {
+    this.href = null;
+  }
+  return this;
+}
+SVGURIReference.prototype.set = function() {
+  try {
+  if (this.href) {
+    var uri = this.base + this.href;
+    if (this.href.indexOf(".") === 0) { //相対URIの場合
+      uri = this.href;
+    }
+    switch (this.show) {
+      case "embed":
+        if (this.tar.tagName === "image") {
+          this.tar.src = uri;
+        }  else{
+          uri.match(/#(.+)$/);
+          this.resource = document.getElementById(RegExp.$1);
+          var dc = this.resource.cloneNode(true);
+          this.tar.appendChild(dc);
+        }
+      break;
+      case "new":
+        this.tar.setAttribute("target","_blank");
+      break;
+    }
+    this.tar.setAttribute("href",uri);
+  }
+  } catch(e) {stlog.add(e,17155);}
+}  interface SVGCSSRule : css::CSSRule { 
     // Additional CSS RuleType to support ICC color specifications
     const unsigned short COLOR_PROFILE_RULE = 7;
   };




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