[Sie-announce] SIEコード [2233] SVGFontElementとSVGFontFaceUriElementの修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 12月 20日 (月) 23:15:48 JST


Revision: 2233
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2233
Author:   dhrname
Date:     2010-12-20 23:15:48 +0900 (Mon, 20 Dec 2010)

Log Message:
-----------
SVGFontElementとSVGFontFaceUriElementの修正

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

Modified: branches/06x/066/org/w3c/dom/svg.js
===================================================================
--- branches/06x/066/org/w3c/dom/svg.js	2010-12-18 12:45:58 UTC (rev 2232)
+++ branches/06x/066/org/w3c/dom/svg.js	2010-12-20 14:15:48 UTC (rev 2233)
@@ -1596,7 +1596,7 @@
       dcp.coordsize = tview.width+ " " +tview.height;
       sp.appendChild(dcp);
       objei.parentNode.insertBefore(sp, objei);
-      dcp.appendChild(sdt)
+      dcp.appendChild(sdt);
       while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
         n = s.importNode(fi, true);
         tar.appendChild(n);
@@ -5185,26 +5185,33 @@
                 SVGExternalResourcesRequired,
                 SVGStylable*/ {
   SVGElement.apply(this);
+  /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
+  /*boolean or number*/ this._isExternal = 0;
   this.addEventListener("DOMNodeInserted", function(evt){
-    var tar = evt.target;
+    var tar = evt.target, svgns = "http://www.w3.org/2000/svg";
     if (evt.eventPhase === Event.BUBBLING_PHASE) {
       return;
     }
-    tar.ownerDocument.documentElement.addEventListener("SVGLoad", function(evt){
-      var svg = evt.target, svgns = "http://www.w3.org/2000/svg";
-      if (!svg.__isExternalFont) {
-        /*以下のtarはfont要素*/
-        var familyName = tar.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
-        var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
-        for (var i=0,tli=textElements.length;i<tli;++i) {
-          var ti = textElements[i], style = tar.ownerDocument.defaultView.getComputedStyle(ti, '');
-          if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
-            NAIBU._noie_createFont(ti, tar, true);
-          }
+    var fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
+    var nefunc = function(evt){
+      var svg = evt.target;
+      /*以下のtarはfont要素*/
+      var familyName = fontFace.getAttributeNS(null, "font-family");
+      var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
+      for (var i=0,tli=textElements.length;i<tli;++i) {
+        var ti = textElements[i], style = tar.ownerDocument.defaultView.getComputedStyle(ti, '');
+        if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
+          NAIBU._noie_createFont(ti, tar, true);
         }
-        evt = tar = svg = curt = textElments = svgns = null;
       }
-    }, false);
+      evt = tar = svg = curt = textElments = svgns = null;
+    };
+    if (!fontFace.__isLinked) {
+      tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
+    }
+    if (tar._isExternal) {
+      nefunc({target : tar.ownerDocument.documentElement});
+    }
   }, false);
   return this;
 };
@@ -5245,7 +5252,15 @@
 
 function SVGFontFaceElement() {
   SVGElement.apply(this);
-  /*string*/ this._familyName = "";
+  /*boolean(or number)*/ this._isLinked = 0;
+  this.addEventListener("DOMNodeInserted", function(evt){
+    if (evt.eventPhase === Event.BUBBLING_PHASE) {
+      if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
+        evt.currentTarget._isLinked = 1;
+      }
+      return; //強制終了させる
+    }
+  }, false);
   return this;
 };
 SVGFontFaceElement.constructor = SVGElement;
@@ -5267,17 +5282,13 @@
     evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
   }, false);
   this.addEventListener("SVGLoad", function(evt){
-    var tar = evt.target, svgns = "http://www.w3.org/2000/svg";
-    var familyName = tar.parentNode.parentNode.getAttributeNS(null, "font-family");
-    var textElements = tar.ownerDocument.documentElement.getElementsByTagNameNS(svgns, "text");
-    for (var i=0,tli=textElements.length;i<tli;++i) {
-      var ti = textElements[i], style = tar.ownerDocument.defaultView.getComputedStyle(ti, '');
-      if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
-        NAIBU._noie_createFont(ti, tar._instance, true);
-      }
+    var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
+    if (tpp.localName === "defs") {
+      tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
     }
-    tar.ownerDocument.documentElement.__isExternalFont = 1;
-    evt = tar = curt = textElments = svgns = null;
+    tar._instance._isExternal = 1;
+    tpp.parentNode.replaceChild(tar._instance, tpp);
+    evt = tar = tpp = null;
   }, false);
   SVGURIReference.apply(this);
   return this;
@@ -5528,7 +5539,13 @@
       }
       node = node.nextSibling;
     }
-    ti.setAttributeNS(null, "opacity", "0");
+    if (isMSIE) {
+      var style = ti.ownerDocument.getOverrideStyle(ti, null);
+      style.setProperty("display", "none");
+      style = null;
+    } else {
+      ti.setAttributeNS(null, "opacity", "0");
+    }
   }
   data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = null;
 };




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