svnno****@sourc*****
svnno****@sourc*****
2010年 2月 14日 (日) 22:42:29 JST
Revision: 1660
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1660
Author: dhrname
Date: 2010-02-14 22:42:29 +0900 (Sun, 14 Feb 2010)
Log Message:
-----------
getComputedStyleメソッドの実装
Modified Paths:
--------------
branches/ufltima/dom/css.js
Modified: branches/ufltima/dom/css.js
===================================================================
--- branches/ufltima/dom/css.js 2010-02-12 12:09:02 UTC (rev 1659)
+++ branches/ufltima/dom/css.js 2010-02-14 13:42:29 UTC (rev 1660)
@@ -596,6 +596,24 @@
textAnchor : "start",
writingMode : "lr-tb"
};
+/*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
+ *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
+ */
+(function(){
+ var s = [], az = /([A-Z])/g;
+ for (var i in CSS2Properties) {
+ if(CSS2Properties.hasOwnProperty(i)) {
+ var n = s[s.length] = new CSSPrimitiveValue();
+ t = i.replace(az, "-" +RegExp.$1.toLowerCase());
+ n.cssText += t;
+ n.cssText += ":";
+ n.cssText += CSS2Properties[i];
+ n = p = m = i = t = u = null;
+ }
+ }
+ CSS2Properties._list = s;
+ az = null;
+})();
function CSSStyleSheet() {
/*CSSRule*/ this.ownerRule = null;
@@ -623,18 +641,10 @@
/*CSSStyleDeclaration*/ getComputedStyle : function( /*Element*/ elt, /*string*/ pseudoElt) {
var s = new CSSStyleDeclaration();
do {
- var eps = elt.style;
- for (var i=0,eli=eps.length;i<eli;++i) {
- var propertyName = eps.item[i];
- s.setProperty(propertyName, eps.getPropertyValue(propertyName), eps.getPropertyPriority(propertyName));
- elt = elt.parentNode;
- }
+ s._list = s._list.concat(elt.style._list); //リストを連結することによって、カスケーディングを実現する
+ elt = elt.parentNode;
} while (elt);
- for (var i in CSS2Properties) { //デフォルト値の設定をする
- if (CSS2Property.hasOwnProperty(i) && !(s.getPropertyCSSValue(i)) ) {
- s.setProperty(i, CSS2Properties[i], "");
- }
- }
+ s._list = s._list.concat(CSS2Properties._list); //デフォルト値の設定
return s;
}
};
@@ -644,7 +654,6 @@
*/
/*function DocumentCSS : stylesheets::DocumentStyle {*/
/*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
- return (elt.paint);
};
/*createCSSStyleSheetメソッド
*文書のスタイルシートを作成