svnno****@sourc*****
svnno****@sourc*****
2011年 7月 5日 (火) 23:24:12 JST
Revision: 2817 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2817 Author: dhrname Date: 2011-07-05 23:24:12 +0900 (Tue, 05 Jul 2011) Log Message: ----------- 0.81モジュール結合 Modified Paths: -------------- branches/08x/sie.js Modified: branches/08x/sie.js =================================================================== --- branches/08x/sie.js 2011-07-05 14:23:29 UTC (rev 2816) +++ branches/08x/sie.js 2011-07-05 14:24:12 UTC (rev 2817) @@ -1909,6 +1909,10 @@ s = isNaN(s) ? 0 : s; if (n >= "0" && n <= "9") { type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1; + if (unitType === 1) { + unitType = tc = n = type = null; + return s; + } } else if (n === "%") { s *= this._percent; type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2; @@ -3979,8 +3983,30 @@ /*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); + ifr.contentWindow.screen.updateInterval = 999; + var _doc = ifr.contentWindow.document; + _doc.write(""); + _doc.close(); // これがないと document.body は null になる + if (("namespaces" in _doc) && !_doc.namespaces["v"]) { + _doc.namespaces.add("v","urn:schemas-microsoft-com:vml"); + _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office"); + var st = _doc.createStyleSheet(), + 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; + st = vmlUrl = null; + } var str = this.xmlhttp.responseText, - _doc = document, objei = this._tar, s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"), tar = s.documentElement, @@ -3993,7 +4019,12 @@ style, fontSize, w, h, sw, sh, trstyle, tpstyle, backrs, viewWidth, viewHeight, bfl, bft, bl, backright, backdown, text, _parseFloat = parseFloat, - ndoc = NAIBU.doc; + ndoc = NAIBU.doc, + oba = _doc.createElement("div"); //obaはradialGradient要素で使う + oba.setAttribute("id","_NAIBU_outline"); + _doc.body.appendChild(oba); + _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor; + s._document_ = _doc; //_document_プロパティはradialGradient要素やNAIBU._setPaintなどで使う ndoc.async = false; /*下記のプロパティについては、Microsoftのサイトを参照 *ResolveExternals Property [Second-level DOM] @@ -4050,11 +4081,13 @@ 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; sp.appendChild(dcp); - objei.parentNode.insertBefore(sp, objei); + _doc.body.appendChild(sp); dcp.appendChild(sdt); while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する n = s.importNode(fi, true); @@ -4135,13 +4168,14 @@ } } s.defaultView._cache = s.defaultView._cache_ele = null; - evt = _doc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = w = h = sw = sh = style = fontSize = 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; /*IEのメモリリーク対策として、空関数を入力*/ this.xmlhttp.onreadystatechange = NAIBU.emptyFunction; if (this._next) { - s = null; + ifr.contentWindow.screen.updateInterval = 0; + ifr = s = null; this._next._init(); } else { /*全要素の読み込みが終了した場合*/ @@ -4914,7 +4948,8 @@ }; SVGPathElement.constructor = SVGElement; SVGPathElement.prototype = new SVGElement(); -SVGPathElement.prototype._attrModi = function(evt){ +(function(_sproto) { +_sproto._attrModi = function(evt){ var tar = evt.target; if (evt.attrName === "d" && evt.newValue !== ""){ /* d属性の値が空の場合は、描画を行わないようにする @@ -5207,7 +5242,7 @@ } evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = null; }; -SVGPathElement.prototype._nodeInsert = function(evt){ +_sproto._nodeInsert = function(evt){ var tar = evt.target; if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) { return; //強制終了させる @@ -5238,7 +5273,7 @@ tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false); evt = tar = null; }; -SVGPathElement.prototype._nodeInsertInto = function(evt){ +_sproto._nodeInsertInto = function(evt){ /*以下の処理は、normalizedpathSegListとCTMに基づいて、 *SVGのd属性をVMLに変換していく処理である。 */ @@ -5283,7 +5318,7 @@ delete tar._currentStyle; evt = tar = dat = t = tx = ty = matrix = tlist = x = y = _parseInt = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = null; }; -SVGPathElement.prototype._com = { +_sproto._com = { _nameCom : { z : " x ", Z : " x ", @@ -5311,7 +5346,7 @@ isRe : /,/, isSp : /\S+/g }; - /*float*/ SVGPathElement.prototype.getTotalLength = function() { + /*float*/ _sproto.getTotalLength = function() { var s = 0, nl = this.normalizedPathSegList; for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) { @@ -5342,7 +5377,7 @@ this.pathLength.baseVal = s; return s; }; - /*SVGPoint*/ SVGPathElement.prototype.getPointAtLength = function(/*float*/ distance ) { + /*SVGPoint*/ _sproto.getPointAtLength = function(/*float*/ distance ) { var segn = this.getPathSegAtLength(distance), x = 0, y = 0, @@ -5390,7 +5425,7 @@ } return s; }; - /*unsigned long*/ SVGPathElement.prototype.getPathSegAtLength = function(/*float*/ distance ) { + /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) { var nl = this.normalizedPathSegList; //仕様ではpathSegList for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) { var seg = nl.getItem(i); @@ -5422,35 +5457,35 @@ */ return (nl.numberOfItems - 1); }; - /*SVGPathSegClosePath*/ SVGPathElement.prototype.createSVGPathSegClosePath = function() { + /*SVGPathSegClosePath*/ _sproto.createSVGPathSegClosePath = function() { var _SVGPathSegClosePath = SVGPathSegClosePath; return (new _SVGPathSegClosePath()); }; - /*SVGPathSegMovetoAbs*/ SVGPathElement.prototype.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) { + /*SVGPathSegMovetoAbs*/ _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) { var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs(); s.x = x; s.y = y; return s; }; - /*SVGPathSegMovetoRel*/ SVGPathElement.prototype.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) { + /*SVGPathSegMovetoRel*/ _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) { var s = new SVGPathSegMovetoRel(); s.x = x; s.y = y; return s; }; - /*SVGPathSegLinetoAbs*/ SVGPathElement.prototype.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) { + /*SVGPathSegLinetoAbs*/ _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) { var s = new SVGPathSegLinetoAbs(); s.x = x; s.y = y; return s; }; - /*SVGPathSegLinetoRel*/ SVGPathElement.prototype.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) { + /*SVGPathSegLinetoRel*/ _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) { var s = new SVGPathSegLinetoRel(); s.x = x; s.y = y; return s; }; - /*SVGPathSegCurvetoCubicAbs*/ SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) { + /*SVGPathSegCurvetoCubicAbs*/ _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) { var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs(); s.x = x; s.y = y; @@ -5460,7 +5495,7 @@ s.y2 = y2; return s; }; - /*SVGPathSegCurvetoCubicRel*/ SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) { + /*SVGPathSegCurvetoCubicRel*/ _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) { var s = new SVGPathSegCurvetoCubicRel(); s.x = x; s.y = y; @@ -5470,7 +5505,7 @@ s.y2 = y2; return s; }; - /*SVGPathSegCurvetoQuadraticAbs*/ SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) { + /*SVGPathSegCurvetoQuadraticAbs*/ _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) { var s = new SVGPathSegCurvetoQuadraticAbs(); s.x = x; s.y = y; @@ -5478,7 +5513,7 @@ s.y1 = y1; return s; }; - /*SVGPathSegCurvetoQuadraticRel*/ SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) { + /*SVGPathSegCurvetoQuadraticRel*/ _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) { var s = new SVGPathSegCurvetoQuadraticRel(); s.x = x; s.y = y; @@ -5486,7 +5521,7 @@ s.y1 = y1; return s; }; - /*SVGPathSegArcAbs*/ SVGPathElement.prototype.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) { + /*SVGPathSegArcAbs*/ _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) { var s = new SVGPathSegArcAbs(); s.x = x; s.y = y; @@ -5497,7 +5532,7 @@ s.sweepFlag = sweepFlag; return s; }; - /*SVGPathSegArcRel*/ SVGPathElement.prototype.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) { + /*SVGPathSegArcRel*/ _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) { var s = new SVGPathSegArcRel(); s.x = x; s.y = y; @@ -5508,31 +5543,31 @@ s.sweepFlag = sweepFlag; return s; }; - /*SVGPathSegLinetoHorizontalAbs*/ SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) { + /*SVGPathSegLinetoHorizontalAbs*/ _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) { var s = new SVGPathSegLinetoHorizontalAbs(); s.x = x; s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる return s; }; - /*SVGPathSegLinetoHorizontalRel*/ SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) { + /*SVGPathSegLinetoHorizontalRel*/ _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) { var s = new SVGPathSegLinetoHorizontalRel(); s.x = x; s.y = 0; return s; }; - /*SVGPathSegLinetoVerticalAbs*/ SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) { + /*SVGPathSegLinetoVerticalAbs*/ _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) { var s = new SVGPathSegLinetoVerticalAbs(); s.x = 0; s.y = y; return s; }; - /*SVGPathSegLinetoVerticalRel*/ SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) { + /*SVGPathSegLinetoVerticalRel*/ _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) { var s = new SVGPathSegLinetoVerticalRel(); s.x = 0; s.y = y; return s; }; - /*SVGPathSegCurvetoCubicSmoothAbs*/ SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) { + /*SVGPathSegCurvetoCubicSmoothAbs*/ _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) { var s = new SVGPathSegCurvetoCubicSmoothAbs(); s.x = x; s.y = y; @@ -5540,7 +5575,7 @@ s.y2 = y2; return s; }; - /*SVGPathSegCurvetoCubicSmoothRel*/ SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) { + /*SVGPathSegCurvetoCubicSmoothRel*/ _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) { var s = new SVGPathSegCurvetoCubicSmoothRel(); s.x = x; s.y = y; @@ -5548,18 +5583,19 @@ s.y2 = y2; return s; }; - /*SVGPathSegCurvetoQuadraticSmoothAbs*/ SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) { + /*SVGPathSegCurvetoQuadraticSmoothAbs*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) { var s = new SVGPathSegCurvetoQuadraticSmoothAbs(); s.x = x; s.y = y; return s; }; - /*SVGPathSegCurvetoQuadraticSmoothRel*/ SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) { + /*SVGPathSegCurvetoQuadraticSmoothRel*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) { var s = new SVGPathSegCurvetoQuadraticSmoothRel(); s.x = x; s.y = y; return s; }; +})(SVGPathElement.prototype) NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数 })(document, parseInt, Math); @@ -5574,11 +5610,13 @@ /*readonly SVGAnimatedLength*/ this.rx = new SVGAnimatedLength(); /*readonly SVGAnimatedLength*/ this.ry = new SVGAnimatedLength(); this.addEventListener("DOMNodeInserted", function(evt){ - var tar = evt.target; if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) { return; //強制終了させる } - var tnext = tar.nextSibling, tpar = tar.parentNode, isLast = true; + var tar = evt.target, + tnext = tar.nextSibling, + tpar = tar.parentNode, + isLast = true; if (tnext && tnext._tar && tpar._tar && (tnext._tar.parentNode === tpar._tar)) { tpar._tar.insertBefore(tar._tar, tnext._tar); } else if (tnext && !tnext._tar && tpar._tar) { @@ -5600,57 +5638,73 @@ } tnext = tpar = isLast = null; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); - var fontSize = parseFloat(style.getPropertyValue("font-size")); + var tar = evt.target, + style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""), + fontSize = parseFloat(style.getPropertyValue("font-size")); tar.x.baseVal._emToUnit(fontSize); tar.y.baseVal._emToUnit(fontSize); tar.width.baseVal._emToUnit(fontSize); tar.height.baseVal._emToUnit(fontSize); - var rx = tar.getAttributeNS(null, "rx"), ry = tar.getAttributeNS(null, "ry"); - var x = tar.x.baseVal.value, y = tar.y.baseVal.value, xw = x + tar.width.baseVal.value, yh = y + tar.height.baseVal.value; - var list; + var rx = tar.getAttributeNS(null, "rx"), + ry = tar.getAttributeNS(null, "ry"), + x = tar.x.baseVal.value, + y = tar.y.baseVal.value, + xw = x + tar.width.baseVal.value, + yh = y + tar.height.baseVal.value, + list; if ((rx || ry) && (rx !== "0") && (ry !== "0")) { tar.rx.baseVal._emToUnit(fontSize); tar.ry.baseVal._emToUnit(fontSize); - var thrx = tar.rx.baseVal, thry = tar.ry.baseVal; + var thrx = tar.rx.baseVal, + thry = tar.ry.baseVal, + twidth = tar.width.baseVal.value, + theight = tar.height.baseVal.value; thrx.value = rx ? thrx.value : thry.value; thry.value = ry ? thry.value : thrx.value; //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する) - var twidth = tar.width.baseVal.value, theight = tar.height.baseVal.value; if (thrx.value > twidth / 2) { thrx.value = twidth / 2; } if (thry.value > theight / 2) { thry.value = theight / 2; } - var rxv = thrx.value, ryv = thry.value; - var rrx = rxv * 0.55228, rry = ryv * 0.55228; - var a = xw - rxv, b = x + rxv, c = y + ryv, d = yh - ryv; + var rxv = thrx.value, + ryv = thry.value, + rrx = rxv * 0.55228, + rry = ryv * 0.55228, + a = xw - rxv, + b = x + rxv, + c = y + ryv, + d = yh - ryv; list = ["m",b,y, "l",a,y, "c",a+rrx,y,xw,c-rry,xw,c, "l",xw,d, "c",xw,d+rry,a+rrx,yh,a,yh, "l",b,yh, "c",b-rrx,yh,x,d+rry,x,d, "l",x,c, "c",x,c-rry,b-rrx,y,b,y]; } else { list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"]; } //以下は、配列listそのものをCTMで座標変換していく処理 - var par = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM(); + var par = tar.ownerDocument.documentElement, + ctm = tar.getScreenCTM(), + dat, p, pmt, + ele = tar._tar, + vi = tar.ownerDocument.documentElement, + w = vi.width.baseVal.value, + h = vi.height.baseVal.value; for (var i=0, lili=list.length;i<lili;) { if (isNaN(list[i])) { //コマンド文字は読み飛ばす ++i; continue; } - var p = par.createSVGPoint(); + p = par.createSVGPoint(); p.x = list[i]; p.y = list[i+1]; - var pmt = p.matrixTransform(ctm); + pmt = p.matrixTransform(ctm); list[i] = pmt.x; ++i; list[i] = pmt.y; ++i; p = pmt = null; } - var dat = list.join(" "); + dat = list.join(" "); //VMLに結び付けていく - var ele = tar._tar, vi = tar.ownerDocument.documentElement; - var w = vi.width.baseVal.value, h = vi.height.baseVal.value; ele.path = dat; ele.coordsize = w + " " + h; NAIBU._setPaint(tar, ctm); @@ -7009,6 +7063,7 @@ this._tar = _doc.createElement("a"); _doc = null; /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString(); + this.target.baseVal = "_self"; this.addEventListener("DOMAttrModified", function(evt){ var tar = evt.target; if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) { @@ -7073,6 +7128,11 @@ tar = evt = null; return; //強制終了させる }, true); + this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){ + var tar = evt.target; + tar._tar.setAttribute("target", tar.target.baseVal); + tar = null; + }, false); SVGURIReference.apply(this, arguments); return this; }; @@ -7438,9 +7498,7 @@ } if (nci._end && (nci._end <= s) && (nci.getCurrentTime() !== 0)) { nci.endElement(); - if (!!nci._frame) { - nci._frame(); - } + nci._frame && nci._frame(); nci._currentFrame = 0; delete nci._begin; nci._end = null;