[Sie-announce] SIEコード [2509] チケット #24648

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 3月 26日 (土) 20:42:11 JST


Revision: 2509
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2509
Author:   dhrname
Date:     2011-03-26 20:42:10 +0900 (Sat, 26 Mar 2011)

Log Message:
-----------
チケット #24648
「単位「%」の解釈が異常」を修正

Ticket Links:
:-----------
    http://sourceforge.jp/projects/sie/tracker/detail/24648

Modified Paths:
--------------
    branches/07x/073/org/w3c/dom/svg.js

Modified: branches/07x/073/org/w3c/dom/svg.js
===================================================================
--- branches/07x/073/org/w3c/dom/svg.js	2011-03-24 12:31:23 UTC (rev 2508)
+++ branches/07x/073/org/w3c/dom/svg.js	2011-03-26 11:42:10 UTC (rev 2509)
@@ -258,6 +258,8 @@
       if (!!tar[name]) {
         var tea = tar[name],
             tod = tar.ownerDocument.documentElement,
+            tvw = tod.viewport.width,
+            tvh = tod.viewport.height,
             n,
             type,
             _parseFloat,
@@ -270,10 +272,12 @@
             n = n[0];
           }
           if (n === "%") {
-            if ((name === "x") || (name === "width")) {
-              tea.baseVal._percent *= tod.viewport.width;
-            } else if ((name === "y") || (name === "height")) {
-              tea.baseVal._percent *= tod.viewport.height;
+            if (tar._x1width[name]) {
+              tea.baseVal._percent = tvw * 0.01;
+            } else if (tar._y1height[name]) {
+              tea.baseVal._percent = tvh * 0.01;
+            } else {
+              tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
             }
             type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
           } else if (n === "em") {
@@ -297,7 +301,7 @@
           s = isNaN(s) ? 0 : s;
           tea.baseVal.newValueSpecifiedUnits(type, s);
         }
-        tea = tod = n = type = _parseFloat = s = null;
+        tea = tod = tvw = tvh = n = type = _parseFloat = s = null;
       }
     }
     evt = _parseFloat = name = tar = null;
@@ -320,7 +324,21 @@
    *getCTMメソッドで使う
    */
   this._cacheMatrix = null;
-
+  /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
+  this._x1width = {
+      "x" : 1,
+      "x1" : 1,
+      "x2" : 1,
+      "width" : 1,
+      "cx" : 1
+  };
+  this._y1height = {
+      "y" : 1,
+      "y1" : 1,
+      "y2" : 1,
+      "height" : 1,
+      "cy" : 1      
+  };
   /*String*/              this.id      = null;        //id属性の値
   /*String*/              this.xmlbase = null;   //xml:base属性の値
   /*SVGSVGElement*/       this.ownerSVGElement;  //ルート要素であるsvg要素
@@ -597,6 +615,7 @@
   },
   /*_emToUnitメソッド
    *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
+   *単位が%の場合は、新しいvalueへと変換させておく
    */
   _emToUnit : function (/*float*/ fontSize) {
     if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {




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