[Sie-announce] SIEコード [1961] image要素の実装

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 7月 21日 (水) 23:49:21 JST


Revision: 1961
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1961
Author:   dhrname
Date:     2010-07-21 23:49:21 +0900 (Wed, 21 Jul 2010)

Log Message:
-----------
image要素の実装

Modified Paths:
--------------
    branches/06x/061/org/w3c/dom/svg.js

Modified: branches/06x/061/org/w3c/dom/svg.js
===================================================================
--- branches/06x/061/org/w3c/dom/svg.js	2010-07-20 14:26:29 UTC (rev 1960)
+++ branches/06x/061/org/w3c/dom/svg.js	2010-07-21 14:49:21 UTC (rev 1961)
@@ -1215,6 +1215,7 @@
         evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
         for (var i=0,sli=s.length;i<sli;++i) {
           var di = s[i];
+          di._cacheMatrix = null; //キャッシュを消去
           di.dispatchEvent(evtt);
           di = null;
         }
@@ -1256,6 +1257,7 @@
 
 function SVGSymbolElement() {
   SVGElement.apply(this, arguments);
+  SVGURIReference.apply(this);
   return this;
 }
 SVGDefsElement.constructor = SVGElement;
@@ -1269,6 +1271,7 @@
   /*readonly SVGAnimatedLength*/   this.height = new SVGAnimatedLength();
   /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
   /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
+  SVGURIReference.apply(this);
   return this;
 };
 SVGUseElement.constructor = SVGElement;
@@ -1301,12 +1304,50 @@
 }
 function SVGImageElement() {
   SVGElement.apply(this, arguments);
+  this._tar = document.createElement("v:image");
   //以下は、与えられた属性の値に対応する
   /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/ this.width = new SVGAnimatedLength();
   /*readonly SVGAnimatedLength*/ this.height = new SVGAnimatedLength();
   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
+  this.addEventListener("DOMNodeInserted", function(evt){
+    if (evt.eventPhase === Event.BUBBLING_PHASE) {
+      return; //強制終了させる
+    }
+    var tar = evt.target;
+    tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
+    if (tar.nextSibling) {
+      if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
+        tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
+      }
+    } else if (!!tar.parentNode._tar){
+      tar.parentNode._tar.appendChild(tar._tar);
+    }
+    tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
+      var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
+      var ts = tar._tar.style;
+      ts.position = "absolute";
+      var ctm = tar.getScreenCTM();
+      var po = tar.ownerDocument.documentElement.createSVGPoint();
+      po.x = tar.x.baseVal.value;
+      po.y = tar.y.baseVal.value;
+      po = po.matrixTransform(ctm);
+      ts.left = po.x + "px";
+      ts.top = po.y + "px";
+      ts.width = tar.width.baseVal.value * ctm.a + "px";
+      ts.height = tar.height.baseVal.value * ctm.d + "px";
+      var fillOpacity = parseFloat(style.getPropertyValue("fill-opacity"));
+      if (fillOpacity !== 1) {
+        ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
+        var ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
+        ttfia.Style = 0;
+        ttfia.Opacity = fillOpacity * 100;
+      }
+    }, false);
+    evt = tar = null;
+  }, false);
+  SVGURIReference.apply(this);
   return this;
 };
 SVGImageElement.constructor = SVGElement;




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