svnno****@sourc*****
svnno****@sourc*****
2010年 7月 12日 (月) 20:55:11 JST
Revision: 1941
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1941
Author: dhrname
Date: 2010-07-12 20:55:11 +0900 (Mon, 12 Jul 2010)
Log Message:
-----------
Modified Paths:
--------------
branches/06x/061/org/w3c/dom/css.js
Modified: branches/06x/061/org/w3c/dom/css.js
===================================================================
--- branches/06x/061/org/w3c/dom/css.js 2010-07-12 11:20:17 UTC (rev 1940)
+++ branches/06x/061/org/w3c/dom/css.js 2010-07-12 11:55:11 UTC (rev 1941)
@@ -187,7 +187,7 @@
this.cssText;
/*long*/ this.length = 0;
/*CSSRule*/ this.parentRule = null;
- this._list = [[]]; //内部のリスト
+ this._list = []; //内部のリスト
return this;
};
CSSStyleDeclaration.prototype = {
@@ -211,40 +211,38 @@
if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
return null;
}
- for (var j=0,tli=this._list.length;j<tli;++j) {
- for (var i=0,ili=this._list[j].length;i<ili;++i) {
- var ti = this._list[j][i], tc = ti.cssText;
- if (tc.indexOf(propertyName) > -1) { //プロパティ名に合致するCSSValueオブジェクトが見つかった場合
- if ((propertyName === "fill:") || (propertyName === "stroke:")) {
- /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
- *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
- */
- if (ti instanceof SVGPaint) {
- return ti;
- }
- ti = new SVGPaint();
- ti.cssText = tc;
- var paintType = SVGPaint.SVG_PAINTTYPE_UNKNOWN, uri = null, color = null;
- if (tc.indexOf("none") > -1) {
- paintType = SVGPaint.SVG_PAINTTYPE_NONE;
- } else if (tc.indexOf("currentColor") > -1) {
- paintType = SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR;
- color = this.getPropertyValue("color");
+ for (var i=0,tli=this._list.length;i<tli;++i) {
+ var ti = this._list[i], tc = ti.cssText;
+ if (tc.indexOf(propertyName) > -1) { //プロパティ名に合致するCSSValueオブジェクトが見つかった場合
+ if ((propertyName === "fill:") || (propertyName === "stroke:")) {
+ /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
+ *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
+ */
+ if (ti instanceof SVGPaint) {
+ return ti;
+ }
+ ti = new SVGPaint();
+ ti.cssText = tc;
+ var paintType = SVGPaint.SVG_PAINTTYPE_UNKNOWN, uri = null, color = null;
+ if (tc.indexOf("none") > -1) {
+ paintType = SVGPaint.SVG_PAINTTYPE_NONE;
+ } else if (tc.indexOf("currentColor") > -1) {
+ paintType = SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR;
+ color = this.getPropertyValue("color");
+ } else {
+ var _urlreg = /url\(#([^)]+)/;
+ if (_urlreg.test(tc)) { //fill属性の値がurl(#id)ならば
+ paintType = SVGPaint.SVG_PAINTTYPE_URI;
+ uri = RegExp.$1;
} else {
- var _urlreg = /url\(#([^)]+)/;
- if (_urlreg.test(tc)) { //fill属性の値がurl(#id)ならば
- paintType = SVGPaint.SVG_PAINTTYPE_URI;
- uri = RegExp.$1;
- } else {
- paintType = SVGPaint.SVG_PAINTTYPE_RGBCOLOR;
- color = tc.substring(tc.indexOf(":")+1, tc.length);
- }
+ paintType = SVGPaint.SVG_PAINTTYPE_RGBCOLOR;
+ color = tc.substring(tc.indexOf(":")+1, tc.length);
}
- ti.setPaint(paintType, uri, color, null);
- this._list[j][i] = ti;
}
- return ti;
+ ti.setPaint(paintType, uri, color, null);
+ this._list[i] = ti;
}
+ return ti;
}
}
return null;
@@ -255,7 +253,7 @@
/*string*/ removeProperty : function( /*string*/ propertyName) {
var tg = this.getPropertyCSSValue(propertyName);
if (tg) { //見つかった場合
- this._list[0].splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
+ this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
--this.length;
}
},
@@ -291,8 +289,8 @@
ti._priority = priority;
ti.cssText = cssText;
//_numプロパティはremovePropertyメソッドで利用する
- ti._num = this._list[0].length;
- this._list[0][ti._num] = ti;
+ ti._num = this._list.length;
+ this._list[ti._num] = ti;
this[propertyName] = 1;
++this.length;
}
@@ -305,15 +303,7 @@
if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
var s = "";
} else {
- for (var i=0,tli=this._list.length;i<tli;++i) {
- var tlii=this._list[j].length;
- if (tlii > index) {
- var s = this._list[i][index].cssText.substring(0, this._list[i][index].cssText.indexOf(":"));
- break;
- } else {
- index -= tlii;
- }
- }
+ var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
}
return s;
}
@@ -754,31 +744,22 @@
return this;
};
/*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
- var s = new CSSStyleDeclaration(), slist = s._list;
- slist[0] = elt.style._list[0];
- slist[1] = elt._attributeStyle._list[0]; //プレゼンテーション属性を結びつける
+ var s = new CSSStyleDeclaration();
//リストを連結することによって、カスケーディングを実現する
var pelt = elt.parentNode;
if (pelt) {
- if (this._cache_ele !== pelt) { //キャッシュを更新する
+ if (this._cache_ele !== pelt) { //キャッシュを更新する
this._cache = this.getComputedStyle(pelt, pseudoElt);
this._cache_ele = pelt;
}
- if (!!this._cache) {
- for (var i=0,dli=this._cache._list.length;i<dli;++i) {
- slist[slist.length] = this._cache._list[i];
- }
- i = dli = null;
- }
+ var p = this._cache._list;
} else {
- slist[slist.length] = CSS2Properties._list; //デフォルト値の設定
+ var p = CSS2Properties._list; //デフォルト値の設定
}
- for (var i=0,sli=slist.length;i<sli;++i) {
- var isl = slist[i];
- for (var j=0,slii=isl.length;j<slii;++j) {
- }
- }
- s._list = slist;
+ s._list = s._list.concat(elt.style._list)
+ .concat(elt._attributeStyle._list) //プレゼンテーション属性を結びつける
+ .concat(p);
+ p = null;
s._document = elt.ownerDocument;
return s;
};