svnno****@sourc*****
svnno****@sourc*****
2011年 8月 6日 (土) 19:23:04 JST
Revision: 2845 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2845 Author: dhrname Date: 2011-08-06 19:23:03 +0900 (Sat, 06 Aug 2011) Log Message: ----------- 0.82モジュール結合 Modified Paths: -------------- branches/08x/sie.js Modified: branches/08x/sie.js =================================================================== --- branches/08x/sie.js 2011-08-06 10:16:59 UTC (rev 2844) +++ branches/08x/sie.js 2011-08-06 10:23:03 UTC (rev 2845) @@ -3983,14 +3983,7 @@ /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因は不明)、 *ここでは、responseTextを用いる */ - var ifr = document.createElement("iframe"); - ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう - ifr.scrolling = "no"; - ifr.frameBorder = "0"; - /*iframe要素を使って、描画のプロセスを分離する - *したがって、_docはdocumentとは別のオブジェクトとなる - */ - this._tar.parentNode.insertBefore(ifr, this._tar); + var ifr = this._tar.previousSibling; ifr.contentWindow.screen.updateInterval = 999; var _doc = ifr.contentWindow.document; _doc.write(""); @@ -4081,8 +4074,6 @@ tar.setAttributeNodeNS(att); } str = attr = null; - ifr.style.width = tview.width+3+ "px"; - ifr.style.height = tview.height+3+ "px"; dcp.style.width = tview.width+ "px"; dcp.style.height = tview.height+ "px"; dcp.coordsize = tview.width+ " " +tview.height; @@ -4169,8 +4160,7 @@ } s.defaultView._cache = s.defaultView._cache_ele = null; oba = _doc = evt = _doc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = w = h = sw = sh = style = fontSize = null; - trstyle = tpstyle = backrs = viewWidth = viewHeight = text = texti = i = bfl = bft = bl = bt = backdown = backright = null; - text = _parseFloat = null; + trstyle = tpstyle = backrs = viewWidth = viewHeight = text = texti = i = bfl = bft = bl = bt = backdown = backright = text = _parseFloat = null; /*IEのメモリリーク対策として、空関数を入力*/ this.xmlhttp.onreadystatechange = NAIBU.emptyFunction; if (this._next) { @@ -4209,9 +4199,9 @@ } dbuf = n = dbufli = null; }, 1); - s = null; + ifr = s = null; } else { - s = null; + ifr = s = null; NAIBU.Time.start(); } delete NAIBU.doc; @@ -6504,8 +6494,8 @@ sty.top = p.y + "px"; sty.width = "0px"; sty.height = "0px"; - sty.marginTop = tar._isYokogaki ? -n+ "px" : "0px"; - sty.lineHeight = n+ "px"; + sty.marginTop = tar._isYokogaki ? -n-10+ "px" : "-10px"; + sty.lineHeight = n+10+ "px"; ttp.appendChild(ti._tars[ij]); sty = p = null; } @@ -6530,7 +6520,10 @@ } } } - var color = style.getPropertyValue("fill"); + var color = style.getPropertyValue("fill"), + cursor = style.getPropertyCSSValue("cursor"), + vis = style.getPropertyCSSValue("visibility"), + disp = style.getPropertyCSSValue("display"); if (color === "none"){ tar._tar.style.color = "transparent"; } else if (color.indexOf("url") === -1) { @@ -6538,14 +6531,19 @@ } else { tar._tar.style.color = "black"; } - var cursor = style.getPropertyValue("cursor"); - if (cursor !== "auto" && cursor !== "") { - tar._tar.style.cursor = cursor; + if (cursor && !cursor._isDefault) { //初期値でないならば + var tc = cursor.cssText; + el.style.cursor = tc.substring(tc.indexOf(":")+1, tc.length); + tc = null; } - var vis = style.getPropertyValue("visibility"); - if (vis !== "visiblee") { - tar._tar.style.visibility = vis; + if (vis && !vis._isDefault) { + el.style.visibility = vis.cssText.substring(vis.cssText.indexOf(":")+1, vis.cssText.length); } + if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) { + el.style.display = "none"; + } else if (disp && !disp._isDefault) { + el.style.display = "block"; + } var isRect = true; if (ttp.lastChild) { if (ttp.lastChild.nodeName !== "rect") { @@ -6567,7 +6565,7 @@ } delete tar._cacheMatrix; delete tar._currentStyle; - isRect = evt = tar = style = tpp = ttpc = null; + isRect = evt = tar = style = tpp = ttpc = style = color = cursor = disp = vis = null; }, false); evt = tar = null; },false); @@ -8297,14 +8295,19 @@ doc = data = null; }; NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) { - var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''), svgns = "http://www.w3.org/2000/svg"; - //isTategakiは縦書きならば真 - var isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"), horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x"; - var node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"); - var em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttribute("units-per-em") || 1000); - var advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ); //字幅の設定 - var dx = parseFloat(ti.getAttributeNS(null, "x") || 0), fontSize = parseFloat(style.getPropertyValue("font-size")), dy = parseFloat(ti.getAttributeNS(null, "y") || 0), fe = fontSize / em; - var ds = false, npdlist = ["fill", + var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''), + svgns = "http://www.w3.org/2000/svg", + //isTategakiは縦書きならば真 + isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"), + horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x", + node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"), + em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000), + advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定 + dx = parseFloat(ti.getAttributeNS(null, "x") || 0), + dy = parseFloat(ti.getAttributeNS(null, "y") || 0), + fontSize = parseFloat(style.getPropertyValue("font-size")), + fe = fontSize / em; + ds = false, npdlist = ["fill", "fill-opacity", "stroke", "stroke-width", @@ -8315,15 +8318,6 @@ "stroke-opacity", "opacity", "cursor"]; - if (isMSIE) { - var rand = "n" +Math.random(); - ti._tar.firstChild.setAttribute("id", rand); - var titf = ti.ownerDocument._document_.getElementById(rand); - /*IEのみ、font-sizeは自動で調整されている(つまり、DOMからよびだされた)ものを使った方がよい*/ - fontSize = parseFloat(titf.currentStyle.fontSize); - fe = fontSize / em; - rand = titf = null; - } if (/a/[-1] === 'a') { //Firefoxならば ds = true; } else if (isMSIE || isTategaki) { @@ -8472,7 +8466,8 @@ */ NAIBU._main = (function() { stlog = new STLog(false); - var xmlhttp; //XMLHttpオブジェクトを生成 + var xmlhttp, //XMLHttpオブジェクトを生成 + _doc = document; //documentのエイリアスを作成 try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { @@ -8491,24 +8486,25 @@ } NAIBU.xmlhttp = xmlhttp; var nd; - if (("namespaces" in document) && !document.namespaces["v"]) { + if (("namespaces" in _doc) && !_doc.namespaces["v"]) { NAIBU.doc = new ActiveXObject("MSXML2.DomDocument"); nd = NAIBU.doc; - document.namespaces.add("v","urn:schemas-microsoft-com:vml"); - document.namespaces.add("o","urn:schemas-microsoft-com:office:office"); - var st = document.createStyleSheet(); + _doc.namespaces.add("v","urn:schemas-microsoft-com:vml"); + _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office"); + var st = _doc.createStyleSheet(); var vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl + "dn\\:defs{display:none}" + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl + "v\\:shape{width:100%;height:100%;" +vmlUrl; } - var ary = document.getElementsByTagName("script"); + var ary = _doc.getElementsByTagName("script"); //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する - for (var i=0; i < ary.length; ++i) { - var hoge = ary[i].type; - if (ary[i].type === "image/svg+xml") { - var ait = ary[i].text; + for (var i=0; ary[i]; ++i) { + var ai = ary[i], + hoge = ai.type; + if (ai.type === "image/svg+xml") { + var ait = ai.text; if (sieb_s && ait.match(/<svg/)) { //ソース内のタグを除去 ait = ait.replace(/<.+?>/g, ""); @@ -8516,7 +8512,7 @@ ait = ait.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&"); } if (NAIBU.isMSIE) { - var gsd = new GetSVGDocument(ary[i]); + var gsd = new GetSVGDocument(ai); gsd.xmlhttp = { readyState : 4, status : 200, @@ -8526,29 +8522,55 @@ } else { var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/ ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base); - var s = NAIBU.textToSVG(ait,ary[i].getAttribute("width"),ary[i].getAttribute("height")); - ary[i].parentNode.insertBefore(s,ary[i]); + var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height")); + ai.parentNode.insertBefore(s,ai); } - ait = null; + ai = ait = null; } hoge = null; } NAIBU.doc = nd; nd = ary = null; if (xmlhttp && NAIBU.isMSIE) { - if (!!document.createElementNS && !!document.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば + if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば } else { //IE6-8ならば - var oba = document.createElement("div"); - oba.setAttribute("id","_NAIBU_outline"); - document.body.appendChild(oba); - var ob = document.getElementsByTagName("object"), em = document.getElementsByTagName("embed"); - var i = 0, s=[]; - for (;i<ob.length;++i) { - s[s.length] = new GetSVGDocument(ob[i]); + var ob = _doc.getElementsByTagName("object"), + em = _doc.getElementsByTagName("embed"), + i = 0, + s=[], + ifr, obi, n; + for (;ob[i];++i) { + obi = ob[i]; + s[s.length] = new GetSVGDocument(obi); + ifr = _doc.createElement("iframe"); + ifr.style.background = "black"; + n = obi.getAttribute("width"); + n && ifr.setAttribute("width", n); + n = obi.getAttribute("height"); + n && ifr.setAttribute("height", n); + ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう + ifr.scrolling = "no"; + ifr.frameBorder = "0"; + /*iframe要素を使って、描画のプロセスを分離する + *したがって、_docはdocumentとは別のオブジェクトとなる + */ + obi.parentNode.insertBefore(ifr, obi); } - for (i=0;i<em.length;++i) { - s[s.length] = new GetSVGDocument(em[i]); + for (i=0;em[i];++i) { + obi = em[i]; + s[s.length] = new GetSVGDocument(obi); + ifr = _doc.createElement("iframe"); + ifr.style.background = "black"; + n = obi.getAttribute("width"); + n && ifr.setAttribute("width", n); + n = obi.getAttribute("height"); + n && ifr.setAttribute("height", n); + ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう + ifr.scrolling = "no"; + ifr.frameBorder = "0"; + obi.parentNode.insertBefore(ifr, obi); } + ob = em = i = obi = ifr = null; for (i=0;i<s.length;++i) { if (i < s.length-1) { s[i]._next = s[i+1] @@ -8560,17 +8582,17 @@ s = null; } } else { - var ob = document.getElementsByTagName("object"); + var ob = _doc.getElementsByTagName("object"); for (var i=0;i<ob.length;++i) { if (ob[i].contentDocument) { NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}}); } else if (ob[i].getSVGDocument) { - ob[i].getSVGDocument().documentElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false); + ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false); } else { } } } - xmlhttp = null; + xmlhttp = _doc = null; }); NAIBU.addEvent("load", NAIBU._main); NAIBU.utf16 = function ( /*string*/ s) {