svnno****@sourc*****
svnno****@sourc*****
2009年 12月 23日 (水) 20:55:13 JST
Revision: 1492 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1492 Author: dhrname Date: 2009-12-23 20:55:13 +0900 (Wed, 23 Dec 2009) Log Message: ----------- 0.56統合 Modified Paths: -------------- branches/05x/sie.js Property Changed: ---------------- branches/05x/sie.js Modified: branches/05x/sie.js =================================================================== --- branches/05x/sie.js 2009-12-22 14:09:17 UTC (rev 1491) +++ branches/05x/sie.js 2009-12-23 11:55:13 UTC (rev 1492) @@ -45,7 +45,7 @@ //これを頭に付けたら、内部処理用 var NAIBU = {}; SIE = { - version : 0.53 + version : 0.56 }; //documentを速くするために /*@cc_on _d=document;eval('var document=_d')@*/ @@ -95,7 +95,7 @@ if (/a/[-1] === 'a'){ //Firefoxだったらtrueを返す NAIBU.STObject.ffnext(); } - _noie_svgfont(); + setTimeout(_noie_svgfont, 500); } } //他のページに移動する際に起動 @@ -334,20 +334,7 @@ } catch(e) {stlog.add(e,185);this.next();} } else { //全要素の読み込みが終われば _ie_svgfont(); - if (NAIBU.Clip.length > 0) { - NAIBU.stop = setInterval( (function(){ - var ntc = NAIBU.Time.currentFrame++; - var nc = NAIBU.Clip; - for (var i=0,ncli=nc.length;i<ncli;++i) { - nc[i]._frame(ntc); - } - if (ntc > 7000) { - clearInterval(NAIBU.stop); - } - }), - 41 - ); - } + NAIBU.Time.start(); } } catch(e) {stlog.add(e,293);this.onumber++;this.next();} }; @@ -373,20 +360,7 @@ s.set(); } } - if (NAIBU.Clip.length > 0) { - NAIBU.stop = setInterval( (function(){ - var ntc = NAIBU.Time.currentFrame++; - var nc = NAIBU.Clip; - for (var i=0,ncli=nc.length;i<ncli;++i) { - nc[i]._frame(ntc); - } - if (ntc > 7000) { - clearInterval(NAIBU.stop); - } - }), - 41 - ); - } + NAIBU.Time.start(); } catch(e) {stlog.add(e,294);} }; @@ -394,7 +368,8 @@ function STGroupElement( /*element*/ g, /*Matrix*/ matrix, /*float*/w, h) { try{ this.tar = g; - this.transformable = NAIBU.transformToCTM(g,matrix); //g要素のtransform属性を前もって処理 + var _ni = NAIBU; //Alias + this.transformable = _ni.transformToCTM(g,matrix); //g要素のtransform属性を前もって処理 //以下、ツリーとして処理 this.children = []; this.chset(g,this.transformable, w, h); @@ -404,7 +379,8 @@ } STGroupElement.prototype.set = function (sw,sh) { try{ - stvsetob(this.children,sw,sh); + var _stvsetob = stvsetob; + _stvsetob(this.children,sw,sh); this.children = this.transformable = null; } catch(e){stlog.addd(e,3145);} }; @@ -606,20 +582,27 @@ //path要素の処理 function STPath( /*element*/ ele, /*Matrix*/ matrix) { this.tar = ele; + var _ni = NAIBU; //Alias this.d = ele.getAttribute("d"); - this.paint = new NAIBU.PaintColor(ele); - this.transformable = NAIBU.transformToCTM(ele,matrix); + this.paint = new _ni.PaintColor(ele); + this.transformable = _ni.transformToCTM(ele,matrix); return this; -} +}; +(function (){ + var a = /\s*([A-DF-Z])/gi, + b = /^\],/, + c = /\s*$/, + d = /[\s,]{2,}|\s/g, + e = /([\d.])-/g; STPath.prototype.set = function ( /*float*/ w, /*float*/ h) { var dat = ""; try { var dd = this.d - .replace(/\s*([A-DF-Z])/gi, '],["$1" ') //convert to JSON array - .replace(/^\],/, "[") - .replace(/\s*$/, "]]") - .replace(/[\s,]{2,}|\s/g, ",") - .replace(/([\d.])-/g, "$1,-"); + .replace(a, '],["$1" ') //convert to JSON array + .replace(b, "[") + .replace(c, "]]") + .replace(d, ",") + .replace(e, "$1,-"); var D = eval('('+dd+')'); //ここまでd属性のパーサ var ttm = this.transformable; var preCom; @@ -709,7 +692,7 @@ dat = this.paint = ttm = this.transformable = this.d = preCom = x = y = x0 = y0 = dx = dy = tma = tmb = tmc = tmd = tme = tmf = w = h = null; //解放 } catch(e) {stlog.add(e,372);} }; - +})(); //QからCに変換 NAIBU.qtoc = function (/*float*/ x, /*float*/ y, /*Array*/ F) { F[0] = "c"; @@ -1489,11 +1472,12 @@ }; NAIBU.FontStyle.prototype.fset = function( /*float*/ w, /*float*/ h, /*Matrix*/ matrix) { try{ + var _fontset = fontset; this.setStyle(); var tts = this.tar.style; tts.whiteSpace = "nowrap"; tts.color = this.fill === "none" ? "transparent" : this.fill; - this.fontSize = fontset(this["font-size"],w,h,matrix); + this.fontSize = _fontset(this["font-size"],w,h,matrix); tts.fontSize = this.fontSize+ "px"; if (this.cursor !== "default") { tts.cursor = this.cursor; @@ -1514,12 +1498,13 @@ try { var tft = ele.getAttribute("transform"); if (tft) { - var coma = tft.match(NAIBU.comaR); //コマンド文字にマッチ translate - var list = tft.match(NAIBU.listR); //カッコ内のリストにマッチ (10 20 30...) + var _naic = NAIBU.comaR, _nail = NAIBU.listR, _naid = NAIBU.degR; + var coma = tft.match(_naic); //コマンド文字にマッチ translate + var list = tft.match(_nail); //カッコ内のリストにマッチ (10 20 30...) var a,b,c,d,e,f,lis,deg,rad,degli,matri; for (var j=0,cli=coma.length;j<cli;j++) { lis = list[j], com = coma[j]; - deg = lis.match(NAIBU.degR); + deg = lis.match(_naid); degli = deg.length; if (degli === 6) { a = parseFloat(deg[0]); @@ -1583,7 +1568,7 @@ } } } - matri = new Matrix(a,b,c,d,e,f); + matri = {a:a, b:b, c:c, d:d, e:e, f:f}; matrix = matrix.multiply(matri); lis = com = deg = rad = null; } @@ -2057,7 +2042,10 @@ x += fontSize / Math.SQRT2; y -= fontSize / Math.SQRT2; } - NAIBU.pathData(glyphData[i], path, true, ti.w, ti.h, (new Matrix(fe, 0, 0, -fe, x, y)) ); + var s = new STPath(path, (new Matrix(fe, 0, 0, -fe, x, y))); + s.d = glyphData[i]; + s.set(ti.w, ti.h); + s = null; adv += advanceX[i]; } } @@ -2085,7 +2073,6 @@ } } NAIBU._fontSearchURI(document); - }; //font-face-uri要素に書かれたuriを手がかりに、Ajaxを使ってファイルを読み込む NAIBU._fontSearchURI = function(doc){ @@ -2174,7 +2161,8 @@ matrix.e = dx + adv*fe; matrix.f = dy; } - NAIBU.pathData(glyphData[i], path, false, 0, 0, matrix); + path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")"); + path.setAttributeNS(null, "d", glyphData[i]); adv += advanceX[i]; matrix = null; } @@ -2189,22 +2177,27 @@ } data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = null; }; -NAIBU.pathData = function(/*string*/ data, /*Element*/ p, /*boolean*/ t, /*float*/ w, h, /*Matrix*/ matrix) { - //CTMでフォントを移動させておく - if (t) { //IEならば - var s = new STPath(p, matrix); - s.d = data; - s.set(w,h); - s = null; - } else { - p.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")"); - p.setAttributeNS(null, "d", data); - } - matrix = data = t = null; -}; NAIBU.Time = { - currentFrame : 0 + currentFrame : 0, + start : function() { + if (NAIBU.Clip.length > 0) { + NAIBU.stop = setInterval( (function() { + var ntc = NAIBU.Time.currentFrame++; + var nc = NAIBU.Clip; + for (var i=0,ncli=nc.length;i<ncli;++i) { + if (nc[i]._begin) { + nc[i]._frame(ntc); + } + } + if (ntc > 7000) { + clearInterval(NAIBU.stop); + } + }), + 125 + ); + } + } }; NAIBU.Clip = []; function STSetElement(/*Element*/ ele, /*Matrix*/ matrix, /*float*/w, h) { @@ -2241,6 +2234,12 @@ } else if (parent.nodeName === "image") { s = new STImage(parent, matrix, w, h); } + var ncl = NAIBU.Clip.length; + if (ncl !== 0) { + if (NAIBU.Clip[ncl-1].tar === ele) { + s = NAIBU.Clip[ncl-1].target; + } + } this.trnasformable = s.transformable; this.target = s; this.tar = ele; @@ -2254,52 +2253,39 @@ this.w = w; this.h = h; this._begin = this._end = this.simpleDuration = null; - NAIBU.Clip[NAIBU.Clip.length] = this; + NAIBU.Clip[ncl] = this; + ncl = null; } return this; }; -STSetElement.prototype.set = function (w,h){ +STSetElement.prototype._eventRegExp = /(mouse|activ|clic)[a-z]+/; +STSetElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)/; +STSetElement.prototype.set = function(w,h) { this.to = this.tar.getAttribute("to"); - var offset, beginOffset = 0; + var offset = 0; try { - var n = parseFloat(this.begin.match(/[\-\d\.]+(h|min|s|ms)/)); - offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; - if ( /(mouse|activ|click)/.test(this.begin) ) { //イベントがある場合 - var tar; - if ( /\.\D/.test(this.begin) ) { - tar = this.tar.ownerDocument.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); - } else { - tar = this.target.tar; - } + this.eventSync(this.begin, (function(te, offse, ta) { - ta.attachEvent( "on" + te.begin.match(/(mouse|activ|clic)[a-z]+/)[0], - function(){te.beginElementAt(offse);}, false ); - })(this, offset, tar); - } else { - this.beginElementAt(offset); - beginOffset = offset; - } + ta.attachEvent( "on" + te.begin.match(te._eventRegExp)[0], + function(){ + if (offse !== 0) { + te.beginElementAt(offse); + } else { + te._begin = NAIBU.Time.currentFrame; + te.beginElement(); + te.currentFrame++; + } + }, false ); + }), "beginElementAt"); if (this.dur) { - var n = parseFloat(this.dur.match(/[\-\d\.]+(h|min|s|ms)/)); - this.simpleDuration = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + this.simpleDuration = this.getOffset(this.dur); } if (this.end) { - var n = parseFloat(this.end.match(/[\-\d\.]+(h|min|s|ms)/)); - offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; - if ( /(mouse|activ|click)/.test(this.end) ) { //イベントがある場合 - var tar; - if ( /\.\D/.test(this.end) ) { - tar = this.tar.ownerDocument.getElementById( this.end.substring(0,this.end.indexOf(".")) ); - } else { - tar = this.target.tar; - } + this.eventSync(this.end, (function(te, offse, ta) { - ta.attachEvent( "on" + te.end.match(/(mouse|activ|clic)[a-z]+/)[0], + ta.attachEvent( "on" + te.end.match(te._eventRegExp)[0], function(){te.endElementAt(offse);}, false ); - })(this, offset, tar); - } else { - this.endElementAt(offset); - } + }), "endElementAt"); } } catch(e) {stlog.add(e, 2239);} }; @@ -2309,52 +2295,71 @@ "s" : 800, "ms" : 0.8 }; +//どれだけズレの時間があるかを計測するメソッド +STSetElement.prototype.getOffset = function(/*string*/ t) { + var n = parseFloat(t.match(this._timeRegExp)); + var offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + n = t = null; + return offset; +}; +STSetElement.prototype.eventSync = function(/*string*/ t, /*function*/ f, /*string*/ methodName) { + var offset = this.getOffset(t); + if ( /(mouse|activ|click)/.test(t) ) { //イベントがある場合 + var tar; + if ( /\.\D/.test(t) ) { + tar = this.tar.ownerDocument.getElementById( t.substring(0, t.indexOf(".")) ); + } else { + tar = this.target.tar; + } + f(this, offset, tar); + } else { + this[methodName](offset); + }}; //sは現在のフレーム数であることに気をつけること -STSetElement.prototype._frame = function (/*int*/ s){ - if (this._begin) { - if (this._begin <= s) { - if (this.currentFrame === 0) { - this.beginElement(); - } - this.currentFrame++; +STSetElement.prototype._frame = function(/*int*/ s) { + if (this._begin <= s) { + if (this.currentFrame === 0) { + this.beginElement(); } - if (this._end) { - if (this._end <= s && this.currentFrame !== 0) { - this.endElement(); - this.currentFrame = 0; - this._begin = null; - } + this.currentFrame++; + } + if (this._end) { + if (this._end <= s && this.currentFrame !== 0) { + this.endElement(); + this.currentFrame = 0; + this._begin = this._end = null; } } }; -STSetElement.prototype.beginElement = function (){ - var target = this.target; - var base = target[this.attributeName]; +STSetElement.prototype.beginElement = function() { + var target = this.target, attrName = this.attributeName; + var base = target[attrName]; try { //fill要素とstroke要素はあらかじめ消しておく if ( !(target instanceof STGroupElement) ) { - var tgebtfill = target.tar.getElementsByTagName("fill"), tgebtstroke = target.tar.getElementsByTagName("stroke"); - if (tgebtfill.length > 0) { - target.tar.removeChild(tgebtfill[0]); - } - if (tgebtstroke.length > 0) { - target.tar.removeChild(tgebtstroke[0]); - } - } + var tart = target.tar; + var tgebtfill = tart.getElementsByTagName("fill"), tgebtstroke = tart.getElementsByTagName("stroke"); + if (tgebtfill.length > 0) { + tart.removeChild(tgebtfill[0]); + } + if (tgebtstroke.length > 0) { + tart.removeChild(tgebtstroke[0]); + } + } if (base !== void 0) { if (typeof base === "string") { - target[this.attributeName] = this.to; + target[attrName] = this.to; } else if (base instanceof STLength) { var s = base.value; base.newValueSpecifiedUnits(base.unitType, parseFloat(this.to)); base = s; } - } else if (target.paint.defaults[this.attributeName] !== void 0) { - base = target.paint[this.attributeName]; - target.paint[this.attributeName] = this.to; + } else if (target.paint.defaults[attrName] !== void 0) { + base = target.paint[attrName]; + target.paint[attrName] = this.to; } else { base = ""; - target.tar.style[this.attributeName] = this.to; + target.tar.style[attrName] = this.to; } target.set(this.w, this.h); target.transformable = this.trnasformable; @@ -2364,6 +2369,7 @@ if (this._end) { var offset = (this.simpleDuration > this._end - this._begin) ? this._end - this._begin : this.simpleDuration; this.endElementAt(offset); + offset = null; } else { this.endElementAt(this.simpleDuration); } @@ -2371,23 +2377,28 @@ } catch(e) { stlog.add(e, 23400); } + attrName = null; return; }; -STSetElement.prototype.endElement = function (){ +STSetElement.prototype.endElement = function() { if (this.fill) { if (this.fill === "freeze") { return; } } + var to = this.to; this.to = this.base; this.beginElement(); + this.to = to; return; }; -STSetElement.prototype.beginElementAt = function (offset){ - this._begin = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame); //フレーム数に変換(軽量化のために、1s = 800msで計算) +STSetElement.prototype.beginElementAt = function(offset) { + var ntc = NAIBU.Time.currentFrame; + this._begin = Math.ceil(offset * 0.8 / 125 + ntc); //フレーム数に変換(軽量化のために、1s = 800msで計算) + this._frame(ntc); }; -STSetElement.prototype.endElementAt = function (offset){ - this._end = Math.ceil(offset * 0.8 / 24 + NAIBU.Time.currentFrame); +STSetElement.prototype.endElementAt = function(offset) { + this._end = Math.ceil(offset * 0.8 / 125 + NAIBU.Time.currentFrame); }; function _noie_STSetElement(/*Element*/ ele) { @@ -2409,65 +2420,51 @@ _noie_STSetElement.prototype = new STSetElement(); _noie_STSetElement.prototype.set = function (){ this.to = this.tar.getAttributeNS(null, "to"); - var offset, beginOffset = 0; + var offset = 0; try { - var n = parseFloat(this.begin.match(/[\-\d\.]+(h|min|s|ms)/)); - offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; - if ( /(mouse|activ|click)/.test(this.begin) ) { //イベントがある場合 - var tar; - if ( /\.\D/.test(this.begin) ) { - tar = this.tar.ownerDocument.getElementById( this.begin.substring(0, this.begin.indexOf(".")) ); - } else { - tar = this.target.tar; - } + this.eventSync(this.begin, //クロージャを参照 (function(te, offse, ta) { - ta.addEventListener( te.begin.match(/(mouse|activ|clic)[a-z]+/)[0], - function(){te.beginElementAt(offse);}, false ); - })(this, offset, tar); - } else { - this.beginElementAt(offset); - beginOffset = offset; - } + ta.addEventListener( te.begin.match(te._eventRegExp)[0], + function(){ + if (offse !== 0) { + te.beginElementAt(offse); + } else { + te._begin = NAIBU.Time.currentFrame; + te.beginElement(); + te.currentFrame++; + } + }, false ); + }), "beginElementAt"); if (this.dur) { - var n = parseFloat(this.dur.match(/[\-\d\.]+(h|min|s|ms)/)); - this.simpleDuration = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; + this.simpleDuration = this.getOffset(this.dur); } if (this.end) { - var n = parseFloat(this.end.match(/[\-\d\.]+(h|min|s|ms)/)); - offset = (!isNaN(n)) ? n * this._unit[RegExp.$1] : 0; - if ( /(mouse|activ|click)/.test(this.end) ) { //イベントがある場合 - var tar; - if ( /\.\D/.test(this.end) ) { - tar = this.tar.ownerDocument.getElementById( this.end.substring(0, this.end.indexOf(".")) ); - } else { - tar = this.target.tar; - } + this.eventSync(this.end, //クロージャを参照 (function(te, offse, ta) { - ta.addEventListener( te.end.match(/(mouse|activ|clic)[a-z]+/)[0], + ta.addEventListener( te.end.match(te._eventRegExp)[0], function(){te.endElementAt(offse);}, false ); - })(this, offset, tar); - } else { - this.endElementAt(offset); - } + }), "endElementAt"); } } catch(e) {stlog.add(e, 2239);} }; -_noie_STSetElement.prototype.beginElement = function (){ +_noie_STSetElement.prototype.beginElement = function() { try { - var target = this.target, base = target.getAttributeNS(null, this.attributeName) || target.style.getPropertyValue(this.attributeName); - target.setAttributeNS(null, this.attributeName, this.to); - target.style.setProperty(this.attributeName, this.to, ""); //第三引数に関しては、W3CやMDCを参照 + var target = this.target, attrName = this.attributeName, base = target.getAttributeNS(null, attrName) || target.style.getPropertyValue(attrName); + target.setAttributeNS(null, attrName, this.to); + target.style.setProperty(attrName, this.to, ""); //第三引数に関しては、W3CやMDCを参照 this.base = base; if (this.simpleDuration) { if (this._end) { var offset = (this.simpleDuration > this._end - this._begin) ? this._end - this._begin : this.simpleDuration; this.endElementAt(offset); + offset = null; } else { this.endElementAt(this.simpleDuration); } } + attrName = null; } catch(e) { stlog.add(e, 24370); } @@ -2593,10 +2590,12 @@ obst.width = regwv+ "px"; obst.height = reghv+ "px"; ob.coordsize = regwv +" "+ reghv; + var dewp = new Date(); var STdocument = new SVGtoVML(obc, obwidth, obheight, regw, regh); obj.parentNode.insertBefore(ob, obj); STdocument.read(ob); STdocument.set(ob); + alert((new Date()).getTime() - dewp.getTime()); STdocument = obw = obh = regw = regh = null; NAIBU.PaintColor.prototype.cache = {}; //キャッシュの初期化 if (NAIBU.STObject !== void 0) {NAIBU.STObject.next();} Property changes on: branches/05x/sie.js ___________________________________________________________________ Modified: svn:mergeinfo - /branches/04x/040/sie.js:812-829 /branches/04x/041/sie.js:891-923 /branches/04x/042/sie.js:927-967 /branches/04x/043/sie.js:969-1013 /branches/04x/044/sie.js:1015-1067 /branches/04x/045/sie.js:1069-1078 /branches/04x/046/sie.js:1080-1129 /branches/04x/047/sie.js:1131-1164 /branches/04x/048/sie.js:1166-1180 /branches/04x/sie.js:830-1181 /branches/05x/050/sie.js:1183-1201 /branches/05x/051/sie.js:1207-1323 /branches/05x/052/sie.js:1325-1352 /branches/05x/053/sie.js:1354-1400 /branches/05x/054/sie.js:1403-1422 /branches/05x/055/sie.js:1424-1454 + /branches/04x/040/sie.js:812-829 /branches/04x/041/sie.js:891-923 /branches/04x/042/sie.js:927-967 /branches/04x/043/sie.js:969-1013 /branches/04x/044/sie.js:1015-1067 /branches/04x/045/sie.js:1069-1078 /branches/04x/046/sie.js:1080-1129 /branches/04x/047/sie.js:1131-1164 /branches/04x/048/sie.js:1166-1180 /branches/04x/sie.js:830-1181 /branches/05x/050/sie.js:1183-1201 /branches/05x/051/sie.js:1207-1323 /branches/05x/052/sie.js:1325-1352 /branches/05x/053/sie.js:1354-1400 /branches/05x/054/sie.js:1403-1422 /branches/05x/055/sie.js:1424-1454 /branches/05x/056/sie.js:1456-1491