OSDN Git Service

trefの実装開始
authordhrname <dhrname@users.sourceforge.jp>
Fri, 23 Dec 2011 14:42:44 +0000 (23:42 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Fri, 23 Dec 2011 14:42:44 +0000 (23:42 +0900)
org/w3c/dom/svg.js

index 141f2a8..8a01aff 100644 (file)
@@ -3853,7 +3853,7 @@ t.prototype = new SVGElement();
   t.prototype._list = null;         //文字の位置を格納しておくリストのキャッシュ
   t.prototype._length = 0;          //全文字数
   t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
-  t.prototype._chars = 0;           //tspan要素が全体の何文字目から始まっているか
+  t.prototype._chars = 0;           //tspan (tref)要素が全体の何文字目から始まっているか
   t.prototype._isYokogaki = true;          //横書きかどうか
 /*long*/     t.prototype.getNumberOfChars = function() {
   return (this._length);
@@ -3925,7 +3925,7 @@ t.prototype = new SVGElement();
       while (ti) {
         if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
           tt = ti._tars;
-          /*tspan要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
+          /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
            *使う。また、属性が指定されていないときも同様に祖先や親を使う。
            *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
            *この処理はdx属性やdy、y属性でも同様とする
@@ -4007,8 +4007,9 @@ t.prototype = new SVGElement();
             ti = ti.parentNode;
           }
           ti = ti.nextSibling;
-        } else if ((ti.localName === "tspan") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
-          /*現在のテキスト位置(x,y)の分だけ、tspan要素をずらしておく。
+        } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
+            && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
+          /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
            *さらに、現在のテキスト位置を更新する
            */
           ti._stx = x;
@@ -4337,7 +4338,6 @@ SVGTextPositioningElement.prototype = new SVGTextContentElement();
 
 function SVGTextElement(_doc) {
   SVGTextPositioningElement.apply(this, arguments);
-
   return this;
 };
 SVGTextElement.constructor = SVGTextPositioningElement;
@@ -4352,6 +4352,22 @@ SVGTSpanElement.prototype = new SVGTextPositioningElement();
 
 function SVGTRefElement(_doc) {
   SVGTextPositioningElement.apply(this, arguments);
+  this.addEventListener("DOMNodeInserted", function(evt){
+    if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
+      return; //強制終了させる
+    }
+    evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
+  }, false);
+  this.addEventListener("S_Load", function(evt){
+    var tar = evt.target,
+        tic = tar._instance.firstChild;
+    /*textノードのデータだけを処理*/
+    while (tic && (tic.nodeName !== "#text")) {
+      tic = tic.nextSibling;
+    }
+    tic && tar.appendChild(tar.ownerDocument.importNode(tic, false));
+    tar = tic = evtt = void 0;
+  }, false);
   SVGURIReference.apply(this, arguments);
   return this;
 };