[Sie-announce] SIEコード [1742] IE8の標準モードでも表示できるように改良

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 3月 20日 (土) 20:44:25 JST


Revision: 1742
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1742
Author:   dhrname
Date:     2010-03-20 20:44:25 +0900 (Sat, 20 Mar 2010)

Log Message:
-----------
IE8の標準モードでも表示できるように改良
ルートに当たるv:group要素に、position:absoluteを追加したことで改良

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

Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js	2010-03-18 14:36:40 UTC (rev 1741)
+++ branches/ufltima/dom/svg.js	2010-03-20 11:44:25 UTC (rev 1742)
@@ -781,7 +781,13 @@
   /*DOMString*/                  this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
   /*DOMString*/                  this.contentStyleType  = "text/css";
   /*readonly SVGRect*/           this.viewport          = this.createSVGRect();
-  /*boolean*/                    this.useCurrentView    = false;                       //ズームなど加工がされていれば、true
+  /*useCurrentViewプロパティ
+   * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
+   */
+  /*boolean*/                    this.useCurrentView    = false;
+  /*currentViewプロパティ
+   * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
+   */
   /*readonly SVGViewSpec*/       this.currentView       = new SVGViewSpec(this);
   /*もし、画像をズームやパンしたとき、どのような倍率になるかを
    *以下のプロパティを使って次の行列で示すことができる
@@ -789,7 +795,9 @@
    */
   /*float*/                      this.currentScale     = 1;
   /*readonly SVGPoint*/          this.currentTranslate = this.createSVGPoint();
-  //SVGFitToViewBoxのインターフェースを用いる
+  /*以下は、SVGFitToViewBoxのインターフェースを用いる
+   *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
+   */
   /*readonly SVGAnimatedRect*/   this.viewBox = this.currentView.viewBox;
   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
@@ -807,6 +815,7 @@
       tv.y = parseFloat(ovb[1]);
       tv.width = parseFloat(ovb[2]);
       tv.height = parseFloat(ovb[3]);
+      tar.viewBox.baseVal._isUsed = 1;
     } else if (name === "preserveAspectRatio") {
       var par = evt.newValue, tp = tar.preserveAspectRatio.baseVal;
       var sa = 1, mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
@@ -897,8 +906,12 @@
  */
 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
   var vw = this.viewport.width, vh = this.viewport.height;
-  var vB = this.currentView.viewBox.baseVal, par = this.currentView.preserveAspectRatio.baseVal;
-  if (!vB) {
+  if (!this.useCurrentView) {
+    var vB = this.viewBox.baseVal, par = this.preserveAspectRatio.baseVal;    
+  } else {
+    var vB = this.currentView.viewBox.baseVal, par = this.currentView.preserveAspectRatio.baseVal;
+  }
+  if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
     this._tx = this._ty = 0;
     return this.createSVGMatrix();
   } else {
@@ -1016,9 +1029,7 @@
 
 function SVGTitleElement() {
   SVGElement.apply(this, arguments);
-  try {
-    this.ownerDocument.title = this.firstChild.nodeValue;
-  } catch(e){}
+  this.ownerDocument.title = this.firstChild.nodeValue;
   return this;
 }
 SVGTitleElement.constructor = SVGElement;
@@ -1130,6 +1141,7 @@
       xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState === 4  &&  xmlhttp.status === 200) {
           /*SVGDocument*/ objei.getSVGDocument = function(){
+            var dew = new Date();
             /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因は不明)、
              *ここでは、responseTextを用いる
              */
@@ -1140,8 +1152,17 @@
             var tar = s.documentElement;
             var sdt = tar._tar;
             document.body.insertBefore(sdt, document.body.lastChild);
+            alert((new Date()).getTime() - dew.getTime());
+            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;
+            while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
+              n = s.importNode(fi, true);
+              sdoce.appendChild(n);
+              fi = fi.nextSibling;
+            }
             /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
              *作り出す作業を行う。これは必須
              */
@@ -1157,6 +1178,7 @@
             var trstyle = tar._tar.style;
             var tpstyle = objei.style;
             trstyle.visibility = "visible";
+            trstyle.position = "absolute";
             //以下、画像を切り取り
             trstyle.overflow = "hidden";
             var backrs = backr.currentStyle;
@@ -1174,15 +1196,9 @@
             var backright = bl + viewWidth + 1;
             var backdown = bt + viewHeight + 1;
             trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
-            var fi = doc.documentElement.firstChild, sdoce = s.documentElement, n;
-            while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
-              n = s.importNode(fi, true);
-              sdoce.appendChild(n);
-              fi = fi.nextSibling;
-            }
             return s;
           };
-          alert(objei.getSVGDocument());
+          objei.getSVGDocument();
         }
       };
       xmlhttp.send(null);




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