[Sie-announce] SIEコード [1770] svg要素に関する属性の修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 3月 31日 (水) 23:37:21 JST


Revision: 1770
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1770
Author:   dhrname
Date:     2010-03-31 23:37:21 +0900 (Wed, 31 Mar 2010)

Log Message:
-----------
svg要素に関する属性の修正

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

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-03-31 14:19:24 UTC (rev 1769)
+++ branches/ufltima/dom/svg.js	2010-03-31 14:37:21 UTC (rev 1770)
@@ -427,8 +427,8 @@
  */
 function SVGLength() {
   /*readonly attribute unsigned short*/ this.unitType = SVGLength.SVG_LENGTHTYPE_UNKNOWN;
-  /*attribute float*/          this.value = SVGLength.SVG_LENGTHTYPE_UNKNOWN;                  //利用単位における値
-  /*attribute float*/          this.valueInSpecifiedUnits = 0;  //unitTypeにおける値
+  /*attribute float*/          this.value = 0;                  //利用単位における値
+  /*attribute float*/          this.valueInSpecifiedUnits = SVGLength.SVG_LENGTHTYPE_UNKNOWN;  //unitTypeにおける値
   /*attribute DOMString*/      this.valueAsString;
 };
     // Length Unit Types
@@ -861,10 +861,6 @@
       }
       tp.align = sa;
       tp.meetOrSlice = mos;
-    } else if (name === "width") {
-      tar.viewport.width = tar.width.baseVal.value; //width属性があれば、viewportの値を上書きする
-    } else if (name === "height") {
-      tar.viewport.height = tar.height.baseVal.value;
     }
   }, false);  
   this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
@@ -921,6 +917,9 @@
  *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
  */
 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
+  if (!!this._cacheScreenCTM) { //キャッシュがあれば
+    return this._cacheScreenCTM;
+  }
   var vw = this.viewport.width, vh = this.viewport.height;
   if (!this.useCurrentView) {
     var vB = this.viewBox.baseVal, par = this.preserveAspectRatio.baseVal;    
@@ -979,6 +978,7 @@
   var m = this.createSVGMatrix();
   m.a = xr;
   m.d = yr;
+  this._cacheScreenCTM = m; //キャッシュを作っておく
   return m;
 };
 
@@ -1156,7 +1156,7 @@
     var obje = document.getElementsByTagName("object");
     for (var i=0, objli=1;i<objli;++i) {
       var objei = {style:{}};//obje[i];
-      xmlhttp.open("GET", "4wd.svg", true);//objei.getAttribute("data"), true);
+      xmlhttp.open("GET", "tiger.svg", true);//objei.getAttribute("data"), true);
       xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
       xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
@@ -1174,19 +1174,24 @@
             document.body.insertBefore(sdt, document.body.lastChild);
             tar.viewport.top = 0;
             tar.viewport.left = 0;
-            tar.viewport.width = 1000;
-            tar.viewport.height = 1000;
-            var fi = doc.documentElement.firstChild, sdoce = s.documentElement, n;
+            tar.width.baseVal.value = tar.viewport.width = 1000;
+            tar.height.baseVal.value = tar.viewport.height = 1000;
+            var fi = doc.documentElement.firstChild, n;
+            var attr = tar.attributes, att;
+            for (var i=0,atli=attr.length;i<atli;++i) { //NamedNodeMapを検索する
+              att = this.importNode(attr[i], false);
+              s.setAttributeNodeNS(att);
+            }
             while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
               n = s.importNode(fi, true);
-              sdoce.appendChild(n);
+              tar.appendChild(n);
               fi = fi.nextSibling;
             }
             /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
              *作り出す作業を行う。これは必須
              */
             var backr = document.createElement("v:rect");
-            var w = tar.viewport.width, h = tar.viewport.height, sw = tar.width.baseVal, sh = tar.height.baseVal;
+            var w = tar.viewport.width, h = tar.viewport.height, sw = tar.width.baseVal.value, sh = tar.height.baseVal.value;
             backr.style.position = "absolute";
             backr.style.width = w+ "px";
             backr.style.height = h+ "px";




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