svnno****@sourc*****
svnno****@sourc*****
2011年 10月 17日 (月) 21:49:40 JST
Revision: 3009 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=3009 Author: dhrname Date: 2011-10-17 21:49:38 +0900 (Mon, 17 Oct 2011) Log Message: ----------- SVGPolygonElementとSVGPolylineインターフェースの共通インターフェースとして、_GenericSVGPolyElementを導入して、軽量化 Modified Paths: -------------- branches/08x/087/org/w3c/dom/svg.js Modified: branches/08x/087/org/w3c/dom/svg.js =================================================================== --- branches/08x/087/org/w3c/dom/svg.js 2011-10-15 13:43:07 UTC (rev 3008) +++ branches/08x/087/org/w3c/dom/svg.js 2011-10-17 12:49:38 UTC (rev 3009) @@ -3694,7 +3694,11 @@ SVGLineElement.constructor = SVGElement; SVGLineElement.prototype = new SVGElement(); -function SVGPolylineElement(_doc) { +/*_GenericSVGPolyElementインターフェース + * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。 + * ファイルサイズを軽量にすることができる + */ +NAIBU._GenericSVGPolyElement = function (_doc, xclose) { SVGElement.apply(this); this._tar = _doc.createElement("v:shape"); _doc = void 0; @@ -3747,115 +3751,46 @@ } tnext = tpart = isLast = void 0; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target, tp = tar.points; + var tar = evt.target, + tp = tar.points, + ctm = tar.getScreenCTM(); //以下は、配列listそのものをCTMで座標変換していく処理 - var ctm = tar.getScreenCTM(); for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) { - var p = tp.getItem(i); - var pmt = p.matrixTransform(ctm); + var p = tp.getItem(i), + pmt = p.matrixTransform(ctm); list[2*i] = pmt.x; list[2*i + 1] = pmt.y; p = pmt = void 0; } list.splice(2, 0, "l"); - var dat = "m" + list.join(" ") + "e"; + var dat = "m" + list.join(" ") + xclose, + ele = tar._tar, + vi = tar.ownerDocument.documentElement; + w = vi.width.baseVal.value, + h = vi.height.baseVal.value; //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); delete tar._cacheMatrix; delete tar._currentStyle; - evt = ele = tar = dat = list = ctm = w = h = void 0; + evt = ele = tar = dat = list = ctm = w = h = vi = void 0; }, false); evt = tar = void 0; }, false); return this; +} +function SVGPolylineElement(_doc) { + NAIBU._GenericSVGPolyElement.call(this, _doc, "e"); + _doc = void 0; + return this; }; SVGPolylineElement.constructor = SVGElement; SVGPolylineElement.prototype = new SVGElement(); function SVGPolygonElement(_doc) { - SVGElement.apply(this); - this._tar = _doc.createElement("v:shape"); + NAIBU._GenericSVGPolyElement.call(this, _doc, "x e"); _doc = void 0; - //interface SVGAnimatedPoints - /*readonly SVGPointList*/ this.animatedPoints = this.points = new SVGPointList(); - this.addEventListener("DOMAttrModified", function(evt){ - var tar = evt.target; - if (evt.attrName === "points") { - var tp = tar.points, par = tar.ownerDocument.documentElement; - var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/); - for (var i=0, p, lili=list.length;i<lili;i+=2) { - if (isNaN(list[i])) { - --i; - continue; - } - p = par.createSVGPoint(); - p.x = parseFloat(list[i]); - p.y = parseFloat(list[i+1]); - tp.appendItem(p); - } - } - evt = tar = list = tp = par = p = void 0; - }, false); - this.addEventListener("DOMNodeInserted", function(evt){ - if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) { - return; //強制終了させる - } - var tar = evt.target, - tnext = tar.nextSibling, - tpart = tar.parentNode._tar; - if (tnext && !!tpart) { - if (!!!tnext._tar) { - /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの - *use要素や実体参照などは_tarプロパティがないことに注意 - */ - var isLast = true; - while (tnext) { - if (!!tnext._tar) { - tpart.insertBefore(tar._tar, tnext._tar); - isLast = false; - } - tnext = tnext.nextSibling; - } - if (isLast) { - tpart.appendChild(tar._tar); - } - isLast = void 0; - } else { - tpart.insertBefore(tar._tar, tnext._tar); - } - } else if (!!tpart){ - tpart.appendChild(tar._tar); - } - tnext = tpart = void 0; - tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target, tp = tar.points; - //以下は、配列listそのものをCTMで座標変換していく処理 - var ctm = tar.getScreenCTM(); - for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) { - var p = tp.getItem(i); - var pmt = p.matrixTransform(ctm); - list[2*i] = pmt.x; - list[2*i + 1] = pmt.y; - p = pmt = void 0; - } - list.splice(2, 0, "l"); - var dat = "m" + list.join(" ") + "x e"; - //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); - delete tar._cacheMatrix; - delete tar._currentStyle; - evt = ele = tar = dat = list = ctm = w = h = void 0; - }, false); - evt = tar = void 0; - }, false); return this; }; SVGPolygonElement.constructor = SVGElement;