[Sie-announce] SIEコード [2216] 1, SVGTextContentElementにおいて、文字列の分割にsplitを用いた

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2010年 12月 9日 (木) 21:52:40 JST


Revision: 2216
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2216
Author:   dhrname
Date:     2010-12-09 21:52:40 +0900 (Thu, 09 Dec 2010)

Log Message:
-----------
1, SVGTextContentElementにおいて、文字列の分割にsplitを用いた
2, NAIBU._fontSearchURIを追加

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-08 10:16:07 UTC (rev 2215)
+++ branches/06x/066/org/w3c/dom/svg.js	2010-12-09 12:52:40 UTC (rev 2216)
@@ -28,7 +28,7 @@
  * respective copyright-holders):
  *    layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
  *
- * Contributor(s):DHRNAME revulo
+ * Contributor(s):DHRNAME revulo bellbind
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
@@ -152,7 +152,6 @@
     var name = evt.attrName, tar = evt.target;
     if (!!CSS2Properties[name] || name.indexOf("-") > -1) { //スタイルシートのプロパティならば
       tar._attributeStyle.setProperty(name, evt.newValue, "");
-      tar._currentStyle = null;  //キャッシュは消しておく
     }
     if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
       tar.id = evt.newValue;
@@ -177,7 +176,7 @@
           cm.f = +(deg[5]);
         } else {
           if (degli === 3) {
-            var degz = _parseFloat(deg[0]);
+            var degz = +(deg[0]);
             s.setRotate(degz, +(deg[1]), +(deg[2]))
           } else if (degli <= 2) {
             var degz = +(deg[0]);
@@ -216,7 +215,6 @@
         }
         a = sc = null;
       }
-      tar._currentStyle = null;
     } else if (name === "class") {
       tar.className = evt.newValue;
     } else if (name.indexOf("on") === 0) {           //event属性ならば
@@ -3449,6 +3447,7 @@
       tar._tars = [];
       var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
       tar.data = data;
+      data = data.split('');
       for (var i=0, tdli=data.length;i<tdli;++i) {
         var d = document.createElement("div"), dstyle = d.style;
         dstyle.position = "absolute";
@@ -3456,7 +3455,7 @@
         dstyle.paddingTop = dstyle.paddingLeft = "0px";
         dstyle.whiteSpace = "nowrap";
         dstyle.textIndent = "0px";
-        d.appendChild(document.createTextNode(data.charAt(i)));
+        d.appendChild(document.createTextNode(data[i]));
         tar._tars[tar._tars.length] = d;
       }
       data = null;
@@ -5361,25 +5360,41 @@
   pattern:         SVGPatternElement
 };
 
+NAIBU._fontSearchURI = function(evt){
+  var doc = evt.target.ownerDocument;
+  var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
+  for (var i=0;i<tsrc.length;++i) {
+    var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href");
+    var ids = src.substring(src.indexOf("#")+1, src.length);
+    var xmlhttp = NAIBU.xmlhttp;
+    xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
+    xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+    xmlhttp.onreadystatechange = function() {
+      if ((xmlhttp.readyState === 4)  &&  (xmlhttp.status === 200)) {
+        var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
+        NAIBU._font({document:doce, docu:doc});
+        xmlhttp = doc = doce = null;
+      }
+    };
+    xmlhttp.send(null);
+  }
+};
 /*_font関数は、SVGFontで使う*/
 NAIBU._font = function (data) {
-  if (!!data.success) {
-    var doc = data.document;
-    //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
-    var font = doc.getElementsByTagNameNS(NAIBU.svgNameSpace, "font").item(0);
-    var familyName = font.getElementsByTagNameNS(NAIBU.svgNameSpace, "font-face").item(0).getAttributeNS(null, "font-family");
-    if (familyName && font.getAttributeNS(null, "id") === data.obj[0].id) {
-      var textElements = data.obj[0].docu.getElementsByTagNameNS(NAIBU.svgNameSpace, "text");
-      for (var i=0,tli=textElements.length;i<tli;++i) {
-        var ti = textElements[i], style = data.obj[0].docu.defaultView.getComputedStyle(ti, '');
-        if (style.fontFamily.indexOf(familyName) > -1) {
-          NAIBU._noie_createFont(ti, font);
-        }
+  var doc = data.document, svgns = "http://www.w3.org/2000/svg";
+  //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
+  var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
+  var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
+  if (familyName && font.getAttributeNS(null, "id") === data.obj[0].id) {
+    var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
+    for (var i=0,tli=textElements.length;i<tli;++i) {
+      var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
+      if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
+        NAIBU._noie_createFont(ti, font);
       }
     }
-    doc = data = null;
-    NAIBU.STObject.readSvgFont();
   }
+  doc = data = null;
 };
 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font) {
   var style = ti.ownerDocument.defaultView.getComputedStyle(ti, '');




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