svnno****@sourc*****
svnno****@sourc*****
2011年 5月 16日 (月) 19:54:44 JST
Revision: 2681 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2681 Author: dhrname Date: 2011-05-16 19:54:44 +0900 (Mon, 16 May 2011) Log Message: ----------- 0.77モジュールを結合 Modified Paths: -------------- branches/07x/sie.js Modified: branches/07x/sie.js =================================================================== --- branches/07x/sie.js 2011-05-16 10:48:12 UTC (rev 2680) +++ branches/07x/sie.js 2011-05-16 10:54:44 UTC (rev 2681) @@ -976,7 +976,7 @@ var s = new EventListener(useCapture, type, listener), //リスナーを作成 t = type.charAt(0), that; - this._capter[this._capter.length] = s; //このノードにリスナーを登録しておく + this._capter.push(s); //このノードにリスナーを登録しておく if ((t !== "D") && (t !== "S") && (type !== "beginEvent") && (type !== "endEvent") && (type !== "repeatEvent")) { //MouseEventsならば that = this; that._tar && that._tar.attachEvent("on" +type, (function(node) { @@ -1024,8 +1024,8 @@ } else if ((etime - td._limit_time_) > 1000) { /*1秒を超えたらバッファにため込んで後で使う*/ tob = td.implementation._buffer_ || []; - tob[tob.length] = this; - tob[tob.length] = evt; + tob.push(this); + tob.push(evt); td.implementation._buffer_ = tob; return true; } @@ -1561,7 +1561,7 @@ this.type = CSSRule.STYLE_RULE; this.selectorText = ""; /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration(); - this.style.parentRule = this; + this.style.parentRule = null; return this; }; CSSStyleRule.prototype = new CSSRule(); @@ -2120,9 +2120,23 @@ CSSStyleSheet.prototype = new StyleSheet(); CSSStyleSheet.constructor = StyleSheet; /*long*/ CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) { - var s = new CSSStyleRule(); + var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m; s.parentStyleSheet = this; - s.cssText = rule; + style.cssText = rule; + //style値の解析; + sc = sc.replace(/^[^a-z\-]+/, "") + .replace(/\:\s+/g, ":") + .replace(/\s*;[^a-z\-]*/g, ";"); + a = sc.split(";"); + for (var i=0, ali=a.length;i<ali;++i) { + ai = a[i], + m = ai.split(":"); + if (ai !== "") { + style.setProperty(m[0], m[1]); + } + ai = m = null; + } + a = sc = style = null; this.cssRules.splice(index,s,1); }; /*void*/ CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) { @@ -2162,6 +2176,16 @@ q[q.length] = easl[i]; //プレゼンテーション属性を結びつける } estl = easl = null; + //スタイルシートのルールを結びつける + if (elt._rules) { + for (var i=0,eli=elt._rules.length;i<eli;++i) { + var ei = elt._rules[i].style._list; + for (var j=0,esli=ei.length;j<esli;++j) { + q[q.length] = ei[j]; + } + } + } + //inheritの値があれば、削除しておく for (var i=0,qli=q.length;i<qli;++i) { if (q[i].cssValueType === csi) { q.splice(i, 1); @@ -2235,7 +2259,7 @@ s.title = title; var nm = new MediaList(); nm.mediaText = media; - if (media !== "") { + if (media && (media !== "")) { var mes = media.split(","); //文字列をコンマで区切って配列に for (var i=0,mli=mes.length;i<mli;++i) { nm.appendMedium(mes[i]); //メディアリストに値を加えていく @@ -3362,7 +3386,8 @@ *SVGの文書オブジェクト */ function SVGDocument(){ - Document.apply(this, arguments); + Document.apply(this); + DocumentStyle.apply(this); /*readonly DOMString*/ this.title = ""; /*readonly DOMString*/ this.referrer = document.referrer; /*readonly DOMString*/ this.domain = document.domain; @@ -4154,11 +4179,95 @@ */ function SVGStyleElement() { SVGElement.apply(this); + LinkStyle.apply(this); + /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。 + *CSS2 1. Document Object Model Style Sheets + * 1.3. Document Extensions + * Interface LinkStyle (introduced in DOM Level 2) + * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle + */ /*以下はそれぞれ、属性の値に対応している*/ /*DOMString*/ this.xmlspace; /*DOMString*/ this.type = "text/css"; /*DOMString*/ this.media; /*DOMString*/ this.title; + SVGURIReference.apply(this); + this.addEventListener("DOMAttrModified", function(evt){ + if (evt.attrName === "type") { + evt.target.type = evt.newValue; + } else if (evt.attrName === "title") { + evt.target.title = evt.newValue; + } + evt = null; + }, false); + this.addEventListener("SVGLoad", function(evt){ + var tar = evt.target, + sheet = tar.sheet, + styleText = tar._text, + tod = tar.ownerDocument, + style = document.createElement("style"), + ri, rsc, scri, rsi; + NAIBU._temp_doc = tod; + sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media); + sheet.ownerNode = tar; + /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/ + document.documentElement.firstChild.appendChild(style); + style.styleSheet.cssText = styleText; + for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) { + ri = rules[i]; + scri = new CSSStyleRule(); + scri.selectorText = ri.selectorText; + scri.style.cssText = ri.style.cssText; + rsc = scri.style.cssText.split(";"); + for (var j=0, rsli=rsc.length;j<rsli;++j) { + rsi = rsc[j].split(": "); + scri.style.setProperty(rsi[0], rsi[1]); + } + sheet.cssRules[sheet.cssRules.length] = scri; + } + tod.documentElement._svgload_limited--; + tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { + var tar = evt.target, + doc = tar.ownerDocument, + rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [], + selector, ru, tcb = tar.className.baseVal || ".,."; + for (var i=0, rli=rules.length;i<rli;++i) { + selector = rules[i].selectorText; + /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/ + ru = tar._rules || []; + if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1) + || (tar.nodeName === selector)) { + ru[ru.length] = rules[i]; + } + tar._rules = ru; + } + tar = doc = rules = null; + }, true); + if (tod.documentElement._svgload_limited < 0) { + evt = tod.createEvent("SVGEvents"); + evt.initEvent("SVGLoad", false, false); + tod.documentElement.dispatchEvent(evt); + } + tar = evt = style = sheet = styleText = tod = i = rules = rli = null; + }, false); + this.addEventListener("DOMNodeInserted", function(evt){ + var tar = evt.target; + if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) { + if (tar.nodeName === "#cdata-section") { + evt.currentTarget._text = tar.data; + } + return; + } + tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){ + var tar = evt.target; + if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) { + var evtt = tar.ownerDocument.createEvent("SVGEvents"); + evtt.initEvent("SVGLoad", false, false); + evt.currentTarget.dispatchEvent(evtt); + } + tar = evt = null; + }, false); + }, false); return this; }; SVGStyleElement.constructor = SVGElement; @@ -5150,30 +5259,30 @@ isZ = tar._com._isZ, isC = tar._com._isC; for (var i=0, tli=tlist.numberOfItems;i<tli;++i) { var ti = tlist[i], - tps = ti.pathSegTypeAsLetter, - t = cname[tps]; + tps = ti.pathSegTypeAsLetter; + dat.push(cname[tps]); if (isC[tps]) { /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり *[ma mc me] [x] *[mb md mf] * [y] *[0 0 1 ] [1] */ - t += ([_parseInt(ma*ti.x1 + mc*ti.y1 + me, 10), - _parseInt(mb*ti.x1 + md*ti.y1 + mf, 10), - _parseInt(ma*ti.x2 + mc*ti.y2 + me, 10), - _parseInt(mb*ti.x2 + md*ti.y2 + mf, 10), - _parseInt(ma*ti.x + mc*ti.y + me, 10), - _parseInt(mb*ti.x + md*ti.y + mf, 10)]).join(" "); + dat.push(_parseInt(ma*ti.x1 + mc*ti.y1 + me, 10)); + dat.push(_parseInt(mb*ti.x1 + md*ti.y1 + mf, 10)); + dat.push(_parseInt(ma*ti.x2 + mc*ti.y2 + me, 10)); + dat.push(_parseInt(mb*ti.x2 + md*ti.y2 + mf, 10)); + dat.push(_parseInt(ma*ti.x + mc*ti.y + me, 10)); + dat.push(_parseInt(mb*ti.x + md*ti.y + mf, 10)); } else if (!isZ[tps]) { - t += _parseInt(ma*ti.x + mc*ti.y + me, 10)+ " " +_parseInt(mb*ti.x + md*ti.y + mf, 10); + dat.push(_parseInt(ma*ti.x + mc*ti.y + me, 10)); + dat.push(_parseInt(mb*ti.x + md*ti.y + mf, 10)); } - dat[i] = t; } var vi = tar.ownerDocument.documentElement, w = vi.width.baseVal.value, h = vi.height.baseVal.value, tt = tar._tar; - dat[dat.length] = " e"; + dat.push(" e"); tt.path = dat.join(" "); tt.coordsize = w + " " + h; NAIBU._setPaint(tar, matrix);