[Sie-announce] SIEコード [1285] getCTMメソッドなどを実装

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 9月 25日 (金) 23:19:42 JST


Revision: 1285
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1285
Author:   dhrname
Date:     2009-09-25 23:19:42 +0900 (Fri, 25 Sep 2009)

Log Message:
-----------
getCTMメソッドなどを実装

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-25 14:19:10 UTC (rev 1284)
+++ branches/DOM/org/w3c/dom/svg.js	2009-09-25 14:19:42 UTC (rev 1285)
@@ -1593,6 +1593,7 @@
    *TransformListはtransform属性を行列で表現したあとのリスト構造
    */
   /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
+  this.transform._matrix = null;                                                //SVGMatrixのキャッシュ
   return this;
 };
 SVGElement.constructor = Element;
@@ -1601,33 +1602,50 @@
  *プレゼンテーション属性の値を得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
  */
 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function(/*DOMString*/ name ) {
-	
+  var s = new CSSValue(), tgn = this.attributes.getNamedItemNS(null, name);
+  if (!tgn) {
+    s.cssText = tgn.nodeValue;
+    return s;
+  } else {
+    return null;
+  }
 }
 /*interface SVGLocatable*/
 /*SVGRect*/   SVGElement.prototype.getBBox = function(){};
-/*SVGMatrix*/ SVGElement.prototype.getCTM = function(){};
-/*SVGMatrix*/ SVGElement.prototype.getScreenCTM = function(){};
+/*getCTMメソッド
+ *CTMとは現在の利用座標系に対する変換行列
+ */
+/*SVGMatrix*/ SVGElement.prototype.getCTM = function(){
+  if (!this.transform._matrix) {  //キャッシュがなければ、
+    var n = this.transform.baseVal.consolidate();
+    n = n ? n.matrix : this.documentElement.createSVGMatrix();
+    this.transform._matrix = this.parentNode.getCTM().multiply(n);
+  }
+  return (this.transform._matrix);
+};
+/*SVGMatrix*/ SVGElement.prototype.getScreenCTM = function(){
+  return (this.viewportElement.getCTM());
+};
 /*SVGMatrix*/ SVGElement.prototype.getTransformToElement = function(/*SVGElement*/ element ){
-  
+  var s = this.getCTM().inverse().multiply(element.getCTM());
 }
 function SVGAnimatedBoolean() {
-  /*boolean*/ this.baseVal = true;
-  /*readonly boolean*/ this.animVal;
+  /*boolean*/  this.animVal = this.baseVal = true;
   return this;
 };
 
 function SVGAnimatedString() {
-  /*String*/ this.baseVal = "";
-  /*readonly String*/ this.animVal = "";
+  /*String*/ this.animVal = this.baseVal = "";
   return this;
 };
 function SVGStringList() {
   /*readonly unsigned long*/ this.numberOfItems = 0;
+  this._list = []; //リストの本体
   return this;
 };
 SVGStringList.prototype = {
   /*void*/   clear : function(){
-    
+    this._list = [];
   },
                   //raises( DOMException );
   /*DOMString*/ initialize : function(/*DOMString*/ newItem ) {
@@ -2071,6 +2089,8 @@
   /*readonly SVGAnimatedRect*/   this.viewBox = this.currentView.viewBox;
   /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
   /*unsigned short*/             this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
+  //あらかじめ、transformのキャッシュを作っておく
+  this.transform._matrix = this.createSVGMatrix();
   return this;
 };
 SVGSVGElement.constructor = SVGElement;
@@ -2956,10 +2976,7 @@
 SVGLineElement.constructor = SVGElement;
 SVGLineElement.prototype = new SVGElement();
 
-function SVGAnimatedPoints { 
-  /*readonly SVGPointList   points;
-  /*readonly SVGPointList   animatedPoints;
-  };
+
 function SVGPolylineElement : 
                 SVGElement,
                 SVGTests,
@@ -2968,7 +2985,10 @@
                 SVGStylable,
                 SVGTransformable,
                 events::EventTarget,
-                SVGAnimatedPoints {};
+                SVGAnimatedPoints {
+  //interface SVGAnimatedPoints
+  /*readonly SVGPointList*/   this.animatedPoints = this.points = new SVGPointList();
+};
 function SVGPolygonElement : 
                 SVGElement,
                 SVGTests,




Sie-announce メーリングリストの案内
アーカイブの一覧に戻る