svnno****@sourc*****
svnno****@sourc*****
2011年 7月 15日 (金) 20:43:48 JST
Revision: 2838 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2838 Author: dhrname Date: 2011-07-15 20:43:48 +0900 (Fri, 15 Jul 2011) Log Message: ----------- 画像フレームの幅と高さをonloadの段階で決定させるようにした Modified Paths: -------------- branches/08x/082/org/w3c/dom/svg.js Modified: branches/08x/082/org/w3c/dom/svg.js =================================================================== --- branches/08x/082/org/w3c/dom/svg.js 2011-07-15 11:31:02 UTC (rev 2837) +++ branches/08x/082/org/w3c/dom/svg.js 2011-07-15 11:43:48 UTC (rev 2838) @@ -1781,8 +1781,6 @@ tar.setAttributeNodeNS(att); } str = attr = null; - ifr.setAttribute("width", objw); - ifr.setAttribute("height", objh); dcp.style.width = tview.width+ "px"; dcp.style.height = tview.height+ "px"; dcp.coordsize = tview.width+ " " +tview.height; @@ -6172,7 +6170,8 @@ */ NAIBU._main = (function() { stlog = new STLog(true); - var xmlhttp; //XMLHttpオブジェクトを生成 + var xmlhttp, //XMLHttpオブジェクトを生成 + _doc = document; //documentのエイリアスを作成 try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { @@ -6191,19 +6190,19 @@ } 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; ary[i]; ++i) { var ai = ary[i], @@ -6237,17 +6236,22 @@ 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 ob = document.getElementsByTagName("object"), - em = document.getElementsByTagName("embed"), + var ob = _doc.getElementsByTagName("object"), + em = _doc.getElementsByTagName("embed"), i = 0, s=[], - ifr, obi; + ifr, obi, n; for (;ob[i];++i) { obi = ob[i]; s[s.length] = new GetSVGDocument(obi); - ifr = document.createElement("iframe"); + 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"; @@ -6259,13 +6263,15 @@ for (i=0;em[i];++i) { obi = em[i]; s[s.length] = new GetSVGDocument(obi); - ifr = document.createElement("iframe"); + 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); } ob = em = i = obi = ifr = null; @@ -6280,17 +6286,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) {