svnno****@sourc*****
svnno****@sourc*****
2010年 2月 12日 (金) 21:09:02 JST
Revision: 1659
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1659
Author: dhrname
Date: 2010-02-12 21:09:02 +0900 (Fri, 12 Feb 2010)
Log Message:
-----------
CSSStyleDeclarationクラスの実装とテスト
Modified Paths:
--------------
branches/ufltima/dom/css.js
Modified: branches/ufltima/dom/css.js
===================================================================
--- branches/ufltima/dom/css.js 2010-02-12 11:19:32 UTC (rev 1658)
+++ branches/ufltima/dom/css.js 2010-02-12 12:09:02 UTC (rev 1659)
@@ -215,40 +215,58 @@
}
return null;
},
+ /*removePropertyメソッド
+ *プロパティを宣言内から除去
+ */
/*string*/ removeProperty : function( /*string*/ propertyName) {
var tg = this.getPropertyCSSValue(propertyName);
- if (tg) { //見つかった場合
- this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
+ if (tg) { //見つかった場合
+ this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
}
},
+ /*getPropertyPriorityメソッド
+ *importantなどのpriorityを取得する
+ */
/*string*/ getPropertyPriority : function( /*string*/ propertyName) {
var tg = this.getPropertyCSSValue(propertyName);
- if (tg) { //見つかった場合
+ if (tg) { //見つかった場合
return (tg._priority);
} else {
return "";
}
},
+ /*setPropertyメソッド
+ *プロパティを宣言内で、明示的に設定。継承は無視する
+ */
/*void*/ setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
- var tg = this.getPropertyCSSValue(propertyName);
+ var tg = this.getPropertyCSSValue(propertyName), cssText = "";
+ cssText += propertyName;
+ cssText += ":";
+ cssText += value;
if (tg) { //見つかった場合
tg._priority = priority;
- tg.cssText += propertyName;
- tg.cssText += ":"
- tg.cssText += value;
+ tg.cssText = cssText;
} else {
var ti = new CSSPrimitiveValue();
- tg._priority = priority;
- tg.cssText += propertyName;
- tg.cssText += ":"
- tg.cssText += value;
+ ti._priority = priority;
+ ti.cssText = cssText;
+ //_numプロパティはremovePropertyメソッドで利用する
ti._num = this._list.length;
this._list[ti._num] = ti;
++this.length;
}
+ cssText = null;
},
+ /*itemメソッド
+ *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
+ */
/*string*/ item : function( /*long*/ index) {
- return (this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":")));
+ if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
+ var s = "";
+ } else {
+ var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
+ }
+ return s;
}
};
@@ -264,6 +282,7 @@
CSSValue.CSS_CUSTOM = 3;
function CSSPrimitiveValue() {
+ CSSValue.call(this, arguments);
this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
this._n = [1, 0.01, 1, 1, 1, 35.43307, 3.543307, 90, 1.25, 15, 1, 180 / Math.PI, 90/100, 1, 1000, 1, 1000, 1]; //CSS_PX単位への変換値(なお、CSS_SはCSS_MSに、CSS_RADとCSS_GRADはCSS_DEGに、CSS_KHZはCSS_HZに統一)